Lesson 7: Connecting IoT to the Internet

Learning Objectives

By the end of this lesson, you will be able to:

  • Explain how IoT devices share data over the internet.

  • Describe the role of Wi-Fi in connecting IoT devices.

  • Identify how microcontrollers like the ESP32 can send data online.

  • Demonstrate how sensor data can be displayed on a simple IoT dashboard.


How Do IoT Devices Share Data?

In the simplest terms: IoT devices “talk” to each other using the internet.
Just like sending a message to a friend’s phone, IoT devices send data to other devices or online platforms.

  • The sensor collects information (e.g., temperature, light level, motion).

  • The microcontroller (like Arduino or ESP32) processes that information.

  • Using Wi-Fi, the microcontroller sends the data to a server or cloud platform.

  • The data can be stored, analyzed, or shown on a dashboard so people can see it from anywhere in the world.

Analogy:
Think of the IoT device as a student (sensor) writing down results (data) and handing it to a teacher (microcontroller). The teacher sends the report by email (Wi-Fi) to the school office (cloud dashboard) so everyone can see it.


Wi-Fi: The Messenger for IoT

Wi-Fi allows IoT devices to send and receive data without cables.

  • It works like a wireless postal service for your device’s information.

  • Examples: Smart lights receiving ON/OFF commands from your phone; weather sensors sending data to a public app.




ESP32 – An IoT-Ready Microcontroller (Optional for Advanced Students)

The ESP32 is a special type of microcontroller that already has Wi-Fi and Bluetooth built-in.

  • It can do everything an Arduino Uno does plus connect directly to the internet.

  • This makes it perfect for IoT projects that need live updates without extra hardware.

Examples with ESP32:

  • A temperature sensor sending readings to a mobile app.

  • A plant watering system sending a phone alert when soil is dry.

  • A motion detector sending an email when someone enters a room.


WOKWI is an online electronics simulator that lets you build and test Arduino, ESP32, Raspberry Pi Pico, and other microcontroller-based projects directly in your web browser, no hardware needed.

Here’s how it works and why it’s useful:

1. What WOKWI Does

  • Circuit Simulation – You can connect components like LEDs, sensors, motors, LCDs, and buzzers virtually.

  • Code Execution – It runs your Arduino (C/C++), MicroPython, or CircuitPython code in real time.

  • Live Interaction – You can click buttons, move sliders, or change sensor readings to see how your code responds.

  • Realistic Behavior – The simulation mimics how the hardware works, so your code will behave almost exactly as it would on a physical board.

2. Key Features

  • Free & Browser-Based – No installation needed, works on Chrome, Edge, or other modern browsers.

  • Multiple Microcontrollers Supported – Arduino Uno, Mega, Nano, ESP32, Raspberry Pi Pico, etc.

  • Virtual Components – LEDs, resistors, push buttons, potentiometers, OLED displays, ultrasonic sensors, stepper motors, and more.

  • Code Editor with Syntax Highlighting – Built-in editor for writing and running code instantly.

  • Library Support – Many Arduino libraries work directly in WOKWI.

  • Share Projects Easily – Every project has a shareable link so others can open and run your simulation.

3. Advantages of Using WOKWI

  • No Physical Hardware Required – Perfect for learning, teaching, or prototyping without buying parts.

  • Safe Testing – No risk of burning components or damaging boards.

  • Quick Experimentation – Change code or wiring instantly and see the effect right away.

  • Accessible Anywhere – Works on PCs, laptops, and even some tablets.

4. Common Uses

  • Teaching IoT and Arduino basics in classrooms.

  • Practicing coding before uploading to real hardware.

  • Debugging and troubleshooting circuits virtually.

  • Prototyping ideas quickly before investing in components.

Example:
If you want to make an LED blink with Arduino in WOKWI:

  1. Drag an Arduino Uno and an LED into the workspace.

  2. Connect the LED’s positive pin through a resistor to Arduino Pin 13.

  3. Write a simple digitalWrite() blink code in the editor.

  4. Click Run - the LED in the simulator will blink just like a real one.

WOKWI Simulator


Demonstration: Sending Sensor Data to a Simple IoT Dashboard

Goal: Show how an IoT device sends data online and displays it for a user.

Steps:

  1. Connect a sensor (e.g., temperature sensor) to an ESP32 or a simulated IoT board in Wokwi/ThinkSpeak.

  2. Write a program that reads the sensor value and sends it via Wi-Fi to an online dashboard.

  3. Open the dashboard on a browser or app to see the live data.

  4. Explain how the same setup can be used for real-life applications like weather monitoring, home automation, or security alerts.



Real-World Applications

  • Smart Home Controls – Turn lights on/off from anywhere using an app.

  • Remote Health Monitoring – Send patient health data directly to a doctor’s dashboard.

  • Environmental Monitoring – Track air quality or pollution levels online.







Comments