kdarnok / lwz180

Adapter for Stiebel Eltron LWZ 180 control unit interface
GNU General Public License v2.0
10 stars 3 forks source link

Debugging the connection #1

Closed KKSzymanowski closed 3 months ago

KKSzymanowski commented 4 months ago

Hi. I was looking for a way to monitor the status of my VRC-W 400 and I came across your repository. I've tried connecting my ESP32-WROOM-32 with your code to the I2C bus but I don't see any data coming through.

You've mentioned that you used a cheap signal analyzer to see the raw I2C data. Can you point me to the specific hardware you used?

Did you connect to the contacts on top of the unit (under a small cover, next to the pipes) or directly to the contacts for the built-in display?

kdarnok commented 3 months ago

Hi, Kuba, I attached everything to the pins at the top of the unit, with the pin assignment described in the manual:

image

The logic analyser I used is one of these Saleae 24MHz 8 channel ones which are sold at various places online. This is the exact one I bought: https://www.roboter-bausatz.de/p/usb-logic-analyzer-24mhz-8ch With sigrok and pulseview one can capture data and analyse all sorts of protocols.

If you see data coming through using that device, maybe try dumping all i2c frames onto a serial connection on your esp32 so you can test the hardware setup independent of that firmware?

Good luck with your project!

KKSzymanowski commented 3 months ago

Yeah, I came across this exact device and it arrived today. I'm getting the data but the GND line goes high once in a while which is weird. Channels are in the order of pins on the device, meaning: Ch 0: Clock Ch 1: Ground Ch 2: +5V Ch 3: Data

Have you seen similar things? Do you think it might cause issues? I still should be getting some data because the GND is almost always low.

I'm also seeing some NAKs.

image

KKSzymanowski commented 3 months ago

try dumping all i2c frames onto a serial connection on your esp32

Can you point me to some resources explaining how to do that? I have little experience with I2C, especially on the slave side.

KKSzymanowski commented 3 months ago

I think I know what might be the issue - when I copied your code I got compilation error on this line:

TWAR = (I2C_SLAVE_ADDR << 1) | 1;  // listen for broadcasts -- all i2c messages are sent using "general calls"

I just commented it out to make it compile and forgot about it. Apparently TWAR doesn't exist for ESP32 and so I'm unable to listen for broadcasts.

Do you know any alternative mechanism for listening on broadcasts on ESP32 or do I have to buy an actual Arduino board?

kdarnok commented 3 months ago

Yeah, I came across this exact device and it arrived today. I'm getting the data but the GND line goes high once in a while which is weird. Channels are in the order of pins on the device, meaning: Ch 0: Clock Ch 1: Ground Ch 2: +5V Ch 3: Data

i think you may have wired it up incorrectly. this device basically repeatedly measures the voltage (potential difference) on these lines. for that it needs a reference against which to measure. that should be GND -- not the GND of the device, but the GND of the bus. so you should connect GND of the bus to GND of the signal analyser to establish a shared ground.

i would assume that the "fluctuating GND" you're seeing is an artifact of those two GND (bus and signal analyser) being off. +5 doesn't need to be connected iirc.

Do you know any alternative mechanism for listening on broadcasts on ESP32 or do I have to buy an actual Arduino board?

no, haven't looked much into ESP32 for that purpose. you could try setting the i2c address to 0 -- this might allow you to at least eavesdrop on all the broadcast chatter. but i am not sure it will allow you to send correctly. you can find a few discussions about this (e.g. https://github.com/espressif/esp-idf/issues/3220), but i would assume you need to select a device that properly support broadcasts (aka general calls).

Can you point me to some resources explaining how to do that? I have little experience with I2C, especially on the slave side.

i'd suggest you have a look at arduino tutorials and docs -- there's a lot out there. maybe a good starting point could be https://docs.arduino.cc/learn/communication/wire/ and something specifically for the esp32 platform: https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/

KKSzymanowski commented 3 months ago

i think you may have wired it up incorrectly.

Yeah, that might've been the case. On my analyzer the last pin is not labeled GND but CND (probably a printing mistake) which misled me into thinking it's something else. Now I don't get these weird GND spikes.

I did a temporary workaround by connecting the signal analyzer to Raspberry Pi by USB and running sigrok-cli to get the i2c frames, then parsing them in Python and saving the data to the DB to visualize it in Grafana.

I'll probably buy some Arduino or Arduino-compatible hardware to be able to do it properly.

Thanks for your help