reaper7 / SDM_Energy_Meter

reading SDM72 SDM120 SDM220 SDM230 SDM630 modbus energy meters from arduino (esp8266, esp32, avr)
245 stars 97 forks source link

Expected polling performance #11

Closed apreb closed 7 years ago

apreb commented 7 years ago

Hi, thank you for sharing this repository.

Can this meter reply to polling rates of 1 second or below? Is there any way to get all the data at once?

Bets regards

reaper7 commented 7 years ago

Currently one register at a time(request).

But You can read all selected registers in loop (for, while...):

const uint8_t MYREGCNT = 5;
uint16_t myRegisters[MYREGCNT] = {SDM220T_VOLTAGE, SDM220T_CURRENT, SDM220T_POWER, SDM220T_POWER_FACTOR, SDM220T_FREQUENCY};
float myResults[MYREGCNT] = {0, 0, 0, 0, 0};

void readAllMyRegisters() {
  for (uint8_t i = 0; i < MYREGCNT; i++) {
    myResults[i] = sdm.readVal(myRegisters[i]);
    yield();
  }
}
apreb commented 7 years ago

Thank you for you prompt reply. From your experience can the meter keep up with 1-second polling of { VOLTAGE; CURRENT; POWER } ?

best regards

reaper7 commented 7 years ago

reading all 14 sdm220 registers + uploading data to thingspeak -> below 500ms (483-490)

apreb commented 7 years ago

That's great. Thanks!