• stoy@lemmy.zip
      link
      fedilink
      arrow-up
      5
      ·
      16 hours ago

      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.

    • stoy@lemmy.zip
      link
      fedilink
      arrow-up
      3
      ·
      15 hours ago

      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.

      • DontNoodles@discuss.tchncs.de
        link
        fedilink
        arrow-up
        1
        ·
        3 hours ago

        I think a Pi is an overkill for this. If I were to attempt this, i would try getting it done with an ESP8266 module which uses far less power, making the battery last much longer. Bootup and shutdown times would be much less so using coin cells or supercapacitors charged using small solar panels could also be used. If your home is not too far (few km), using LoRa could eliminate dependency on the WiFi. Cool use case, nonetheless!

        • stoy@lemmy.zip
          link
          fedilink
          arrow-up
          1
          ·
          3 hours ago

          A Pi is obviously overkill, even a Pi Z w which we ended up using, but they are efficient enough for us, and more importantly, I know the system, and I could relatively quickly get it working using just bash on the Pi.

          I was not really interested in learning how to program on a different system just for this.

          We did some power analytics on the Pi and disabled a few things, sorry I don’t remember it right now.

          The unit is placed in a semi public place where teenagers sometimes congregate and we don’t want to draw any attention to the device, so solar power is out.

          A LoRa unit though could be interesting to implement, sadly my parents house is up a steap hill and there is no line of sight.

          I have been thinking of experimenting with Meshtastic and LoRa for off grid coms due to the geopolitical situation here in Europe, might be worth it getting a few units to test out.