Closed BoW2EviL closed 2 years ago
i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- 38 39 -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
38-39 are aht10'2 20 is the mcp23017
so im not sure i will give it a try but i dont think it will work
python3 -m mqtt_io config.yaml
2022-07-06 01:46:27 mqtt_io.modules [DEBUG ] Module <module 'mqtt_io.modules.gpio.mcp23017' from '/usr/local/lib/python3.9/dist-packages/mqtt_io/modules/gpio/mcp23017.py'> has all of its requirements installed already.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 174, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 169, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 52, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 180, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 159, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=stop)
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 59, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py", line 181, in read_bytes
return self._device.read(number)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/__main__.py", line 85, in <module>
main()
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/__main__.py", line 80, in main
mqtt_gpio.run()
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/server.py", line 1226, in run
self._init_gpio_modules()
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
self.gpio_modules[gpio_config["name"]] = _init_module(
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/server.py", line 128, in _init_module
return module_class(module_config)
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/modules/gpio/__init__.py", line 105, in __init__
self.setup_module()
File "/usr/local/lib/python3.9/dist-packages/mqtt_io/modules/gpio/mcp23017.py", line 57, in setup_module
self.io = mcp23017.MCP23017(
File "/usr/local/lib/python3.9/dist-packages/adafruit_mcp230xx/mcp23017.py", line 57, in __init__
super().__init__(i2c, address)
File "/usr/local/lib/python3.9/dist-packages/adafruit_mcp230xx/mcp23xxx.py", line 38, in __init__
self._device = i2c_device.I2CDevice(bus_device, address)
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 61, in __init__
self.__probe_for_device()
File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 183, in __probe_for_device
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x22
so i dont get the traceback error when i use "0x20" like i do when i use an address thats not assigned.
Okay it works perfectly now. Thank you for a wonderful project! @bsmith76s thanks for the advise.
Solved
Action description A clear and concise description of what you're trying to achieve.
Previous attempts Describe what you've tried so far.
i can get mqtt-io to start and connect to the mqtt broker.
using mqtt explorer i attempted to manually trigger the output with a raw ON | OFF post to "home/livingroom/climate/output/socket8/set" with success, mqtt-io responds by setting home/livingroom/climate/output/socket8 to ON | OFF respectively.
i seem to get no debug logs concerning mcp23017 so i am not sure how to determine whether or not mcp23017 module is doing?
i2c_bus_num fails validation when enabled with gpio module mcp23017 like the examples show
when the address is assigned to a non valid device, it reports a error with traceback see post below
now that i have more time to play.....
it does not appear to be a problem with this source code itself but is a issue with all python source ive tried so far.
cpp & c works fine to trigger the mcp23017 still, but anything ive tried based on smbus or smbus2 fails to trigger the device.
Error messages and traceback
traceback failure with the i2c_bus_num enabled
Config
Hardware
System:
Additional context
pip list output
Thanks for any advise you can give.
Soloution
After the suggestion of changing the mcp23017 to 0x22 i relized the i2c was indeed attempting to commuicate with the mcp23017 just it was not responding correctly. i remembered this happening while exploring several other cpp mcp23017 libs in the past not sure why the init cmds dont reinit the device without a power cycle but whatever. if anyone knows why this happens please share.
Not sure why but these mcp23017 seem to hold some kind of setting that would not allow the new commands to be applied? mine has not powered off for?? months, years? lol Note Just Power Cycling the Rpi was not enough to reset the mcp23017.