Added seneca powermeter driver

This commit is contained in:
Emanuele Trabattoni
2025-07-12 23:00:21 +02:00
parent 1ad98799b4
commit d2eba9085e
4 changed files with 200 additions and 10 deletions

View File

@@ -7,6 +7,7 @@
#include <PCF85063_Driver.h>
#include <R4DCB08_Driver.h>
#include <S50140_Driver.h>
#include <ETH_Driver.h>
#include <digitalIO.h>
@@ -41,6 +42,7 @@ void loop()
{
const uint8_t tempBoardAddr(0xAA);
const uint8_t relayBoardAddr(0x01);
const uint8_t senecadAddr(0xBB);
const uint8_t baseRegister(0x00);
uint16_t k(0);
uint8_t ethRetries(0);
@@ -56,6 +58,8 @@ void loop()
delay(100);
auto io = digitalIO(i2c, bus, {relayBoardAddr});
delay(100);
auto seneca = drivers::S50140(bus, senecadAddr);
delay(100);
Network.onEvent([&eth](arduino_event_id_t event, arduino_event_info_t info)
{ eth.onEvent(event, info); });
@@ -91,7 +95,7 @@ void loop()
while (true)
{
LOG_INFO("[", k++, "] Loop");
eth.getNtpTime(ntpTime);
dt = drivers::PCF85063::fromEpoch(ntpTime);
LOG_INFO("Network Datetime", rtc.datetime2str(dt).c_str());
@@ -99,27 +103,27 @@ void loop()
mqtt.publish("test/esp32-out", ("[" + std::to_string(k) + "] -> " + rtc.getTimeStr()).c_str());
uint8_t i(0);
delay(10);
for (auto v: tmp.getTempAll()) {
for (auto v : tmp.getTempAll())
{
LOG_INFO("Temperature channel", i++, "->", v);
}
i=0;
i = 0;
delay(10);
for (auto v : tmp.getCorrection()){
for (auto v : tmp.getCorrection())
{
LOG_INFO("Temperature correction channel", i++, "tc", v);
}
for (auto j(0); j < io.getOutNum(); j++)
{
//io.digitalIOWrite(j, true);
// io.digitalIOWrite(j, true);
LOG_INFO("Input", j, io.digitalIORead(j) ? "True" : "False");
delay(500);
// io.digitalIOWrite(j, false);
}
//for (auto j(0); j < io.getOutNum(); j++)
//{
// io.digitalIOWrite(j, false);
//}
drivers::S50140::powerinfo_t pinfo = seneca.getAll();
LOG_INFO("Power Info\nV:", pinfo.v, "\nA:", pinfo.a, "\nW:", pinfo.pAct, "\nWh_t:", pinfo.whTot, "\nWh_p:", pinfo.whPar);
delay(5000);
}