arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.21k stars 4.81k forks source link

Feature request: adding Obi Socket #1988

Closed Frickelmaster1 closed 6 years ago

Frickelmaster1 commented 6 years ago

German DIY store "OBI" is selling ESP8266-based sockets (very similar to Sonoff S20) for less than 10 EUR.

I got two of these sockets. It's quite easy to flash Tasmota on it but it was neccesary to modify sonoff/sonoff_template.h to make it work correctly. The same reason as with other clones: they assigned the GPIOs randomly to the available functions and chose others than ITEAD with their Sonoffs.

It would be nice if this configuration snippet could be added to the official sonoff_template.h.

I suggest adding these lines to sonoff_template.h for making the Obi Socket work:

{ "Obi Socket", // Obi socket (ESP8266) - https://www.obi.de/hausfunksteuerung/wifi-stecker-schuko/p/2291706 0, // GPIO00 Flash jumper - not available 0, // GPIO01 0, // GPIO02 0, // GPIO03 GPIO_LED1, // GPIO04 LED on top and in switch button GPIO_REL1, // GPIO05 Relay 1 (0 = Off, 1 = On) 0, 0, 0, 0, 0, 0, // Flash connection 0, // GPIO12 0, // GPIO13 GPIO_KEY1, // GPIO14 switch button 0, 0, // GPIO16 0 // },

reloxx13 commented 6 years ago

could you add images from the pins with description which pin is what?

Frickelmaster1 commented 6 years ago

The descriptions of the pins are printed on the PCB. They are similar to the pin names on any FTDI adapter.

reloxx13 commented 6 years ago

you could try to use the generic module (ex. wemos d1 pre 5.11.0 i think) on the web interface and set up your gpio config.

grafik (note: this is not from obi)

martin-ger commented 6 years ago

Some pics from the opened device can be found here: https://github.com/martin-ger/ESP8266-WiFi-Socket

martin-ger commented 6 years ago

It works somewhat different than the Sonoff basic: a low pulse on GPIO12 switches the relay on, a low pulse on GPIO5 switches it off.

Frickelmaster1 commented 6 years ago

In my Tasmota there is no "Generic" type so I had to edit the templates...

tobox commented 6 years ago

"Generic" has been added during the last days, replacing Wemos D1 Mini and NodeMCU variants.

Jason2866 commented 6 years ago

@Frickelmaster1 Does it work with your setup? I ask this because martin-ger describes the on off function different

Frickelmaster1 commented 6 years ago

My first Obi socket works fine, the second doesn't. I flashed the binary with ESPloader to the sockets. The first is OK, the second (with exactly the same firmware) is accessible via web interface, the on-off works (including the blue LED) but the relay isn't switching at all.

Maybe Martin can explain how he modified Tasmota to make it work with the Obi sockets?!

martin-ger commented 6 years ago

I did not use Tasmota but my onw software - works fine. I am not into the Tasmota code and platform.io, but use the esp_open_sdk and my MQTT framework.

The control of the relay works as follows:

The two ports are even named "RELAY ON" and "RELAY OFF" on the PCB of the ESP.

Also have an Arduino sketch that controls the device: https://github.com/martin-ger/ESP8266-WiFi-Socket/blob/master/OBISocket.ino

martin-ger commented 6 years ago

In the sources I read something about "latch" - should be similar to this issue #58.

Frickelmaster1 commented 6 years ago

Although I can't imagine maybe there are differences between my sockets I'll compare them tonight.

Strange... one is working fine, the other one doesn't switch the relay - with identical firmware.

I'll try to use a modified EXS relay configuration on the second socket. Thanks, Martin!

thxthx0 commented 6 years ago

I have solved the 'pulse issue' by setting GPIO12 to always 0 (as LED) and works fine.

obi wlan kenobi

Gulaschcowboy commented 6 years ago

Got mine today and can confirm @thxthx0 solution. Thanx

hudecitydave commented 6 years ago

Same here. Confirm @thxthx0. Firmware flash with GND/GPIO0 pin method, update to tasmota 5.12, shown config above. works. THANKS! What a great community!

Frickelmaster1 commented 6 years ago

Tried it yesterday in the evening - works fine with Tasmota 5.12.x and "Generic" device with the settings above.

Thanks! So my request to add "Obi socket" to Tasmota's sonoff_template.h is no longer necessary :-) Nice!

reloxx13 commented 6 years ago

added to wiki https://github.com/arendst/Sonoff-Tasmota/wiki/Obi-Socket

etamtlosz commented 6 years ago

How did you manage to access Tasmota on the OBI plug? I'm struggling since yesterday evening. I'm able to flash it, but no wifi, no interface, nothing.

reloxx13 commented 6 years ago

build the firmware yourself, enter wifi credentials in the user_config.h and flash again.

dont forget to reset the cfg_holder

enter wifi data change cfg_holder flash change cfg_holder back to default flash again.

their is not btn on gpio1 thats why you cannot start the manager with btn press and default is wps mode

etamtlosz commented 6 years ago

I'm doing something wrong.

edited my wireless settings, including ip changed cfg_holder to the actual day flashed reconnected changed the cfg_holder to 0x20161209 flashed

It won't connect to my wireless, no ping, etc. I think I'll wait until some more detailed tutorials are going to be published for this plug.

reloxx13 commented 6 years ago

their is nothing more to add, its an esp like in all other devices.

do you got other devices with tasmota which are connected to your wifi?

ip on 0.0.0.0 for dhcp.

no special chars in wifiname and password.

how you want to send a ping without an ip or connection to your router wtf dude...

even if it says its flashed 100% it can be not flashed due a defect usb flasher or you used wrong device config in arduino/atom. read the flash guides in the wiki.

etamtlosz commented 6 years ago

My ip was set to a fix IP, this is why I was monitoring the IP with ping. I'll try with DHCP, now.

I'm using the correct flashing method, I assume - Generic ESP8266 Module.

gunnwo commented 6 years ago

I have the latest firmware flashed. As the wlan was preconfigured access was possible. But I'm struggeling with the OBI socket and generic Type. Comparing the screen shot from above with the settings I only get 4 entries in the module configuration: GPIO1/3/4/14. So how do you enable the rest of the fields and enter the settings?

etamtlosz commented 6 years ago

Change it to generic, save. It will restart an you'll have the other options as well.

thxthx0 commented 6 years ago

If someone wants to confgure more sensors:

the onboard ESP8266 Module with 1MB is similar to 'WT8266-S1'

wt8266-s1-pins

cyablo commented 6 years ago

Got mine flashed with tasmota and used the settings suggested by thxthx0, but my relay does not turn on. Only Red & Blue LED's turn on. @Frickelmaster1 : Did you get it working on yours?

EDIT: MY BAD!!! Relay only works on wall power, not on 3.3V from USB TTL

CarstenKochems commented 6 years ago

I tryed to flash it with esptool. Connected gpio0 to grnd it flashes but then dosent boot up.

after 2-3 trys i got:

00:00:09 APP: starte neu

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

wdt reset

and nothign happend further, i used 5.12

Jason2866 commented 6 years ago

@Steakschen PreBuild Image or self compiled?

CarstenKochems commented 6 years ago

@Jason2866 pre-build https://github.com/arendst/Sonoff-Tasmota/releases

CarstenKochems commented 6 years ago

i flashed 2 times, and booted it 5 minutes, now it works solved :-) wait 2min+ to boot

