mc0110 / inetbox2mqtt

communicate over mqtt protocol to simulate a truma inetbox
MIT License
85 stars 18 forks source link

Rx/Tx GPIO pins #4

Closed 7wells closed 2 years ago

7wells commented 2 years ago

Hi Magnus! I was unsure which GPIO pins of the ESP32 I need to connect, so I first looked into Daniel's project readme:

TX connects to GPIO 15 on the Raspberry Pi (RX).
RX connects to GPIO 14 on the Raspberry Pi (TX).

However, in your truma_serv.py I read this comment:

# The communication with the CPplus uses ESP32-UART2 - connect (tx:GPIO17, rx:GPIO16)

So, it should be these, right?

1

Not that I bother much, but I wonder if there is a reason for this difference. I ask also for my personal education. 😀

7wells commented 2 years ago

And could you please confirm whether the following is correct? I adopted it from Daniel's readme and plan to update it in my forked repo from you. If it helps, I can send a PR later, so you can check if you want to add it to your readme, too.

You need a LIN to UART Transceiver for connecting the ESP32 to the LIN bus. On the transceiver module, the connections are as follows:

12V connects to a 12V power supply that also powers the Combi and CP Plus.
TX connects to GPIO 17 on the ESP32.
RX connects to GPIO 16 on the ESP32.
LIN connects to the RJ12 connector, Pin 3.
GND connects to the RJ12 connector, Pin 5.
The second GND should connect to one of the GND pins on the ESP32.
The other pins (INH and SLP) are not used.

Is it correct that GND should be connected to a GND pin of the ESP32?

If Daniel does not disagree, you could add his photo of the RJ12 cable.

mc0110 commented 2 years ago

I assume, you are joking...... Honestly, though, there are no bad questions, only bad answers! Daniel uses a RPI board, you try to use a ESP32. The ESP32 has 3 hardware-UARTS (0-2), all with programmable Pins. But the default for UART2 is tx-GPIO17, rx-GPIO16

mc0110 commented 2 years ago

And yes, I confirm your adapted connection description

mc0110 commented 2 years ago

So my answer is hopefully okay for you

mc0110 commented 2 years ago

Short explanation of the connection - we can then also include it in our description: LIN connection: Clearly speaking, an RJ11 cable is enough - only the inner cables are needed. In some cables, the wires are unfortunately swapped (especially in the splitters) because this is not critical for the telephone. I only found the LIN signal on the second try (Pin3 / Pin5 swapped).

TX and RX are correctly marked on your picture. The pins are also not critical against twisting (nothing will break). So just try it.

If you use the LEDs (see my instructions, but be sure to use a 300-600Ohm resistor), the GPIO12 will react immediately if the connection is correct and an Inetbox has already been connected. Otherwise, nothing happens until you have done Init once.

mc0110 commented 2 years ago

Is it correct that GND should be connected to a GND pin of the ESP32?

It must connected!

7wells commented 2 years ago

No joking - I have zero knowledge of the ESP32, hence my question. Thanks for your patience - I really appreciate it! 😃

mc0110 commented 2 years ago

No, no - it's OK! Please give me a hint if your ESP32 has a LIN connection. That will be a reason to celebrate

7wells commented 2 years ago

Well, I think we need to postpone the party till tomorrow. I was stupid enough to mix up the RPI's LAN and Wifi IPs and thus had no connection to the MQTT broker. I only found out too late (getting dark and late).

I have HA up and running on my RPi4 (same local network as the ESP32) with the MQTT broker addon in HA. Apart from the fact that I was too much puzzled over the Truma not showing up on my CP+ display, I can see in the MQTT Explorer (on Windows 11) these: grafik

Since I had to disconnect the ESP32 from the Truma and bring it in (to flash the correct IP), the output is anyway not 100% what I should except, I guess, but maybe this is already some little progress.

This concerns me a bit: Despite PR SET (multiple times), I see only these on my CP+:

C4.03.00 => 0050.00
H1.02.00 => 0340.02

The Truma is missing, i.e. this is not displayed (was, when I had the RPi4 in use): T23.700 => 1F00.00

Am I right that when switching from RPI4 to ESP32, the LIN wire between the UART-LIN board and the Truma remains unchanged? I checked the other wiring and ensured that the power supply is ok, which it is. Let me check again tomorrow - and thanks for bearing with me.

