diff --git a/.vscode/settings.json b/.vscode/settings.json index 3a59a7b..b8ae5d2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,5 +16,6 @@ "ctime": "cpp", "*.tcc": "cpp" }, - "julia.environmentPath": "/home/andrew/Projects/SeniorDesign/esp32-tm-code" + "julia.environmentPath": "/home/andrew/Projects/SeniorDesign/esp32-tm-code", + "frontMatter.content.pageFolders": [] } \ No newline at end of file diff --git a/include/transformerMonitor.h b/include/transformerMonitor.h index 2e783f5..dc7a3c7 100644 --- a/include/transformerMonitor.h +++ b/include/transformerMonitor.h @@ -77,7 +77,6 @@ ATM90E26_IC eic; ATM90E36 ic; ATM90E36_IC eic(ctLine, ic); -ATM90E36_IC SetupEic(ctLine, ic); #endif @@ -156,6 +155,15 @@ hw_timer_t *readEICTimer = NULL; void IRAM_ATTR ReadData(); // End timer variable and function +// LED pins +#define PIN_RED 23 // GPIO23 +#define PIN_GREEN 22 // GPIO22 +#define PIN_BLUE 21 // GPIO21 + +// LED color Function +void setColor(int R, int G, int B); + + struct xformerMonConfigData { char *wifiSsid; char *wifiPass; diff --git a/platformio.ini b/platformio.ini index fe3e3d3..d4a20a5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,7 @@ board = featheresp32 framework = arduino extra_scripts = pre:envSetup.py monitor_speed = 115200 -upload_port = COM4 +upload_port = COM6 [env:dev] build_flags = -D DEV ${env.build_flags} @@ -78,6 +78,23 @@ lib_deps = milesburton/DallasTemperature@^3.11.0 build_src_filter = -<*> -<.git/> -<.svn/> + +[env:TestTemps] +build_flags = -D DEV ${env.build_flags} +lib_deps = + SPI + knolleary/pubsubclient + https://github.com/CircuitSetup/ATM90E36 + bblanchon/ArduinoJson @ ^6.21.3 + paulstoffregen/OneWire@^2.3.8 + milesburton/DallasTemperature@^3.11.0 +build_src_filter = -<*> -<.git/> -<.svn/> + + +[env:TestSPI] +build_flags = -D DEV ${env.build_flags} +lib_deps = + SPI +build_src_filter = -<*> -<.git/> -<.svn/> + + [env:TestEncryption] build_flags = -D DEV ${env.build_flags} lib_deps = diff --git a/src/transformerMonitor.cpp b/src/transformerMonitor.cpp index 64882c8..b2bd4e7 100644 --- a/src/transformerMonitor.cpp +++ b/src/transformerMonitor.cpp @@ -17,6 +17,13 @@ void setupEnergyMonitor(); // const char* test_client_cert = ""; //to verify the client void setup() { + pinMode(PIN_RED, OUTPUT); + pinMode(PIN_GREEN, OUTPUT); + pinMode(PIN_BLUE, OUTPUT); + + // set LED to Red - FF0000 + setColor(255, 0, 0); + delay(10000); eicDataQueue = xQueueCreate( 50, sizeof( xformerMonitorData ) ); // configure time @@ -39,14 +46,18 @@ void setup() monitorTempSensors.oil.getAddress(oilTempSensorAddr, 0); monitorTempSensors.cabinet.getAddress(cabinetTempSensorAddr, 0); + + setupMQTTClient(); setupEnergyMonitor(); + // set LED color + setColor(0, 0, 255); xTaskCreatePinnedToCore( readEICData, /* Function to implement the task */ "Read EIC data", /* Name of the task */ - 10000, /* Stack size in words */ + 100000, /* Stack size in words */ NULL, /* Task input parameter */ 0, /* Priority of the task */ &taskReadEIC, /* Task handle. */ @@ -55,7 +66,7 @@ void setup() xTaskCreatePinnedToCore( sendSensorDataOverMQTT, /* Function to implement the task */ "Send sensor data over MQTT", /* Name of the task */ - 10000, /* Stack size in words */ + 100000, /* Stack size in words */ NULL, /* Task input parameter */ 0, /* Priority of the task */ &taskSendData, /* Task handle. */ @@ -114,12 +125,9 @@ void messageReceived(String &topic, String &payload) void loop() { - - // mqttClient.publish("xfmormermon", "buffer"); - - // // publish a message roughly every second. - Serial.println("Sleeping 10s"); - delay(10000); + // publish a message roughly every second. + // Serial.println("Sleeping 10s"); + // delay(10000); } void setupMQTTClient() @@ -261,4 +269,10 @@ void IRAM_ATTR ReadData(){ xQueueSend(eicDataQueue, &sensorData, portMAX_DELAY); +} + +void setColor(int R, int G, int B) { + analogWrite(PIN_RED, R); + analogWrite(PIN_GREEN, G); + analogWrite(PIN_BLUE, B); } \ No newline at end of file