Hey,
My problem is that the thing.write_bucket is not working all the time.
I tried the stream option but it didn’t work aswell. Hope someone can help. I’m quite new to coding.
Project:
For my home automated watering system i’d like to log the state of a switch.
My Idea is that arduino 1 is monitoring the soil moisture. (it is working for some weeks and logging all the date to thinger) If the moisture level is too low, it will put HIGH on an Output bin.
Now i want to log this state with my other Arduino 2. (all ESP8266 WIFI)
And then power on an relais for the pump.
Somehow the LED Output (outPIN) is working good.
The Serial Print prints only if there is a change between 0 / 1.
Now i want to log exactly the same data as printed.
If the Input is HIGH then is should log Timestamp + 1
If the Input is LOG it should log Timestamp + 0
Thanks"
Code for Arduino 2(without all the login infos)
// Thinger Stuff
ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
int inPin = 16; //D0 am Board
int outPin = 5; //d1 am board
int state = HIGH; // the current state of the output pin
int drylimit = 0;
int old_drylimit = 0;
void setup() {
thing.add_wifi(SSID, SSID_PASSWORD);
thing[“Switch”] >> (pson & out) {
out[“on”] = drylimit;
};
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
Serial.begin(9600);
Serial.println(“initalize…”);
}
void loop() {
thing.handle();
drylimit = digitalRead(inPin);if (old_drylimit != drylimit) {
old_drylimit = drylimit;
thing.write_bucket(“l2_switchstate”, “Switch”);Serial.print(drylimit);
Serial.println(“”);
if (drylimit == 1){
state = HIGH;
}
else
state = LOW;}
digitalWrite(outPin, state);
}