Library for Meters using M5UnitUnified.
M5UnitUnified is a library for unified handling of various M5 units products.
Unit AMeter is a current meter that can monitor current in real-time.
It uses a 16-bit ADC digital-to-analog converter ADS1115 internally and communicates via I2C (0X48).
To ensure measurement accuracy, it has a built-in DC-DC isolated power supply, and the I2C interface is electrically isolated using a low-power isolator CA-IS3020S to prevent noise and surges on the data bus or other circuits from entering the local ground and interfering with or damaging sensitive circuits.
Each unit is individually calibrated at the factory, with an accuracy of 1% of full scale, ±1 digit reading, a resolution of 0.3mA, and a maximum measurement current of ±4A.
It has an internal 4A fuse to prevent circuit damage from excessive measurement current.
Voltmeter Unit is a voltage meter that can monitor the voltage in real time. The 16-bit ADC (analog-to-digital) converter ADS1115 is used internally to communicate through I2C (0X49).
In order to ensure the measurement accuracy, there is a built-in DC-DC isolated power supply, and the I2C interface is also electrically isolated through the low-power isolator CA-IS3020S.
This prevents noise and surges on the data bus or other circuits from entering the local ground terminal to interfere or damage sensitive circuits. Each Unit is individually calibrated when leaving the factory, initial accuracy of 0.1%FS, ±1 count, and a maximum measurement voltage of ±36V.
KMeterISO unit is an integrated K-type thermocouple sensor unit that integrates the functions of "acquisition + isolation + communication", using STM32F030+MAX31855KASA 14bit thermocouple digital conversion chip scheme to achieve high-precision temperature acquisition and conversion, MCU using STM32F030 to realize data acquisition and I2C communication interface,
using CA-IS3641HW as a signal isolator. The unit supports access to thermocouple probes with a measurement range of -200°C to 1350°C, and adopts a universal standard K-type flat interface, which is convenient for subsequent replacement of different measuring probes to match different needs.
This module is widely used in application scenarios such as temperature collection, control, and monitoring in industrial automation, instrumentation, power and electrical, heat treatment and other fields.
Module13.2 Dual Kmeter is a dual-channel K-type temperature measurement module based on the "MAX31855KASA + stm32f030f4p6 + electrical isolation" solution. The module features two K-type thermocouple sensor interfaces, and uses a signal relay to alternately measure the temperature values of the two channels. It supports a measurement range of -200°C to 1350°C with an accuracy of ±2°C. Additionally, the module includes B0505LS-1WR2 and CA-IS3020S voltage and signal isolation chips, ensuring system stability and safety. The module also has a built-in DIP switch for easily switching different I2C addresses to meet various application needs. It can be used in industrial automation, instrument detection, and other scenarios.
Unit INA226-10A is a fully isolated high-precision current and voltage measurement unit, suitable for scenarios measuring DC 0 ~ 30V voltage and up to 10A current, supporting simultaneous voltage and current measurements.
Unit INA226-1A is a fully isolated high-precision current, voltage, and power measurement unit, suitable for scenarios measuring DC 0 ~ 30V voltage and up to 1A current, supporting simultaneous voltage and current measurements.
- Unit Ameter & Datasheet
- Unit Vmeter & Datasheet
- Unit KMeterISO & Datasheet
- Unit DualKmeter & Datasheet
- Unit INA226-10A & Datasheet
- Unit INA226-1A & Datasheet
Support via PaHub
| Unit | Support | Note |
|---|---|---|
| UnitAmeter | OK | |
| UnitVmeter | OK | |
| UnitKmeterISO | OK | |
| UnitINA226-10A / UnitINA226-1A | OK |
See also examples/UnitUnified/ViaPaHub and M5Unit-HUB
See also examples/UnitUnified
You must choose a define symbol for the unit you will use. (Rewrite source or specify with compile options)
- GraphicalMeter
// *************************************************************
// Choose one define symbol to match the unit you are using
// *************************************************************
#if !defined(USING_UNIT_VMETER) && !defined(USING_UNIT_AMETER) && !defined(USING_UNIT_KMETER_ISO) && \
!defined(USING_UNIT_DUAL_KMETER)
// For UnitVmeter (U087)
// #define USING_UNIT_VMETER
// For UnitAmeter (U086)
// #define USING_UNIT_AMETER
// For UnitKmeterISO (U133-V11)
// #define USING_UNIT_KMETER_ISO
// For ModuleDualKmeter (M127)
// #define USING_UNIT_DUAL_KMETER
#endif- UnitINA226/PlotToSerial
// *************************************************************
// Choose one define symbol to match the unit you are using
// *************************************************************
#if !defined(USING_UNIT_INA226_1A) && !defined(USING_UNIT_INA226_10A) && !defined(BUILTIN_UNIT_INA226_10A)
// For UnitINA226-1A (U200-1A)
// #define USING_UNIT_INA226_1A
// For UnitINA226-10A (U200)
// #define USING_UNIT_INA226_10A
// For Tab5 built-in INA226 (10A)
// #define BUILTIN_UNIT_INA226_10A
#endifNOTE: The ESP-IDF native build (
idf.py) targets ESP-IDF 5.1 or later (5.x and 6.x).
On ESP-IDF native builds (idf.py), the unit is selected via Kconfig instead of editing the source #define. The examples with a variant expose the choice through main/Kconfig.projbuild, which sources one of the Kconfig files in examples/UnitUnified/common/:
| Kconfig file | Variants offered | Used by |
|---|---|---|
Kconfig.variant.ina226 |
UnitINA226-10A / UnitINA226-1A / M5Tab5 built-in INA226 | UnitINA226/PlotToSerial |
Kconfig.variant.meter |
UnitVmeter / UnitAmeter / UnitKmeterISO / ModuleDualKmeter | GraphicalMeter |
examples/UnitUnified/common/variant.cmake then maps the chosen CONFIG_EXAMPLE_USING_* to the source-level macro shared with the Arduino build, so the example source itself does not need to be edited. The M5Tab5 built-in INA226 option appears only when the target is esp32p4.
Pick the variant with menuconfig:
cd examples/UnitUnified/UnitINA226/PlotToSerial # or GraphicalMeter
idf.py set-target esp32s3 # or esp32 / esp32c6 / esp32p4 / ...
idf.py menuconfig
# -> M5Unit-METER INA226 example (or M5Unit-METER GraphicalMeter example) -> Target unit -> choose ONE
idf.py build flash monitorThe other examples (UnitAmeter / UnitVmeter / UnitKmeterISO / UnitDualKmeter PlotToSerial, ViaPaHub) have no variant; run idf.py set-target <chip> and idf.py build flash monitor directly.
If you want to generate documents on your local machine, execute the following command
bash docs/doxy.sh
It will output it under docs/html
If you want to output Git commit hashes to html, do it for the git cloned folder.