#🔒 create input module for PCF8575

5 messages · Page 1 of 1 (latest)

nova notch
#

I have this code which works great from CLI:
https://paste.pythondiscord.com/TQEQ
It's expected output is:

DEBUG:main:Performing direct I2C read test
DEBUG:main:Test Read Data: 0x0FF0, Processed Value: 0xF00F
INFO:main:Channel 1: ON
INFO:main:Channel 2: ON
INFO:main:Channel 3: ON
INFO:main:Channel 4: ON
INFO:main:Channel 5: OFF
INFO:main:Channel 6: OFF
INFO:main:Channel 7: OFF
INFO:main:Channel 8: OFF
INFO:main:Channel 9: OFF
INFO:main:Channel 10: OFF
INFO:main:Channel 11: OFF
INFO:main:Channel 12: OFF
INFO:main:Channel 13: ON
INFO:main:Channel 14: ON
INFO:main:Channel 15: ON
INFO:main:Channel 16: ON

That code proves that the PCF8575 module is correctly connected and the values can be read via I2C.

I need help with the code from: https://paste.pythondiscord.com/2N5Q

The issue is that the values are not correctly read, the value for all outputs (16) is 'None'
measurement state: {‘button_0_state’: None, ‘button_1_state’: None, ‘button_2_state’: None, ‘button_3_state’: None, ‘button_4_state’: None, ‘button_5_state’: None, ‘button_6_state’: None, ‘button_7_state’: None, ‘button_8_state’: None, ‘button_9_state’: None, ‘button_10_state’: None, ‘button_11_state’: None, ‘button_12_state’: None, ‘button_13_state’: None, ‘button_14_state’: None, ‘button_15_state’: None}
2024-08-10 22:19:02,837 - DEBUG - mycodo.controllers.controller_input_5443884c - Adding measurements to InfluxDB with ID 5443884c-1fe8-4379-b818-8bfac05de5e1: {}

prime scarabBOT
#

@nova notch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

nova notch
#

more information: I'm using a raspberry pi running mycodo which reads different temperature sensors and activates outputs (relays). I have 22 buttons connected to the GPIO, but using edge detection I get false triggers when turning on /off a light switch for example. A possible solution to this issue would be to use an I2C I/O extender like PCF8575 to read the button states.
However the composed input module doesn't work, can't read the state properly..

prime scarabBOT
#

@nova notch

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.