AIN4-20ma Raspberry Pi Detection
-
@andrew-winton do you have any other M5Stack unit on i2c to be checked possibly, not AIN unit I mean.
-
@robski I do not. I was considering getting a core and base to make sure it worked with those first to rule out the device.
-
Hello @andrew-winton
I don't have a RP4 nor do I have the AIN4-20mA module so my tests might be irrelevant for your setup.
Using an RP3 and about every M5Stack I2C unit I have (RFID, Relay4, PaHub, PbHub, EXTIO, etc.), all of them get detected just fine using
i2cdetect -y 1.That said:
- have you verified that there are proper pull-up resistors on SCL and SDA? (RP should have them by default.)
- have you tried with different wires?
- have you tried w/o supplying 12 v? I think it's redundant looking at the schematic. (External 12 V power also produces BUS_5V which might clash with the 5 V from RP.)
- have you tried to reduce the I2C speed? (default seems to be 100k)
Thanks
Felix -
I'm bk home tday for weekend and I have AIN single chnl unit so I'll try to check it out.
-
@felmue RP has the pull-ups by default. Although these are brand new wires, I've tried different ones. I've also tried it with and without the power to the stack. I've also tried speeds of 50k, 100k, and 400k, which have all worked for other i2c devices on the Pi.
-
@andrew-winton I've checked my AIN module with RPi4 and i can confirm that it is not detecting it, plugged in ENV module, ACCEL module, ultrasound module and i2c scan detects it straight in, when AIN is plugged in scan goes fast to place where it should be detected ( 0x55 i think) and then without its ID detection scan continues but slowly like 1s for every next ID field till the scan end
-
@andrew-winton tday I had a chance to test AIN with raspberry pico 2 W and it is detetcting ok

-
@robski Yeah I had seen that behavior with it jumping to the right address and then crawling after not finding it.
-
@andrew-winton
Hi, did you ever solve this problem?
Thanks -
Dear @Steve-Mack @andrew.winton,
Did you solve the problem? I have the same issue with a Raspberry PI Zero W (no detection with "i2cdetect -y 1"). As I have 2 AIN4-20ma and 2 raspberry PI Zero W, I tried to exchange them but it is never detected. Other I2C devices are working well.
Thanks,
Seb -
Hopefully I can shed a little light on this topic. The AIN4-20mA unit uses a STM32 processor to handle the I2C interface in software. For some reason, the timing is not wholly compatible with the Raspberry Pi kernel I2C drivers. However, the Espressif I2C implementation is a lot more tolerant and flexible and works just fine. That's why it works with the M5 controllers.
There was a an update to the github repo for this unit's firmware (https://github.com/m5stack/M5Module-4-20mA-Internal-FW) which changed the I2C library that was used. It's possible that this will fix it, but I haven't bothered to set up a STM32 development system to try it.
If you really want to use a Pi or other Linux host board, you could use any inexpensive ESP device (like an M5Stamp) as a go-between. Another option is to use something like the Arduino UNO Q, which runs Linux on the main processor and allows you to run C++ code on the STM32 microcontroller to talk to I2C devices. It's really better to run real-time control on a separate microcontroller anyway.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login