AIN4-20mA Unit to Arduino Nano Every
-
I am trying to talk to the module using a Nano Every using the standard wire example, I get no output at all. If I use a sniffing sketch, it detects the device on 0x55 so it is visible on the bus.
#include <Wire.h> void setup() { Wire.begin(8); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output } void loop() { Wire.requestFrom(0x55, 8); // request 8 bytes from slave device 0x55 while (Wire.available()) { // slave may send less than requested char c = Wire.read(); // receive a byte as character Serial.print(c,DEC); // print the character } delay(250); }I have a 4-20mA current source which I can measure, so I am confident I have a variable input.
I have not used I2C before, I am confident the Arduino libraries are correct, so any pointers to what it might be would be appreciated. Thanks.
-
@spectrad said in AIN4-20mA Unit to Arduino Nano Every:
I am trying to talk to the module using a Nano Every using the standard wire example, I get no output at all. If I use a sniffing sketch, it detects the device on 0x55 so it is visible on the bus.
#include <Wire.h> void setup() { Wire.begin(8); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output } void loop() { Wire.requestFrom(0x55, 8); // request 8 bytes from slave device 0x55 while (Wire.available()) { // slave may send less than requested char c = Wire.read(); // receive a byte as character Serial.print(c,DEC); // print the character } delay(250); }I have a 4-20mA current source which I can measure, so I am confident I have a variable input.
I have not used I2C before, I am confident the Arduino libraries are correct, so any pointers to what it might be would be appreciated. Thanks.
not sure if you can marry M5stack sensor/module with diff MCUs than esp32? maybe I'm wrong here.
-
@robski I assumed as it was I2C then anything that had an I2C port should work as it's a standard protocol, but I could be wrong as well.
-
-
@Cognitive5525 said in AIN4-20mA Unit to Arduino Nano Every:
No as I am not using an M5Stack, I am trying to use an Arduino Nano Every.
-
@Cognitive5525 said in AIN4-20mA Unit to Arduino Nano Every:
he doesn't have M5Stack controller, only M5Stack sensor trying to read back to Arduino NANO so not esp32 board.
-
@spectrad said in AIN4-20mA Unit to Arduino Nano Every:
@spectrad have you tried with the M5Stack example here?No as I am not using an M5Stack, I am trying to use an Arduino Nano Every.
Ah sorry I overlooked that, but even though you're not using a M5stack MC I still believe that you might be able to get some "inspiration" from it. Have a look at the module MODULE_4_20MA in src-folder. As far as I can see it does not rely on any special M5stack libraries at this level.
-
@Cognitive5525 said in AIN4-20mA Unit to Arduino Nano Every:
@spectrad said in AIN4-20mA Unit to Arduino Nano Every:
@spectrad have you tried with the M5Stack example here?No as I am not using an M5Stack, I am trying to use an Arduino Nano Every.
Ah sorry I overlooked that, but even though you're not using a M5stack MC I still believe that you might be able to get some "inspiration" from it. Have a look at the module MODULE_4_20MA in src-folder. As far as I can see it does not rely on any special M5stack libraries at this level.
Although you are not wrong about getting inspiration from it, using the Arduino Wire functions I should get something (and they do detect the device), the M5 library really just decodes the values its reading using the M5 version of the wire library (I assume, I don't know the M5).
I am not reading anything from the module using I2c (a standard protocol), that's the bit I don't understand, if I can read some data back, I can manipulate it from there to get a reading, it's just I don't get data, so I am left scratching my head.
-
I think the MODULE_4_20MA (in the src folder) is only using some standard libraries:
From top src/MODULE_4_20MA.h:#ifndef __MODULE_4_20MA_H #define __MODULE_4_20MA_H #include "Arduino.h" #include "Wire.h"Try to download only the two files in the src-folder and see if you can include them into your project and compile.
Also: If you look at the code in src/MODULE_4_20MA.cpp you'll see that they include some register addresses, maybe that is required for this AIN4-20mA unit?
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