Helllo @Handy_ID,
you can try with something like:
if(millis()%(1000*60*15)==0)thing.stream("TempHum");
Helllo @Handy_ID,
you can try with something like:
if(millis()%(1000*60*15)==0)thing.stream("TempHum");
Hi, nice code. I tryed to use it as sample, but it disconnects after 2 min, and not connect again? do you have idea why? thanks
Hi, write at the top of your sketch the following:
#define _DEBUG_
It will give info about what is going on with the cloud process, paste the serial console report to see how can we help you.
Have you connected the ESP8266 RST pin to D0 so that it can wake up?
Hi @shean,
D0 on '66 contains the boot mode selection. The right wiring to wkup using the watchdog is GPIO16 which contains the XPD_DCDC. With this wiring you can implement ESP.deepsleep function with really low power consumption, which is quite useful while working with batteries BTW.
Hi, thanks for the reply, i started from your code, and from the âclimastickâ example, i managed to make it stay connected and write to bucket every x time i want⌠it works perfectly⌠BUT⌠iâm trying to adapt for my application and it cannot connect att all!! please can you have a look? posting the code that works, and after the one that doesnât workâŚ
#define DEBUG // Grazie a questi finalmente si eâ connesso, dopo infiniti tentativi
#define DISABLE_TLS //
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h> // reqâd by thinger
// THINGER ID LOGIN CREDENTIALS
#define USERNAME âsistralsrlâ
#define DEVICE_ID âWemosIFRprototipoâ
#define DEVICE_CREDENTIAL âifr1234â
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
// LAN WIFI CREDENTIALS
#define SSID âRigertâ
#define SSID_PASSWORD âalbinoniE45â
// SET A TIME PERIOD TO UPDATE TEMP AND HUMID READINGS
//#define SLEEP_MS 120000 // 60,000 milliseconds FOR DEEPSLEEP MODE
// DHT11 START
#include âDHT.hâ
float temperature;
float humidity;
#define DHTPIN D2 // ESP8266 pin number for DHT11 data pin
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
// DHT11 END
int timer = 0;
// SETUP START
void setup() {
//// TEMP HUMIDITY DEVICE
dht.begin();
//// END TEMP DEVICE
//// WIFI STUFF
Serial.begin(115200);
delay(100);
Serial.println(âBootingâ);
//// WIFI STUFF END
//// THINGER START
thing.add_wifi(SSID, SSID_PASSWORD);
thing[âWemosIFRâ] >> [](pson& out){
out[âtemperatureâ] = 10 ;
out[âhumidityâ] = dht.readHumidity();
};
thing[âin_outâ] = [](pson& in, pson& out){
out[âsumâ] = (int)in[âvalue1â] + (int)in[âvalue2â];
out[âmultâ] = (int)in[âvalue1â] * (int)in[âvalue2â];
out[âmultâ] = (int)in[âtemperatureâ] * (int)in[âvalue2â];
out[âmultâ] = (int)out[âmillisâ] * 2;
};
thing["temperature"] >> outputValue(millis());
//// THINGER END
}
//// SETUP END
//// TEMP HUMIDITY SUBROUTINE (not reqâd except for serial print)
void TempHum(){
humidity = dht.readHumidity();
temperature = dht.readTemperature();
// Check if any reads failed and exit.
if (isnan(humidity) || isnan(temperature)) {
Serial.println(âFailed to read from DHT sensor!â);
return;
}
Serial.print(âHumidity: â); //nome della colonna
Serial.print(humidity);
Serial.print(â %\tâ);
Serial.print("Temperature: â); ////nome della colonna
Serial.print(temperature);
Serial.println(â *C ");
}
//// END TEMP HUMIDITY SUBROUTINE
void loop() {
thing.handle();
if(millis()>timer+(600001)){ //call each 1 minutes (THIS MADE ME CONNECT IT STABLE)
//call thinger.io endpoint function and attacht the pson
thing.write_bucket(âBucketIFRâ, âWemosIFRâ); //ID Bucket , thing
//actualize time counter
timer = millis();
}
//ESP.deepSleep(SLEEP_MS1000, WAKE_RF_DEFAULT);
//END OF THE CODE THAT WORKD
This is the adaption of my code, pretty similar but it cannot connect!!!
#define DEBUG // Grazie a questi finalmente si eâ connesso, dopo infiniti tentativi
#define DISABLE_TLS
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h> // reqâd by thinger
#include <OneWire.h> // Libreria per lâuso del protocollo unico filo
#include <DallasTemperature.h> // Libreria per la lettura della temperatura
#include <HX711.h> // Libreria per la lettura della scheda AD HX711 per ponti estensimetrici
// THINGER ID LOGIN CREDENTIALS
#define USERNAME âsistralsrlâ
#define DEVICE_ID âWemosIFRprototipoâ
#define DEVICE_CREDENTIAL âifr1234â
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
// LAN WIFI CREDENTIALS
#define SSID âRigertâ
#define SSID_PASSWORD âalbinoniE45â
// SET A TIME PERIOD TO UPDATE TEMP AND HUMID READINGS
//#define SLEEP_MS 120000 // 60,000 milliseconds FOR DEEPSLEEP MODE
#define wire D3 // Unico filo - D3 = GPIO0
#define ledPin D4 // Led scheda - D4 = GPIO2
#define GND1 D8 // Primo HX711 (Sezione 1) - GND - D8 = GPIO15
#define sezione1_SCK_PIN D7 // Primo HX711 (Sezione 1) - Clock - D7 = GPIO13
#define sezione1_DOUT_PIN D6 // Primo HX711 (Sezione 1) - Data - D6 = GPIO12
#define alim1 D5 // Primo HX711 (Sezione 1) - Alim - D5 = GPIO14
//const int sezione2_SCK_PIN = 4; // Secondo HX711 (Sezione 2) - Clock - D2 = GPIO4
//const int sezione2_DOUT_PIN = 5; // Secondo HX711 (Sezione 2) - Data - D1 = GPIO5
float temp = 0; // inizializza valore temperatura
int hx1ass = 0; // valore iniziale di 0 del primo HX711 collegato
int hx1zero = 0; // costante di 0 del Primo HX711 collegato
int hx1sens = 1; // corrisponde alla coeff di conversione digit/me/kN del primo HX711 (taratura con calibratore Pavone Sistemi)
int carico1 = 0; // inizializzazione di carico1
int soglia1 = 500; // definizione soglia1 da confrontare con carico1 dellâhx1
//int hx2ass = 0; // valore iniziale di 0 del secondo HX711 collegato
//int hx2zero = 0; // costante di 0 del Secondo HX711 collegato
//int hx2sens = 1; // corrisponde alla coeff di conversione digit/me/kN del secondo HX711 (taratura con calibratore Pavone Sistemi)
float temperature;
float humidity;
int timer = 0; // timer per lettura dati temporizzata
int freq = 20; // frequenza di lettura e trasmissione dati (in secondi)
OneWire oneWire(wire); // Sensore Temperatura DS18B20 - D3=GPIO0
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature
HX711 sezione1(sezione1_DOUT_PIN, sezione1_SCK_PIN); // We define the first scale (Sezione 1)
//HX711 sezione2(sezione2_DOUT_PIN, sezione2_SCK_PIN); // We define the second scale (Sezione 2)
// SETUP START
void setup() {
//pinMode(ledPin, OUTPUT); // collegato al led sulla scheda WeMos D1R2
//pinMode(GND1, OUTPUT); // per creare un GND
//pinMode(alim1, OUTPUT); // per creare una Alim +3.3V
//digitalWrite(GND1, LOW); // configura un GND
//digitalWrite(alim1, HIGH); // configura una Alim +3.3V
sensors.begin(); // per la lettura della temperatura
// sezione1.set_scale(221); // <- coef di calibrazione tarato per ottenere mV/V x 10000 sui HX711
// sezione2.set_scale(221); // <- coef di calibrazione tarato per ottenere mV/V x 10000 sui HX711
//// WIFI STUFF
Serial.begin(115200);
delay(100);
Serial.println(âBootingâ);
//// WIFI STUFF END
//// THINGER START
thing.add_wifi(SSID, SSID_PASSWORD);
thing[âLetturaDatiâ] >> [](pson& out){
out[âtemperatureâ] = sensors.getTempCByIndex(0);
out[âHx711â] = sezione1.read_average(20);
};
thing[âin_outâ] = [](pson& in, pson& out){
out[âsumâ] = (int)in[âvalue1â] + (int)in[âvalue2â];
out[âmultâ] = (int)in[âvalue1â] * (int)in[âvalue2â];
out[âmultâ] = (int)in[âtemperatureâ] * (int)in[âvalue2â];
out[âmultâ] = (int)out[âmillisâ] * 2;
};
thing["temperature"] >> outputValue(millis());
//// THINGER END
}
//// SETUP END
void loop() {
// if (WiFi.status() != 6) digitalWrite(ledPin, LOW); // se wifi collegato allora led scheda acceso (invertito)
// else digitalWrite(ledPin, HIGH); // nel caso contrario: led scheda spento (invertito)
//}
thing.handle();
if (millis() > timer + (freq * 1000)) { //call each âfreqâ minutes
sensors.requestTemperatures();
thing.write_bucket(âBucketIFRâ, âLetturaDatiâ); //call thinger.io endpoint function and attacht the pson (ID Bucket, thing)
timer = millis(); //actualize time counter
}
//ESP.deepSleep(SLEEP_MS*1000, WAKE_RF_DEFAULT);
}
Hi @sistralsrl, two things:
1st When publish your sketchs, please post the code in the appropriate way, the forum has a tool to publish the code, it is useful to read the code in a more comfortable way, help us to help you.
2nd Please post the serial debug behaviour (as I explicit asked in my previous reply), it may save us a lot of time, instead of wasting reading and understanding all the details to find what it is wrong in your code, make the machine work for you and us (showing the issue), not us to work for them (it is a waste of time for something that could be diagnosticated in seconds), and tell us any behaviour you may see, we have experience but we cannot see across your eyes, any particular detail may help us to detect what is going on with your particular case.
Iâm still waiting to help you solve the issue.
Hi, thank you and sorry for my elementary mistakes! you can find attached the sketch and as you can see on the line, just adding the inclusion of a library, it does not work, attaching also the serial monitor:
Thanks
Preformatted text
#define DEBUG /
#define DISABLE_TLS
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>#include âDHT.hâ
#include âHX711.hâ //just including this, it doesnât connect!! without this yes!!
//even this way is not connecting: <HX711.h>#define USERNAME âsistralsrlâ
#define DEVICE_ID âdevidâ
#define DEVICE_CREDENTIAL âpassâ
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);#define SSID âRigertâ
#define SSID_PASSWORD âpassâint timer = 0;
//int freq = 20;#define DHTPIN D2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);//#define sezione1_DOUT_PIN D6
//#define sezione1_SCK_PIN D7
//HX711 sezione1(sezione1_DOUT_PIN, sezione1_SCK_PIN);void setup() {
Serial.begin(9600);
delay(100);
Serial.println(âBootingâ);// Setup WiFi
thing.add_wifi(SSID, SSID_PASSWORD);
// Define the âthingâ with a name and data direction
thing[âdht11â] >> (pson& out){
// Add the values and the corresponding code
out[âhumidityâ] = dht.readHumidity();
out[âcelsiusâ] = dht.readTemperature();
//out[âHx711â] = sezione1.read();};
}void loop() {
thing.handle();
if(millis()>timer+(60000*1)) { //call each âfreqâ minutes
thing.write_bucket(âBucketIFRâ, âdht11â); //call thinger.io endpoint function and attacht the pson (ID Bucket, thing)
timer = millis(); //actualize time counter
}
}
Not working sketch
Working Sketch
I saw you opened a post with the issue, I will answer overthere.