I am trying to detect AHT10 and INA3221 sensors on bpi-r4.
I compiled kernel with AHT and INA modules, and after kernel denied insmod aht10.ko because of unknown symbol in the modul, I recompiled kernel with these drivers added in the kernel.
I connected modules on GPIO:
GPIO18/I2C_1_SDA
GPIO17/I2C_1_SCL
GND
5 or 3V3
when I try i2cdetect -y [0-5], there are some detects on every i2c bus, but no new device. The result is the same.
I tried to help some examples on how to work with i2c on debian, but I do not have an idea what am i doing wrong?
It looks like you have to enable i2c1 (for gpio header) in dts. I2c0 is i2c0 in dts,but i2c1 above is i2c2 in dts with the i2cmux below (the other i2c busses are channels from i2cmux).
waw, thanks for pointing me. I am trying to imagine what do you mean with the i2c1 is i2c2 in dts with the i2cmux.
I assume that you mean that in the i2cdetect -l the:
i2c-1 i2c i2c-mt65xx I2C adapter
should be in mt7988a-bananapi-bpi-r4.dts somehow pointed to the
i2c-2 i2c i2c-1-mux (chan_id 0) I2C adapter
I am so sorry @frank-w , but as I never used i2c, dts, dtsi, I have more questions than I expected, and I really do not want screw up things too much…
How it is possible that I am able to get some results from i2cdetect -y 1 if the bus is not enabled?
If so, why it is not possible to use the i2c-2 instead?
And is there any reason to not commit this configuration in the mt7988a-bananapi-bpi-r4.dts?
You have i2c0 with the pmic and i2c2 with the i2c-mux (both not accesible from gpio header pins). Linux kernel counts from 0 while creating devices,so i2c2 gets i2c1 because soc i2c1 is not enabled there…
So you just need this with recompiling and installing kernel:
But I am still not able to scan INA3221 or AHT10. I try and solder shorter dupont cables on AHT10 directly, but I am still unable to detect it.
Using osciloscope, there is standard 3V3 high level on SDA and SCL, and I am able to see some data on both channels whenever i run i2cdetect -y 1 , but still nothing is detected. I will test more i2c capable modules i find.
Please let me know whenever anyone have another idea, as I wrote, I do not have any experiences.
Now I try INA3221 and even epaper module. Nothing was detected.
I was thinking that it have to be an modul, but what about any problem which could block reading of data from SDA? Out of ideas.
You cannot use 5V powered devices. Likely they will have pullups on the SDA and SCL lines. This means that SDA and SCL lines are pulled up to 5V, which is too high for the gpio’s on the bpi-r4. They may get damaged.
If you must use 5V, then use a bi-directional level converter.
If you doubt the functionality of the i2c1 port (driver or hardware) you could always setup a software driven i2c port on any of the other gpio pins.:
Nice, thanks for the informations.
I was used just 3V3, as I am used from playing with arduino.
Now I verified that INA3221 is functional, I detect it on the Arduino nano.
Ouuups, now i realize what do you mean with the 5V level. the AHT10 wich I tested as the first is powered only with 3V3, but as it did not worked, I tested the INA3221 which can be powered 3V3 and even 5V, and if there is 5V logic levels along with the 5V DC power…
But, what do you think, does it is possible to have i2c damaged when I am able to see the data with the 3V3 logic level on SCL and SDA on osciloscope?
Best option is to power the ina3221 with the 3.3V from the gpio-header. Always make sure the GND is properly connected. This way your gpio-pins are safe from over-voltage.
Only if you have supplied your ina3221 with 5V, both your sda/scl pins may have also been pulled to 5V, through the two 10k resistors you found, which is higher than the specifications. Usually they do not die immediately, your pins may have been damaged, maybe not, who knows.
So you can setup another i2c bus with ‘i2c-gpio’. You could first try it on pins other then the ones you have tried before, they should not have been subjected to over-voltage. If that works, you could try the ‘i2c-gpio’ on the same pins as the i2c1 port (with i2c1 port left disabled).
As far as i see you only enabled the i2c1 without assigning pinctrl…was it defined in openwrt already? But yes scanning sometimes do not show up devices…remember i had this with the oled display.
Waw, good to know that some modules/devices could be problem even detect.
If it could be more strightforward with another sensors, do you anybody knows and recommends some others? As I really do not need precise current, hall sensor could be sufficient and preffered. I find some on aliexpress, but there are the cheap one only to 5A and I need limit 20A.
And as I would like wo know consumption of:
12V for bpi-r4
12V for hard drives
5V for hard drives
use of 3-channel INA3221 looked great. Whenever I will have 3 modules, they have to have possibility to set-up different i2c address. I assume that it will not be a problem?