How to make a resource (button) can be accessed both via manual and via platform?


#1

Hello all,
As i mentioned above, i want to make a button that can be accessible via thinger platform and via physical button also to turn ON/Off an electrical appliances. This way, when the device is not connected to internet or the internet is down, we can still ON and Off the appliances using physical button.

I already write the code like this, but still cannot work :

void setup() {
Serial.begin(115200);
Serial.println();
//Set mode for all IO pins
pinMode(output1, OUTPUT);
pinMode(output2, OUTPUT);
pinMode(reedSwitch, INPUT);
pinMode(panicPin, INPUT_PULLUP);
pinMode(switch1, INPUT_PULLUP);
pinMode(switch2, INPUT_PULLUP);
delay(10);
thing.add_wifi(SSID, SSID_PASSWORD);
Serial.print(“connecting”);

thing[“sakelar1”]<< [](pson& in) {
if(in.is_empty()) {
in = (bool)digitalRead(switch1);
state = in ? LOW : HIGH; // control of the GPIO15
}
else {
digitalWrite(output1, state);
}
};

I am using NodeMCU with arduino IDE. The circuit is using input Pull-up with 10K resistor connected to On/Off switch. Anybody has the same experience?