Deep Sleep Do'nt work

hello

My setch work goog, but when I active this ligne
// ESP.deepSleep(3000000, WAKE_RF_DEFAULT);
i lose yhe WiFi connection

Can you help me, thanks

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeMono9pt7b.h>
Adafruit_SSD1306 display(128, 64);

#include <Sodaq_SHT2x.h>

#include <ThingerESP8266.h>
#define USERNAME “MVe”
#define DEVICE_ID “DataSerre”
#define DEVICE_CREDENTIAL “***”
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
#define SSID “***”
#define SSID_PASSWORD “***”

#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS_1 0 //pin D3
#define ONE_WIRE_BUS_2 2 //pin D4

OneWire oneWire_TExt(ONE_WIRE_BUS_1);
OneWire oneWire_TAux(ONE_WIRE_BUS_2);

DallasTemperature sensor_TExt(&oneWire_TExt);
DallasTemperature sensor_TAux(&oneWire_TAux);

int TInt = 21;
int TExt = 21;
int TAux = 21;
int rel_hum = 50;
byte Previoustemp = 0;
byte PreviousHR = 0;

void setup() {

thing.add_wifi(SSID, SSID_PASSWORD);

Serial.begin(9600);

delay(100);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(WHITE);

Wire.begin(); //pin D1 (SCL GIPO5) pin D2 (SDA GIPO4)

sensor_TExt.begin();
sensor_TAux.begin();

thing[“data-serre”] >> [](pson & out) {

out ["temperatureIN"] = sensor_TAux.getTempCByIndex(0);
out["temperatureOUT"] = sensor_TExt.getTempCByIndex(0);
out["temperatureSTH"] = SHT2x.GetTemperature();
out ["Humidity(%RH):"] = SHT2x.GetHumidity();

};
}

void loop() {
sp();
ecran();
thing.handle();

thing.write_bucket(“dataserre”, “data-serre”);

delay(5000);
Serial.print("Dodo ");

// ESP.deepSleep(3000000, WAKE_RF_DEFAULT);
}

