Skip to the content.

MycilaJSY

License: MIT Continuous Integration PlatformIO Registry

Arduino / ESP32 library for the JSY-MK-194T single-phase two-way electric energy metering module

    // tore or first clamp
    volatile float current1 = 0; // A
    volatile float energy1 = 0; // kWh
    volatile float energyReturned1 = 0; // kWh
    volatile float power1 = 0; // W
    volatile float powerFactor1 = 0;
    volatile float voltage1 = 0; // V

    // clamp (or second clamp)
    volatile float current2 = 0; // A
    volatile float energy2 = 0; // kWh
    volatile float energyReturned2 = 0; // kWh
    volatile float power2 = 0; // W
    volatile float powerFactor2 = 0;
    volatile float voltage2 = 0; // V

    volatile uint8_t frequency = 0; // Hz

Usage

Have a look at all the examples in the examples folder.

There is a getter for each metric.

Blocking mode

Mycila::JSY jsy;

void setup() {
  jsy.begin(&Serial2, 17, 16);
}

void loop() {
  jsy.read();

  // access values

  delay(1000);
}

Non-Blocking mode (async)

Mycila::JSY jsy;

void setup() {
  jsy.begin(&Serial2, 17, 16, true, 0);
}

void loop() {
  // access values
}

Energy reset

jsy.resetEnergy();

Update Baud rate (change speed)

if (jsy.isEnabled() && jsy.getBaudRate() != Mycila::JSYBaudRate::BAUD_38400) {
  if (jsy.setBaudRate(Mycila::JSYBaudRate::BAUD_38400)) {
    // speed changed and switched to new speed
  } else {
    // speed changed failed, keeping current speed
  }
  
}

Reference material