/!\ Vorläufig / Preliminary, work in progress /!\

.

.

.

.

.

.

attachment:Sonoff_OBI_WIFI_Steckdose_DSC07686.jpg

OBI WIFI Steckdose

In the German Computer magazine c't 2018-11 page 152 an interesting project was described:

With the software Tasmota you can connect via Web Browser to the WLAN Steckdose for configuration and direct ON/OFF switching. Also a time switching plan for a week can be setup.

/!\ DANGER This devices uses mains power 230VAC! For good reasons it is not build to be opened and if you do so, you are responsible for your life! Never ever touch it or connect it to your computer when connected to mains.

/!\ A mouse click on a picture will expand the picture for better viewing.

/!\ A mouse click on a source program will show the listing in a new window with colour coding.

attachment:Sonoff_Drei-Fluegel_Bit_DSC07685.jpg

Hardware

In order to flash the Tasmota software at the ESP8266 controller, first you need to open the case.

Then solder a 7 pin connector (2.54 mm spacing) to the PCB for connecting an USB to UART adapter.

attachment:Sonoff_Stiftleiste_DSC07682.jpg

See the photo on the right.

The lower part of the pin's should be bent 90 degrees for better soldering.

Use an 3.3 V USB to UART adapter, with a 3.3 V supply pin. The 3.3 V must be supported with a 1000 uF 10 V capacitor to GND in order to avoid programming errors. A normal USB to UART adapter chip does not provide the peak power for programming the ESP8266.

The connection between USB to UART adapter and 7 pin connector must be:

# USB to UART adapter - 7 pin connector
           +-------     GND 
           +- jumper to GPIO00
          TXD    ---    RXD
          GND    ---    GND
          RXD    ---    TXD
    not connected       RESET
          3.3 V  ---    VCC

attachment:Sonoff_OBI_ESP8266_Module_pinout.png

/!\ Take care to install the suitable software driver for the USB to UART adapter chip (e.g. CP2102, etc) for your PC operating system (Linux, Mac OS or Windows). If you plugin the USB to UART adapter in the USB port of your PC, you should see a new serial port, e.g. /dev/ttyUSB0, /dev/cu.SLAB_USBtoUART or COM3:.

For the ESP8266 module pinout see the picture on the right.

The pin assignment is the following:

GPIO4 - blue WiFi LED
GPIO5 - Relay off (LOW pulse)
GPIO12 - Relay on (LOW pulse)
GPIO14 - Push Button

Software

/!\ Do not connect the WLAN Steckdose to the 230 VAC supply for flashing/programming. The 3.3 V supply from the USB to UART adapter is enough for working.

The software binary with the German version is sonoff-DE.bin (version 5.14, ESP8266/Arduino core version 2.3.0, 527 KB) for download.

For flashing/programming you need the actual Python program esptool.py versiom 2.3.1.

# Install Python 2.7, if not already provided
# run in a terminal:
$ pip2 install esptool
or
$ pip install esptool
  1. Download the file sonoff-DE.bin to a local folder.

  2. Connect the USB to UART adapter to your PC.

  3. Working in the Terminal, example under Mac OS:

# change to working folder
$ cd /Volumes/DAT/HDA8/INSTALL/Netzwerk/OBI

# test for function, download flash content
$ esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 read_flash 0x00000 0x100000 image1M.bin
esptool.py v2.3.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Uploading stub...
Running stub...
Stub running...
1048576 (100 %)
1048576 (100 %)
Read 1048576 bytes at 0x0 in 94.5 seconds (88.7 kbit/s)...
Hard resetting via RTS pin...  # only works if connected to RESET

# replug USB to UART adapter for RESET
# erase flash ROM
$ esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 erase_flash
esptool.py v2.3.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 2.7s
Hard resetting via RTS pin...  # only works if connected to RESET

