|
Post by cbluto on Jan 28, 2020 12:28:04 GMT -8
when adding a device to the I2C 4 channel mux on bus 1 thru 3 how/where do you program the python code for the device to find what bus it is on? For example adding the INA3221 voltage/current monitor on bus 2 what gets added to the program to tell this device it is operating on bus 2?
|
|
|
Post by SDL on Jan 28, 2020 15:11:53 GMT -8
|
|
rlee171
New Member
Posts: 12
Raspberry Pi: Yes
|
Post by rlee171 on Apr 20, 2021 16:10:14 GMT -8
Hello,
First let me say that I am new to the world of linux and python programming.
I purchased a I2C 4 Channel Mux TCA9545A Breakout Board. everything seems pretty straight forward. Doing an i2cdetect -y 1 I receive that the device is located at 0X73 as it should be per the documentation and github info.
My problem is that when I attempt to run the testSDL_Pi_TCA9545.py I receive the following errors.
Test SDL_Pi_TCA9545 Version 1.0 - SwitchDoc Labs
Sample uses 0x73 Program Started at:2021-04-20 18:48:15
-----------BUS 0------------------- Traceback (most recent call last): File "testSDL_Pi_TCA9545.py", line 58, in <module> tca9545.write_control_register(TCA9545_CONFIG_BUS0) File "/home/pi/SDL_Pi_TCA9545/SDL_Pi_TCA9545.py", line 74, in write_control_register self._write(TCA9545_REG_CONFIG, config) File "/home/pi/SDL_Pi_TCA9545/SDL_Pi_TCA9545.py", line 52, in _write self._bus.write_byte_data(self._addr, register, data) IOError: [Errno 5] Input/output error
When using Thonny in an attempt at debugging, I receive the following:
Traceback (most recent call last): File "/usr/lib/python3.7/ast.py", line 35, in parse return compile(source, filename, mode, PyCF_ONLY_AST) File "/home/pi/SDL_Pi_TCA9545/testSDL_Pi_TCA9545.py", line 58 tca9545.write_control_register(TCA9545_CONFIG_BUS0) ^ TabError: inconsistent use of tabs and spaces in indentation
This script is 6 years old and I am wondering if the errors are due to it wanting to run under Python3.7. Is there a way to force it to run using Python 2.7 or is there a better way to approach this. I have spent several hours doing multiple Google searches and trying find what I am sure i a simple solution.
Any help would be sincerely appreciated.
Ralph
|
|
|
Post by SDL on Apr 21, 2021 8:19:49 GMT -8
Download the GitHub again. All converted to python3.
When you run the test outside of Thonny, make sure you use python3
BP
|
|
rlee171
New Member
Posts: 12
Raspberry Pi: Yes
|
Post by rlee171 on Apr 21, 2021 8:38:42 GMT -8
BP,
Thanks for the prompt reply and help with the code.
Regards,
Ralph
|
|
rlee171
New Member
Posts: 12
Raspberry Pi: Yes
|
Post by rlee171 on Apr 21, 2021 9:17:23 GMT -8
BP,
I ran the test file using python3 from the Command line. I still get an error. Surely your code is correct. I removed the previous files before installing the new code. Do you have any suggestions on where to start looking?
Thonny results:
Traceback (most recent call last): File "/home/pi/SDL_Pi_TCA9545/testSDL_Pi_TCA9545.py", line 51, in <module> tca9545 = SDL_Pi_TCA9545.SDL_Pi_TCA9545(addr=TCA9545_ADDRESS, bus_enable = TCA9545_CONFIG_BUS0) File "/home/pi/SDL_Pi_TCA9545/SDL_Pi_TCA9545.py", line 47, in __init__ self._write(TCA9545_REG_CONFIG, config) File "/home/pi/SDL_Pi_TCA9545/SDL_Pi_TCA9545.py", line 52, in _write self._bus.write_byte_data(self._addr, register, data) OSError: [Errno 5] Input/output error
Also I added the following line in the config.txt in the /boot/ directory when I first installed the original code: dtoverlay=i2c-mux-pca9545a,addr=0x73
Thank you for your time,
Ralph
|
|
|
Post by SDL on Apr 21, 2021 10:48:05 GMT -8
You don't have I2C enabled on your P or you don't have the I2C mux plugged in correctlyI. We don' t use the overlay.
We tested the code and it works on our Pi's.
What happens when you type: "sudo i2cdetect -y 1"? Post it please. BP
|
|
rlee171
New Member
Posts: 12
Raspberry Pi: Yes
|
Post by rlee171 on Apr 21, 2021 12:24:34 GMT -8
I removed the overlay from the config file. I realized that it was leftover from another GitHub script I was trying. I have done a clean install of the OS. Enabled i2c and here is what I have:
pi@raspberrypi:~ $ i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- 73 -- -- -- --
|
|
rlee171
New Member
Posts: 12
Raspberry Pi: Yes
|
Post by rlee171 on Apr 21, 2021 13:12:19 GMT -8
I took a close look at the .pdf file and there is a pic showing 4 devices hooked up to a raspberrypi. I noticed that there are only 4 wires connected to the pi. I had a wire on the int pin on the mux going to pin 7 GPIO4. That is because one of the devices, an AS3935 was using it prior to installing the mux. I am attempting to add a LCD display, the reason for the mux. After removing the wire from the pi, here are my results: HooRaa However, how do I get the interrupt enabled on the AS3935 now?
-----------BUS 0------------------- tca9545 control register B3-B0 = 0x1 ignore Interrupts if INT3' - INT0' not connected tca9545 control register Interrupts = 0x4 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- 73 -- -- -- --
-----------------------------------
-----------BUS 1------------------- tca9545 control register B3-B0 = 0x2 ignore Interrupts if INT3' - INT0' not connected tca9545 control register Interrupts = 0x4 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- 73 -- -- -- --
-----------------------------------
-----------BUS 2------------------- tca9545 control register B3-B0 = 0x4 ignore Interrupts if INT3' - INT0' not connected tca9545 control register Interrupts = 0x4 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: 03 -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- 73 -- -- -- --
-----------------------------------
-----------BUS 3------------------- tca9545 control register B3-B0 = 0x8 ignore Interrupts if INT3' - INT0' not connected tca9545 control register Interrupts = 0x4 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- 73 -- -- -- --
|
|
|
Post by SDL on Apr 22, 2021 15:01:51 GMT -8
You can wire an interrupt pin. But we don't provide instructions for doing that. Lots of tutorials on Arduino interrupts. Raspberry Pi, check it out. Not sure what you can do there.
All looks good now.
BP
|
|