It run off of a 12v motorcycle battery, the whole thing is on a timer, every halfhour, the timer gives the pi power for two minutes, during those two minutes the pi boots up, and runs a bash script to collect and send the data, wait for one min and shutdown the pi.
The pi communicates over wifi with a friendly neighbouring house.
Some more details, the temperature probe is a DS18B20, it connects to the GPIO pins, and communicates over the 1-w protocol which is built into the pi, you get the data digitally in celsius, if it is a negative temperature it is a hassle to deal with so I just made it report 0 as default when it is too close.
The probe can error out, it then reports the temp as 85, since the water never actually gets that high in reality, I solved it by checking if the value returned from the probe is 85 before submitting it, if it is, it will take another measurement, check that for 85, if that is still 85, it will check one final time and then just submit the result, so far this has solved the issue.
Once the data is formated and ready, the pi makes an HTTP request, posting the data using curl, to a simple PHP/MySQL site I hacked together, where a page displays the current temp, a timestamp of when the temp was taken and a small graph showing changes to the temp over the last 24h
Planned improvements:
Use the status field that the pi reports to include wifi signal strength, as trees grows around the device it will reduce the signal strength meaning that measurements are lost, with the signal strength data we can check how bad it is and clear leaves ahead of the problem.
Considered improvements:
Security, as it stands right now, there is zero security to submit data to the database, anyone can just access the submit.php page and it will add an empty entry to the database, or if they figure out the syntax they can just post whatever data they want into the database. I would like to add a simple validation of a static random string that the pi sends along with the rest of the data. I am no real webdev, just an IT guy who hacked this together.
Power monitoring, it would be good to have an idea of of how well charged the battery is, it would require a separate module which would also require power, reducing the battery life as it is. Currently the battery lasts a few months and we have a manual schedule to replace it, it is not a huge problem, but it would be nice to have the data.
I forgot about three more technical aspects of the device…
The bash script it set up to run as a service in systemd, this is to make it run on startup and have some control over it, this is important for the next part.
The one min delay after submitting the data and shutting down the pi, this gives me time to find the command to stop the script before the script shuts down the pi, this is important so you can access the system and service it.
Why shut it down at all, the power will be cut shortly after?
This is to preserve the filesystem and reduce the risk of corruption, consider that the pi will turn on and off 24 times every day, any error caused by improper shutdowns will quickly amplify.
It run off of a 12v motorcycle battery, the whole thing is on a timer, every halfhour, the timer gives the pi power for two minutes, during those two minutes the pi boots up, and runs a bash script to collect and send the data, wait for one min and shutdown the pi.
The pi communicates over wifi with a friendly neighbouring house.
Ingenious setup!
Some more details, the temperature probe is a DS18B20, it connects to the GPIO pins, and communicates over the 1-w protocol which is built into the pi, you get the data digitally in celsius, if it is a negative temperature it is a hassle to deal with so I just made it report 0 as default when it is too close.
The probe can error out, it then reports the temp as 85, since the water never actually gets that high in reality, I solved it by checking if the value returned from the probe is 85 before submitting it, if it is, it will take another measurement, check that for 85, if that is still 85, it will check one final time and then just submit the result, so far this has solved the issue.
Once the data is formated and ready, the pi makes an HTTP request, posting the data using curl, to a simple PHP/MySQL site I hacked together, where a page displays the current temp, a timestamp of when the temp was taken and a small graph showing changes to the temp over the last 24h
Planned improvements:
Use the status field that the pi reports to include wifi signal strength, as trees grows around the device it will reduce the signal strength meaning that measurements are lost, with the signal strength data we can check how bad it is and clear leaves ahead of the problem.
Considered improvements:
Security, as it stands right now, there is zero security to submit data to the database, anyone can just access the submit.php page and it will add an empty entry to the database, or if they figure out the syntax they can just post whatever data they want into the database. I would like to add a simple validation of a static random string that the pi sends along with the rest of the data. I am no real webdev, just an IT guy who hacked this together.
Power monitoring, it would be good to have an idea of of how well charged the battery is, it would require a separate module which would also require power, reducing the battery life as it is. Currently the battery lasts a few months and we have a manual schedule to replace it, it is not a huge problem, but it would be nice to have the data.
I forgot about three more technical aspects of the device…
The bash script it set up to run as a service in systemd, this is to make it run on startup and have some control over it, this is important for the next part.
The one min delay after submitting the data and shutting down the pi, this gives me time to find the command to stop the script before the script shuts down the pi, this is important so you can access the system and service it.
Why shut it down at all, the power will be cut shortly after?
This is to preserve the filesystem and reduce the risk of corruption, consider that the pi will turn on and off 24 times every day, any error caused by improper shutdowns will quickly amplify.