Building the Connected Future with IoT
https://wiki.norseiot.club/projects/techolympics24/
Your Presenters
Cassian Godsted
Your Presenters
Riley Weber-Horowitz
Your Presenters
Christian Lane
So, what is IoT?
wiki.norseiot.club
ESP-32
Arduino Uno
Raspberry Pi
What powers IoT?
wiki.norseiot.club
Raspberry Pi 4b
Function | Spec |
Microcontroller | Broadcom Quad Core A72 64-bit |
Clock Speed | 1.5 GHz |
Flash Memory | 4 MB |
SRAM | 1 / 2 / 4 / 8 GB |
Operating Voltage/Input Voltage | 5V DC / 2.2-3.6V DC |
Current Consumption | 600 mA |
DC Current per IO Pin | 16 mA |
Digital IO Pins | 26 |
Analog IO Pins | 0 |
UARTs | 6 |
SPI | 6 |
I2C | 6 |
CAN | No |
PWM | 2 |
Network | 802.11 ac, Bluetooth 5, Gigabit Ethernet |
$35 - $75
In a nutshell…
Arduino Uno R3
Function | Spec |
Microcontroller | ATMega328P |
Clock Speed | 16 MHz |
Flash Memory | 32 KB |
SRAM | 2 KB |
Operating Voltage/Input Voltage | 5V DC / 7-12V DC |
Current Consumption | 45-80 mA |
DC Current per IO Pin | 20 mA |
Digital IO Pins | 14 |
Analog IO Pins | 6 |
UARTs | 1 |
SPI | 1 |
I2C | 1 |
CAN | No |
PWM | 6 |
Network | None |
$18
In a nutshell…
ESP-32
Function | Spec |
Microcontroller | Xtensa Dual-Core 32-bit LX6 |
Clock Speed | 240 MHz |
Flash Memory | 4 MB |
SRAM | 520 KB |
Operating Voltage/Input Voltage | 3.3V DC / 2.2-3.6V DC |
Current Consumption | 80-90 mA, 5μA deep sleep |
DC Current per IO Pin | 40 mA |
Digital IO Pins | 36 |
Analog IO Pins | 18 |
UARTs | 3 |
4 | |
2 | |
Yes v2.0 | |
16 | |
Network | 802.11 b/g/n, Bluetooth 4.2, Ethernet (supported) |
$5 - $10
In a nutshell…
What We’re Building
TechOlympics Dashboard
The Hardware
Components: ESP-32 Microcontroller
Components: Thingsboard Server
Receives data and displays it on a visual dashboard.
Components: Breadboards
Allows for easy and adaptable assembly of the microcontroller with input and output devices
Components: Wires
Connects Point A (Microcontroller) to Point B (Sensor)
Components: Resistors
1
2
3
1
2
3
Components: DHT22 Sensor
The Software
1
2
3
1
2
3
Software: Setup Function
1
2
3
1
2
3
Software: Loop Function
1
2
3
1
2
3
Software: Wi-Fi Function
1
2
3
1
2
3
Software: Blink LED Function
Getting Started
Blink LED Test
int pin = 2;
void setup() {
pinMode(pin, OUTPUT);
}
bool state = HIGH;
void loop() {
digitalWrite(pin, state);
state = !state;
delay(1000);
}
STEP 1: Import Libraries
#define SERIAL_BAUD 115200
#include <DHTesp.h>
#include <WiFi.h>
#include <ThingsBoard.h>
#define DHTTYPE DHT22
#define DHT_PIN 4
#define TOKEN "YOURTOKENHERE"
#define THINGSBOARD_SERVER "10.0.1.2"
#define WIFI_AP_NAME "NORSEIOT5G"
#define WIFI_PASSWORD "freezerburn15"
WiFiClient espClient;
ThingsBoard tb(espClient);
int status = WL_IDLE_STATUS;
DHTesp dht;
int quant = 20;
int send_delay= 2000;
int send_passed = 0;
STEP 2: Connecting to the Web
void setup() {
Serial.begin(SERIAL_BAUD);
pinMode(LED_BUILTIN, OUTPUT);
WiFi.begin(WIFI_AP_NAME, WIFI_PASSWORD);
InitWiFi();
dht.setup(DHT_PIN, DHTesp::DHTTYPE);
}
STEP 3: Integrating the Server
void loop() {
delay(quant);
send_passed += quant;
if (WiFi.status() != WL_CONNECTED) {
InitWiFi();
return;
}
if (!tb.connected()) {
Serial.print("Connecting to ");
Serial.print(THINGSBOARD_SERVER);
Serial.print(" with token ");
Serial.println(TOKEN);
if (!tb.connect(THINGSBOARD_SERVER, TOKEN)) {
Serial.println("Failed!");
return;
}
}
STEP 4a: Measure and Report Humidity Data
if (send_passed > send_delay) {
Serial.print("Sending data ");
TempAndHumidity measurements = dht.getTempAndHumidity();
if (isnan(measurements.humidity) || isnan(measurements.temperature)) {
Serial.println("**Failed to read DHT sensor!**");
} else {
STEP 4b: Measure and Report Humidity Data
tb.sendTelemetryFloat("temperature", measurements.temperature);
tb.sendTelemetryFloat("humidity", measurements.humidity);
Serial.print(measurements.temperature);
Serial.print("c / ");
Serial.print(measurements.humidity);
Serial.println("%).");
blinkLED(1,250,0);
}
send_passed = 0;
}
tb.loop();
}
STEP 5: Ensuring a stable connection
void InitWiFi()
{
Serial.println("");
Serial.print("Connecting to AP as ");
Serial.print(WiFi.macAddress());
WiFi.begin(WIFI_AP_NAME, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
blinkLED(3,120,120);
Serial.println("");
Serial.print("Connected to AP with IP address ");
Serial.println(WiFi.localIP());
}
STEP 6: Finalize with LED
void blinkLED(int numberOfFlashes, int durationOn, int durationOff) {
for(int i = 0; i < numberOfFlashes; i++){
digitalWrite(LED_BUILTIN, HIGH);
delay(durationOn);
digitalWrite(LED_BUILTIN, LOW);
delay(durationOff);
}
}
Let’s put it all together!
The final code is posted here:
https://techolympics.norseiot.club