Hello everyone, I am trying to send my data to the bucket, it gets connected for a while and sends data to the bucket but after 2 mins, my device becomes disconnected. I chose the FROM DEVICE WRITE CALL. The bucket receives data too, But unfortunately it gets disconnected. Here’s my code. I followed through the thing.write_bucket and I wonder what seems to be the problem. Is it inside my loop function? Thanks in advance for the help.
#define DEBUG*
#include <ThingerESP8266.h>*
#include <ESP8266WiFi.h>*
#include <SPI.h>*
#include <Wire.h>*
#define USERNAME "**********"
#define DEVICE_ID “BUCKET_1”
#define DEVICE_CREDENTIAL “BUCKET_1”
#define SSID “"
#define SSID_PASSWORD "”*
byte indicator = 13;
byte sensorInt = 0;
byte sensorPIN = 2;
float constant = 6.0; //constant for the formula
volatile byte pulseCount;
float A;
float B;
unsigned int flowML;
unsigned long totalML;
unsigned long oldTime;
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);*
void setup()
{
Serial.begin(115200);
pulseCount = 0;
A = 0.0;
flowML = 0;
totalML = 0;
oldTime = 0;
B = 0.0;
thing[“sensor”] >> [](pson & out) {
digitalWrite(sensorPIN, HIGH);
attachInterrupt(digitalPinToInterrupt(2), pulseCounter, FALLING);
out["volume"] = totalML;
};
}
void loop()
{
thing.handle();
thing.write_bucket(“BUCKET_1”, “volume”);
Serial.println(“Going to deep sleep”);
ESP.deepSleep(1000000 * 30, WAKE_RF_DEFAULT);
if ((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInt);
A = ((1000.0 / (millis() - oldTime)) * pulseCount) / constant;
oldTime = millis();
flowML = (A / 60) * 1000;
totalML += flowML;
B = totalML * 0.0000025; //at 2.50 per cubic meter or 0.0000025 per mL
unsigned int frac;
Serial.print("Volume: ");
Serial.print(totalML);
Serial.print("mL");
Serial.print("\t");
pulseCount = 0;
attachInterrupt(digitalPinToInterrupt(2), pulseCounter, FALLING);
}
}
void pulseCounter()
{
// Increment the pulse counter*
pulseCount++;
}