Dienstag, 11. Juli 2023

Using the Arduino IDE to flash an ESP32 with a CP2102 serial adapter after you did not do that in a LONG time

Currently trying to run the openDTU project on one of my ESP32. But well, how to get it on there...

 

The programming command the openDTU docs state:

 

 esptool.py --port /dev/ttyUSB0 --chip esp32 --before default_reset --after hard_reset write_flash --flash_mode dout --flash_freq 40m --flash_size detect 0x0 opendtu-generic.factory.bin


Playing around with the ArduinoIDE this is one of the programming commands from the extended serial output there:


 
"C:\Users\user\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe" --chip esp32 --port "COM4" --baud 115200  --before default_reset --after hard_reset write_flash  -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 "C:\Users\user\AppData\Local\Temp\arduino\sketches\507DD89FBC5B73B753AA5D4AE9A38EF2/WiFiScan.ino.bootloader.bin" 0x8000 "C:\Users\user\AppData\Local\Temp\arduino\sketches\507DD89FBC5B73B753AA5D4AE9A38EF2/WiFiScan.ino.partitions.bin" 0xe000 "C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.9/tools/partitions/boot_app0.bin" 0x10000 "C:\Users\user\AppData\Local\Temp\arduino\sketches\507DD89FBC5B73B753AA5D4AE9A38EF2/WiFiScan.ino.bin"
esptool.py v4.5.1



The command I derived from the two above:


C:\Users\user\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe --chip esp32 --port "COM4" --before default_reset --after hard_reset write_flash --flash_mode dout --flash_freq 40m --flash_size detect 0x0 opendtu-generic.factory.bin

A successfull programming run looks like this. You still have to unplug and replug the CP2102 with the ESP32 attached while pressing the "right" button:


C:\Users\user\Downloads>C:\Users\user\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe --chip esp32 --port "COM4" --before default_reset --after hard_reset write_flash --flash_mode dout --flash_freq 40m --flash_size detect 0x0 opendtu-generic.factory.bin
esptool.py v4.5.1
Serial port COM4
Connecting....
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: cc:50:e3:8b:c9:18
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00000000 to 0x00186fff...
Compressed 1598240 bytes to 1022460...
Wrote 1598240 bytes (1022460 compressed) at 0x00000000 in 92.1 seconds (effective 138.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

C:\Users\user\Downloads>


Sonntag, 26. März 2023

New power meter, new tracking aka "Eingespeister Strom MUSS erfasst werden!"

Welcome to Germany: Eingespeister Strom MUSS erfasst werden!

 

So lets switch my perfectly good and gauged "EasyMeter Drehstrom-Einrichtungszähler 60A Typ Q3AA1054" to an even better gauged "eBZ DD3 2r06 eta odz1".

The eBZ model comes in 32 different variations, I guess I have a 3phase model caunting in two directions. Overproduction will be displayed as negative values in the Tasmota tracking.

 

Following up on:

https://tasmota.github.io/docs/Scripting-Language/#script-sections
https://tasmota.github.io/docs/Smart-Meter-Interface/#meter-metrics
https://tasmota.github.io/docs/Smart-Meter-Interface/#ebz-dd3-obis

I modded the example script for the eBZ model, changed the granularity from WH to kWH and voila:


>D
>B
TelePeriod 30
=>sensor53 r
>M 1
; Device: eBZ DD3 2R06 ODZ1
; protocol is D0 OBIS ASCII
; 9600@7E1 for OP-type devices, 9600@8N1 for SM-type devices
+1,3,o,0,9600,SM,1
; Zählerstand zu +A, tariflos,
; Zählerstände Auflösung 10 µW*h (6 Vorkomma- und 8 Nachkommastellen)
1,1-0:1.8.0*255(@1,Energie Bezung,kWh,1_8_0,8
; Zählerstand zu +A, Tarif 1
; 1,1-0:1.8.1*255(@0.001,Energie Bezung T1,Wh,1_8_1,8
; Zählerstand zu +A, Tarif 2
; 1,1-0:1.8.2*255(@0.001,Energie Bezung T2,Wh,1_8_2,8
; Zählerstand zu -A, tariflos
1,1-0:2.8.0*255(@1,Energie Export,kWh,2_8_0,8
; Summe der Momentan-Leistungen in allen Phasen, Auflösung 0,01W (5 Vorkomma- und 2 Nachkommastellen)
1,1-0:16.7.0*255(@1,Leistung,W,16_7_0,18
; Momentane Leistung in Phase Lx, Auflösung 0,01W (5 Vorkomma- und 2 Nachkommastellen)
1,1-0:36.7.0*255(@1,Leistung L1,W,36_7_0,18
1,1-0:56.7.0*255(@1,Leistung L2,W,56_7_0,18
1,1-0:76.7.0*255(@1,Leistung L3,W,76_7_0,18
; Spannung in Phase Lx, Auflösung 0,1V (nur über MSB)
1,1-0:32.7.0*255(@1,Spannung L1,V,32_7_0,1
1,1-0:52.7.0*255(@1,Spannung L2,V,52_7_0,1
1,1-0:72.7.0*255(@1,Spannung L3,V,72_7_0,1
; Statuswort, 4 Byte Information über den Betriebszustand, HEX string
; tasmota can decode one string per device only!
;1,1-0:96.5.0*255(@#),Status1,,96_5_0,0
;1,1-0:96.8.0*255(@#),Status2,,96_8_0,0
; Geräte-Identifikation, Nach DIN 43863-5
1,1-0:96.1.0*255(@#),Identifikation,,96_1_0,0
;1,1-0:0.0.0*255(@#),Identifikation,,0_0_0,0
#

Update:


Well, it took me a while, but the above script has a logical flaw in it. The following one will fix it. If you look closely I matched the individual phase values against 36_7_0, 56_7_0 and 76_7_0. But the actual phase values are 16_7_0, 36_7_0and 56_7_0. The sum of the phase values is 76_7_0, So this has been easy to fix but hard to find, at least for me. So always make sure to have your values under control.

>D
>B
TelePeriod 30
=>sensor53 r
>M 1
; Device: eBZ DD3 2R06 ODZ1
; protocol is D0 OBIS ASCII
; 9600@7E1 for OP-type devices, 9600@8N1 for SM-type devices
+1,3,o,0,9600,SM,1
; Summen der bezogenen und eingespeisten Leistung
1,1-0:1.8.0*255(@1,Energie Bezung,kWh,z1_8_0,8
1,1-0:2.8.0*255(@1,Energie Export,kWh,z2_8_0,8
; Momentane Leistung in Phase Lx, Auflösung 0,01W (5 Vorkomma- und 2 Nachkommastellen)
1,1-0:36.7.0*255(@1,Leistung L1,W,z16_7_0,18
1,1-0:56.7.0*255(@1,Leistung L2,W,z36_7_0,18
1,1-0:76.7.0*255(@1,Leistung L3,W,z56_7_0,18
; Summe der Momentan-Leistungen in allen Phasen, Auflösung 0,01W (5 Vorkomma- und 2 Nachkommastellen)
1,1-0:16.7.0*255(@1,Leistung,W,z76_7_0,18
#