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
21.96k stars 4.77k forks source link

Support for SONOFF Smart Power Meter Switch | POW Elite #15856

Closed nobodyman1 closed 2 years ago

nobodyman1 commented 2 years ago

PROBLEM DESCRIPTION

Is it possible to use Tasmota on the new SONOFF POW Elite? I found some Pictures here. It´s based on an ESP32 and the power measuring is done with a CSE7759B (same as used in SONOFF POW R2). But what´s about the LCD driver?

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

arendst commented 2 years ago

I have one on order. Will see what's possible.

dervomsee commented 2 years ago

I received my POW elite yesterday and tried to run my own Platformio code on it.

The used hardware is the following:

As usually the button is connected to GPIO00 to enable the flash mode. It is possible to flash a basic program but it is not starting correctly. I based the first test program on the OTA example (https://github.com/espressif/arduino-esp32/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino). It connects to the WIFI, but does not start properly and it is not possible to run a OTA update.

In Platformio i used board = esp32dev as the base. Does anyone has a idea, what stops the program running on the ESP?

sfromis commented 2 years ago

Did you try just flashing the standard Tasmota build? If that works......

dervomsee commented 2 years ago

Hmm, good Idea. I started with my own firmware to play with the IOs and the LCD. I will try the default image later..

Update: Great, this works. Maybe my build environment is broken. Now Tasmota runs on my POWR320D ESP Chip Id 1124244 (ESP32-D0WD-V3 rev.3) Flash Chip Id 0x16405E Flash Size 4096 KB Program Flash Size 4096 KB Program Size 1397 KB Free Program Space 1482 KB Free Memory 159.0 KB (frag. 28%)

arendst commented 2 years ago

GPIO00 = Button1 GPIO02 = Relay1 (320D - bi-stable - Off) GPIO05 = LedLink_i GPIO13 = Relay1 (316D) GPIO14 = TM1621 DA GPIO15 = Relay1 (320D - bi-stable - On) GPIO16 = CSE7766 Rx GPIO18 = Led_i1 GPIO25 = TM1621 CS GPIO26 = TM1621 RD GPIO27 = TM1621 WR

Also DO NOT CONNECT SERIAL WHILE AC IS CONNECTED. Just blew my Earth Leakage Circuit Breaker. No visible damage. Pfew. How could I forget...

image

Current template for POWR316D is:

{"NAME":"Sonoff POWR316D","GPIO":[32,0,0,0,0,576,0,0,0,224,0,0,3104,0,320,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
barbudor commented 2 years ago

Lcd driver datasheet Titan Micro TM1621 Lcd driver.pdf Chinese but seems understandable. Otherwise Google translate is our friend 😊

sfromis commented 2 years ago

Some driver code found here: https://github.com/emsyscode/TM1621

/*
This code is not clean and also is not perfect, this is only 
a reference to extract ideas and adapte to your solution.
*/
nobodyman1 commented 2 years ago

Lcd driver datasheet Titan Micro TM1621 Lcd driver.pdf Chinese but seems understandable. Otherwise Google translate is our friend 😊

I found the HT1621 which looks very similar to me.

Nuffic commented 2 years ago

TH Elite seems to have the same base as POW Elite (by the looks at least). Would be nice to get support for it as well. I have few of them here + DS18B20, THS01 sensors. I can share info if needed, willing to help any way I can.

sfromis commented 2 years ago

Looks like support for both is in the works.

dervomsee commented 2 years ago

@arendst Are you sure with the 320D pins? My bistable relay uses the following pins: on=GPIO2, off=GPIO4. The LEDs and the CSE pins are the same.

My config is currently the following: {"NAME":"Sonoff POWR320D","GPIO": 32,0,224,0,225,576,0,0,0,0,0,0,3104,0,320,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

Does the 316D not have a bistable relay?

arendst commented 2 years ago

Not sure about gpio15. As you noticed it's gpio4 it might well be ok.

My 316D has no bistable relay and is controlled by gpio13.

In the meantime I managed to logic analyse the sonoff lcd init sequence and 5 second display update sequence (on the thr316d to stay away from AC voltage). Currently need to find out which bit controls which part of the lcd. Init sequence is clear.

The ht1621 docs are indeed equal to my google translated tm1621 docs.

IMG_20220704_100542417_HDR

arendst commented 2 years ago

I have the TM1621 init code working resulting in displaying default state on the POW ;-)

- - - - C
- - - - %RH

Now I have to find out which bit is which element on the LCD screen. Then I have to make a reference between these bits and numbers 0-9. Takes some time.

UPDATE1: Which is bit is which element solved: IMG_20220704_163039721

Now come up with some nice small tables referencing digit to element.

Philippe12 commented 2 years ago

Hello, I use for few time a THR316D

The IO that I configured are :

Nuffic commented 2 years ago

@Philippe12 big thanks, I've managed to get everything working with this config, but the temperature sensor. Have you managed to use the temperature sensor there?

arendst commented 2 years ago

By adding define USE_DISPLAY_TM1621_SONOFF you should be able to see Sonoff POWR3xxD alternating Voltage/Current and TotalEnergy/Power on the LCD display.

Using these templates:

 * {"NAME":"Sonoff POWR316D","GPIO":[32,0,0,0,0,576,0,0,0,224,9280,0,3104,0,320,0,0,0,0,0,0,9184,9248,9216,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
 * {"NAME":"Sonoff POWR320D","GPIO":[32,0,224,0,225,576,0,0,0,0,9280,0,3104,0,320,0,0,0,0,0,0,9184,9248,9216,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

That's it for today (00:11)

Philippe12 commented 2 years ago

@Nuffic THR sensor (Sonoff Si7021) is a dificulty, it use the same protocole one wire than DHT11 but not with the same timming.

You can find mi first modification at : https://github.com/Philippe12/Tasmota/commit/0d9f6749f605c61473bd4413445b25117ed74a0f

I know all this modifications are dirty that it for test, but if can help you.

BangerTech commented 2 years ago

hey @Philippe12 thanks for your modification i´m testing it right now ;-) could you please post your template? Thanks

Philippe12 commented 2 years ago

@BangerTech

{"NAME":"THR316D","GPIO":[32,3200,0,3232,225,9280,0,0,0,8224,0,544,3872,9184,9216,0,0,224,0,9248,0,1248,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

I add TM1621 pin

Nuffic commented 2 years ago

@Philippe12 thanks for all the info. We even got the DS18b20 working with it.

BangerTech commented 2 years ago

so for now the THR320D shows no Temp/Hum on the Display (Tasmota Interface is correct) instead it shows Watt, kWH like the POW try to figure out what to change...

arendst commented 2 years ago

Try latest dev.

BangerTech commented 2 years ago

@arendst it does show some temps but some weird ones ;-) and the Tasmota Interface shows no Temp/Hum at all. See Pic. so i think one of the temps on the display is correct it is the esp32 temp. @Philippe12 build worked well with the status infos in the tasmota interface but nothing on the display

Screenshot 2022-07-06 094134 Screenshot 2022-07-06 094216
arendst commented 2 years ago

This is expected. The SI7021 driver is not available on the ESP32 (yet). The @Philippe12 patched version is not stable either considering the DHT: Invalid reading logging messages.

The display driver selects the current global-temp for being displayed. As the SI7021 is invalid it displays the ESP32 temp. To remove the ESP32 from being fed to global-temp you can either remove the ESP32 temp with command SetSensor127 0 or use the recently released command GlobalTemp2 1 to select the first JSON temperature being the SI7021 one which in turn is invalid and therefor does not show as a temp on the LCD display.

Also when no valid humidity is read it won't show anything on the LCD. Using command GlobalHum2 1 would select the SI7021 humidity.

BangerTech commented 2 years ago

oh ok didn´t know that the THS01 / SI7021 isn´t supported yet. Thanks for all the informations!!

arendst commented 2 years ago

I'm currently rewriting (once more!!!) the ESP8266 DHT driver to support the ESP32 too.

The main issue with the current solution is/was that ESP32 interrupts disable just doesn't work as (Arduino) advertised; it executes nothing resulting in erratic behaviour. I have a solution which does halt interrupts and it looks very promissing for every DHT type sensor I've tested so far (AM2301 and SI7021 (=THS01)).

arendst commented 2 years ago

Try latest dev available in half an hour containing updated DHT driver for support of SI7021, THS01 and MS01 on ESP32.

Also updated THR316D template:

{"NAME":"Sonoff THR316D","GPIO":[32,0,0,0,225,9280,0,0,0,321,0,576,320,9184,9216,0,0,224,0,9248,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

Still need to find out how to use the second wire of the 4-pin RJ11 connector....

BangerTech commented 2 years ago

Just tried out the new build, but only get the ESP Temp. See Pic.

Screenshot 2022-07-06 170354
arendst commented 2 years ago

I suppose you have selected the correct sensor for gpio25 using config module??

BangerTech commented 2 years ago

ahhh ;-) thaaanks!! so now i get everything in the web interface. so i get temp and hum from si7021 and esp32 temp. but i get one more temp how do i find out which one is that? for example i got si7021 temp - 26,7 , hum - 38,4 , dew point - 11,3 and esp32 temp - 30. then i get one more with 53,3 on the display but not in the console or somewhere in the web interface. on the template side of things are there any differences between THR320D and THR316D? Thanks again!!

nobodyman1 commented 2 years ago

@arendst Today I flashed my SONOFF POW Elite. Everything seems to be okay. Great job! Thanks a lot! When will be the next official release which includes the changes? Should I close the issue or wait until the THR316D implementation is finished?

arendst commented 2 years ago

Difference between thr316d and thr320d is likely the change in relay to bistable for the 320. Change would be like the difference between powr316d and powr320d.

Next release is planned for mid August.

You may close this as the last issue probably cannot be solved without a hardware hack like the th10/16.

arendst commented 2 years ago

As expected, GPIO26 would be the second wire on the RJ11 connector if they had populated R16 and R25. Currently the output is floating and cannot be used.

Pity. Would have been a great opportunity to support I2C. So without a hack it's a single wire interface for either DS18x20 or DHT derivatives.

nobodyman1 commented 2 years ago

Is it possible to enable the Smart Meter Interface? It should be very simple to connect to the device! I added the definitions but there is no change in the webinterface.

arendst commented 2 years ago

Smart Meter Interface as an energy source is not planned. Use the already available MQTT messages as available for over 4 years!

POWR320D template update.

As bistable relays are supported since 20220709 the template for the POWR320D has changed to:

{"NAME":"Sonoff POWR320D","GPIO":[32,0,9313,0,9312,576,0,0,0,0,9280,0,3104,0,320,0,0,0,0,0,0,9184,9248,9216,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

This will show only one web button toggling the relay as designed.

nobodyman1 commented 2 years ago

I think I have to explain my intention: I want to use the Smart Meter Interface as an additional input device. I plan to use the Sonoff for measuring the delivered energy from a photovoltaic system. Therefore I think I place the Sonoff device near to my Smart Meter and connect it via an infrared reader to the Sonoff. Then I´m able to get delivered and consumed energy with one device!

arendst commented 2 years ago

Clear.

In that case it's off topic and I suggest you open a discussion.

nobodyman1 commented 2 years ago

Okay, I have opened #15955. Could you please tell me if it's simple to implement or not?

arendst commented 2 years ago

Latest Sonoff THRxxD templates:

{"NAME":"Sonoff THR316D","GPIO":[32,0,0,0,225,9280,0,0,0,321,0,576,320,9184,9216,0,0,224,0,9248,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
{"NAME":"Sonoff THR320D","GPIO":[32,0,0,0,226,9280,0,0,0,321,0,576,320,9184,9216,9312,0,0,9313,9248,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
BangerTech commented 2 years ago

hey @arendst i've tried the new templates and updated firmware, for the th everything works but for the pow (20a) i don't get the toggle button. Both are gone and the one like on the th is not there.

arendst commented 2 years ago

Ah thx. I watched your video. Nice.

I will dive into the pow PCA as I'm still waiting to receive my 20A version...

BangerTech commented 2 years ago

hope i´ve explained everything the right way ;-) perfect thanks buddy!

arendst commented 2 years ago

Are you sure updated the POWR320D to the very latest dev release? With the latest template there should at least be a button in the GUI....

{"NAME":"Sonoff POWR320D","GPIO":[32,0,9313,0,9312,576,0,0,0,0,9280,0,3104,0,320,0,0,0,0,0,0,9184,9248,9216,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

image

BangerTech commented 2 years ago

ahh sorry never mind i must have used an "old" template ;-) now everything works thanks!

chu11u commented 2 years ago

Hi all, does this thread deal with both POWR3 and THR3? or there is a plan to have a separate discussion for it?

I have trouble connecting the waterproof DB18B20 sensor that came with it. the device shows only the internal temp sensor

Before posting, I changed the template to what Theo posted yesterday and it also didn't work.

Thanks

arendst commented 2 years ago

And you did configure the ds18b20 sensor on gpio25 using configure module?

chu11u commented 2 years ago

yes. it even shoed some data for a short time, but then gone.

I also tried the template on the second module type (there dev0 and dev1). but both didnt work...

I used the tasmota32.bin from the development page. is it the right one?

vbokaty commented 2 years ago

And you did configure the ds18b20 sensor on gpio25 using configure module?

Yes. gpio25 ds18b20 sensor work. my screen doesn't work - it's fine ???

arendst commented 2 years ago

I think I know what goes wrong with the ds18x20 sensor.

The sonoff device doesn't use a pullup resistor. On esp8266 is an option to enable it's internal pullup resistor. This is not available in the esp32 ds18x20 driver. An attached ds18x20 with external pullup resistor therefor just works fine; the sonoff provided sensor won't work with the current tasmota driver.

I'll see what I can do to fix this.

vbokaty commented 2 years ago

I bought a ds18x20 sensor separately. The readings are close to reality. It works stably. I have installed tasmota-displays.bin, the screen is not working.