1 of 34

Building the Connected Future with IoT

2 of 34

https://wiki.norseiot.club/projects/techolympics24/

3 of 34

Your Presenters

Cassian Godsted

  • President of Norse IoT
  • Student Worker and Senior at NKU
  • Internal Systems Admin at INTERalliance

4 of 34

Your Presenters

Riley Weber-Horowitz

  • Vice President of Norse IoT
  • Student Worker and Sophomore at NKU

5 of 34

Your Presenters

Christian Lane

  • Norse IoT Member
  • Senior at NKU
  • Studies Computer Science and Data Science

6 of 34

So, what is IoT?

  • The Internet of Things (IoT) describes the network of physical objects — "things" — that are embedded with sensors, software, and other technologies for the purpose of connecting and exchanging data with other devices and systems over the internet.

  • Range from ordinary household objects to sophisticated industrial tools.

  • 10 billion connected IoT devices today; 22 billion by 2025. (source: Oracle)

wiki.norseiot.club

7 of 34

8 of 34

ESP-32

Arduino Uno

Raspberry Pi

What powers IoT?

wiki.norseiot.club

9 of 34

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…

  • Powerful (by IoT Standards)
  • Overkill for many projects.

10 of 34

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…

  • Well known, but underpowered for the price.

11 of 34

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

3

4

2

Yes v2.0

16

Network

802.11 b/g/n, Bluetooth 4.2,

Ethernet (supported)

$5 - $10

In a nutshell…

  • Powerful, lightweight chip.
  • Useful for many scenarios.
  • Wi-Fi/Bluetooth/Matter enabled allowing for various projects.

12 of 34

What We’re Building

  • A Wi-Fi Enabled Smart Sensor
  • Will feature a Climate Sensor to gather temperature and humidity
  • Will send data to an open-source dashboard that is automatically graphed.

TechOlympics Dashboard

13 of 34

The Hardware

14 of 34

Components: ESP-32 Microcontroller

15 of 34

Components: Thingsboard Server

Receives data and displays it on a visual dashboard.

16 of 34

Components: Breadboards

Allows for easy and adaptable assembly of the microcontroller with input and output devices

17 of 34

Components: Wires

Connects Point A (Microcontroller) to Point B (Sensor)

18 of 34

Components: Resistors

  • Limits electrical current.

19 of 34

1

2

3

1

2

3

Components: DHT22 Sensor

  • Pin 1: VCC (3.3 to 6 volts)​
  • Pin 2: DATA​
  • Pin 3: Ground

20 of 34

The Software

21 of 34

1

2

3

1

2

3

Software: Setup Function

  • Start by beginning to write serial and connect to Wi-Fi.
  • Initialize temperature sensor.

22 of 34

1

2

3

1

2

3

Software: Loop Function

  • Reconnect to Wi-Fi if needed.
  • Wait for a bit, then read data from the sensor and upload it to Thingsboard.

23 of 34

1

2

3

1

2

3

Software: Wi-Fi Function

  • Provided function.
  • Connects to Wi-Fi

24 of 34

1

2

3

1

2

3

Software: Blink LED Function

  • Provided function.
  • Turns on the internal light, turns off the internal light.
  • Lets you know that all your code works.

25 of 34

Getting Started

26 of 34

Blink LED Test

int pin = 2;

void setup() {

pinMode(pin, OUTPUT);

}

bool state = HIGH;

void loop() {

digitalWrite(pin, state);

state = !state;

delay(1000);

}

27 of 34

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;

28 of 34

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

}

29 of 34

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;

}

}

30 of 34

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 {

31 of 34

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();

}

32 of 34

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());

}

33 of 34

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

}

}

34 of 34

Let’s put it all together!

The final code is posted here:

https://techolympics.norseiot.club