Good morning group,
First and foremost i apologize for any mistakes in my english. I am trying to make a solar weather station using a NodeMCU board, a DHT22 sensor and the Blynk app. After uploading the code, everything seems to work just fine, for an hour or such. After that, the app seems to freeze and unless i restart the board it stays like that (sometimes not even the restart works). I have tried to increase the time between my dht22 sensor readings to half an hour, as i suspected that too often readings my cause the freeze, but just as i said, in a matter of hours, it became unusable. Below you have my code and a picture of the app.
Please feel free to butcher it as any advice is helpful. Thank you in advance.
#define BLYNK_PRINT Serial
#pragma message(THIS EXAMPLE IS FOR ESP8266 ONLY!)
#error Select ESP8266 board.
int Sensor_PIN = 0; //D3
char auth = "xxxxx";
char ssid = "xxxxx";
char pass = "xxxxx";
Temperature = dht.getTemperature();
Humidity = dht.getHumidity();
Blynk.begin(auth, ssid, pass);
Add Serial.println to see temp in the serial monitor.
Change pin D2 to DO because D2 is GPIO 0 can’t be used as input.
What version of the Blynk library are you using?
What happens if you power your NodeMCU from a regular 5v supply rather than your solar supply?
You should be able to take DHT22 readings every 10 seconds without a problem.
Also, I notice that you don’t have a line which defines your DHT type as DHT22.
I will update my code accordingly. Thank you
I am using the Blynk 1.0 library. Also, if i power the NodeMCU from a regularly 5v power supply, nothing changes. I get the same problem. It works for a little while, then it stops receiving data from the sensor. I thought that this line describes my sensor as being dht22: dht.setup(Sensor_PIN, DHTesp::DHT22);
How should i define it otherwise? Thank you
I am using pin D3, as shown in the code
Sorry, missed that line in your void setup, I was expecting something more like this:
You should be using version 0.6.1 with legacy Blynk.
No , you have defined pin 0 ! So it’s GPIO 0
I will update the code as in the example you’ve showed me and give it a go. Thank you very much for your time. I am still a rookie when it comes to Arduino based projects but am keen to learn about it
Thank you for your input. I will acknowledge that and as i previously said, i am still learning the basics but tried to make it the fun-IoT-way
On the other hand, i am also trying to add a voltage sensor to the battery wich should return the state of the battery charged by the solar panel. How should i update the code for that? Thanks in advance
I’d start by googling how to do it, then getting the code working without Blynk (just sending the data to the serial monitor) then add-in Blynk.virtualWrite to send the data to the app.
Ok. So, for the moment, i have changed the port (int Sensor_PIN = D0;) and changed the update interval at 60 seconds. I have tested the functionality of the device and it works ok, both on solar energy and 5v power supply. I only have one more question for you guys. I heard that Li-Ion batteries, while subjected to heat (my “device” is basically a plastic box in the sun, with little holes for sensing the humidity) tend to… catch fire. Should i be concerned about this aspect?
The batteries will almost certainly distort as a result of the heat. If you’ve gone for the flat battery packs then this often leads to them bulging and failing.
It also depends what over-charge regulation circuitry you’ve used.