Sensor Setup on Raspberry Pi

Requirements

  • Raspberry Pi OS installed and running (here)
  • Arduino script uploaded to your Arduino board
  • Arduino connected via USB to the Raspberry Pi

Running and Checking the Sensor Script

1. Connect to your Raspberry Pi

Connect via SSH:

ssh smartfarming@<IP_ADDRESS>

For example:

ssh smartfarming@172.3.23.125

2. Navigate to the smartfarming directory

cd smartfarming

3. Check the status of the data sender service

The service collects sensor data from the Arduino and transmits it to the database using a REST API.

systemctl status smartfarming_data_sender.service

Typical status messages:

  • active (running) → Everything is working
  • inactive (dead) → Service is stopped

4. Start the service if it is not running

systemctl start smartfarming_data_sender.service

Other useful commands:

  • Restart the service: systemctl restart smartfarming_data_sender.service
  • Stop the service: systemctl stop smartfarming_data_sender.service

5. Troubleshooting

  • View the system log: journalctl
  • Verify permissions: ls -lah
  • Test running the Python script manually: ./sender_copy.py. This will help to identify whether the issue lies with the service or the script itself (it will attempt to send data to a non-existent IP address).