Unknown i2c device - 4-20 mA measurement M5stack
Moderators: grovkillen, Stuntteam, TD-er
Unknown i2c device - 4-20 mA measurement M5stack
Hello,
I would like to use this 4-20 mA measurement device with i2c but I don't know how to communicate with it to get the current values
https://docs.m5stack.com/en/unit/AIN4-20mA%20Unit
I think it is not included up to now to the plugin list? Is it possible to talk to it with esp easy ? i2c protocol can find at the end of the link.
With i2c scan I can find the device (adress 0x55) and my display.
At the moment I use a wemos s2 mini with ESP_Easy_mega_20241222_normal_ESP32s2_4M316k_CDC Dec 22
Thank you!
Regards
I would like to use this 4-20 mA measurement device with i2c but I don't know how to communicate with it to get the current values
https://docs.m5stack.com/en/unit/AIN4-20mA%20Unit
I think it is not included up to now to the plugin list? Is it possible to talk to it with esp easy ? i2c protocol can find at the end of the link.
With i2c scan I can find the device (adress 0x55) and my display.
At the moment I use a wemos s2 mini with ESP_Easy_mega_20241222_normal_ESP32s2_4M316k_CDC Dec 22
Thank you!
Regards
Re: Unknown i2c device - 4-20 mA measurement M5stack
This is not currently supported via any plugin right now.
It looks like this is a separate processor running some proprietary code and wired as an I2C device.
So this is not an actual part which we could implement based on some datasheet, but it is a small microprocessor running code from M5Stack.
Not sure if they use a somewhat 'generic' protocol, so we could add a 'generic' plugin for these kinds of parts M5stack made.
There are others, like a module with several rotary encoders, also using a similar approach where they added a small microcontroller to make it communicate with I2C.
It looks like this is a separate processor running some proprietary code and wired as an I2C device.
So this is not an actual part which we could implement based on some datasheet, but it is a small microprocessor running code from M5Stack.
Not sure if they use a somewhat 'generic' protocol, so we could add a 'generic' plugin for these kinds of parts M5stack made.
There are others, like a module with several rotary encoders, also using a similar approach where they added a small microcontroller to make it communicate with I2C.
Re: Unknown i2c device - 4-20 mA measurement M5stack
Instead of this specific device, you can also use one of the INA219 or INA3221 I2C voltage/current sensors, that are supported by ESPEasy. Both plugins are in the Energy builds. Those plugins won't support that M5Stack device though.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
Ok thank you, but now I have the m5 ones and it would be nice to use them...
Re: Unknown i2c device - 4-20 mA measurement M5stack
Hm, well, depending on the level of software engineer you are, you could write a plugin for the device. We have a Developers Getting Started guide 
I can reserve a new PluginID if needed.

I can reserve a new PluginID if needed.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
ok.. not nice news, I don't think that I am able to write a plugin... I thought that there is maybe a solution with a rule or something else to build an i2c communication with the mentioned protocol
the resolution of the INA devices are not so good with 0,4 mA and 0,8 mA, the m5 devices are really nice for measuring 4-20 mA,
I will try to read it out with a python programm and then I try to send the values to my mqtt server, maybe this works better
the resolution of the INA devices are not so good with 0,4 mA and 0,8 mA, the m5 devices are really nice for measuring 4-20 mA,
I will try to read it out with a python programm and then I try to send the values to my mqtt server, maybe this works better
Re: Unknown i2c device - 4-20 mA measurement M5stack
The device is rather simple to read data from, we just don't have a generic I2C plugin to retrieve that data from a device. We're already discussing about how to implement that
To be continued...

/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
I have assigned Plugin ID P180 for a generic I2C interface plugin.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
Yay!
Finally

