Hello all,
I try to make a simple weather station totally powered by solar panel. The wemos D1 is the hart of this project together with a DHT22 for taken the measurements. The data retrieved from the data must be showed in the blynk app.
For so far all works. But the power consumption of the wemos is to big and slurps all energy out of the battery. Therefore i coded a deepsleep. But than all started to go wrong. No data is being transferred to the blynk system.
The D0 and RSTare connected with a switch, so I ca still upload my arduino ino. and close the switch so D0 and RST are connected.
I think the solution is in the arduino ino. But I don't know where or how. Any suggestions on this?
My code so far:
/*************************************************************
This example shows how value can be pushed from Arduino to
the Blynk App.
WARNING :
For this example you'll need Adafruit DHT sensor libraries:
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library
App dashboard setup:
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "XXXXX"
#define BLYNK_TEMPLATE_NAME "XXXXX"
#define BLYNK_AUTH_TOKEN "XXXX"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXX";
char pass[] = "XXXXXXX!";
#define DHTPIN D5 // What digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
ESP.deepSleep(600e6); // Sleep for 10 minutes (600 seconds)
}