thecweb.com

A place just for me

DHT22 is logging

For my indoor garden I wanted to monitor the temperature inside and outside the tent. It is in the basement, which I don’t think ever gets above 70 or below 50, but to control the plant’s cycles I need to control light and temp. The light came with an App so I just needed to get temp data into my database. Here is the code I’m using at the moment. I’d also like to log outside temperature data, but I haven’t figured that out yet. I’m think there has got to be an API for the NWS that I can put in a zip code and get the temp and humidity. Here is the code, and some notes.

We need to get some libraries and connect to the sensors.

I have two functions. One to get the data from the sensors, and one to insert the data into the database.

sensors
insert data

Where the magic happens

and some cleanup

So I calculated the space needed by putting 10 readings in the db, and if the average holds(which it should only go down) I will use about 840 MB a year to get a reading every minute, which I don’t really think I would need, so I’ll probably lower it to once an hour maybe later.

1638 average row size, in bytes(i think)

so 1.6kb a reading.

60 minutes * 24 hours * 1.6kb = 2,304kb a day

2.3MB * 365 = 839.5MB a year

One response

  1. cweb Avatar

    Some links to the National Weather Service’s api. It’s “free” as in I’m already paying for it, so this is where I’ll get the outside temp info.

    https://www.weather.gov/nwr/sites?site=KID77

    I think the KID77 is the station ID I need to feed the API.

    https://www.weather.gov/documentation/services-web-api

Leave a Reply

Your email address will not be published. Required fields are marked *