Wishing you a nice evening! 😃

mc0110 commented 2 years ago

I am surprised and very sorry for you! There must be something wrong with the connection between CPplus and ESP32. To be honest, I always had the problem with Daniel's solution - I had also used an RPI at first - that there was no connection after a restart without an initial init. This was completely different with the ESP32. Since the routine reacts much faster, the init worked immediately if there were no electrical problems. I tested this several times. If the third entry is missing, then something is wrong electrically. I have already had positive news from several testers in the last few days - the routine works. I think, according to your hints - but this also corresponds to other user wishes, we have to work on the connectivity (credentials/ web server / MQTT). As far as I know, the LIN routine works great!

7wells commented 2 years ago

I agree that the problem is with my electric setup, and I am confident to get things running; not today, though. 😃

mc0110 commented 2 years ago

Honestly, this is my first experience with a merge! Thanks for the effort and really great work.

7wells commented 2 years ago

I don't know which great work of mine you mean but thanks a lot! 😄

mPython and Python seem to be ideal to learn (again) programming. My experience with this is decades ago (C64 assembler). Sorry, I am drifting off. 🫢

Maybe I can start learning Python. Your project is very nice and encouraging. 👍

mc0110 commented 2 years ago

I approved your changes - thanks for that .... but more interesting for me Is your LIN-connection online?

7wells commented 2 years ago

Unfortunately not 😦 I do not see the third entry on my CP+ under INDEX and therefore assume that the ESP32 cannot talk to the Truma. I need to check the cables once more. Surprisingly, the same wiring worked with Daniel's program on my RPi4, but there might be other factors I am missing.

Now I would like to add the 2 LEDs to me ESP32 with the 300-600 Ohm resistor. As electric noob I have no clue, though, where exactly to place the resistor (despite your very nice guide), and more important, I am struggling with finding the right resistor. I have plenty here but don't know mich about the colour codes etc., even after searching in the Internet. Do you know of a website, where one can enter just the resistance (300-600 Ohm) and get a bunch of possibilities of colour codes (understanding that there are some further specs, but I know even less of them).

I am still very confident to get this right, but as I lack basic Physics knowledge (much to my regret), it takes me much more time than others. 😀

7wells commented 2 years ago

Important PS:

Without any extra hardware - i.e. only standard CP+ and Truma connected (no iNet box, no UART-LIN board, etc.), I also only see 2 entries on my CP+:

C4.03.00 => 0050.00
H1.02.00 => 0340.02

I.e., even in the from-the-factory-setup, the third entry is missing: T23.700 => 1F00.00

But I can control my Truma via the CP+, so the connection between them should be ok.

What am I missing? When exactly is the third entry to be expected? Only in case an official Truma iNet Box or an UART-LIN board are attached? I ask because I was worried that me factory-setup got somehow corrupted (which I doubt).

Thanks for your great patience with me! 👍

7wells commented 2 years ago

I approved your changes - thanks for that

Which ones do you mean? Of today? I ask because my fork still seems to be 2 commits ahead of yours and 1 behind (after you amended the text under the alive-topic). But this is a bit OT here, and besides, I do not want to make it unnecessarily complicated. It's your project and your precious time, and I am happy to get some support - and hope to be able to give something useful back in the next days, when this is in principle working here, too.

mc0110 commented 2 years ago

Stop for a second and let's sum up: Is Daniel's setup running now - have you tried again? When Daniel's setup is running, you have only to connect 3 wires (GPIO16 /17 and GND) thats all. And if we disregard the leds, the box must then be recognised during an init. Better still, if an init has been carried out with Daniel's box, then no new init is required. When the ESP32 is attached, everything works.

7wells commented 2 years ago

Daniel's program was working, yes, but with my RPi4, not with my ESP32. However, I cannot go back now, as my RPi4 now runs HA OS (and I don't plan to go back if I can avoid it).

Let me take a photo - might take a moment...

mc0110 commented 2 years ago

A lot of questions: The third entry in the index is the inetbox-simulation - only with this 3. entry you can control the CPplus. Let's do the troubleshooting in a structured way: 1) We assume that the ESP32 is working (and that there may not have been 5V or 12V on one of its legs, because it doesn't like that at all). 2) You have clearly identified the two contacts (LIN and GND) and have not changed anything in the wiring. 3) Then it can only be because tx and rx are reversed!!! tx from ESP32 go to rx from TJA1020 and vice versa!

