I just wanted to give an update in the event someone comes across the same issue in the future:
I was able to get the KMeterISO to work with the Core.2 unit and using the Arduino IDE by doing the following:
-
I needed to download the M5Unit-KMeterISO library from GITHUB - https://github.com/m5stack/M5Unit-KMeterISO
-
I used the included "demo" example that was part of the library download but I had to make a few changes: I added a line "#include <M5Core2.h>" to the beginning. Added "M5.begin();" in void setup(), and finally changed the i2c pins from 21 & 22 to 32 & 33 in the kmeter.begin line - "while (!kmeter.begin(&Wire, KMETER_DEFAULT_ADDR, 32, 33, 100000L)) {"
Here is the complete modified demo example code:
#include "M5UnitKmeterISO.h"
#include <M5Core2.h>
#define INTERVAL_TIME 500
M5UnitKmeterISO kmeter;
uint8_t error_status = 0;
long delay_time = 0;
long map(long x, long in_min, long in_max, long out_min, long out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void setup() {
M5.begin();
Serial.begin(115200);
while (!kmeter.begin(&Wire, KMETER_DEFAULT_ADDR, 32, 33, 100000L)) {
Serial.println("Unit KmeterISO not found");
}
delay_time = millis() + INTERVAL_TIME;
}
void loop() {
if (millis() > delay_time) {
error_status = kmeter.getReadyStatus();
if (error_status == 0) {
Serial.printf("Celsius Temp: %.2fC\r\n",
((float)(kmeter.getCelsiusTempValue())) / 100);
Serial.printf("Fahrenheit Temp: %.2fF\r\n",
((float)(kmeter.getFahrenheitTempValue())) / 100);
Serial.printf(
"Chip Celsius Temp: %.2fC\r\n",
((float)(kmeter.getInternalCelsiusTempValue())) / 100);
Serial.printf(
"Chip Fahrenheit Temp: %.2fF\r\n",
((float)(kmeter.getInternalFahrenheitTempValue())) / 100);
} else {
Serial.printf("Error: %d", kmeter.getReadyStatus());
}
delay_time = millis() + INTERVAL_TIME;
}
}