renne commented 6 years ago

The current c't magazine 11/2018 presents the Obi/Euromate power socket on page 48 and explains how to open the power socket, solder the serial port and flash and configure Tasmota on page 152. The vendor is Euromate. The price at Obi is still 9,99 €.

@arendst An Obi WLAN Kenobi profile would be great for newbies.

I suggest to enable the internal pull-ups for GPIO5 and GPIO12 and display OFF/ON buttons which pull GPIO5 or GPIO12 down for 200 msec.

etamtlosz commented 6 years ago

It would be nice if someone could post some screenshots.

Jason2866 commented 6 years ago

Just my humble opinion. If a OBI is near you, this is a deal if you want the device fast. If you not in a hurry i would choose sonoff. The build quality of a sonoff S20 is better and it is cheaper.

Jason2866 commented 6 years ago

@etamtlosz See post @martin-ger

renne commented 6 years ago

@etamtlosz Use a Tri-Wing screw-driver instead of @martin-ger's drill. ;-)

@Jason2866 If you can get a CE/VDE-compliant sonoff device in Germany ...

Jason2866 commented 6 years ago

@renne Do you think the OBI device is really tested to be VDE compliant? (hüstel) CE this means nothing, every crab has this....

cremofix commented 6 years ago

hey folks,

I build the binaries with Atom and flashed the OBI Socket with the latest Tasmota. worked fine I used the workaround described in ct magazine and by @thxthx0 (GPIO12=LED2 and GPIO5=Relais1) it works fine. I can access the sockets IP and switch it on/off via browser

But I fail to acces the socket via MQTT

I have mosquitto installed on a raspberry as mqtt-broker I can connect to mosquitto with mqtt.fx unfortunately it seems that I do not have any connection between the socket an the mqtt broker this are my mqtt settings: bildschirmfoto von 2018-05-23 13-31-07