mc0110 commented 2 years ago

Daniel's program was working, yes, but with my RPi4, not with my ESP32. However, I cannot go back now, as my RPi4 now runs HA OS (and I don't plan to go back if I can avoid it).

Bad news - now I understand your comment yesterday

7wells commented 2 years ago

The black screw terminal in the middle receives 12 V from the car.

It provides 12 V (red) and GND (black) to the DC DC downstepper, which provides 5 V to the ESP32.

The other red wire provides 12 V to the UART-LIN board, which has GND with GND of the ESP32.

The ESP32 is connected with blue (Tx) and green (Rx) with the opposite on the UART-LIN board (Rx and Tx, respectively).

The UART-LIN board is connected to the Truma (there is a second LIN plug besides the one already occupied by the CP+) via brown wire (GND) and yellow wire (LIN).

1 2

7wells commented 2 years ago

Do I have to push a button on the ESP32 after powering it? I assume no, as it should boot after power-on.

PS1: It's getting late, and maybe I should attach the 2 LEDs you mentioned. I only need to know how the resistor looks like and see if I have an appropriate one (or two?) at home.

PS2: Hopefully, you (or other readers) are not utterly shocked by my "flying circus". 🎪

mc0110 commented 2 years ago

The pictures look OK! Did the software run on the ESP32, did you see that on your computer? When you press RST on the ESP, the programme must start. The entry Lin-loop started is important. If so, try the following procedure: Switch on the ESP32 after you have established the LIN connection. Then press the RST button on the ESP32 briefly (not the other button, please). Then go to the RESET menu on the CPplus and perform INIT. After a few seconds, the menu flickers and then returns to the normal display. Then the 3rd entry in the index must be found. I am keeping my fingers crossed

7wells commented 2 years ago

Thank you so much! I will do this and let you know tomorrow. Wishing you a relaxing evening!

mc0110 commented 2 years ago

Were you successful?

7wells commented 2 years ago

I brought my laptop to the motor-home, unplugged the ESP32 from the gear, and plugged it to my laptop with the Python IDE shell open (COM4). This is the shell output, and I assume it is ok. Do you agree? The entry Lin-loop started is not shown, as I have the ESP32 disconnected from the gear. I will connect it (while also connected to my laptop to check the Python IDE shell) and report again...

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4540
ho 0 tail 12 room 4
load:0x40078000,len:12344
ho 0 tail 12 room 4
load:0x40080400,len:4124
entry 0x40080680

Device is busy or does not respond. Your options:

  - wait until it completes current work;
  - use Ctrl+C to interrupt current work;
  - reset the device and try again;
  - check connection properties;
  - make sure the device has suitable MicroPython / CircuitPython / firmware;
  - make sure the device is not in bootloader mode.

