Weather Station Code

Here is the code I used for the weather station that connects the wifi network, then to a mysql database to save data. I think most of it is self explanatory, change a few passwords and login details as well as the database and table names and it should be good to go.

sprintf(INSERT_SQL,”INSERT INTO weatherstation.SensorData VALUES ( ”, now(), now(), ‘%d’, ‘%d’, ‘%d’, ‘%d’, ‘%d’ )”,temp, humidity, pressure, heatindex, dewpoint);

This line might look a bit odd, 8 elements but only 5 variables, the first table element is a primary key that auto increments, the next 2, now() inserts the server data and server time followed by the 5 variables. These need to be in that exact order when you create the database table.



Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.