Is there a list of brands and models of wifi power sockets/strips out there that will accept http commands or otherwise can be directly controlled from a script, without having to use a hub or the cloud?
Is there a list of brands and models of wifi power sockets/strips out there that will accept http commands or otherwise can be directly controlled from a script, without having to use a hub or the cloud?
If you have the compiled code then you can use ESPYTOOL. If you have the uncompiled sketch the you need the IDE or a DE.
Yes and no! You do need a USB-serial module though since these boards do not have USB micros on board. But it looks like you have it and have soldered in the header above.
OK, I figured that out last night. Two new questions:
- Is there a way with the BC tools to copy or backup what is on the Sonoff device currently and put it back on?
- do I use one of the selections in the InterfaceSetup.bat , the two Sonoff ones look similar with the exception of the '-bm dio' argument
/*************************************************************
ITEAD Sonoff S31 - OTA version for the Blynk app.
*************************************************************/
/* Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int buttonPin = 0; // Sonoff On/Off button
int relayPin = 12; // Sonoff relay
int ledPin = 13; // Sonoff green LED - always on
int relayStatus = 0;
// variables will change
int buttonState = LOW; // variable for reading the pushbutton status
int lastButtonState = HIGH; // previous state of the button
int relayState = LOW;
int ledState = LOW;
int volts = 0;
long lastTime = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
// Your WiFi credentials.
// Set password to "" for open networks.
const char* ssid = "ssid";
const char* password = "passward";
char auth[] = "blynk authorization"; // Sonoff S31 "4M(3M SPIFFS)"
WidgetLED led1(V10); // Widget Relay LED
BLYNK_WRITE(V1) { // Widget relay button
relayStatus = param.asInt();
if (relayStatus == 1) {
relayState = HIGH;
}
else {
relayState = LOW;
}
} // end - BLYNK_WRITE(V1)
void setup() {
Serial.begin(115200);
Serial.println("Booting");
Blynk.begin(auth, ssid, password);
while (Blynk.connect() == false) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
// ============ OTA =============
ArduinoOTA.onStart([]() {
Serial.println("Start");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// ============ OTA end =============
pinMode(buttonPin, INPUT); // on/off button
pinMode(relayPin, OUTPUT); // relay
pinMode(ledPin, OUTPUT); // led
digitalWrite(ledPin, LOW); // always on
}
void loop() {
ArduinoOTA.handle();
Blynk.run();
pushButton();
ledStatus();
}
void pushButton() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && lastButtonState == LOW && millis() - lastTime > debounce) {
if (relayState == HIGH) {
relayState = LOW;
Blynk.virtualWrite(V1, 0);
}
else {
relayState = HIGH;
Blynk.virtualWrite(V1, 1);
}
lastTime = millis();
}
digitalWrite(relayPin, relayState); // Relay open/close - digital pin 12
lastButtonState = buttonState;
} //end - pushButton()
void ledStatus() { // Widget LED - relay status
ledState = digitalRead(relayPin);
if (ledState == HIGH)
led1.on();
else
led1.off();
}
I'm using craftbeerpi3 and the HTTP actor plugin. Easy and cheap. Can control relays and ssrs through an esp8266 or esp32.
per original post, what brand/model of wifi power socket are you using... and how(specifically, not just 'arduino IDE' ) did you program it? pics?
Enter your email address to join: