Sending the Sensor Outputs to a Server

Install FTP Remote Access

FTP (File Transfer Protocol) is needed to copy the temperature sensor information to a web server.  

The variant of FTP to be used is LFTP.  To install this on the Pi enter the following command:

[email protected] ~ $ sudo apt-get install lftp

We will use the FTP client to upload the graphs to a server.

Create an upload script to run to upload all the files to the web server.

[email protected] ~ $ sudo nano upload.sh

Copy the script below into the newly created file.

#!/bin/bash
sleep 30
lftp -u FTP_USERID,PASSWORD ftp.raspbeepi.uk <<EOF
put RBP_temp_log_h.png
put RBP_temp_log_d.png
put RBP_temp_log_w.png
put RBP_temp_log_m.png
put RBP_temp_log_y.png
#put RBP_humidity_log_h.png
#put RBP_humidity_log_d.png
#put RBP_humidity_log_w.png
#put RBP_humidity_log_m.png
#put RBP_humidity_log_y.png
quit 0
EOF

Now make the file executable.

[email protected] ~ $ sudo chmod +x upload.sh

To add a scheduled job to upload the graphs regularly we need to set-up another cron job.  Start crontab by running the following command:

[email protected]:/RaspBeePi_Monitor $ sudo crontab -e

Now add the following line to the file, save and close the file:

# m h dom mon dow command
*/5 * * * * /RaspBeePi_Monitor/upload.sh >> /RaspBeePi_Monitor/RaspBeePi_cron.log 2>&1

This command runs the upload.sh script every five minutes. "&> /dev/null" takes the output from this command and discards it.