Add LED code

andrews-local-changes
Andrew Woodlee 1 month ago
parent ca37ffa1d9
commit 90b8a22da3

@ -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": []
}

@ -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;

@ -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/> +<tests/AT90E36.cpp>
[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/> +<tests/temps.cpp>
[env:TestSPI]
build_flags = -D DEV ${env.build_flags}
lib_deps =
SPI
build_src_filter = -<*> -<.git/> -<.svn/> +<tests/spi.cpp>
[env:TestEncryption]
build_flags = -D DEV ${env.build_flags}
lib_deps =

@ -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);
}
Loading…
Cancel
Save