INFO:mqtt_async:connecting wifi
lin-loop is running
INFO:mqtt_async:Connecting to ('192.168.178.55', 1883) id=b'xxxxxxxxxxxx' clean=0
connected
main-loop is running
error_code : [homeassistant/sensor/error_code/configpayload: {}]
heating_mode : [homeassistant/sensor/heating_mode/configpayload: {}]
truma_alive : [homeassistant/binary_sensor/truma/alive/configpayload: {}]
operating_status : [homeassistant/sensor/operating_status/configpayload: {}]
truma_energy_mix : [homeassistant/sensor/energy_mix/configpayload: {}]
truma_current_temp_water : [homeassistant/sensor/current_temp_water/configpayload: {}]
el_power_level : [homeassistant/sensor/el_level/configpayload: {}]
truma_target_temp_room : [homeassistant/sensor/target_temp_room/configpayload: {}]
set_target_temp_water : [homeassistant/select/target_temp_water/configpayload: {}]
set_energy_mix : [homeassistant/select/energy_mix/configpayload: {}]
set_target_temp_room : [homeassistant/select/target_temp_room/configpayload: {}]
set_el_power_level : [homeassistant/select/el_power_level/configpayload: {}]
set_heating_mode : [homeassistant/select/heating_mode/configpayload: {}]
truma_target_temp_water : [homeassistant/sensor/target_temp_water/configpayload: {}]
clock : [homeassistant/sensor/clock/configpayload: {}]
truma_current_temp_room : [homeassistant/sensor/current_temp_room/configpayload: {}]
set ha_autoconfig
error_code : [homeassistant/sensor/error_code/configpayload: {"name": "truma_error_code", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/error_code"}]
heating_mode : [homeassistant/sensor/heating_mode/configpayload: {"name": "truma_heating_mode", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/heating_mode"}]
truma_alive : [homeassistant/binary_sensor/truma/alive/configpayload: {"name": "truma_alive", "model": "inetetbox", "sw_version": "V01", "device_class": "running", "state_topic": "service/truma/control_status/alive"}]
operating_status : [homeassistant/sensor/operating_status/configpayload: {"name": "truma_operating_status", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/operating_status"}]
truma_energy_mix : [homeassistant/sensor/energy_mix/configpayload: {"name": "truma_energy_mix", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/energy_mix"}]
INFO:mqtt_async:Connecting to ('192.168.178.55', 1883) id=b'xxxxxxxxxxxx' clean=0
truma_current_temp_water : [homeassistant/sensor/current_temp_water/configpayload: {"name": "truma_current_temp_water", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/current_temp_water"}]
el_power_level : [homeassistant/sensor/el_level/configpayload: {"name": "truma_el_power_level", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/el_power_level"}]
truma_target_temp_room : [homeassistant/sensor/target_temp_room/configpayload: {"name": "truma_target_temp_room", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/target_temp_room"}]
set_target_temp_water : [homeassistant/select/target_temp_water/configpayload: {"name": "truma_set_warmwater", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/target_temp_water", "options": ["0", "40", "60", "200"] }]
set_energy_mix : [homeassistant/select/energy_mix/configpayload: {"name": "truma_set_energy_mix", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/energy_mix", "options": ["none", "gas", "electricity", "mix"] }]
set_target_temp_room : [homeassistant/select/target_temp_room/configpayload: {"name": "truma_set_roomtemp", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/target_temp_room", "options": ["0", "10", "15", "18", "20", "21", "22"] }]
set_el_power_level : [homeassistant/select/el_power_level/configpayload: {"name": "truma_set_el_power_level", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/el_power_level", "options": ["0", "900", "1800"] }]
set_heating_mode : [homeassistant/select/heating_mode/configpayload: {"name": "truma_set_heating_mode", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/heating_mode", "options": ["off", "eco", "high"] }]
truma_target_temp_water : [homeassistant/sensor/target_temp_water/configpayload: {"name": "truma_target_temp_water", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/target_temp_water"}]
clock : [homeassistant/sensor/clock/configpayload: {"name": "truma_clock", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/clock"}]
truma_current_temp_room : [homeassistant/sensor/current_temp_room/configpayload: {"name": "truma_current_temp_room", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/current_temp_room"}]
publish energy_mix:gas
publish el_power_level:0
publish target_temp_water:0
publish target_temp_room:0
publish alive:OFF
publish heating_mode:off
publish operating_status:Off
publish current_temp_room:0
publish current_temp_water:0
publish alive:OFF
publish alive:OFF
7wells commented 2 years ago

Now the ESP32 is connected to the gear and to my laptop. The Thonny shell shows an error:

Task exception wasn't retrieved
future: <Task> coro= <generator object 'lin_loop' at 3fff4a40>
Traceback (most recent call last):
  File "uasyncio/core.py", line 1, in run_until_complete
  File "truma_serv.py", line 141, in lin_loop
  File "lin.py", line 273, in loop_serial
AttributeError: 'bytes' object has no attribute 'hex'

Full output:

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4540
ho 0 tail 12 room 4
load:0x40078000,len:12344
ho 0 tail 12 room 4
load:0x40080400,len:4124
entry 0x40080680

Device is busy or does not respond. Your options:

  - wait until it completes current work;
  - use Ctrl+C to interrupt current work;
  - reset the device and try again;
  - check connection properties;
  - make sure the device has suitable MicroPython / CircuitPython / firmware;
  - make sure the device is not in bootloader mode.

INFO:mqtt_async:connecting wifi
lin-loop is running
INFO:mqtt_async:Connecting to ('192.168.178.55', 1883) id=b'xxxxxxxxxxxx' clean=0
connected
main-loop is running
error_code : [homeassistant/sensor/error_code/configpayload: {}]
heating_mode : [homeassistant/sensor/heating_mode/configpayload: {}]
truma_alive : [homeassistant/binary_sensor/truma/alive/configpayload: {}]
operating_status : [homeassistant/sensor/operating_status/configpayload: {}]
truma_energy_mix : [homeassistant/sensor/energy_mix/configpayload: {}]
truma_current_temp_water : [homeassistant/sensor/current_temp_water/configpayload: {}]
el_power_level : [homeassistant/sensor/el_level/configpayload: {}]
truma_target_temp_room : [homeassistant/sensor/target_temp_room/configpayload: {}]
set_target_temp_water : [homeassistant/select/target_temp_water/configpayload: {}]
set_energy_mix : [homeassistant/select/energy_mix/configpayload: {}]
set_target_temp_room : [homeassistant/select/target_temp_room/configpayload: {}]
set_el_power_level : [homeassistant/select/el_power_level/configpayload: {}]
set_heating_mode : [homeassistant/select/heating_mode/configpayload: {}]
truma_target_temp_water : [homeassistant/sensor/target_temp_water/configpayload: {}]
clock : [homeassistant/sensor/clock/configpayload: {}]
truma_current_temp_room : [homeassistant/sensor/current_temp_room/configpayload: {}]
set ha_autoconfig
error_code : [homeassistant/sensor/error_code/configpayload: {"name": "truma_error_code", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/error_code"}]
heating_mode : [homeassistant/sensor/heating_mode/configpayload: {"name": "truma_heating_mode", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/heating_mode"}]
truma_alive : [homeassistant/binary_sensor/truma/alive/configpayload: {"name": "truma_alive", "model": "inetetbox", "sw_version": "V01", "device_class": "running", "state_topic": "service/truma/control_status/alive"}]
operating_status : [homeassistant/sensor/operating_status/configpayload: {"name": "truma_operating_status", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/operating_status"}]
truma_energy_mix : [homeassistant/sensor/energy_mix/configpayload: {"name": "truma_energy_mix", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/energy_mix"}]
truma_current_temp_water : [homeassistant/sensor/current_temp_water/configpayload: {"name": "truma_current_temp_water", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/current_temp_water"}]
el_power_level : [homeassistant/sensor/el_level/configpayload: {"name": "truma_el_power_level", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/el_power_level"}]
truma_target_temp_room : [homeassistant/sensor/target_temp_room/configpayload: {"name": "truma_target_temp_room", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/target_temp_room"}]
set_target_temp_water : [homeassistant/select/target_temp_water/configpayload: {"name": "truma_set_warmwater", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/target_temp_water", "options": ["0", "40", "60", "200"] }]
set_energy_mix : [homeassistant/select/energy_mix/configpayload: {"name": "truma_set_energy_mix", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/energy_mix", "options": ["none", "gas", "electricity", "mix"] }]
set_target_temp_room : [homeassistant/select/target_temp_room/configpayload: {"name": "truma_set_roomtemp", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/target_temp_room", "options": ["0", "10", "15", "18", "20", "21", "22"] }]
set_el_power_level : [homeassistant/select/el_power_level/configpayload: {"name": "truma_set_el_power_level", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/el_power_level", "options": ["0", "900", "1800"] }]
set_heating_mode : [homeassistant/select/heating_mode/configpayload: {"name": "truma_set_heating_mode", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/heating_mode", "options": ["off", "eco", "high"] }]
truma_target_temp_water : [homeassistant/sensor/target_temp_water/configpayload: {"name": "truma_target_temp_water", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/target_temp_water"}]
clock : [homeassistant/sensor/clock/configpayload: {"name": "truma_clock", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/clock"}]
truma_current_temp_room : [homeassistant/sensor/current_temp_room/configpayload: {"name": "truma_current_temp_room", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/current_temp_room"}]
Task exception wasn't retrieved
future: <Task> coro= <generator object 'lin_loop' at 3fff4a40>
Traceback (most recent call last):
  File "uasyncio/core.py", line 1, in run_until_complete
  File "truma_serv.py", line 141, in lin_loop
  File "lin.py", line 273, in loop_serial
AttributeError: 'bytes' object has no attribute 'hex'
publish energy_mix:gas
publish el_power_level:0
publish target_temp_water:0
publish target_temp_room:0
publish alive:OFF
publish heating_mode:off
publish operating_status:Off
publish current_temp_room:0
publish current_temp_water:0
publish alive:OFF
publish alive:OFF
publish alive:OFF
publish alive:OFF
mc0110 commented 2 years ago

You have the wrong microPython version! You need a version from Nov. 2022 - pls see this fact also in our README.md

mc0110 commented 2 years ago

I have been thinking about just that for a moment. The good news is that it indicates that your electrical connection is working. The error only occurs when the ESP32 receives control codes. So you're on the verge of a breakthrough.

About the error, I found it by random because I had compiled an upython kernel myself and used that version to develop the software and then I saw that on another chip (with the stable version from July) this error occurred. Hence my comment about the changes in upython itself that are yet to be seen.

mc0110 commented 2 years ago

Why we should delete the "Alive-topic" logic?

7wells commented 2 years ago

You have the wrong microPython version! You need a version from Nov. 2022 - pls see this fact also in our README.md

When I went through the README, I misunderstood that an older version was not yet capable of making it work. When I searched for the correct firmware for my ESP32, I was indeed a bit lost, as there are so many ESP32 flavours, and I ended up in downloading and flashing v1.19.1 (2022-06-18) .bin [.elf] [.map] [Release notes] (latest), which is wrong, as I now understand.

You recommend a version from November. EDIT: Oh, you mean the nightly build? https://micropython.org/download/esp32 E.g. this one? https://micropython.org/resources/firmware/esp32-20221108-unstable-v1.19.1-617-g43dd3ea74.bin

Besides, to ensure that I have not screwed up your README in my fork and pull request, can you please have a second look, at least at the part about MicroPyhton? Thank you so much!

7wells commented 2 years ago

Why we should delete the "Alive-topic" logic?

What do you refer to? The README or the code? Have I asked to have it removed? In case you refer to the README, I just found out that I had it misplaced in my fork, then doubled it, and now it should be correct. Please accept my apologies if I have screwed things up via my PR. I promise to be more careful in the future about this.

7wells commented 2 years ago

Flashing latest unstable now...

mc0110 commented 2 years ago

this sounds good

7wells commented 2 years ago

TADAA! 😃

@mc0110 Dear Magnus, thank you very much for your persistent patience with me and all the very helpful hints have have provided me with. It seems to work now very nicely, as you can hopefully agree upon when looking at the output below. You will also see lines where I did a RESET => PR SET. And INDEX shows the third entry, too, indicating that the ESP32 now talks/listens to the Truma. What are the next steps I should try?

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4540
ho 0 tail 12 room 4
load:0x40078000,len:12344
ho 0 tail 12 room 4
load:0x40080400,len:4124
entry 0x40080680

Device is busy or does not respond. Your options:

  - wait until it completes current work;
  - use Ctrl+C to interrupt current work;
  - reset the device and try again;
  - check connection properties;
  - make sure the device has suitable MicroPython / CircuitPython / firmware;
  - make sure the device is not in bootloader mode.

INFO:mqtt_async:connecting wifi
lin-loop is running
INFO:mqtt_async:Connecting to ('192.168.178.55', 1883) id=b'xxxxxxxxxxxx' clean=0
connected
main-loop is running
error_code : [homeassistant/sensor/error_code/configpayload: {}]
heating_mode : [homeassistant/sensor/heating_mode/configpayload: {}]
truma_alive : [homeassistant/binary_sensor/truma/alive/configpayload: {}]
operating_status : [homeassistant/sensor/operating_status/configpayload: {}]
truma_energy_mix : [homeassistant/sensor/energy_mix/configpayload: {}]
truma_current_temp_water : [homeassistant/sensor/current_temp_water/configpayload: {}]
el_power_level : [homeassistant/sensor/el_level/configpayload: {}]
truma_target_temp_room : [homeassistant/sensor/target_temp_room/configpayload: {}]
set_target_temp_water : [homeassistant/select/target_temp_water/configpayload: {}]
set_energy_mix : [homeassistant/select/energy_mix/configpayload: {}]
set_target_temp_room : [homeassistant/select/target_temp_room/configpayload: {}]
set_el_power_level : [homeassistant/select/el_power_level/configpayload: {}]
set_heating_mode : [homeassistant/select/heating_mode/configpayload: {}]
truma_target_temp_water : [homeassistant/sensor/target_temp_water/configpayload: {}]
clock : [homeassistant/sensor/clock/configpayload: {}]
truma_current_temp_room : [homeassistant/sensor/current_temp_room/configpayload: {}]
set ha_autoconfig
error_code : [homeassistant/sensor/error_code/configpayload: {"name": "truma_error_code", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/error_code"}]
heating_mode : [homeassistant/sensor/heating_mode/configpayload: {"name": "truma_heating_mode", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/heating_mode"}]
truma_alive : [homeassistant/binary_sensor/truma/alive/configpayload: {"name": "truma_alive", "model": "inetetbox", "sw_version": "V01", "device_class": "running", "state_topic": "service/truma/control_status/alive"}]
operating_status : [homeassistant/sensor/operating_status/configpayload: {"name": "truma_operating_status", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/operating_status"}]
truma_energy_mix : [homeassistant/sensor/energy_mix/configpayload: {"name": "truma_energy_mix", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/energy_mix"}]
truma_current_temp_water : [homeassistant/sensor/current_temp_water/configpayload: {"name": "truma_current_temp_water", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/current_temp_water"}]
el_power_level : [homeassistant/sensor/el_level/configpayload: {"name": "truma_el_power_level", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/el_power_level"}]
truma_target_temp_room : [homeassistant/sensor/target_temp_room/configpayload: {"name": "truma_target_temp_room", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/target_temp_room"}]
set_target_temp_water : [homeassistant/select/target_temp_water/configpayload: {"name": "truma_set_warmwater", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/target_temp_water", "options": ["0", "40", "60", "200"] }]
set_energy_mix : [homeassistant/select/energy_mix/configpayload: {"name": "truma_set_energy_mix", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/energy_mix", "options": ["none", "gas", "electricity", "mix"] }]
set_target_temp_room : [homeassistant/select/target_temp_room/configpayload: {"name": "truma_set_roomtemp", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/target_temp_room", "options": ["0", "10", "15", "18", "20", "21", "22"] }]
set_el_power_level : [homeassistant/select/el_power_level/configpayload: {"name": "truma_set_el_power_level", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/el_power_level", "options": ["0", "900", "1800"] }]
set_heating_mode : [homeassistant/select/heating_mode/configpayload: {"name": "truma_set_heating_mode", "model": "inetetbox", "sw_version":"V01", "command_topic": "service/truma/set/heating_mode", "options": ["off", "eco", "high"] }]
truma_target_temp_water : [homeassistant/sensor/target_temp_water/configpayload: {"name": "truma_target_temp_water", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/target_temp_water"}]
clock : [homeassistant/sensor/clock/configpayload: {"name": "truma_clock", "model": "inetetbox", "sw_version":"V01", "state_topic": "service/truma/control_status/clock"}]
truma_current_temp_room : [homeassistant/sensor/current_temp_room/configpayload: {"name": "truma_current_temp_room", "model": "inetetbox", "sw_version":"V01", "device_class": "temperature", "unit_of_measurement": "°C", "state_topic": "service/truma/control_status/current_temp_room"}]
publish energy_mix:gas
publish el_power_level:0
publish target_temp_water:0
publish target_temp_room:0
publish alive:OFF
publish heating_mode:off
publish operating_status:Off
publish current_temp_room:0
publish current_temp_water:0
publish alive:OFF
publish alive:OFF
publish alive:OFF
B2 - identifier for NAD 03
B2 - initializer for NAD 03   -----------------> start registration
B0 - init finalized - send ackn ---------------> registration finalized
publish alive:ON
publish operating_status:start/cool down
publish error_code:0
publish el_power_level:0
publish timer_start_hours:0
publish timer_stop_minutes:0
publish timer_active:0
publish timer_stop_hours:0
publish current_temp_water:12.0
publish alive:ON
publish current_temp_room:14.6
publish target_temp_room:0
publish timer_target_temp_room:0
publish energy_mix:gas
publish heating_mode:off
publish timer_target_temp_water:0
publish timer_start_minutes:0
publish target_temp_water:0
publish energy_mix:gas
publish el_power_level:0
publish heating_mode:off
publish operating_status:start/cool down
publish error_code:0
publish clock:17:34
publish alive:ON
publish target_temp_room:0
publish target_temp_water:0
publish current_temp_water:12.0
publish current_temp_room:14.6
publish alive:ON
publish clock:17:35
publish alive:ON
publish alive:ON
publish alive:ON
publish alive:ON
publish alive:ON
mc0110 commented 2 years ago

Yes, I was aware of that. Great work and thanks for sticking it out. I think all the comments are misleading, I need to revise that again.

I'm happy, that it is now running

7wells commented 2 years ago

I might have a problem with the power to the ESP32, when using the DC DC downstepper, as the ESP32 then does not seem to run properly (no third INDEX on the CP+, MQTT alive = off. When I power the ESP32 via my laptop, it is working (see above).

Or does the ESP32 need the Thonny IDE to properly start?

Anyway, I will check another power supply, but that is OT here.

If there is anything I should propose for the README, please let me know. And feel free to take from the README from my fork, whatever you might find helpful.

Thank you so much for your great project. Having ported Daniel's code to the ESP32 is really cool! 😎

mc0110 commented 2 years ago

Too bad it doesn't work that way! No, it doesn't need the Thonny IDE - that's more of a hindrance. But the ESP32 is sensitive to the power supply. example for power supply You have to decide whether to use the 5V on the board or the 3.3V. The chip will also work if you feed the 3.3V to the right pin.

All my ESP32s that run in my car do this on custom boards of mine. They all run with step-down converters that are operated with 3.3V.

7wells commented 2 years ago

Ok, with the proper power supply (5V, 2A) for the ESP32, it works! 😀 I can see lots of data in my MQTT Snooper/Explorer.

Screenshot_20221108_180918.jpg Screenshot_20221108_180943.jpg

mc0110 commented 2 years ago

I am thinking about developing a circuit board for this application. You could participate ;-) I'll keep you informed!

7wells commented 2 years ago

Thanks for keeping me in the loop!

BTW, after I have replaced the DC DC downstepper (with the blue LED on in my photos) by a 240V transformer (5V, 2A output), the ESP32 is only grounded to the UART-LIN board (and not anymore directly with the car's 12V net), which in turn is grounded (brown cable in my photos) with the Truma. Do you think this can cause a problem? Should I ground the ESP32 additionally with something else? Sorry that my knowledge of electricity is almost null. ☺️

mc0110 commented 2 years ago

Smile! In your photos you can see the LIN connection with a brown cable and your connection to the ESP32 with a black cable. The two cables are connected on the LIN transceiver board. So you have a ground. All is OK!

mc0110 commented 2 years ago

Have you tried to send something? Can you control the TRUMA?

7wells commented 2 years ago

Not yet, as I don't know how. E.g., I would like to change/set the target room temperature and see these: Screenshot_20221108_192547.jpg Screenshot_20221108_192610.jpg

Why do I see service/truma/ and another two homeassistant/select/ and homeassistant/sensor?

I assume that the service/truma/ part is the relevant one, correct?

I published the text string "5" (without the quotation marks) in this topic: Screenshot_20221108_193111.jpg

7wells commented 2 years ago

I cannot check if this has worked on my motor-home now but tomorrow.

7wells commented 2 years ago

I miss display_status messages. With Daniel's code on the RPi4, I had e.g. these as source for a graph:

service/truma/display_status/current_temp_room service/truma/display_status/current_temp_water

No display_status messages are currently to be seen, but maybe I'm doing something wrong?

mc0110 commented 2 years ago

There are sets that only work in combination. I had thought about including this, but it would be a change to Daniel's command set. So temp_room can only be switched on in combination with heating_mode. Simplest command is target_temp_water = 40 - I have always tested with this

mc0110 commented 2 years ago

Okay, if you had display-status-messages with Daniel's RPI, then I'll go into the analysis again and see if I can find such messages with the RPI. But I can't remember them. In my approach I never have seen them

mc0110 commented 2 years ago

The control approach has been taken over 1:1 from Daniel. There is the following problem: When you send a command, the command is transmitted to the CPplus. This means that the inetbox also writes the command to the MQTT server. In the result you see, for example, target_temp_room = 20. "APP" then appears in the CPplus display. If the CPplus does not accept the result, it overwrites the status after a while (1-2min) and target_temp_room = 0 appears again. If you wanted to change this, you would have to set up the software differently. So far I have avoided this - compatibility at the expense of user-friendliness.