i have to correct myself. There is a connection . I can subscribe to "#"in mqtt.fx an I get the state of the socket without any problems. But I can not send any commands.

If i try to publish: /OBI1/cmnd/power on

nothing happens did I forget something? any idea? thanks

dzett commented 6 years ago

Hi there,

as per the described behaviour of the stock firmware, the Obi socket seems to use a latching relay only triggered via a short pulse.

Such a relay cannot be triggered from the "Generic" configuration because even though there is a capability to deal with latching relays introduced with 533855c , this is hardcoded against the module type EXS_RELAY which unfortunately has the Two relay outputs on different GPIOs.

I would prefer to use the relay as intended (hence not giving a constant high output on the "On" side of the relay). Is there any easy way to refactor this to be not bound to the module type but have some other "configuration switch" to indicate that GPIO_REL1 and GPIO_REL2 are actually the two latching "ends" of the relay configured?

renne commented 6 years ago

@dzett You're right. Firing one coil constantly not only increases wear of that coil but also makes the switching of the relaiy unreliable and increases switching time which can lead to burned contacts.

@arendst I suggest to add xx Relay N ON and xx xx Relay N OFF in the GPIO list of device configuration. Before and after firing a coil both GPIOs should be set to low.

cremofix commented 6 years ago

hey folks,

I do not know what I changed but now everything works fine I can subscribe and publish via MQTT and the OBI socket does everything correctly. I agree with dzett and renne. the workaround with GPIO=LED2 and coinstant fire on the coil does not seem to be ideal. I found out that the socket needs more than 2 Watts when switched on and only 0.6 W in standby It gets about handwarm. So running the latching relay without constant current should be a big improvement @arendst : would it be a big job to add a profile for this OBI socket? probably after the article in the ct magazine there will be a lot of persons buying this gadget.

arendst commented 6 years ago

Get me one for testing (I cannot order with obi as a non-german alien) and I will see how to get it implemented the correct way (using the pulses).

cremofix commented 6 years ago

@arendst : if you do not want to buy one, perhaps you just implement the pulse function for gpio12 and gpio5. I can test it here with the sockets and give you the results.

dzett commented 6 years ago

@arendst After playing around with the socket a bit more yesterday (trying to use the existing latching implementation for module EXS_RELAY which I assume is working and remapping the GPIOs), I am not so sure that the Obi socket really has a latching relay, as it would turn off right away when the pulse was over. Also, I looked for some sort of datasheet for the relay that is used (same type as seen on the pictures in earlier posts) and from what I found it seems to be just a plain standard relay. Does anybody still have the stock firmware on it and actually look at the outputs?

Edit: On the other hand, @martin-ger 's coding obviously uses pulses and his pictures show the same hardware :-)

cremofix commented 6 years ago

I just opened my socket and found this relais SMIH-NingBoSongle.pdf

this is not a latching relais. perhaps they use different models?

thxthx0 commented 6 years ago

That's right, it is not a latching relay.

There is a standard 16 amp relay, but driven by 'some kind of latching' transistor circuit.

I couldn't measure any differences in power consumption by using stock firmware, Tasmota (GPIO12 always 0) or martin-ger's ino.

The relay is driven at about 140mA and 5.4 V

dzett commented 6 years ago

Hi all,

@thxthx0, thanks for clarification - should have checked my inbox a bit earlier :-)

I just picked up another one at Obi and can confirm that also with stock firmware, across the pins driving the relay coil, there is a constant voltage visible while the output is active. The "Relay On" trace from the ESP8266 board goes into something that looks like a circuit around two transistors (flip flop, eh? good old times). So I guess we don't need any code changes after all. Thanks to all!

thilokru commented 6 years ago

Is it normal that the devices get hot? When turned off, it is warm to the touch, but when on it realy heats up.

thxthx0 commented 6 years ago

Yes, seems to be normal (and a 'feature' of this relay ;).

Power Consumption of the relay is about 0.75W (data sheet says 0.72W).

It also works reliable @ 4V and 0.4W, but temperature isn't much different
(~ 40°C at the solder joints & case opened).

rudi48 commented 6 years ago

Unfortunately the Button1 wired to GPIO14 no longer allows to use the Button usage (usually wired to GPIO0), described on https://github.com/arendst/Sonoff-Tasmota/wiki/Button-Usage

Does anybody know how to regain this Button-Usage, e.g. for providing an Access Point with IP address 192.168.4.1?

Correction: Button1 works also with GPIO14, I had a problem with the test.

renne commented 6 years ago

@arendst I suggest a profile for the Obi WLAN "KenObi" which usses GPIO14 for "Button usage".