Re: Unknown i2c device - 4-20 mA measurement M5stack
woah this was fast, how can I get the plugin to test it ?
Re: Unknown i2c device - 4-20 mA measurement M5stack
it is planned, not done yet
Re: Unknown i2c device - 4-20 mA measurement M5stack
First question: How can I find out if the generic i2c interface plugin is available ?
Second question: Is ESP-now available meanwhile? Then I could use on ESP for the i2c communication with a simple C programm and sent the values to another ESP which shows the values on a display and communicate to my mqtt server
Second question: Is ESP-now available meanwhile? Then I could use on ESP for the i2c communication with a simple C programm and sent the values to another ESP which shows the values on a display and communicate to my mqtt server
Re: Unknown i2c device - 4-20 mA measurement M5stack
There will be a notification in this thread
ESP-now is not released yet, for several (mostly technical) reasons.
For communication between ESP nodes on the same WiFi or Ethernet network, you can use the ESPEasy P2P network to transfer data from one unit to the other, either by using the SendTo command, and/or by configuring the P2P Controller. Alternatively, you can use http commands to send data to a remote ESPEasy unit.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
is there a simple wired communication possible between two ESP32, one with espeasy? Over UART for example ?
I had an ESP32 running now with the M5Stack device and I get the current values, I want so sent them wired to another device with espeasy which makes the communication to wifi and show values on a display
I had an ESP32 running now with the M5Stack device and I get the current values, I want so sent them wired to another device with espeasy which makes the communication to wifi and show values on a display
Re: Unknown i2c device - 4-20 mA measurement M5stack
Do you need it to be wired, or are the ESPs both connected to the same WiFi network? As in the case of single-network, you can easily pass data via the P2P network (via SendTo command and optionally using the P2P Controller). P2P is enabled by default on ESPEasy (using the IANA-registered UDP port 8266). Important requirement: All units must have a unique Unit number, not being 0 or 255.
Edit:
You can connect a serial-out from a non-ESPEasy device to the console port of ESPEasy (115200 baud, 8N1), and send commands, just like in Rules, to the device for setting values f.e. to a Dummy device, using TaskValueSet. Those values can then be displayed or sent to a Controller.
Edit:
You can connect a serial-out from a non-ESPEasy device to the console port of ESPEasy (115200 baud, 8N1), and send commands, just like in Rules, to the device for setting values f.e. to a Dummy device, using TaskValueSet. Those values can then be displayed or sent to a Controller.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
it would be nice to have an easy wired serial connection, because I have no experience with c++ and wifi and I want to keep it as simple as possible, both devices are close together
the sender is the ESP with my own software, the receiver ist espeasy, one value around every 5 seconds
the sender is the ESP with my own software, the receiver ist espeasy, one value around every 5 seconds
Re: Unknown i2c device - 4-20 mA measurement M5stack
I've created PR #5296 to add P180 - Generic - I2C Generic to enable to read I2C devices 'manually', by getting the required command sequence from the data sheet.
I'll add a command sequence for your M5Stack sensor soon, and also a binary to upload to your ESP32-S2.
Last edited by Ath on 11 Apr 2025, 08:23, edited 1 time in total.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
woah thank you
Re: Unknown i2c device - 4-20 mA measurement M5stack
I'm thinking of adding this plugin to all ESP32 Collection builds (including Climate, Display, Energy and Neopixel), so I've built an ESP32-S2 Collection_A build for testing:
This will read the 'Current' value from the M5Stack sensor, divide it by 100 to get the mA value, and assign it to the first (and single) Value1 field.
If you also need the raw ADC value, set the Output Data Type to Dual, and enter this for the I2C Commands 2 setting:
It will read the raw value from the sensor and set that to the second Value2 field. You can rename those Value names, if desired, of course.
Writing custom commands, like changing the calibration, to the sensor can be achieved via the 'geni2c,cmd,...' command, where for the dots you can add a supported command, as listed in the source (and later in the docs, of course)
You can add the Generic - I2C Generic plugin to an available task slot, give it a name, set the I2C Address to '0x55', set Output Data Type to 'Single' and enter this for the I2C Commands 1 setting:
Code: Select all
read.u16le.0x20;calc.%value%/100
If you also need the raw ADC value, set the Output Data Type to Dual, and enter this for the I2C Commands 2 setting:
Code: Select all
read.u16le.0x0
Writing custom commands, like changing the calibration, to the sensor can be achieved via the 'geni2c,cmd,...' command, where for the dots you can add a supported command, as listed in the source (and later in the docs, of course)
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
I am sorry, I am not able to flash my wemos s2 mini and I don't understand why....
I was able to flash it online with a normal ESPeasy Version, the ESP Easy Flasher find the device as COM4 but there are always errors..
I tried it with two boards. If I try my C++ programs with Arduino IDE the USB connection sound is coming from time to time, it seems that there is no stable seriell connection. Sometines it is COM4 and then COM5.
I push 0 and RST button and then release RST to bring the device in flash mode, then the USB sound appearrs.
I was able to flash it online with a normal ESPeasy Version, the ESP Easy Flasher find the device as COM4 but there are always errors..
I tried it with two boards. If I try my C++ programs with Arduino IDE the USB connection sound is coming from time to time, it seems that there is no stable seriell connection. Sometines it is COM4 and then COM5.
I push 0 and RST button and then release RST to bring the device in flash mode, then the USB sound appearrs.
Code: Select all
######2025-04-12######
#######0.04.009#######
######FLASH INFO######
BIN file: ESP_Easy_mega_20250411_collection_A_ESP32s2_4M316k_CDC.bin
COM port: (COM4) Generic Serial Port
Baud rate: 115200
######POST FLASH######
No post flash information entered...
######FLASH LOG######
[esptool.exe -vv -cd nodemcu -cb 115200 -cp COM4 -ca 0x00000 -cf "D:\EspEasy\bin\ESP_Easy_mega_20250411_collection_A_ESP32s2_4M316k_CDC.bin"]
[12.04.2025 21:50:53] esptool v0.4.12 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
[12.04.2025 21:50:53] setting board to nodemcu
[12.04.2025 21:50:53] setting baudrate from 115200 to 115200
[12.04.2025 21:50:53] setting port from to COM4
[12.04.2025 21:50:53] setting address from 0x00000000 to 0x00000000
[12.04.2025 21:50:53] espcomm_upload_file
[12.04.2025 21:50:53] espcomm_upload_mem
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] opening bootloader
[12.04.2025 21:50:53] resetting board
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] resetting board
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] resetting board
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] trying to connect
[12.04.2025 21:50:53] flush start
[12.04.2025 21:50:53] setting serial port timeouts to 1 ms
[12.04.2025 21:50:53] setting serial port timeouts to 1000 ms
[12.04.2025 21:50:53] flush complete
[12.04.2025 21:50:53] espcomm_send_command: sending command header
[12.04.2025 21:50:53] espcomm_send_command: sending command payload
[12.04.2025 21:50:53] read 0, requested 1
[12.04.2025 21:50:53] warning: espcomm_sync failed
[12.04.2025 21:50:53] error: espcomm_open failed
[12.04.2025 21:50:53] error: espcomm_upload_mem failed
[2025-04-12 21:50:53] STOPPED due to 2 errors! (try reset on the unit, then start a new flash attempt)
Re: Unknown i2c device - 4-20 mA measurement M5stack
I tried it with an ESP32 C3 super mini too, it doesn't work....
Code: Select all
######2025-04-12######
#######0.04.009#######
######FLASH INFO######
BIN file: ESP_Easy_mega_20250411_collection_A_ESP32s2_4M316k_CDC.bin
COM port: (COM6) Generic Serial Port
Baud rate: 115200
######POST FLASH######
No post flash information entered...
######FLASH LOG######
[esptool.exe -vv -cd nodemcu -cb 115200 -cp COM6 -ca 0x00000 -cf "D:\EspEasy\bin\ESP_Easy_mega_20250411_collection_A_ESP32s2_4M316k_CDC.bin"]
[12.04.2025 22:32:14] esptool v0.4.12 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
[12.04.2025 22:32:14] setting board to nodemcu
[12.04.2025 22:32:14] setting baudrate from 115200 to 115200
[12.04.2025 22:32:14] setting port from to COM6
[12.04.2025 22:32:14] setting address from 0x00000000 to 0x00000000
[12.04.2025 22:32:14] espcomm_upload_file
[12.04.2025 22:32:14] espcomm_upload_mem
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] opening bootloader
[12.04.2025 22:32:14] resetting board
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 20 instead of C0
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 30 instead of C0
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 30 instead of C0
[12.04.2025 22:32:14] resetting board
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 32 instead of C0
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 30 instead of C0
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 30 instead of C0
[12.04.2025 22:32:14] resetting board
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 20 instead of C0
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 30 instead of C0
[12.04.2025 22:32:14] trying to connect
[12.04.2025 22:32:14] flush start
[12.04.2025 22:32:14] setting serial port timeouts to 1 ms
[12.04.2025 22:32:14] setting serial port timeouts to 1000 ms
[12.04.2025 22:32:14] flush complete
[12.04.2025 22:32:14] espcomm_send_command: sending command header
[12.04.2025 22:32:14] espcomm_send_command: sending command payload
[12.04.2025 22:32:14] serialport_receive_C0: 30 instead of C0
[12.04.2025 22:32:14] warning: espcomm_sync failed
[12.04.2025 22:32:14] error: espcomm_open failed
[12.04.2025 22:32:14] error: espcomm_upload_mem failed
[2025-04-12 22:32:15] STOPPED due to 2 errors! (try reset on the unit, then start a new flash attempt)
Re: Unknown i2c device - 4-20 mA measurement M5stack
For flashing via an external tool, the .factory.bin file must be uploaded. For flashing from the Tools page (Firmware Update button) you can use the 'regular' .bin file.
If ESPEasy is still usable from the browser, please use the Firmware Update button to upload the .bin file (without .factory in the name!). If not, then you can use https://td-er.nl/ESPEasy/latest to upload an S2 build, and after, that upload the new & improved version (with P180 included) I have here: NB: You can't upload an ESP32-S2 build to a C3, that's never going to work because of different CPU architectures
If ESPEasy is still usable from the browser, please use the Firmware Update button to upload the .bin file (without .factory in the name!). If not, then you can use https://td-er.nl/ESPEasy/latest to upload an S2 build, and after, that upload the new & improved version (with P180 included) I have here: NB: You can't upload an ESP32-S2 build to a C3, that's never going to work because of different CPU architectures

