updates to library, comments, etc

master
Andrew Woodlee 1 month ago
parent a00ba602ab
commit c67894f4a1

@ -70,7 +70,7 @@ ATM90E26_IC eic;
// extract the ATM90E36 CT LINE from its macro
#ifdef TM_ATM90E36_CT_LINE
char const ctLine = (char) STR(TM_ATM90E36_CT_LINE);
#else
#else // if nothing is defined, use 'A' as the default value
char const ctLine = 'A';
#endif
#include <ATM90E36_IC.h>
@ -80,12 +80,12 @@ ATM90E36_IC eic(ctLine, ic);
#endif
// we are using the ESP32's MAC address to provide a unique ID
String client_id = "xformermon-";
// we are using the transformer's name to provide a unique ID
String client_id = "name-of-transformer";
// GPIO where the DS18B20 is connected to
// GPIO pins where the DS18B20 sensors are connected
const int oilTempBus = 4;
const int cabinetTempBus = 9;
@ -104,9 +104,9 @@ OneWire cabinetTempBusOneWire(cabinetTempBus);
DallasTemperature oilTempSensor(&oilTempBusOneWire);
DallasTemperature cabinetTempSensor(&cabinetTempBusOneWire);
// temp sensor objects
tempSensors monitorTempSensors{oilTempSensor, cabinetTempSensor};
StaticJsonDocument<256> dataStore[60];
time_t now;
// Data structs for queue
@ -138,7 +138,7 @@ struct xformerMonitorData {
// Global to be used in ISR
xformerMonitorData sensorData;
// Variables for tasks
// Variables for tasks and queue
TaskHandle_t taskReadEIC;
TaskHandle_t taskSendData;
@ -161,6 +161,9 @@ void IRAM_ATTR ReadData();
#define PIN_BLUE 21 // GPIO21
// LED color Function
// Red - 0 to 255
// Green - 0 to 255
// Blue - 0 to 255
void setColor(int R, int G, int B);

@ -17,7 +17,7 @@
}
void ATM90E36_IC::begin(){
this->eic->begin(5, 0x003C, 0x100, 0x100, 0x100,0x100, 0x100, 0x100);
this->eic->begin(5, 0x003C, 0x1000, 0x1000, 0x1000,0x1000, 0x1000, 0x1000);
}
double ATM90E36_IC::GetLineVoltage()
{
@ -26,8 +26,10 @@ void ATM90E36_IC::begin(){
{
case 'A':
lv = eic->GetLineVoltageA();
break;
case 'B':
lv = eic->GetLineVoltageB();
break;
case 'C':
lv = eic->GetLineVoltageC();
break;

@ -17,6 +17,7 @@ void setupEnergyMonitor();
// const char* test_client_cert = ""; //to verify the client
void setup()
{
// set LED pins
pinMode(PIN_RED, OUTPUT);
pinMode(PIN_GREEN, OUTPUT);
pinMode(PIN_BLUE, OUTPUT);
@ -26,6 +27,7 @@ void setup()
delay(10000);
Serial.begin(9600);
// create data queue
eicDataQueue = xQueueCreate( 50, sizeof( xformerMonitorData ) );
if (eicDataQueue == 0)
{
@ -240,7 +242,7 @@ void sendSensorDataOverMQTT(void *pvParameters)
delay(50);
mqttClient.publish("xfmormermon/", buffer, n);
}
delay(1000); // <- fixes some issues with WiFi stability
delay(100); // <- fixes some issues with WiFi stability
mqttClient.loop();
if (!mqttClient.connected())
@ -278,15 +280,16 @@ void IRAM_ATTR ReadData(){
sensorData.timeInfo = gmtime(&now);
sensorData.lineVoltage = eic.GetLineVoltage();
sensorData.lineCurrent = eic.GetLineCurrent();
sensorData.neutralCurrent = eic.GetLineCurrentN();
// sensorData.energy.exp =
sensorData.power.factor = eic.GetPowerFactor();
xQueueSend(eicDataQueue, &sensorData, portMAX_DELAY);
Serial.println("hello from ISR");
}
void setColor(int R, int G, int B) {
analogWrite(PIN_RED, R);
analogWrite(PIN_GREEN, G);
analogWrite(PIN_BLUE, B);
Serial.println("hello from ISR");
}
Loading…
Cancel
Save