Hi guys, i have created a weather station based on Wemos d1 mini pro. Now it has 4 sensors connected. I have tested it some days ago, and was working completely fine for 3-4 days. Then it had a little break cause i wanted to add another sensor. Today i launched station again, to test it with added VEML6070 Adafruit UV sensor. It was working fine for 4 hours, then station stopped uploading data to database (im doing it every 5 minutes).
Here is my code:
#include <Adafruit_VEML6070.h>
#include <Adafruit_BMP085.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#define ONE_WIRE_BUS 2
#define DHTPIN 0
#define DHTTYPE DHT21
DHT dht(DHTPIN, DHTTYPE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Adafruit_BMP085 bmp;
Adafruit_VEML6070 uv = Adafruit_VEML6070();
//SSID of your network
char ssid[] = "xxx"; //SSID of your Wi-Fi router
char pass[] = "xxx"; //Password of your Wi-Fi router
char server[] = "xxx";
void setup()
{
dht.begin();
uv.begin(VEML6070_1_T);
Serial.begin(115200);
if (!bmp.begin()) {
Serial.println("Could not find BMP180 or BMP085 sensor at 0x77");
while (1) {}
}
delay(10);
// Connect to Wi-Fi network
Serial.println();
Serial.println();
Serial.print("Connecting to...");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Wi-Fi connected successfully");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
WiFiClient client;
void loop () {
sensors.begin();
sensors.requestTemperatures();
float temperatura = sensors.getTempCByIndex(0);
Serial.println("temperatura: ");
Serial.println(temperatura);
delay(2000);
float tt = dht.readTemperature();
float h = dht.readHumidity();
Serial.println("Temperatura DHT: ");
Serial.println(tt);
Serial.println("Wilgotnosc: ");
Serial.println(h);
delay(2000);
float seaLevelPressure = 101890;
float t = bmp.readTemperature();
float p = bmp.readPressure()/100;
Serial.println("temperatura BMP: ");
Serial.println(t);
Serial.println("Cisnienie hPa:");
Serial.println(p);
delay(2000);
double uvNow = uv.readUV()*0.05625;
Serial.println("Natezenie UV W/m2: ");
Serial.println(uvNow);
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP GET request:
client.print("GET /data.php?temperatura=" ) ;
client.print(temperatura);
client.print("&");
client.print("wilgotnosc=");
client.print(h);
client.print("&");
client.print("cisnienie=");
client.print(p);
client.print("&");
client.print("irradiancja=");
client.print(uvNow);
client.print("&");
client.println( " HTTP/1.1"); // embedded space and println !
client.println("Host: xxx");
client.println("Connection: close");
client.println();
Serial.println("Dane przeslane pomyslnie!");
Serial.println("ESP going to sleep!");
ESP.deepSleep(300e6);
}
}
As u can see every 5 minutes im launching deepsleep on esp to save energy. I power the wemos through 5V/1A samsung charger with micro usb. Is it software problem that it freezes?