sonoff

ESP32 – Stop Hard-coding WiFi Credentials!

Table of Contents

Links

Starter Code

				
					#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager


void setup() {
    WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
    // it is a good practice to make sure your code sets wifi mode how you want it.

    // put your setup code here, to run once:
    Serial.begin(115200);
    
    //WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wm;

    // reset settings - wipe stored credentials for testing
    // these are stored by the esp library
    //wm.resetSettings();

    // Automatically connect using saved credentials,
    // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
    // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
    // then goes into a blocking loop awaiting configuration and will return success result

    bool res;
    // res = wm.autoConnect(); // auto generated AP name from chipid
    // res = wm.autoConnect("AutoConnectAP"); // anonymous ap
    res = wm.autoConnect("AutoConnectAP","password"); // password protected ap

    if(!res) {
        Serial.println("Failed to connect");
        // ESP.restart();
    } 
    else {
        //if you get here you have connected to the WiFi    
        Serial.println("connected...yeey :)");
    }

}

void loop() {
    // put your main code here, to run repeatedly:   
}
				
			

Sonoff – Touch US tasmota flashing

Table of Contents

Upload

Wait until the all is done!

IP

Get the IP direct from tasmotizer

Error

I got this error and had to change my USB -> TTL converter!

Setup Tasmota

				
					Connect to your new flashed Sonoff over WiFi

SSID will be something like that "tasmota_xxxxxx-xxxx" without a password

Now connect in browser to 192.168.4.1

The tasmota interface will show up

add your WiFi credentials

if an error showsup restart device

ifnot get the
				
			
				
					button function_____________________________

setoption14 0
pulsetime1 10

MY Switch settings
_____________________________

savedata 1
SetOption13 1

setoption1 1
switchmode 5
setoption32 4
statetext4 Hold
buttontopic 1
setoption11 1
_____________________________