Difference between revisions of "IoT - Collabs - ESP Firmware with Guru"
(→OTA) |
|||
(26 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Modular Firmware== | ==Modular Firmware== | ||
+ | |||
+ | === main.cpp === | ||
+ | * [[IoT - Modular - Baseline|Baseline]] | ||
===Baseline=== | ===Baseline=== | ||
Line 5: | Line 8: | ||
This is the basis for pretty much ANY ESP-based firmware project. It'll get your device online. | This is the basis for pretty much ANY ESP-based firmware project. It'll get your device online. | ||
− | [[Modular ESP Firmware - Baseline - | + | ====main.cpp==== |
+ | |||
+ | =====#includes, Defines, etc...===== | ||
+ | |||
+ | You'll note this is currently aimed at the SugarBush project. | ||
+ | |||
+ | <syntaxhighlight lang="cpp" line="1"> | ||
+ | #include "libraries.h" | ||
+ | #include "functions.h" | ||
+ | |||
+ | #ifdef s_CLIMATE | ||
+ | #include "s-Climate.h" | ||
+ | #endif // s_CLIMATE | ||
+ | |||
+ | #include "externs.h" | ||
+ | #include "TopSecret.h" | ||
+ | |||
+ | /************************************************************************************************/ | ||
+ | struct CLIMATE_Readings | ||
+ | { | ||
+ | byte Status; | ||
+ | |||
+ | float Temperature; | ||
+ | float Humidity; | ||
+ | float AbsPressure; | ||
+ | float SeaPressure; | ||
+ | }; | ||
+ | |||
+ | struct CLIMATE_Readings CLIMATE_Datum; | ||
+ | /************************************************************************************************/ | ||
+ | |||
+ | // I2C pins suitable for the ESP-M3-Everything! | ||
+ | const int SSD1306_SDA = 14; // Tarduino D5 | ||
+ | const int SSD1306_SCL = 12; // Tarduino D6 | ||
+ | |||
+ | #ifdef d_SDD1306 | ||
+ | bool WalkingDudeIndicator = false; | ||
+ | bool WavingDudeIndicator = true; | ||
+ | #endif | ||
+ | |||
+ | SimpleTimer timer; | ||
+ | |||
+ | extern int BMP180_Count; | ||
+ | extern int BME280_Count; | ||
+ | |||
+ | #ifdef SS_Dumper | ||
+ | int ReedPin = 4; | ||
+ | int HallPin = 5; | ||
+ | // int Dumptime = 0; | ||
+ | #endif // SS_Dumper | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | =====setup()===== | ||
+ | |||
+ | You'll note this is currently aimed at the SugarBush project. | ||
+ | |||
+ | <syntaxhighlight lang="cpp" line="1"> | ||
+ | void setup() | ||
+ | { | ||
+ | char debugTEXT[46]; | ||
+ | sprintf(debugTEXT, "nothing yet"); | ||
+ | |||
+ | Serial.begin(115200); | ||
+ | delay(500); // Delay to let the ESP get booted before sending out serial data | ||
+ | |||
+ | debug_TitleScreen(); | ||
+ | |||
+ | if (I2C_Test(SSD1306_SDA, SSD1306_SCL)) // Force a reset of the I2C bus if needed | ||
+ | { | ||
+ | Wire.begin(SSD1306_SDA, SSD1306_SCL); // Select SDA & SCL pins | ||
+ | ///////////////////////////// | ||
+ | pinMode(SSD1306_SDA, INPUT); | ||
+ | pinMode(SSD1306_SCL, INPUT); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | //////////////////////////////// Need to send an MQTT error status message! | ||
+ | debug_Action("POOP!"); | ||
+ | } | ||
+ | |||
+ | // ESP Info ////////////////////////////////////////////////////////////////// | ||
+ | #ifdef DEBUG6 | ||
+ | debug_Separator(); | ||
+ | debug_ESP_info(); | ||
+ | #endif // DEBUG6 | ||
+ | |||
+ | // WiFi ////////////////////////////////////////////////////////////////////// | ||
+ | debug_Separator(); | ||
+ | WiFi_init(); | ||
+ | |||
+ | // MQTT ////////////////////////////////////////////////////////////////////// | ||
+ | debug_Separator(); | ||
+ | MQTT_init(); | ||
+ | |||
+ | debug_Separator(); | ||
+ | debug_Action("Initialising Outputs..."); | ||
+ | |||
+ | // Pixels ////////////////////////////////////////////////////////////////////// | ||
+ | #ifdef d_Pixels | ||
+ | |||
+ | Pixels_init(); | ||
+ | |||
+ | for (int i = 0; i < PixelCount; i++) | ||
+ | { | ||
+ | SetAPixel(i, BLU); | ||
+ | } | ||
+ | |||
+ | #endif // d_Pixels | ||
+ | |||
+ | // Audio /////////////////////////////////////////////////////////////////////// | ||
+ | #ifdef d_Audio | ||
+ | Noise_init(); | ||
+ | #endif // d_Audio | ||
+ | |||
+ | #ifdef d_SDD1306 | ||
+ | SSD1306_init(); | ||
+ | // Display static text | ||
+ | // SSD1306_title("ColdStuff"); | ||
+ | SSD1306_title("SugarBush"); | ||
+ | #ifdef DEBUG | ||
+ | debug_LineOut("Title on-screen"); | ||
+ | #endif | ||
+ | #endif // d_SDD1306 | ||
+ | |||
+ | debug_Separator(); | ||
+ | debug_Action("Initialising Sensors..."); | ||
+ | |||
+ | // Event Triggers ////////////////////////////////////////////////////////////// | ||
+ | #ifdef SS_Dumper | ||
+ | debug_LineOut("Dumper Sensor"); | ||
+ | pinMode(HallPin, INPUT); | ||
+ | attachInterrupt(digitalPinToInterrupt(ReedPin), DumpDetect, CHANGE); | ||
+ | sprintf(debugTEXT, "Reed Switch on pin %d", ReedPin); | ||
+ | debug_LineOut(debugTEXT); | ||
+ | attachInterrupt(digitalPinToInterrupt(HallPin), DumpDetect2, CHANGE); | ||
+ | sprintf(debugTEXT, "Hall Effect Sensor on pin %d", HallPin); | ||
+ | debug_LineOut(debugTEXT); | ||
+ | #endif // SS_Dumper | ||
+ | |||
+ | // Depth Probes //////////////////////////////////////////////////////////////// | ||
+ | #ifdef s_Depth | ||
+ | Depth_init(); | ||
+ | #endif // d_Depth | ||
+ | |||
+ | // BMP180 //////////////////////////////////////////////////////////////////// | ||
+ | #ifdef s_BMP180 | ||
+ | BMP180_Count = BMP180_init(); | ||
+ | #endif | ||
+ | |||
+ | // BME280 //////////////////////////////////////////////////////////////////// | ||
+ | #ifdef s_BME280 | ||
+ | BME280_Count = BME280_init(); | ||
+ | #endif | ||
+ | |||
+ | #ifdef s_CLIMATE | ||
+ | BMP180_Count = BMP180_init(); | ||
+ | if (BMP180_Count > 0) | ||
+ | { | ||
+ | #define s_BMP180 | ||
+ | } | ||
+ | BME280_Count = BME280_init(); | ||
+ | if (BME280_Count > 0) | ||
+ | { | ||
+ | #define s_BME280 | ||
+ | } | ||
+ | #endif | ||
+ | |||
+ | // Hall-Effect /////////////////////////////////////////////////////////////// | ||
+ | // #ifdef SS_Dumper | ||
+ | // debug_Separator(); | ||
+ | // debug_SectionTitle("Hall Effect Sensor"); | ||
+ | // pinMode(HallPin, INPUT); | ||
+ | // attachInterrupt(digitalPinToInterrupt(ReedPin), DumpDetect, CHANGE); | ||
+ | // sprintf(debugTEXT, "Reed Switch on pin %d", ReedPin); | ||
+ | // debug_LineOut(debugTEXT); | ||
+ | // attachInterrupt(digitalPinToInterrupt(HallPin), DumpDetect2, CHANGE); | ||
+ | // sprintf(debugTEXT, "Hall Effect Sensor on pin %d", HallPin); | ||
+ | // debug_LineOut(debugTEXT); | ||
+ | // #endif // SS_Dumper | ||
+ | |||
+ | // Interval Timers /////////////////////////////////////////////////////////// | ||
+ | debug_Separator(); | ||
+ | debug_SectionTitle("Interval Timers"); | ||
+ | |||
+ | timer.setInterval(20, MQTT_handler); | ||
+ | debug_LineOut("MQTT"); | ||
+ | |||
+ | timer.setInterval(2000, WiFi_Test); | ||
+ | debug_LineOut("WiFiCheck"); | ||
+ | |||
+ | #ifdef s_Depth | ||
+ | timer.setInterval(5000, CheckProbes); | ||
+ | debug_LineOut("Check Probes"); | ||
+ | #endif // s_Depth | ||
+ | |||
+ | #ifdef s_BMP180 | ||
+ | if (BMP180_Count != 0) | ||
+ | { | ||
+ | timer.setInterval(10000, BMP180_main); | ||
+ | debug_LineOut("BMP180 Handler"); | ||
+ | } | ||
+ | #endif | ||
+ | |||
+ | #ifdef s_BME280 | ||
+ | if (BME280_Count != 0) | ||
+ | { | ||
+ | timer.setInterval(10000, BME280_main); | ||
+ | debug_LineOut("BME280 Handler"); | ||
+ | } | ||
+ | #endif | ||
+ | |||
+ | #ifdef s_CLIMATE | ||
+ | if (BMP180_Count != 0) | ||
+ | { | ||
+ | timer.setInterval(10000, BMP180_main); | ||
+ | debug_LineOut("BMP180 Handler"); | ||
+ | } | ||
+ | if (BME280_Count != 0) | ||
+ | { | ||
+ | timer.setInterval(10000, BME280_main); | ||
+ | debug_LineOut("BME280 Handler"); | ||
+ | } | ||
+ | #endif | ||
+ | |||
+ | #ifdef d_SDD1306 | ||
+ | timer.setInterval(100, WavingDude); // Waving Dude in the top-right corner | ||
+ | debug_LineOut("Waving Dude Indicator"); | ||
+ | #endif | ||
+ | |||
+ | // READY ///////////////////////////////////////////////////////////////////// | ||
+ | debug_ReadyScreen(); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | =====loop()===== | ||
+ | |||
+ | You'll note this is currently aimed at the SugarBush project. | ||
+ | |||
+ | <syntaxhighlight lang="cpp" line="1"> | ||
+ | void loop() | ||
+ | { | ||
+ | // Run the interval timers | ||
+ | // Running processes here in loop() is a synchronous flow. | ||
+ | // Running processes via the interval timers is assynchronous. | ||
+ | // If your actions don't depend directly on each other, | ||
+ | // synchronous flow makes no sense at all... | ||
+ | timer.run(); | ||
+ | |||
+ | #ifdef SS_Dumper | ||
+ | // This is just here to give me console output while developing... | ||
+ | // Serial.print("."); | ||
+ | // delay(1000); | ||
+ | #endif // SS_Dumper | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ====The parts==== | ||
+ | |||
+ | [[Modular ESP Firmware - Baseline - Work Environment|Work Environment]] (Platformio/VSC setup) | ||
+ | |||
+ | [[Modular ESP Firmware - Baseline - Declarations and Defines|Declarations and Defines]] | ||
+ | |||
+ | [[Modular ESP Firmware - Baseline - Individual Functions|Individual Functions]] | ||
===MQTT=== | ===MQTT=== | ||
This is intended to be added to the [[#Baseline|baseline]]. | This is intended to be added to the [[#Baseline|baseline]]. | ||
− | + | ||
You'll need to add: | You'll need to add: | ||
lib_deps = | lib_deps = | ||
PubSubClient | PubSubClient | ||
to your <code>platformio.ini</code> file. | to your <code>platformio.ini</code> file. | ||
+ | |||
+ | ====main.cpp==== | ||
+ | |||
+ | Add: | ||
+ | |||
+ | <code>setup_mqtt();</code> | ||
+ | |||
+ | to '''setup()''' after the <code>setup_wifi();</code> call. | ||
+ | |||
+ | Put: | ||
+ | |||
+ | <code>DOtheBloodyMQTT();</code> | ||
+ | |||
+ | inside '''loop()''' | ||
+ | |||
+ | ====The rest of the parts==== | ||
[[Modular ESP Firmware - MQTT - Declarations and Defines|Declarations and Defines]] | [[Modular ESP Firmware - MQTT - Declarations and Defines|Declarations and Defines]] | ||
Line 25: | Line 306: | ||
[[Modular ESP Firmware - OTA - Source|Source code]] | [[Modular ESP Firmware - OTA - Source|Source code]] | ||
+ | |||
+ | Ffffffuuuuuuuu...... | ||
===Configuration HotSpot=== | ===Configuration HotSpot=== | ||
Line 36: | Line 319: | ||
===NeoPixels=== | ===NeoPixels=== | ||
− | [[Modular ESP Firmware - NeoPixels - | + | '''<u><big>Extreme WIP</big></u>''' |
+ | |||
+ | This is intended to be added to the [[#Baseline|baseline]]. | ||
+ | |||
+ | You'll need to add: | ||
+ | lib_deps = | ||
+ | Adafruit NeoPixel | ||
+ | to your <code>platformio.ini</code> file. | ||
+ | |||
+ | and put | ||
+ | |||
+ | <code>#include <Adafruit_NeoPixel.h></code> | ||
+ | |||
+ | in your source | ||
+ | |||
+ | [[Modular ESP Firmware - NeoPixels - Declarations and Defines|Declarations and Defines]] | ||
+ | |||
+ | [[Modular ESP Firmware - NeoPixels - Individual Functions|Individual Functions]] | ||
===Web Serving=== | ===Web Serving=== | ||
Line 45: | Line 345: | ||
[[Modular ESP Firmware - TFT - Source|Source code]] | [[Modular ESP Firmware - TFT - Source|Source code]] | ||
+ | |||
+ | ===OLED Display=== | ||
+ | |||
+ | [[Modular ESP Firmware - OLED - Source|Source code]] | ||
+ | |||
+ | ====(upcoming)==== | ||
+ | |||
+ | [[File:Little OLEDs.jpg|thumb]] | ||
+ | |||
+ | [[File:OLED example.mp4|thumb]] | ||
===Climate Sensing=== | ===Climate Sensing=== | ||
[[Modular ESP Firmware - Climate - Source|Source code]] | [[Modular ESP Firmware - Climate - Source|Source code]] | ||
+ | |||
+ | ====Sensors==== | ||
+ | |||
+ | *DS18B20 | ||
+ | *BME280 | ||
+ | *Si7021 | ||
+ | *HiH6130 | ||
===Energy Monitoring=== | ===Energy Monitoring=== | ||
[[Modular ESP Firmware - Energy - Source|Source code]] | [[Modular ESP Firmware - Energy - Source|Source code]] | ||
+ | |||
+ | ==Multitasking== | ||
+ | |||
+ | Jean-Francois Turcots [https://github.com/jfturcot/SimpleTimer SimpleTimer Library] makes this fairly straightforward. It allows you to specify that any function run repeatedly (triggered independantly of whatever is going on in '''loop()'''. | ||
+ | |||
+ | Add <code>SimpleTimer</code> to the <code>lib_deps</code> in yout <code>platformio.ini</code> file. | ||
+ | |||
+ | ===an Example=== | ||
+ | |||
+ | <syntaxhighlight lang="cpp" line="1"> | ||
+ | #include <SimpleTimer.h> | ||
+ | |||
+ | // the timer object | ||
+ | SimpleTimer timer; | ||
+ | |||
+ | // functions to be executed periodically | ||
+ | void repeatMe() { | ||
+ | Serial.print("Uptime (s): "); | ||
+ | Serial.println(millis() / 1000); | ||
+ | } | ||
+ | |||
+ | void repeatMe2() { | ||
+ | Serial.print("Boop: "); | ||
+ | Serial.println(millis() / 1000); | ||
+ | } | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | timer.setInterval(1000, repeatMe); // Run RepeatMe() every 1000 miliseconds. | ||
+ | timer.setInterval(100, repeatMe2); // Run RepeatMe2() every 100 miliseconds. | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | timer.run(); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==Modularization Tutorial (WIP)== | ||
+ | |||
+ | The [[Modular ESP Firmware - Modularization - source code|source code]]... |
Latest revision as of 13:24, 29 April 2021
Contents
Modular Firmware
main.cpp
Baseline
This is the basis for pretty much ANY ESP-based firmware project. It'll get your device online.
main.cpp
#includes, Defines, etc...
You'll note this is currently aimed at the SugarBush project.
1 #include "libraries.h"
2 #include "functions.h"
3
4 #ifdef s_CLIMATE
5 #include "s-Climate.h"
6 #endif // s_CLIMATE
7
8 #include "externs.h"
9 #include "TopSecret.h"
10
11 /************************************************************************************************/
12 struct CLIMATE_Readings
13 {
14 byte Status;
15
16 float Temperature;
17 float Humidity;
18 float AbsPressure;
19 float SeaPressure;
20 };
21
22 struct CLIMATE_Readings CLIMATE_Datum;
23 /************************************************************************************************/
24
25 // I2C pins suitable for the ESP-M3-Everything!
26 const int SSD1306_SDA = 14; // Tarduino D5
27 const int SSD1306_SCL = 12; // Tarduino D6
28
29 #ifdef d_SDD1306
30 bool WalkingDudeIndicator = false;
31 bool WavingDudeIndicator = true;
32 #endif
33
34 SimpleTimer timer;
35
36 extern int BMP180_Count;
37 extern int BME280_Count;
38
39 #ifdef SS_Dumper
40 int ReedPin = 4;
41 int HallPin = 5;
42 // int Dumptime = 0;
43 #endif // SS_Dumper
setup()
You'll note this is currently aimed at the SugarBush project.
1 void setup()
2 {
3 char debugTEXT[46];
4 sprintf(debugTEXT, "nothing yet");
5
6 Serial.begin(115200);
7 delay(500); // Delay to let the ESP get booted before sending out serial data
8
9 debug_TitleScreen();
10
11 if (I2C_Test(SSD1306_SDA, SSD1306_SCL)) // Force a reset of the I2C bus if needed
12 {
13 Wire.begin(SSD1306_SDA, SSD1306_SCL); // Select SDA & SCL pins
14 /////////////////////////////
15 pinMode(SSD1306_SDA, INPUT);
16 pinMode(SSD1306_SCL, INPUT);
17 }
18 else
19 {
20 //////////////////////////////// Need to send an MQTT error status message!
21 debug_Action("POOP!");
22 }
23
24 // ESP Info //////////////////////////////////////////////////////////////////
25 #ifdef DEBUG6
26 debug_Separator();
27 debug_ESP_info();
28 #endif // DEBUG6
29
30 // WiFi //////////////////////////////////////////////////////////////////////
31 debug_Separator();
32 WiFi_init();
33
34 // MQTT //////////////////////////////////////////////////////////////////////
35 debug_Separator();
36 MQTT_init();
37
38 debug_Separator();
39 debug_Action("Initialising Outputs...");
40
41 // Pixels //////////////////////////////////////////////////////////////////////
42 #ifdef d_Pixels
43
44 Pixels_init();
45
46 for (int i = 0; i < PixelCount; i++)
47 {
48 SetAPixel(i, BLU);
49 }
50
51 #endif // d_Pixels
52
53 // Audio ///////////////////////////////////////////////////////////////////////
54 #ifdef d_Audio
55 Noise_init();
56 #endif // d_Audio
57
58 #ifdef d_SDD1306
59 SSD1306_init();
60 // Display static text
61 // SSD1306_title("ColdStuff");
62 SSD1306_title("SugarBush");
63 #ifdef DEBUG
64 debug_LineOut("Title on-screen");
65 #endif
66 #endif // d_SDD1306
67
68 debug_Separator();
69 debug_Action("Initialising Sensors...");
70
71 // Event Triggers //////////////////////////////////////////////////////////////
72 #ifdef SS_Dumper
73 debug_LineOut("Dumper Sensor");
74 pinMode(HallPin, INPUT);
75 attachInterrupt(digitalPinToInterrupt(ReedPin), DumpDetect, CHANGE);
76 sprintf(debugTEXT, "Reed Switch on pin %d", ReedPin);
77 debug_LineOut(debugTEXT);
78 attachInterrupt(digitalPinToInterrupt(HallPin), DumpDetect2, CHANGE);
79 sprintf(debugTEXT, "Hall Effect Sensor on pin %d", HallPin);
80 debug_LineOut(debugTEXT);
81 #endif // SS_Dumper
82
83 // Depth Probes ////////////////////////////////////////////////////////////////
84 #ifdef s_Depth
85 Depth_init();
86 #endif // d_Depth
87
88 // BMP180 ////////////////////////////////////////////////////////////////////
89 #ifdef s_BMP180
90 BMP180_Count = BMP180_init();
91 #endif
92
93 // BME280 ////////////////////////////////////////////////////////////////////
94 #ifdef s_BME280
95 BME280_Count = BME280_init();
96 #endif
97
98 #ifdef s_CLIMATE
99 BMP180_Count = BMP180_init();
100 if (BMP180_Count > 0)
101 {
102 #define s_BMP180
103 }
104 BME280_Count = BME280_init();
105 if (BME280_Count > 0)
106 {
107 #define s_BME280
108 }
109 #endif
110
111 // Hall-Effect ///////////////////////////////////////////////////////////////
112 // #ifdef SS_Dumper
113 // debug_Separator();
114 // debug_SectionTitle("Hall Effect Sensor");
115 // pinMode(HallPin, INPUT);
116 // attachInterrupt(digitalPinToInterrupt(ReedPin), DumpDetect, CHANGE);
117 // sprintf(debugTEXT, "Reed Switch on pin %d", ReedPin);
118 // debug_LineOut(debugTEXT);
119 // attachInterrupt(digitalPinToInterrupt(HallPin), DumpDetect2, CHANGE);
120 // sprintf(debugTEXT, "Hall Effect Sensor on pin %d", HallPin);
121 // debug_LineOut(debugTEXT);
122 // #endif // SS_Dumper
123
124 // Interval Timers ///////////////////////////////////////////////////////////
125 debug_Separator();
126 debug_SectionTitle("Interval Timers");
127
128 timer.setInterval(20, MQTT_handler);
129 debug_LineOut("MQTT");
130
131 timer.setInterval(2000, WiFi_Test);
132 debug_LineOut("WiFiCheck");
133
134 #ifdef s_Depth
135 timer.setInterval(5000, CheckProbes);
136 debug_LineOut("Check Probes");
137 #endif // s_Depth
138
139 #ifdef s_BMP180
140 if (BMP180_Count != 0)
141 {
142 timer.setInterval(10000, BMP180_main);
143 debug_LineOut("BMP180 Handler");
144 }
145 #endif
146
147 #ifdef s_BME280
148 if (BME280_Count != 0)
149 {
150 timer.setInterval(10000, BME280_main);
151 debug_LineOut("BME280 Handler");
152 }
153 #endif
154
155 #ifdef s_CLIMATE
156 if (BMP180_Count != 0)
157 {
158 timer.setInterval(10000, BMP180_main);
159 debug_LineOut("BMP180 Handler");
160 }
161 if (BME280_Count != 0)
162 {
163 timer.setInterval(10000, BME280_main);
164 debug_LineOut("BME280 Handler");
165 }
166 #endif
167
168 #ifdef d_SDD1306
169 timer.setInterval(100, WavingDude); // Waving Dude in the top-right corner
170 debug_LineOut("Waving Dude Indicator");
171 #endif
172
173 // READY /////////////////////////////////////////////////////////////////////
174 debug_ReadyScreen();
175 }
loop()
You'll note this is currently aimed at the SugarBush project.
1 void loop()
2 {
3 // Run the interval timers
4 // Running processes here in loop() is a synchronous flow.
5 // Running processes via the interval timers is assynchronous.
6 // If your actions don't depend directly on each other,
7 // synchronous flow makes no sense at all...
8 timer.run();
9
10 #ifdef SS_Dumper
11 // This is just here to give me console output while developing...
12 // Serial.print(".");
13 // delay(1000);
14 #endif // SS_Dumper
15 }
The parts
Work Environment (Platformio/VSC setup)
MQTT
This is intended to be added to the baseline.
You'll need to add:
lib_deps = PubSubClient
to your platformio.ini
file.
main.cpp
Add:
setup_mqtt();
to setup() after the setup_wifi();
call.
Put:
DOtheBloodyMQTT();
inside loop()
The rest of the parts
OTA
Gurus source code...
Ffffffuuuuuuuu......
Configuration HotSpot
Wiegand RFID keypad
NeoPixels
Extreme WIP
This is intended to be added to the baseline.
You'll need to add:
lib_deps = Adafruit NeoPixel
to your platformio.ini
file.
and put
#include <Adafruit_NeoPixel.h>
in your source
Web Serving
TFT Display
OLED Display
(upcoming)
Climate Sensing
Sensors
- DS18B20
- BME280
- Si7021
- HiH6130
Energy Monitoring
Multitasking
Jean-Francois Turcots SimpleTimer Library makes this fairly straightforward. It allows you to specify that any function run repeatedly (triggered independantly of whatever is going on in loop().
Add SimpleTimer
to the lib_deps
in yout platformio.ini
file.
an Example
1 #include <SimpleTimer.h>
2
3 // the timer object
4 SimpleTimer timer;
5
6 // functions to be executed periodically
7 void repeatMe() {
8 Serial.print("Uptime (s): ");
9 Serial.println(millis() / 1000);
10 }
11
12 void repeatMe2() {
13 Serial.print("Boop: ");
14 Serial.println(millis() / 1000);
15 }
16
17 void setup() {
18 Serial.begin(9600);
19 timer.setInterval(1000, repeatMe); // Run RepeatMe() every 1000 miliseconds.
20 timer.setInterval(100, repeatMe2); // Run RepeatMe2() every 100 miliseconds.
21 }
22
23 void loop() {
24 timer.run();
25 }
Modularization Tutorial (WIP)
The source code...