# replug USB to UART adapter for RESET
# flashing/programming
$ esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 write_flash -fs 1MB -fm dout 0x0 sonoff-DE.bin
esptool.py v2.3.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 540128 bytes to 368726...
Wrote 540128 bytes (368726 compressed) at 0x00000000 in 32.4 seconds (effective 133.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...   # only works if connected to RESET

# remove jumper GPIO00 to GND
# replug USB to UART adapter for RESET

# Push WPS button on the router (Fritz!Box 7490)
# after about 1 minute look at the router network connection list
# you should see host: sonoff-xxxx

For trouble shooting you can connect a virtual terminal to sonoff (Steckdose):

  1. Arduino IDE monitor with 115200 baud, or
  2. Terminal program, e.g. CoolTerm with 115200 baud 8N1

You can see the logging (Tasmota version 5.14):

attachment:Sonoff_Main_menu.png

00:00:48 APP: starte neu

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3fff3390
~ld
.
00:00:00 Projekt sonoff Sonoff (Topic sonoff, Fallback DVES_523824, GroupTopic sonoffs) Version 5.14.0-2_3_0
00:00:00 WIF: verbinden mit AP1  in Modus 11N wie sonoff-6180...
00:00:14 WIF: Verbindung fehlgeschlagen, da der AP nicht antwortet (timeout)
00:00:14 WIF: verbinden mit AP1  in Modus 11N wie sonoff-6180...
00:00:28 WIF: WPSConfig aktiv f..r 3 Minuten
00:00:48 WIF: SmartConfigSSId1 FRITZ-IR
00:00:51 APP: starte neu

# Push WPS button on the router until LED blinks (e.g. Fritz!Box 7490)

00:00:00 Projekt sonoff Sonoff (Topic sonoff, Fallback DVES_523824, GroupTopic sonoffs) Version 5.14.0-2_3_0
00:00:00 WIF: verbinden mit AP1 FRITZ-IR in Modus 11N wie sonoff-6180...
00:00:05 WIF: verbunden
00:00:05 DNS: initialisiert
00:00:05 HTP: Web-Server aktiv bei sonoff-6180.local mit IP-Adresse 192.168.xxx.xxx

# In web browser input IP-address 192.168.xxx.xxx
# See the screenshot "Main menu" on the right

Software No WPS

If you do not have WPS (Wi-Fi Protected Setup) in your router, you can use the Terminal connection, see also here for more details.

All Supported Commands are listed here.

In the Terminal enter the WiFi router credentials:

# hit ENTER
00:00:37 CMD: 
00:00:37 RSL: stat/sonoff/RESULT = {"Command":"Unknown"}

# setup router SSID (do NOT enter the lace braces)
ssid1 <yourSSID>  ENTER

# setup router password (do NOT enter lace braces)
password1 <yourPassword>  ENTER

# disable MQTT activity
SetOption3 0   ENTER
18:07:05 RSL: RESULT = {"SetOption3":"OFF"}
18:07:06 RSL: INFO1 = {"Module":"Sonoff Basic","Version":"5.14.0","FallbackTopic":"DVES_51B1BE","GroupTopic":"sonoffs"}
18:07:06 RSL: INFO2 = {"WebServerMode":"Admin","Hostname":"sonoff-4542","IPAddress":"192.168.xxx.xxx"}
18:07:06 RSL: INFO3 = {"RestartReason":"Software/System restart"}
18:07:07 APP: starte neu

# wait for WLAN connect

attachment:Sonoff_Sonstige-Einstellungen.png

Configuration

Route your web browser (e.g. Firefox, Chrome) to the local IP address 192.168.xxx.xxx.

In order to stop the MQTT logging disable MQTT mode (remove mark on MQTT aktivieren), see the screenshot on the right.

.

.

.

.

.

The left screenshot below shows the Configuration menu.

The middle screenshot below shows the Device Type (Gerätetyp) menu it will show 01 Sonoff Basic, select here type 18 Generic.

Then click on Save (Speichern) and wait for the restart has finished.

The right screenshot below shows the Device Type (Gerätetyp) menu. Configure your device with the same I/O's, e.g. D2 GPIO4 will get 48 LED 1.

Then click on Save (Speichern) and wait for the restart has finished.

attachment:Sonoff_Konfiguration.png

attachment:Sonoff_Geraetetyp-Basic.png

attachment:Sonoff_Geraetetyp-Generic-OBI.png

attachment:Sonoff_Zeitplan_DST.png

Timer DST

If you use the Timer it may be useful to use the sunrise and sunset times. But those times depend on your geographic location (Latitude, Longitude) and also on the Daylight Saving Time (DST).

See the screenshot on the right for the sunrise and sunset times at 2018-06-15 at a location near Frankfurt.

Both are considered in the Tasmota software. I will explain the case for Germany (stock software sonoff-DE.bin, version 5.14).

Geographic Location

The default graphic location is set to the location of the Tour Eiffel in Paris. In order to change that to your personal location, you can use the Console window of the sonoff web server.

When you change the values, they are stored in Flash ROM.

In order to find you own location values, you can use Google Maps. Enter your address and read the Latitude and Longitude values from the URL line. Now the Console (virtual terminal) handling (The lines with a time at the beginning are output lines, finish your command with ENTER):

# check the default location
latitude
05:08:06 CMD: latitude
05:08:06 RSL: RESULT = {"Latitude":"48.858360"}  # Tour Eiffel, Paris
longitude
05:11:35 CMD: longitude
05:11:35 RSL: RESULT = {"Longitude":"2.294442"}

# Example Frankfurt Römerberg, 50.1100897,8.6800605 (from Google Maps)
latitude 50.1100897
05:09:09 CMD: Latitude 50.1100897
05:09:09 RSL: RESULT = {"Latitude":"50.1100897"}
longitude 8.6800605
05:12:27 CMD: Longitude 8.6800605
05:12:27 RSL: RESULT = {"Longitude":"8.6800605"}
# The values are stored in Flash ROM.

Daylight Saving Time

You also have to consider the DST. Check first your Timezone and the DST dates in the Console:

timezone
05:34:40 CMD: timezone
05:34:40 RSL: RESULT = {"Timezone":1}  # MEZ

timeDST
05:35:34 CMD: TimeDST
05:35:34 RSL: RESULT = {"TimeDst":{"Hemisphere":0,"Week":0,"Month":3,"Day":1,"Hour":2,"Offset":120"}}

timeSTD
05:38:32 CMD: TimeSTD
05:38:32 RSL: RESULT = {"TimeStd":{"Hemisphere":0,"Week":0,"Month":10,"Day":1,"Hour":3,"Offset":60"}}

In order to consider the sunrise and sunset times you need to set the timezone parameter to 99. Again type in the Console:

timezone 99 # Use Daylight Saving parameters configured with TimeDST and TimeSTD
05:43:56 CMD: timezone 99
05:43:56 RSL: RESULT = {"Timezone":99}
# The values are stored in Flash ROM.

Button1 usage

The most useful original Button1 usage:

See below the logging if you press Button1 4 times, in the virtual Terminal:

11:00:39 RSL: RESULT = {"WifiConfig":"WifiManager selected"}
11:00:39 WIF: WifiManager aktiv f..r 3 Minuten
11:00:39 HTP: Web-Server angehalten
11:00:40 HTP: Web-Server aktiv bei sonoff-4542.local mit IP-Adresse 192.168.4.1
11:02:00 RSL: UPTIME = {"Time":"2018-06-17T11:02:00","Uptime":"0T00:07:05"}
11:02:18 WIF: Hostname %s-%04d, SSId1 FRITZ-IR, SSId2 
11:02:20 APP: starte neu

Final

Now you can assemble your Steckdose and test it again by plugging it into a 230 VAC power plug and route the web browser to the known IP address.

By looking through all the menu items you can see all the standard capabilities of the WLAN switch.

When you click AN (ON) in the main menu, you can hear the relay switching, and the blue and red LED's are illuminated.

There are much more features in the Tasmota software, please have a look at the Tasmota wiki.

  1. Sonoff basic schematic on this web page

  2. Arduino Software IDE download (Integrated Development Environment), actual version 1.8.5.

  3. Tasmota Button usage

  4. Flash-Sonoff-using-Raspberry-Pi

Contact Email

Please enter your Email address, if you expect an answer.

/!\ The entered Email address will not be published, or given away.

Comment this page
Name:
Comment:
Are you human?

List of pages in this category:

-- RudolfReuter 2018-06-12 16:37:47


Go back to CategoryIoT or FrontPage

ObiWIFISteckdose (last edited 2018-06-17 18:05:06 by RudolfReuter)