se-bastiaan / esphome-simplebus2

Component that allows you to run alternative ESPHome based firmware on your Simplebus2 MQTT Bridge.
GNU General Public License v3.0
5 stars 1 forks source link

MCP4017 values are incorrectly written/read #1

Closed se-bastiaan closed 2 months ago

se-bastiaan commented 3 months ago
[C][simplebus2:027]: Setting up Simplebus2
[D][simplebus2:348]: Gain to set: 30
[D][simplebus2:355]: Gain resistor value: 3448.275879
[D][simplebus2:311]: Write value of MCP4017 0: 4
[D][simplebus2:362]: Voltage to set: 200
[D][simplebus2:368]: Voltage limit resistor value: 6451.612793
[D][simplebus2:311]: Write value of MCP4017 1: 8
[D][simplebus2:342]: Current resistance of MCP4017 0: 8
[D][simplebus2:342]: Current resistance of MCP4017 1: 8
[D][binary_sensor:036]: 'Incoming call': Sending state OFF
[C][simplebus2:055]: Setup for Simplebus2 complete

Not entirely sure yet what is going on here but the resistance for the two MCP4017 chips should not be the same. Turning around the two writing operations does result in the latest value written however.

Elektroarzt commented 3 months ago

Maybe it helps ... gurkenflieger wrote the Arduino code for the original project and also faced the issue of not working voltage dividers. He then sent some initial reset commands to the potentiometers and voila, everything worked fine. I made a measurement series about accuracy of the threshold with the fix and it was quite good:

image
Elektroarzt commented 3 months ago

For the gain I also successfully measured a complete series after the fix. CH1 is before the comparator U6 and CH2 is after the comparator. Here just a few gain values ... If you need more, let me know.

image image image
se-bastiaan commented 3 months ago

thanks! maybe i should try some repeated resets when I have time

it's certainly weird, before i reflashed Saturday morning everything worked fine for two weeks or so. Now I don't see anything coming in at all

se-bastiaan commented 2 months ago

Seems like the problem is the reading, same happens with the original firmware. And I've got the events working so 🤷 Scherm­afbeelding 2024-04-24 om 19 30 46