Make it happen

Make it happen

"Plant monitor" code

Home automationPosted by Thu, March 10, 2016 09:07:31
Here is some of the code to get the "Plant information".
The DHT and Soil moisture information is sent to my webserver using HTTP GET requests.

The sketch sends the HTTP request to temp.php on my webserver and this page then reads the data sent in the request (temp, hum, id & soil). Since the sensor data is updated every 30 seconds (I will change this to maybe 4 times per day), the database is filled with a lot of information. To deal with this I have created a "daily" table to store information for longer periods of time and also to be able to create nice graphs in the future. All data in my "detailed" table older than 7 days will be deleted since I don't see a actual need for this detailed infor for so long time.

Below I have attached the code for the temp.php page.

  • Comments(2)

Fill in only if you are not real

The following XHTML tags are allowed: <b>, <br/>, <em>, <i>, <strong>, <u>. CSS styles and Javascript are not permitted.
Posted by Fredrik Fri, March 11, 2016 15:17:54

@mrkale: I have two tables for the data. when moving data from my "detail" table i calculate the daily avereage and then move that data to a table with that daily data. The delete is only done in the "detailed" table

Posted by mrkale Fri, March 11, 2016 12:33:07

I recommend to implement a round robin database in MySQL. The old records should be aggregated, e.g., to average, median, max, min, etc., for longer time period into another table and deleted after when. At bare deleting you loose valuable historical information.