AIN4-20ma Raspberry Pi Detection
-
I am trying connect the AIN4-20 current sensor to the raspberry pi and communicate directly with i2c. i2cdetect fails to find the device (I've tried both the single channel unit and the 4 channel stack). I've enabled and tried the built in ARM i2c (bus 1), and also the software i2c (bus 3). Other i2c devices show up on these busses, just not the m5 products. Should these be detected, or are they not compatible without a M5 host? I have a raspberry pi project that uses another company's industrial i2c current receivers, but they are 12-bit units, and was hoping to easily upgrade to m5 units.
-
I guess this is a voltage level issue on the power supply for the sensor. M5 Groove Ports use 5V, RPi use 3.3V. Internally the AIN4-20mA use 3.3V (there is a voltage regulator between Groove port and the converter, see the schematic on https://docs.m5stack.com/en/unit/AIN4-20mA Unit) and 5V for the OP-Amp. You may supply the unit with 5V.
-
@holofloh Thanks for the reply. I'm using a raspberry pi 4 with 5v that draws directly from it's own power supply https://pinout.xyz/pinout/i2c. I tried hooking up to an external 5v power supply and it still doesn't detect either the unit or the module.
-
@andrew-winton did you connect the sensor +5V to the +5V and GND to GND of the RPi? Are you sure not having crossed the clock/data pins? I speak from experience... spent more than one hour for a simple failure like this.
When powering on the 5V can you measure if the 3.3V inside the sensor is correct? -
AIN needs 5v in to its Vcc pin, then i2c is on 3.3V same as Rpi, there is nothing special in it like only M5Stack compatibility its just a sensor on i2c at the end
-
I was hoping there wasn't something unique about the I2C on these, so I'm glad you confirmed that, however it's still confusing why I can't even detect it. Here it is with the stack module hooked up https://docs.m5stack.com/en/module/AIN4-20mA%20Module%2013.2. When I have SDA and SCL disconnected, an i2cdetect immediately returns no results. When I hook them up, i2cdetect crawls through each address until they time out. I've double checked the pinouts, and made sure I'm supplying 12v (also tried 24v) to the 9-24V high voltage plug, and that it's getting 5v from the Pi.
Yellow - 5v
Brown - Ground
Orange - SDA
Red - SCL -
so you have M5base here not sure about that as there is M-bus in it.
But you also mentioned single channel unit was behiving same right? -
@robski Yes, the single channel unit was behaving the exact same way.
-
@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