Outdoor dust sensor V3
Post date: Sep 25, 2019 8:7:39 AM
The haze ,due to peat fire in south east sumatra is back in west sumatra (as in 2015). So i have decided to update and put back online my dust sensor to fit my actual and future IOT infrastructure.
The dust sensor itself remain the same as described in :The outdoor unit
The communication link has been upgrated from the 3DR telemetry module to a esp8266-01 wifi module.
The sensor can now send data directly to a local emoncms server and on the thingspeak.com cloud.
The Arduino pin from the previous sensor connected to the radio TX and RX where pin9 and pin8.
Just need to add a voltage divider form the arduino pin8 and the esp rxpin to reduce the high logic voltage from 5v to 3.3 by using a 2.2k and 3.3 k ohm with the 3.3 connected to ground and the end of the 2.2k to the pin8 of the arduino. (as described in my esp8266 datasheet/tutorial).
For the 3.3V power supply i connect a LM2596 step down adjustable converter from the 12V main adjusted to3.3v to the esp vcc pn. It' is over killed for the setup but i have it available.
How to connect the esp to local and web-server and send the dust density value online:
I did not modify the code for data acquistion and dust sensor measurement from my previous The outdoor unit project
i just inserted the code to print AT commands on the softwareserial port and read the reply from the same softwareserial port.
The At command sequence is as follow:
AT+RST // To reset the board and connect to the last recorded AP
Wait 4 seconds
AT+CIPSTART=\"TCP\",\"" + server + "\","+port //Connect to the server in HTTP on the server port (usualy 80)
AT+AT+CIPSEND=(data packet lenght) //sending a packet size data before sending data
GET /emoncms/input/post.json?node=2&fulljson={\"dust\":"+String(int(averageDust))+"}&apikey="+apikey+" HTTP/1.1\r\nHost: " + server + ":"+port+"\r\n\r\n
// Send the Get request to post the data and wait for server reply (emonCms server)
.GET /update?api_key="+thingspeakAPI+"&field1="+String(int(averageDust))+" HTTP/1.1\r\nHost: " + serverThingspeak + ":"+portThingspeak+"\r\n\r\n
//Send GET request to post the data and wait for server reply (thingspeak.com server)
if replay "SEND OK"= Data received by the server
AT+CIPCLOSE //Close the TCP server connection
Wait for the next transmission.
Some Code:
As definition:
In the setup:
In the Loop:
Some function definition:
The Complete code:
Data available at :https://thingspeak.com/channels/869691