Hello,
I want to use a M5Stack I2C 4-20 mA unit with a wemos S2 mini with ESP32 chip but I am not able to get some data from it.
I had a look at the github examples from M5Stack and made a program to show the current on a display. Display is working and I can find the unit with an i2c scanner.
Arduino IDE gives no mistakes during compiling but it doesn`t work. My control LED is not blinking and there is always the sound from connecting a new usb device if I start the program? I don't understand why...
Any ideas ?
I asked at the M5stack forum too, but there is not so much support....
Thank you
Here is the code:
#include <Wire.h>
#include <Arduino.h>
#include <U8g2lib.h>
#include "MODULE_4_20MA.h"
U8G2_SSD1309_128X64_NONAME2_F_HW_I2C u8g2(U8G2_R0,U8X8_PIN_NONE);
const byte led_gpio = 15; // LED GPIO 15
MODULE_4_20MA cr;
void setup() {
Wire.begin(33, 18); // SDA pin 33, SCL pin 18
u8g2.begin();
pinMode(led_gpio, OUTPUT);
}
void loop() {
float current = cr.getCurrentValue(0);
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0,20,"Strom:");
u8g2.setCursor(0, 40);
u8g2.print(current);
} while ( u8g2.nextPage() );
digitalWrite(led_gpio, HIGH);
delay(1000);
digitalWrite(led_gpio, LOW);
delay(1000);
}