void sp () {

Serial.println("");
Serial.println("WiFi ");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

Serial.print("T.EXT: ");
Serial.println(sensor_TExt.getTempCByIndex(0));

Serial.print("Humidity(%RH): ");
Serial.print(SHT2x.GetHumidity());

Serial.print(" T.INT©: “);
Serial.println(SHT2x.GetTemperature());
Serial.print(” Dewpoint©: ");
Serial.println(SHT2x.GetDewPoint());
Serial.print("T.AUX: ");
Serial.println(sensor_TAux.getTempCByIndex(0));
}

void ecran () {
TInt = SHT2x.GetTemperature() ;
char stringTI[10];

dtostrf(TInt, 3, 0, stringTI);

rel_hum = SHT2x.GetHumidity();
char stringHR[10];
dtostrf(rel_hum, 3, 0, stringHR);

TExt = sensor_TExt.getTempCByIndex(0);
char stringTE[10];
dtostrf(TExt, 3, 0, stringTE);

TAux = sensor_TAux.getTempCByIndex(0);
char stringTA[10];
dtostrf(TAux, 3, 0, stringTA);

sensor_TExt.requestTemperatures();
sensor_TAux.requestTemperatures();
display.clearDisplay();

display.setFont(&FreeMono9pt7b);

if (WiFi.status() == WL_CONNECTED) {

display.setCursor(78, 10); // (x,y)
display.println("WiFi");

}
else {
display.setCursor(78, 10); // (x,y)
display.println(“NoWF”);
}

display.setCursor(10, 26);
display.println(“T INT”);
display.setCursor(70, 26);
display.println(stringTI);
display.setCursor(110, 26);
display.println(“C”);

display.setCursor(10, 10);
display.println(“HR”);
display.setCursor(30, 10);
display.println(stringHR);
display.setCursor(65, 10);
display.println("%");

display.setCursor(10, 42);
display.println(“T.EXT”);
display.setCursor(70, 42);
display.println(stringTE);
display.setCursor(110, 42);
display.println(“C”);

display.setCursor(10, 58);
display.println(“T.AUX”);
display.setCursor(70, 58);
display.println(stringTA);
display.setCursor(110, 58);
display.println(“C”);

display.display();
}

Hi, please post the code in the right way, select all of it and press the button “</>” at the menu bar, this helps us to read the code easy.

Add the line
#define _DEBUG_
At the begining of the sketch, this will show in serial console what is going on with thinger process at the microcontroller on serial console, paste the result if you can’t solve the issue.

Using the deepsleep you need to make a particular connection, here you may see a detailed guide to use this feature

Hope this helps to solve your issue.

hello


I think the data is send, I don’t see it in Bucket Data in Thinger

Thanks fou your help

image

#define _DEBUG_
#include <Adafruit_GFX.h>       
#include <Adafruit_SSD1306.h>  
#include <Fonts/FreeMono9pt7b.h> 
Adafruit_SSD1306 display(128, 64);           

#include <Sodaq_SHT2x.h>


#include <ThingerESP8266.h>
#define USERNAME "MVe"
#define DEVICE_ID "DataSerre"
#define DEVICE_CREDENTIAL "**"
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
#define SSID "WiFi-****"
#define SSID_PASSWORD "***"


#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS_1 0  //pin D3
#define ONE_WIRE_BUS_2 2  //pin D4

OneWire oneWire_TExt(ONE_WIRE_BUS_1);
OneWire oneWire_TAux(ONE_WIRE_BUS_2);

DallasTemperature sensor_TExt(&oneWire_TExt);
DallasTemperature sensor_TAux(&oneWire_TAux);

int TInt = 21;
int TExt = 21;
int TAux = 21;
int rel_hum = 50;
byte Previoustemp = 0;
byte PreviousHR = 0;


void setup() {

  thing.add_wifi(SSID, SSID_PASSWORD);

  Serial.begin(9600);
  
  delay(100);  
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  
  display.clearDisplay();  
  display.setTextColor(WHITE);  

  Wire.begin();  //pin D1 (SCL GIPO5) pin D2 (SDA GIPO4)

  sensor_TExt.begin();
  sensor_TAux.begin();

  thing["data-serre"] >> [](pson & out) {

    out ["temperatureIN"] = sensor_TAux.getTempCByIndex(0);
    out["temperatureOUT"] = sensor_TExt.getTempCByIndex(0);
    out["temperatureSTH"] = SHT2x.GetTemperature();
    out ["Humidity(%RH):"] = SHT2x.GetHumidity();
  };
}


void loop() {
  sp();
  ecran();
  thing.handle();

  thing.write_bucket("dataserre", "data-serre");

  delay(5000);
  Serial.print("Dodo ");

   ESP.deepSleep(300000000, WAKE_RF_DEFAULT);
}


void sp () {

  Serial.println("");
  Serial.println("WiFi ");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  Serial.print("T.EXT: ");
  Serial.println(sensor_TExt.getTempCByIndex(0));

  Serial.print("Humidity(%RH): ");
  Serial.print(SHT2x.GetHumidity());

  Serial.print("     T.INT(C): ");
  Serial.println(SHT2x.GetTemperature());
  Serial.print("     Dewpoint(C): ");
  Serial.println(SHT2x.GetDewPoint());
  Serial.print("T.AUX: ");
  Serial.println(sensor_TAux.getTempCByIndex(0));
}

void ecran () {
  TInt = SHT2x.GetTemperature() ;
  char stringTI[10];  
 
  dtostrf(TInt, 3, 0, stringTI);  

  rel_hum = SHT2x.GetHumidity();
  char stringHR[10]; 
  dtostrf(rel_hum, 3, 0, stringHR);  

  TExt = sensor_TExt.getTempCByIndex(0);
  char stringTE[10];  
  dtostrf(TExt, 3, 0, stringTE);  

  TAux = sensor_TAux.getTempCByIndex(0);
  char stringTA[10];  
  dtostrf(TAux, 3, 0, stringTA);


  sensor_TExt.requestTemperatures();
  sensor_TAux.requestTemperatures();
  display.clearDisplay();

  display.setFont(&FreeMono9pt7b);

  if (WiFi.status() == WL_CONNECTED) {

    display.setCursor(78, 10); // (x,y)
    display.println("WiFi");
  }
  else {
    display.setCursor(78, 10); // (x,y)
    display.println("NoWF");
  }

  display.setCursor(10, 26); 
  display.println("T INT");  
  display.setCursor(70, 26); 
  display.println(stringTI);  
  display.setCursor(110, 26); 
  display.println("C");  

  display.setCursor(10, 10); 
  display.println("HR");  
  display.setCursor(30, 10); 
  display.println(stringHR);  
  display.setCursor(65, 10); 
  display.println("%");  

  display.setCursor(10, 42); 
  display.println("T.EXT");  
  display.setCursor(70, 42); 
  display.println(stringTE);  
  display.setCursor(110, 42); 
  display.println("C");  


  display.setCursor(10, 58); 
  display.println("T.AUX"); 
  display.setCursor(70, 58); 
  display.println(stringTA);  
  display.setCursor(110, 58); 
  display.println("C");  


  display.display();
}

Hi, the bucket name is case sensitive, you should use:

thing.write_bucket("DataSerre", "data-serre");

Try it and let me know how it goes.

Hello, you are the best :wink:
Many Thanks

This project is for monitoring my greenhouse

when I go use it, I go show the résult