IoT Development Environment Setup
You can develop IoT applications on any laptop or desktop. This guide covers the tools for MicroPython (ESP32), Arduino (C/C++), and Raspberry Pi (full Python 3).
Option A: MicroPython on ESP32
MicroPython lets you write Python directly on an ESP32 microcontroller.
Step 1 — Install Thonny IDE
Thonny is the easiest way to program MicroPython boards.
Windows/macOS/Linux:
Download from: https://thonny.org
Install and open Thonny.Step 2 — Flash MicroPython Firmware
First, install esptool to flash the firmware:
pip install esptoolDownload the latest MicroPython .bin for ESP32 from micropython.org/download/ESP32_GENERIC.
# Erase existing firmware
esptool.py --chip esp32 --port COM3 erase_flash
# Flash MicroPython (replace COM3 with your port, e.g. /dev/ttyUSB0 on Linux)
esptool.py --chip esp32 --port COM3 --baud 460800 \
write_flash -z 0x1000 esp32-20240105-v1.22.0.binStep 3 — Connect via Thonny
- In Thonny: Run → Configure interpreter
- Select MicroPython (ESP32)
- Choose the correct port (COM3, /dev/ttyUSB0, /dev/cu.usbserial-*)
- Click OK — you should see the REPL prompt
>>>
# Type this in the Thonny Shell (REPL) to test
print("Hello from ESP32!")
import machine
print(machine.freq()) # Should print 240000000 (240 MHz)Option B: Arduino IDE (C/C++)
Step 1 — Install Arduino IDE 2
Download from arduino.cc/en/software.
Step 2 — Add ESP32 Board Support
- Open File → Preferences
- In "Additional boards manager URLs" add:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Open Tools → Board → Boards Manager
- Search "esp32" and install "esp32 by Espressif Systems"
Step 3 — Upload Your First Sketch
// Blink the built-in LED (GPIO 2 on most ESP32 boards)
void setup() {
Serial.begin(115200);
pinMode(2, OUTPUT);
Serial.println("ESP32 ready!");
}
void loop() {
digitalWrite(2, HIGH); // LED on
delay(1000); // Wait 1 second
digitalWrite(2, LOW); // LED off
delay(1000);
Serial.println("Blink!");
}Select Tools → Board → ESP32 Arduino → ESP32 Dev Module, then click Upload.
Option C: PlatformIO (VSCode — Recommended for Projects)
PlatformIO supports 1,000+ boards and both MicroPython and Arduino frameworks inside VSCode.
# Install VSCode, then install the PlatformIO extension
# Create a new project: PIO Home → New ProjectYour platformio.ini for an ESP32 Arduino project:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
knolleary/PubSubClient @ ^2.8 ; MQTT
adafruit/DHT sensor library @ ^1.4.4 ; DHT22 sensorOption D: Raspberry Pi (Full Python 3)
If you have a Raspberry Pi, use Python 3 directly with the system's GPIO libraries.
# Update your Pi
sudo apt update && sudo apt upgrade -y
# Install GPIO library
sudo apt install python3-rpi.gpio python3-pip -y
# Install common IoT libraries
pip3 install paho-mqtt requests adafruit-circuitpython-dht# Test GPIO access (Python 3 on Raspberry Pi)
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT) # Set GPIO 18 as output
GPIO.output(18, GPIO.HIGH) # Turn on
import time
time.sleep(1)
GPIO.output(18, GPIO.LOW) # Turn off
GPIO.cleanup()
print("GPIO test complete")Online Simulators (No Hardware Required)
You can start learning IoT without buying any hardware.
Wokwi — Best Online ESP32/Arduino Simulator
Visit wokwi.com:
- Simulate ESP32, Arduino, Raspberry Pi Pico
- Add virtual sensors (DHT22, PIR, LDR, LCD)
- Use MicroPython or Arduino C/C++
- Share projects via URL
# This MicroPython code runs in Wokwi without real hardware
from machine import Pin
import time
led = Pin(2, Pin.OUT)
while True:
led.on()
print("LED ON")
time.sleep(0.5)
led.off()
print("LED OFF")
time.sleep(0.5)Tinkercad Circuits
- Great for Arduino + basic components
- Simulates sensors and circuits
- Free at tinkercad.com/circuits
Virtual Environment for PC Development
For cloud-side Python development (data pipelines, MQTT clients):
# Create and activate a virtual environment
python -m venv iot-env
# Windows
iot-env\Scripts\activate
# macOS/Linux
source iot-env/bin/activate
# Install common IoT Python libraries
pip install paho-mqtt requests influxdb-client pandas matplotlib \
flask fastapi uvicorn python-dotenvProject Directory Structure
my-iot-project/
├── device/ # Firmware (MicroPython or Arduino)
│ ├── main.py # MicroPython entry point
│ ├── config.py # WiFi credentials, MQTT settings
│ └── sensors/
│ └── dht22.py # Sensor driver module
├── server/ # Cloud/backend code (Python 3)
│ ├── subscriber.py # MQTT subscriber
│ ├── api.py # FastAPI endpoints
│ └── db.py # InfluxDB client
├── dashboard/ # Grafana config or web UI
└── README.mdSummary
- Thonny + MicroPython is the easiest path for ESP32 development
- Arduino IDE is ideal for C/C++ sketches and the Arduino library ecosystem
- PlatformIO is the professional choice for larger projects in VSCode
- Raspberry Pi runs full Python 3 with direct GPIO access
- Wokwi lets you simulate ESP32/Arduino projects without any hardware
- Keep device firmware and cloud server code in separate directories
Next, we'll explore the microcontrollers and single-board computers that power IoT projects.