/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
ok I can use it now... thanks
for a simple first test without current source I want to read out the i2c adress, is this command correct ? or to get the calibration current ?
Because for both values I get 0 at the moment
I2c scan finds the device at 0x55
for a simple first test without current source I want to read out the i2c adress, is this command correct ?
Code: Select all
read.u8le.0xFF;
Code: Select all
read.u16le.0x30;
Because for both values I get 0 at the moment
I2c scan finds the device at 0x55
Re: Unknown i2c device - 4-20 mA measurement M5stack
There is currently no support for u8le, as little endian doesn't apply to a single-byte value
Using u8 there will probably work better. When never set, and there's no real reason to change, it might return 0 though.
Alternatively you could read the firmware version at register 0xFE using the command read.u8.0xfe
NB: you are putting these commands in the I2C commands field, I presume? Then the Interval should also be changed from 0 to f.e. 10 to have a repeated read, or a taskrun should be applied on the (enabled) task, to get the value updated.
Edit: Corrected Version register to 0xFE (first edit was from memory
)

Alternatively you could read the firmware version at register 0xFE using the command read.u8.0xfe
NB: you are putting these commands in the I2C commands field, I presume? Then the Interval should also be changed from 0 to f.e. 10 to have a repeated read, or a taskrun should be applied on the (enabled) task, to get the value updated.
Edit: Corrected Version register to 0xFE (first edit was from memory

/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
for a first test to read out the firmware version, I get value 0, so I think it is wrong
at the moment it is difficult to make tests with this wemos device because I loose the connection a lot of times, don't know if it is a problem of my wifi or of the device....
try more tests tomorrow with a second device....
at the moment it is difficult to make tests with this wemos device because I loose the connection a lot of times, don't know if it is a problem of my wifi or of the device....
Code: Select all
126438: WD : Uptime 2 ConnectFailures 0 FreeMem 99220 WiFiStatus: WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
156438: WD : Uptime 3 ConnectFailures 0 FreeMem 99808 WiFiStatus: WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
- Attachments
-
- i2c_espeasy2.jpg (85.27 KiB) Viewed 1975 times
-
- i2c_espeasy.jpg (71.94 KiB) Viewed 1975 times
Re: Unknown i2c device - 4-20 mA measurement M5stack
The log you show is the normal WatchDog (WD) INFO level log that is output every 30 seconds, that's been there since forever... Not an indication of a bad connection or whatever, the WiFi status info in that log isn't accurate, though
nothing to worry about, work is underway to have that fixed.

/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
I have two esp32-s2 boards here (wemos s2 mini) and both loose the connection all the time... I don't know why but I cannot test with these boards, I ordered new ones today. I have here in the same room and around 4 other ESP8266 running with no connection losses, never, so I guess wifi is ok and the boards have a whatever problem
Re: Unknown i2c device - 4-20 mA measurement M5stack
Purple boards looking like those old Wemos D1 mini boards?
Those for the S2 are really hit-or-miss.
Quite a lot of them have really really poor WiFi.
I assume they have for some batches placed the wrong components for the antenna matching circuit.
You can try to reduce max. TX power on the tools->Advanced page to see if that makes the connection more stable.
Those for the S2 are really hit-or-miss.
Quite a lot of them have really really poor WiFi.
I assume they have for some batches placed the wrong components for the antenna matching circuit.
You can try to reduce max. TX power on the tools->Advanced page to see if that makes the connection more stable.
Re: Unknown i2c device - 4-20 mA measurement M5stack
Would be better not to order ESP32-S2 (or C2) boards, as that's somewhat of an 'in between' model, better opt for ESP32, ESP32-C3, ESP32-C6 or ESP32-S3 boards, as that are the most stable ESP32 MCUs. And when selecting a board, the ones with 8MB or 16MB Flash are preferred, so you can use a MAX build, with all plugins and features enabled.
With your current S2 boards, also check the cable used to power the board. If that's using a micro-USB connector, often the wires in the cable are rather thin, causing unstable power to the board. When powering the ESP on a breadboard, using breadboard patch wires, please use thicker wires, as that's often causing similar power-issues.
With your current S2 boards, also check the cable used to power the board. If that's using a micro-USB connector, often the wires in the cable are rather thin, causing unstable power to the board. When powering the ESP on a breadboard, using breadboard patch wires, please use thicker wires, as that's often causing similar power-issues.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
I've fixed some issues, one of which explains why you didn't get a value from your device... (you could call that a bug, in fact).
Here's a new ESP32-S2 Collection A build for you to test: To get the result available, the I2C Commands should be set to (same as before):
Here's a new ESP32-S2 Collection A build for you to test: To get the result available, the I2C Commands should be set to (same as before):
Code: Select all
read.u16le.0x20;calc.%value%/100
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
Hello,
I am back and got new devices.
Unfortunately I had 5 wemos s2 mini which are not original, now I have one directly from wemos and made a test with that device. Unstable wifi is horrorable, I guess that I got shitty boards. In future I will use different boards than s2, but this firmware only works with s2 or not ?
I can read the firmware (version 1) and the i2c adress (85) succesful.
For the current value and the adc I get strange values, I guess that there is a problem with the data type ?
I connected a 4.00 mA source so a value with something around 3.4 mA would be maybe ok without calibration.
I don't know at the moment how many bits the ADC has M5stack use, I can't find a information about it, only one source says 16 bit, so 65536, 20978 seems to be to high...
I am back and got new devices.
Unfortunately I had 5 wemos s2 mini which are not original, now I have one directly from wemos and made a test with that device. Unstable wifi is horrorable, I guess that I got shitty boards. In future I will use different boards than s2, but this firmware only works with s2 or not ?
I can read the firmware (version 1) and the i2c adress (85) succesful.
For the current value and the adc I get strange values, I guess that there is a problem with the data type ?
I connected a 4.00 mA source so a value with something around 3.4 mA would be maybe ok without calibration.
I don't know at the moment how many bits the ADC has M5stack use, I can't find a information about it, only one source says 16 bit, so 65536, 20978 seems to be to high...
- Attachments
-
- i2c commands.jpg (87.28 KiB) Viewed 1056 times
-
- device.jpg (45.26 KiB) Viewed 1056 times
Re: Unknown i2c device - 4-20 mA measurement M5stack
from M5Stack I got the answer that the function "uint16_t getCalCurrent(uint8_t channel);" is not available and they removed it from the source...
I am sorry but I don't understand how to use the function to send a command. I need this to send the value "1000" for calibration (for 10.00 mA), from the source it would be: with values
register is 0x30
how can I translate this into this?
genI2C,cmd,<i2c-command-sequence>[,<value-index>][,<cache-name>]
I guess I need a rule for that ? An example would be very nice, maybe for the readme two, thanks!
I am sorry but I don't understand how to use the function to send a command. I need this to send the value "1000" for calibration (for 10.00 mA), from the source it would be:
Code: Select all
void setCalCurrent(uint8_t index, uint16_t value);
Code: Select all
void setCalCurrent(0, 1000);
how can I translate this into this?
genI2C,cmd,<i2c-command-sequence>[,<value-index>][,<cache-name>]
I guess I need a rule for that ? An example would be very nice, maybe for the readme two, thanks!
Re: Unknown i2c device - 4-20 mA measurement M5stack
ESPEasy can be run on lots of ESP devices.
ESP32-S2 is only one of many, as can be seen here: https://espeasy.readthedocs.io/en/lates ... -esp-chips
There are lots of those purple boards with an ESP32-S2 which are like a lotery whether you get one with a stable WiFi connection or not.
In the pre-release (working hard on a new official build) with "LittleFS", we are now using ESP-IDF 5.4 as SDK.
See: https://td-er.nl/ESPEasy/latest/
Right now there are not yet many builds for the S2 with LittleFS.
What you can try (regardless of using LittleFS build or not) is to give this command:
Either via the console (serial/USB port) or via the command field on the tools page.
After entering this command, the ESP will disconnect from WiFi and it might have issues reconnect to WiFi without a reboot or power cycle.
Please leave it running for at least 10 sec after this command before power cycle.
It may not immediately run 'fast', but if the RF calibration was successful, it should feel more stable after a few minutes.
N.B.
When switching from a non-LittleFS build to a LittleFS build (and vice verse) you may need to re-run this command.
I'm working on detecting this so it will be done automatically, at least on newer builds.
ESP32-S2 is only one of many, as can be seen here: https://espeasy.readthedocs.io/en/lates ... -esp-chips
There are lots of those purple boards with an ESP32-S2 which are like a lotery whether you get one with a stable WiFi connection or not.
In the pre-release (working hard on a new official build) with "LittleFS", we are now using ESP-IDF 5.4 as SDK.
See: https://td-er.nl/ESPEasy/latest/
Right now there are not yet many builds for the S2 with LittleFS.
What you can try (regardless of using LittleFS build or not) is to give this command:
Code: Select all
EraseSDKwifi
After entering this command, the ESP will disconnect from WiFi and it might have issues reconnect to WiFi without a reboot or power cycle.
Please leave it running for at least 10 sec after this command before power cycle.
It may not immediately run 'fast', but if the RF calibration was successful, it should feel more stable after a few minutes.
N.B.
When switching from a non-LittleFS build to a LittleFS build (and vice verse) you may need to re-run this command.
I'm working on detecting this so it will be done automatically, at least on newer builds.
Re: Unknown i2c device - 4-20 mA measurement M5stack
The firmware I posted above is for ESP32-S2 only, if you have other boards available for testing, I can build a matching binary, just say what board you have (ESP32 model and flash size).
Ah, some readings are getting visible, great. (I tested using a different, more complex protocol, I2C device).
The documentation is quite unclear on what value to expect, so I picked 100 as the factor, but you can change that to 10000, of course. Or maybe the polarity needs to be reverted, as 34009 decimal is 0x84D9, with the highest bit On meaning a negative value... But in that case it should show -1241, also not close to 4 mA.
Or change the command to only be
Code: Select all
read.u16le.0x20
Changing 0x20 to 0x30 will read the current calibration, if that (still) works; removing that feature from the library source doesn't remove it from the device, unless it never worked in the first place

The Arduino library has a function called getADC12BitsValue, which suggests it's 12 bit, but I wouldn't know the actual resolution, again, documentation is sparse.
I'll respond with suggestions for setting the calibration later.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
To see if the sign is actually the cause for these strange/unexpected values, you can replace "u16le" by "16le" to get a signed value from the device.
/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
Are you sure it is "Little Endian" and not "Big Endian" ?
I always mix up those two.
I always mix up those two.
Re: Unknown i2c device - 4-20 mA measurement M5stack
I peeked in the existing I2C functions that read in 'LE' order...

/Ton (PayPal.me)
Re: Unknown i2c device - 4-20 mA measurement M5stack
As promised, here's the suggested method for setting the calibration (untested...

/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 16 guests