Monday, July 30, 2018

ESP8266 Post to Web Service

Purchased a DHT22 recently for a Work Desk Temperature project. Wrote a web service and created some SQL stuff to capture the temperature and humidity at my desk. Here we go.

Web Service

Just a real simple web service to call the stored procedure I wrote:

See my other blog post for more details on creating a web service: http://tech.thejoestory.com/2017/01/simple-sql-server-aspnet-web-service.html

SQL stuff

Created a Table and a couple stored procedures to support this. Here is the table.
Here are the stored procs.


ESP8266 Post

From there I just needed to figure out the ESP8266 Post. I had to search around a bit but finally landed on the script below. The script will establish a WiFi connection. Then it will loop every one minute taking a temperature/humidity reading from the DHT22. Finally it will call the web service I built to store the data in SQL server.

You will need to grab the DHT and AdaFruit Libraries using your Arduino IDE. From there I created a web site using Chart.js and a couple other stored procedures I wrote to get MAX/MIN/AVG Temp and Humidity.


0 comments:

Post a Comment