Never said it won’t work… just basically pointing out that some pins have peculiar issues.
As for the Sonoff Basic, no problem using the built-in button on GPIO0.
I have some Blynkified Sonoff code here that I started with, but it does have some issues with “switch bounce”.
I have since then improved with more reliable anti-bounce code that I found in the tubes, for said button… but all mine now work on Virtuino instead of Blynk, so that is the only code I have handy and do not feel up to editing and testing my existing Blynk code right now.
But here is a snippet of the button monitoring with anti-bounce that you can probably merge if desired…
uint32_t start, dbStart;
const byte pysBtn = 0, led = 13, rly = 12, dbTime = 15;
bool pinState = true,
btnState = true,
prevBtnState = true,
latch = false;
pinMode(pysBtn, INPUT); // Button
pinMode(rly, OUTPUT); // Relay
pinMode(led, OUTPUT); // LED
void PhysButton() {
// Monitor and Debounce Physical Button
if (digitalRead(pysBtn) != pinState) { // get state of GPIO 0
dbStart = millis(); // reset db timer
pinState = !pinState; // now they are equal, won't enter
} // here again unless pin state changes
if (millis() - dbStart > dbTime) { // db timer has elapsed
btnState = pinState; // button state is valid
}
if (btnState != prevBtnState && btnState == HIGH) { // btnState changed
// if button pressed and NOT latched
if (!latch) {
latch = true; // prevents entry while latched
digitalWrite(led, HIGH); // LED ON
digitalWrite(rly, LOW); // Relay OFF
} else {
// if button pressed while latched,
latch = false;
digitalWrite(led, LOW); // LED OFF
digitalWrite(rly, HIGH); // Relay ON
}
if (latch) {
V_memory[1] = 1; // Update Virtuino Button Widget ON
} else {
V_memory[1] = 0; // Update Virtuino Button Widget OFF
}
}
prevBtnState = btnState;
}