ThingSpeak in an application to store data from IoT devices. We are going to use the https://thingspeak.com/ website.
Once we have created our account and we need to make a new channel, and collect the Channel ID and the Write API Key for that channel, we will then set those parameters in our meter configuration.
The sensor I'm going to use is a DNA701 from LSI http://www.lsi-lastem.it/. It's a wind speed sensor supplied with 24V AC, and industrial current output 4..20mA. A friend give this away to me, and so I would like to use in some way.
LSI sends me the datasheet for this sensor, it turned out that current to wind speed m/s is a linear function, so simple.
So, I just have to measure current with my ESP8266. In order to have an accurate measurement i prefer to use a linear current to voltage converter, then read the voltage using an ADC.
As for the current to voltage converter I go for a cheap board, it is supplied with 12V DC, and it gives you 0 to 5V output depending on the 4 to 20mA input.
Then, i read the voltage output from this sensor using an ADS1115 ADC board.
I supply the ADS1115 with 5V.
Software side I'm using the Adafruit ADS1X15 library. I initialize the sensor setting the gain to 2/3. By datasheet setting the 2/3 gain means the sensor can read +/-6.144V in 16bit. This means 6.144V in 15bit, which is 187.5uV per bit. So if we get a raw value of 32768 from the ADC, the voltage we are reading is 32768*187.5uV, which is 5V.
I prefer to add a Exponential Moving Average filter to the ADC raw value that I read, this can smooth wrong readings if there are any.
Now that we know how to read the voltage, we just have to transform back to current, that's a simple linear interpolation. For this we can use the map function.
Now that we get the current we just substitute this in the LSI conversion formula, and we so have wind speed expressed m/s.
To be more usable I've add an 8 digit seven segment display which displays the wind speed in real/time, updated each second. To be honest a 4 digit display could be enough but the simplest thing is to connect a 8 digit board you simply buy.
Then, every 60 seconds, the wind speed is sent to out ThingSpeak channel.
As on other device based on ESP8266 I've built, the WiFi AP to use can be setup using the WiFiManager integrated library. This time the device tries to connect to the AP, if any was configured, if it's not able to connect to the AP you have 3 minutes to connect to the "forced AP" of the ESP8266 and configure a WiFi, otherwise it will go on and work just like a meter with the seven segment display.
Other parameters, like the ThingSpeak Channel ID and Write API Key, can be changed in the configuration web page generated from the device itselft.
Code
Notes
Once we have created our account and we need to make a new channel, and collect the Channel ID and the Write API Key for that channel, we will then set those parameters in our meter configuration.
The sensor I'm going to use is a DNA701 from LSI http://www.lsi-lastem.it/. It's a wind speed sensor supplied with 24V AC, and industrial current output 4..20mA. A friend give this away to me, and so I would like to use in some way.
LSI sends me the datasheet for this sensor, it turned out that current to wind speed m/s is a linear function, so simple.
So, I just have to measure current with my ESP8266. In order to have an accurate measurement i prefer to use a linear current to voltage converter, then read the voltage using an ADC.
Then, i read the voltage output from this sensor using an ADS1115 ADC board.
I supply the ADS1115 with 5V.
Software side I'm using the Adafruit ADS1X15 library. I initialize the sensor setting the gain to 2/3. By datasheet setting the 2/3 gain means the sensor can read +/-6.144V in 16bit. This means 6.144V in 15bit, which is 187.5uV per bit. So if we get a raw value of 32768 from the ADC, the voltage we are reading is 32768*187.5uV, which is 5V.
I prefer to add a Exponential Moving Average filter to the ADC raw value that I read, this can smooth wrong readings if there are any.
Now that we know how to read the voltage, we just have to transform back to current, that's a simple linear interpolation. For this we can use the map function.
Now that we get the current we just substitute this in the LSI conversion formula, and we so have wind speed expressed m/s.
To be more usable I've add an 8 digit seven segment display which displays the wind speed in real/time, updated each second. To be honest a 4 digit display could be enough but the simplest thing is to connect a 8 digit board you simply buy.
Then, every 60 seconds, the wind speed is sent to out ThingSpeak channel.
Other parameters, like the ThingSpeak Channel ID and Write API Key, can be changed in the configuration web page generated from the device itselft.
Code
Notes
- read risk disclaimer
- excuse my bad english