Configure Wokwi projects for Arduino and ESP32 simulation with sensors and Wi-Fi
Navigate Tinkercad Circuits for beginner-friendly visual programming
Compare SimulIDE capabilities for desktop-based real-time simulation
Evaluate Proteus Design Suite for professional embedded development
Choose the right simulator based on your project requirements
In 60 Seconds
Online hardware simulators like Wokwi and Tinkercad enable browser-based IoT prototyping without physical hardware, supporting ESP32, Arduino, and Raspberry Pi Pico with simulated sensors, displays, and communication peripherals. These tools are ideal for: initial firmware prototyping, educational exercises, collaborative debugging, and quick concept validation. Limitations include: no real-time constraints, simplified peripheral models, and no RF simulation for wireless protocols.
11.2 For Beginners: Online Hardware Simulators
Testing and validation ensure your IoT device works correctly and reliably in the real world, not just on your workbench. Think of it like test-driving a car in rain, snow, and heavy traffic before buying it. Thorough testing catches problems before your devices are deployed to thousands of locations where fixing them becomes expensive and disruptive.
Sensor Squad: Try Before You Buy
“Let me introduce you to your new favorite tool – Wokwi!” said Max the Microcontroller excitedly. “It is a free online simulator where you can build Arduino and ESP32 projects right in your browser. Drag in components, write code, and click Run. No hardware needed!”
Sammy the Sensor demonstrated. “Watch – I drag in a DHT22 temperature sensor, connect it to Max’s GPIO pin, write three lines of code, and boom! The simulator shows a realistic temperature reading. I can even change the simulated temperature to test edge cases like freezing or boiling.”
Lila the LED loved Tinkercad Circuits. “For absolute beginners, Tinkercad is even simpler. It uses visual block programming – like Scratch for electronics. You drag blocks that say ‘turn LED on’ and ‘wait 1 second’ without writing any text code. Perfect for learning the basics.” Bella the Battery compared them. “Wokwi is best for real Arduino and ESP32 projects with Wi-Fi simulation. Tinkercad is best for learning basics with a visual approach. SimulIDE is a desktop app for real-time circuit simulation. And Proteus is the professional tool used in industry. Pick the one that matches your skill level and project needs!”
11.3 Prerequisites
Before diving into this chapter, you should be familiar with:
Try this live simulation! Click the Start Simulation button to see the LED blink:
Try This!
Experiments to try in the simulator:
Change delay(1000) to delay(100) for faster blinking
Add a second LED on pin 12
Create a pattern: blink twice, pause, repeat
Use a button to control the LED (add from component library)
Code Explanation:
// Arduino codeconstint LED_PIN =13;// LED connected to pin 13void setup(){ pinMode(LED_PIN, OUTPUT);// Set pin 13 as output}void loop(){ digitalWrite(LED_PIN, HIGH);// Turn LED ON (5V) delay(1000);// Wait 1 second (1000 ms) digitalWrite(LED_PIN, LOW);// Turn LED OFF (0V) delay(1000);// Wait 1 second}// Repeat forever
Putting Numbers to It
Online Simulator Power Calculation: LED blink circuit analysis using Wokwi:
Current through LED when ON: Using Ohm’s law with 5V supply, 220Ω resistor, 2V LED forward voltage: \[I = \frac{V_{\text{supply}} - V_{\text{LED}}}{R} = \frac{5V - 2V}{220\Omega} = 13.6mA\]
Power dissipated in resistor:\[P = I^2 \times R = (0.0136A)^2 \times 220\Omega = 40.7mW\]
Battery life with 2000mAh supply:\[\text{Hours} = \frac{2000mAh}{6.8mA + 25mA \text{ (Arduino base)}} = 63 \text{ hours}\]
Wokwi shows these calculations visually - hover over components to see real-time voltage/current. No multimeter needed! Physical testing confirms within 5% (resistor tolerance).
Try adjusting the sliders to see how different LED configurations affect power consumption and battery life!
Circuit Wiring:
LED anode (long leg) -> Arduino pin 13
LED cathode (short leg) -> GND (through built-in resistor)
What’s happening behind the scenes:
setup() runs once: Configures pin 13 as OUTPUT
loop() runs forever:
Sets pin 13 to HIGH (5V) -> LED turns on
Waits 1000 milliseconds
Sets pin 13 to LOW (0V) -> LED turns off
Waits 1000 milliseconds
Repeats from step 2
Try It: LED Blink Timing Visualizer
Adjust the ON and OFF delay values to see how the LED blink pattern changes. The timeline shows exactly what the Arduino pin outputs over time, helping you understand how delay() controls timing.
This simulation demonstrates ESP32 Wi-Fi connectivity with a real sensor! Click Start Simulation to see it work:
Advanced Features Demonstrated
What this simulation shows:
ESP32 Wi-Fi connection (connects to Wokwi-GUEST network automatically)
DHT22 sensor reading (temperature and humidity)
Serial monitor output (view real-time readings)
Real firmware execution (actual ESP32 code running)
Code Explanation:
#include <WiFi.h>#include <DHTesp.h>constchar* ssid ="Wokwi-GUEST";// Wokwi test network (free)constchar* password ="";// No password neededDHTesp dht;// DHT22 sensor objectvoid setup(){ Serial.begin(115200);// Start serial communication dht.setup(15, DHTesp::DHT22);// DHT22 on pin 15 WiFi.begin(ssid, password);// Connect to Wi-Fiwhile(WiFi.status()!= WL_CONNECTED){ delay(500); Serial.print(".");// Print dots while connecting} Serial.println("\nWi-Fi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP());// Show assigned IP}void loop(){float temp = dht.getTemperature();// Read temperaturefloat humidity = dht.getHumidity();// Read humidity Serial.printf("Temp: %.1f°C, Humidity: %.1f%%\n", temp, humidity); delay(2000);// Update every 2 seconds}
Circuit Wiring:
DHT22 VCC -> ESP32 3.3V
DHT22 DATA -> ESP32 GPIO 15
DHT22 GND -> ESP32 GND
Try This:
Open serial monitor (click “Serial Monitor” tab)
Watch Wi-Fi connection messages
See temperature/humidity readings every 2 seconds
Change delay(2000) to delay(5000) for slower updates
Adjust virtual DHT22 temperature slider to see readings change
Real-World Application: This is the foundation for IoT weather stations, greenhouse monitors, and smart home climate control systems. Next step: Send data to cloud (MQTT, HTTP) for remote monitoring!
cmp_features = {const sims = [ { name:"Wokwi",color:"#16A085",caps: { free:true,browser:true,wifi:true,esp32:true,blocks:false,scope:false,pcb:false,share:true,beginner:true,arm:true } }, { name:"Tinkercad",color:"#3498DB",caps: { free:true,browser:true,wifi:false,esp32:false,blocks:true,scope:false,pcb:false,share:true,beginner:true,arm:false } }, { name:"SimulIDE",color:"#E67E22",caps: { free:true,browser:false,wifi:false,esp32:false,blocks:false,scope:true,pcb:false,share:false,beginner:false,arm:false } }, { name:"Proteus",color:"#9B59B6",caps: { free:false,browser:false,wifi:false,esp32:false,blocks:false,scope:true,pcb:true,share:false,beginner:false,arm:true } } ];const selected = [];if (cmp_free.length) selected.push("free");if (cmp_browser.length) selected.push("browser");if (cmp_wifi.length) selected.push("wifi");if (cmp_esp32.length) selected.push("esp32");if (cmp_blocks.length) selected.push("blocks");if (cmp_scope.length) selected.push("scope");if (cmp_pcb.length) selected.push("pcb");if (cmp_share.length) selected.push("share");if (cmp_beginner.length) selected.push("beginner");if (cmp_arm.length) selected.push("arm");const total = selected.length||1;const scored = sims.map(s => {const matched = selected.filter(f => s.caps[f]).length;return { ...s, matched,pct:Math.round((matched / total) *100) }; }).sort((a, b) => b.matched- a.matched);return { scored, total,selectedCount: selected.length };}html`<div style="background: linear-gradient(135deg, #2C3E50 0%, #3498DB 100%); padding: 20px; border-radius: 8px; color: white; margin: 20px 0;"> <h4 style="margin-top: 0; color: white;">Feature Match Results ${cmp_features.selectedCount===0?"(select features above)":"("+ cmp_features.selectedCount+" features selected)"}</h4>${cmp_features.scored.map((s, i) =>html`<div style="margin: 10px 0; padding: 12px; background: rgba(255,255,255,0.1); border-radius: 6px; border-left: 4px solid ${s.color};"> <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;"> <span style="font-weight: bold; font-size: 1.1em;">${s.name}</span> <span style="font-size: 0.9em;">${s.matched}/${cmp_features.total} features</span> </div> <div style="background: rgba(0,0,0,0.2); border-radius: 4px; height: 20px; overflow: hidden;"> <div style="background: ${s.color}; height: 100%; width: ${s.pct}%; border-radius: 4px; transition: width 0.3s; display: flex; align-items: center; justify-content: center; font-size: 0.75em; font-weight: bold; min-width: ${s.pct>0?'30px':'0'};">${s.pct>0? s.pct+"%":""}</div> </div> </div>`)} <div style="margin-top: 12px; padding: 10px; background: rgba(255,255,255,0.1); border-radius: 4px; font-size: 0.85em;"> <strong>Note:</strong> No single simulator does everything. The best approach is to use multiple tools -- start with a browser-based simulator for rapid prototyping, then move to desktop tools for detailed analysis. </div></div>`
11.6 SimulIDE
Description: Open-source real-time electronic circuit simulator with microcontroller support.
Key Features:
Desktop application (Windows, Linux, macOS)
Real-time simulation
PIC, AVR, Arduino support
Circuit schematic editor
Oscilloscope, voltmeter, logic analyzer
VHDL/Verilog support
Installation:
Download from: https://simulide.com
Strengths:
Real-time fast simulation
Advanced measurement tools
Open source
Detailed analog simulation
Limitations:
Desktop only (no web)
Steeper learning curve
Limited modern MCU support (no ESP32)
Typical Use Cases:
Circuit design and validation
Electronics education
AVR/PIC development
11.7 Network and IoT Simulation Visualizations
The following AI-generated diagrams illustrate advanced simulation tools and concepts for IoT development.
Contiki-NG and Cooja Simulator
Figure 11.1: Contiki-NG and Cooja enable testing of complete wireless sensor networks before hardware deployment. This visualization shows how Cooja simulates multiple sensor nodes with realistic radio propagation, enabling protocol debugging and performance analysis of mesh networking code.
Duty Cycle Simulation
Figure 11.2: Duty cycle simulation enables battery life prediction. This visualization shows the timing relationship between wake and sleep periods, demonstrating how a 1% duty cycle (10 seconds active per 1000 seconds) reduces average current by 99%, extending battery life proportionally.
Battery Sizing Exercise
Figure 11.3: Battery sizing exercises bridge theory and practice. This visualization provides a systematic approach to calculating required battery capacity from sensor duty cycle, transmission frequency, and target lifetime, enabling students to validate designs before hardware investment.
Battery Technology Evolution
Figure 11.4: Battery technology improves slowly compared to computing. This visualization shows the 5-8% annual energy density improvement for lithium-ion, emphasizing that firmware efficiency gains of 50-90% through duty cycling and optimization are more impactful than waiting for battery improvements.
Try It: IoT Duty Cycle and Battery Life Explorer
Explore how duty cycle percentage, sensor read frequency, and transmission patterns affect the total battery life of an IoT sensor node. Adjust parameters to find the sweet spot between data freshness and longevity.
Show code
viewof dc_read_interval = Inputs.range([1,3600], {value:60,step:1,label:"Sensor Read Interval (seconds)"})viewof dc_active_time_ms = Inputs.range([10,5000], {value:200,step:10,label:"Active Time per Read (ms)"})viewof dc_tx_every_n = Inputs.range([1,60], {value:5,step:1,label:"Transmit Every N Reads"})viewof dc_tx_time_ms = Inputs.range([50,3000], {value:500,step:50,label:"Transmit Duration (ms)"})viewof dc_active_ma = Inputs.range([10,200], {value:80,step:5,label:"Active Current (mA)"})viewof dc_tx_ma = Inputs.range([50,350], {value:150,step:10,label:"Transmit Current (mA)"})viewof dc_sleep_ua = Inputs.range([1,5000], {value:10,step:1,label:"Sleep Current (uA)"})viewof dc_battery_mah = Inputs.range([200,20000], {value:3000,step:100,label:"Battery Capacity (mAh)"})
Learn the basics of Tinkercad for circuit design, 3D modeling, and Arduino simulation - all in your browser without installing software.
Video: Parking Sensor Prototype in Tinkercad
Build and simulate a practical parking sensor system using Tinkercad’s Arduino simulator and ultrasonic sensors.
Video: Simulated Accelerometer in Tinkercad
Learn how to simulate accelerometer sensors in Tinkercad for motion detection and orientation sensing applications.
Video: Tilt Sensor with Timestamp in Tinkercad
Build a tilt sensor project in Tinkercad that logs timestamps, demonstrating sensor data collection and time-based logging.
Worked Example: Prototyping ESP32 Smart Parking Sensor with Wokwi
Scenario: Design a smart parking sensor using ESP32 + ultrasonic sensor + MQTT for real-time occupancy detection. Validate the design in Wokwi before ordering hardware.
Requirements:
Detect vehicle presence (distance < 50 cm = occupied)
Publish to MQTT broker every 5 seconds
Use ESP32 deep sleep between readings (battery-powered)
Provide visual feedback with LED (green = available, red = occupied)
Wokwi Implementation:
Components:
ESP32 DevKit v1
HC-SR04 ultrasonic sensor
Red LED + 220Ω resistor
Green LED + 220Ω resistor
Circuit Wiring:
HC-SR04:
├─ VCC → ESP32 5V
├─ TRIG → ESP32 GPIO 12
├─ ECHO → ESP32 GPIO 14
└─ GND → ESP32 GND
LEDs:
├─ Green LED anode → ESP32 GPIO 25 (via 220Ω)
├─ Green LED cathode → GND
├─ Red LED anode → ESP32 GPIO 26 (via 220Ω)
└─ Red LED cathode → GND
Simulator Action: Move "distance" slider on HC-SR04 to 30 cm
Expected Result:
├─ Serial: "Distance: 30.0 cm"
├─ Red LED turns ON
├─ Green LED turns OFF
└─ MQTT message: "OCCUPIED"
✓ PASS: All behaviors correct
Test 2: Vehicle Departure
Simulator Action: Move "distance" slider to 200 cm
Expected Result:
├─ Serial: "Distance: 200.0 cm"
├─ Red LED turns OFF
├─ Green LED turns ON
└─ MQTT message: "AVAILABLE"
✓ PASS: State transition works
Test 3: Edge Case (Exactly 50 cm)
Simulator Action: Move slider to 50 cm
Expected Result: Should still show AVAILABLE (threshold is < 50)
✓ PASS: Boundary condition handled correctly
Test 4: MQTT Connectivity Loss
Simulator Action: Disconnect virtual network
Expected Result:
├─ Serial: "Connecting to MQTT... failed, rc=-2, retrying in 5s"
├─ Device keeps measuring but doesn't publish
└─ Reconnects automatically when network restored
✓ PASS: Graceful degradation
Power Optimization (Add Deep Sleep):
// At end of loop(): delay(5000);// Replace with deep sleep// Enter deep sleep for 5 seconds Serial.println("Entering deep sleep for 5 seconds"); esp_sleep_enable_timer_wakeup(5*1000000);// 5 seconds in microseconds esp_deep_sleep_start();}
Simulation Results:
Without Deep Sleep:
Average current: 80 mA (Wi-Fi active)
Battery life (2000 mAh): 25 hours
With Deep Sleep:
Active current: 80 mA for 0.5s every 5s
Sleep current: 0.01 mA (simulated)
Average current: (80×0.5 + 0.01×4.5) / 5 = 8.01 mA
Battery life (2000 mAh): 250 hours (10× improvement!)
11.9.1 Interactive Deep Sleep Battery Calculator
Show code
viewof ds_active_current = Inputs.range([50,150], {value:80,step:5,label:"Active Current (mA)"})viewof ds_active_time = Inputs.range([0.1,5], {value:0.5,step:0.1,label:"Active Time per Cycle (s)"})viewof ds_sleep_current = Inputs.range([0.001,5], {value:0.01,step:0.001,label:"Sleep Current (mA)"})viewof ds_cycle_time = Inputs.range([1,300], {value:5,step:1,label:"Total Cycle Time (s)"})viewof ds_battery_capacity = Inputs.range([500,10000], {value:2000,step:100,label:"Battery Capacity (mAh)"})
Experiment: Adjust the sleep time and cycle duration to see how deep sleep dramatically extends battery life. Try a 1% duty cycle (0.5s active, 50s sleep) to see month-long battery life!
Validation Results:
After 2 hours in Wokwi simulator: - Detected 24 “vehicle arrivals” (distance < 50 cm) - Detected 24 “vehicle departures” (distance > 50 cm) - Zero false positives (no spurious triggers) - MQTT messages: 48 (all delivered successfully) - Average response time: 150 ms (detection to MQTT publish)
Benefits of Wokwi Prototyping:
Validated algorithm before hardware: Found and fixed 3 bugs in code
Tested MQTT integration: Confirmed message format works with broker
Estimated battery life: Confirmed 10-day battery life feasible with deep sleep
Shareable design: Sent Wokwi link to team for review (no hardware needed)
Zero cost: All testing done free, saved $50 in prototype hardware
Time saved: 3 days iteration in Wokwi vs 2 weeks waiting for hardware
Next Steps After Wokwi Validation:
Order hardware components ($15 per unit)
Build physical prototype on breadboard
Test in actual parking spot (validate ultrasonic range in real environment)
Design PCB and 3D-printed enclosure
Deploy pilot of 10 sensors
Key Takeaway: Wokwi caught 3 firmware bugs and validated the entire system architecture in 6 hours. Without simulation, these bugs would have been found after $150 in hardware and 2 weeks of waiting for components.
Decision Framework: When to Use Online vs Desktop vs Physical Hardware
Decision Matrix:
Stage
Tool
Purpose
When to Use
Concept Validation
Wokwi / Tinkercad
Prove algorithm works
Early design, no hardware yet
Firmware Development
Wokwi
Iterate code fast
Writing and testing firmware logic
Hardware Integration
SimulIDE / Proteus
Validate circuit design
Testing voltage levels, pull-ups, etc.
Timing Validation
Physical Hardware
Verify real-world timing
I2C clock stretching, interrupt latency
Production Testing
Physical Hardware
Environmental testing
Temperature, vibration, EMI, etc.
Decision Process:
Question 1: Do you have hardware available?
NO → Start with online simulator (Wokwi)
YES → Use simulator anyway for fast iteration, hardware for validation
Question 2: What are you testing?
Algorithm Logic (if/else, calculations, state machines): - ✓ Wokwi or Tinkercad (sufficient) - Time: Hours to validate
Sensor Reading (I2C, SPI communication): - ✓ Wokwi (good approximation) - ⚠️ Physical validation recommended (sensors have quirks) - Time: 1-2 days in Wokwi, 1 week with hardware
❌ Waiting 2 weeks for hardware before starting firmware (use Wokwi!)
❌ Buying $500 of components before validating algorithm (simulate first!)
❌ Building 100 units without pilot testing (prototype first!)
Best Practice Timeline:
Total Project: 12 weeks
Week 1-2: Simulation (Wokwi)
├─ Validate algorithm
├─ Test edge cases
├─ Estimate power consumption
└─ Share design with team
Week 3: Order Hardware
├─ Based on validated Wokwi design
└─ Cost: $50-200
Week 4-5: Breadboard Prototype
├─ Validate sensor behavior
├─ Measure actual power consumption
└─ Test I2C timing with oscilloscope
Week 6-7: PCB Design
├─ Schematic capture
├─ PCB layout
└─ Order PCB ($100, 1-week lead time)
Week 8-9: PCB Assembly & Testing
├─ Assemble 10 prototypes
├─ Functional testing
└─ Fix any issues
Week 10-12: Pilot Deployment
├─ Deploy 10 units to real environment
├─ Monitor for 2-4 weeks
└─ Iterate based on field data
The Rule: Simulation accelerates early stages (save weeks). Physical hardware validates simulation (catch issues). Both are required for production-ready IoT devices.
Common Mistake: Trusting Wokwi Power Consumption Estimates Without Measurement
The Problem: Your Wokwi simulation shows ESP32 average current of 15 mA. You design for 2-year battery life. Real hardware consumes 120 mA average. Batteries die in 2 months. What happened?
Why Wokwi Power Estimates Are Inaccurate:
1. Wokwi Models Ideal Behavior
Wokwi Simulation:
esp_deep_sleep_start();// Wokwi assumes: 10 µA deep sleep (datasheet spec)
Reality on Physical ESP32:
Deep sleep current: 10 µA (ONLY if configured perfectly)
With USB connected: 5-15 mA (USB circuitry stays powered)
With built-in LED: +20 mA (often forgotten to disable)
With external sensor powered: +5-50 mA (not turned off)
Real measured current: 50-120 mA ❌
2. Wokwi Doesn’t Model External Components
Wokwi Circuit:
ESP32 + DHT22 sensor
Wokwi says: 25 mA average
Real Circuit:
ESP32: 80 mA (Wi-Fi active)
DHT22: 1.5 mA (when reading)
Voltage regulator: 50 µA quiescent
Pull-up resistors (2× 10kΩ): 660 µA (3.3V / 10kΩ × 2)
Status LED: 20 mA (forgot to disable in firmware!)
TOTAL: 102 mA ❌ (4× Wokwi estimate!)
3. Wokwi Doesn’t Model Dynamic Voltage
Wokwi Assumption: Stable 3.3V power supply Reality: Battery voltage drops from 4.2V (full) to 3.0V (empty) - At 3.0V: Boost converter efficiency drops from 90% to 75% - Result: 20% more current draw from battery
Real-World Disaster Example:
Wokwi Design: Solar-powered weather station
ESP32 + DHT22 + 5W solar panel + 2000 mAh battery
Wokwi Power Budget:
├─ Active (1s every 5 min): 80 mA × 1s = 80 mAs
├─ Deep sleep (299s): 0.01 mA × 299s = 3 mAs
├─ Average per 5 min: 83 mAs
├─ Average current: 83 / 300 = 0.28 mA
└─ Battery life (no solar): 2000 / 0.28 = 7,143 hours = 297 days
Wokwi Conclusion: "System will work year-round even with 3 cloudy weeks"
Physical Deployment Results:
Actual Power Consumption (measured with ammeter):
├─ Active: 150 mA × 2s (Wi-Fi connect takes 2s, not 1s)
├─ Deep sleep: 2.5 mA (USB circuitry + pull-ups + LED)
├─ Average per 5 min: 300 + 748 = 1,048 mAs
├─ Average current: 1,048 / 300 = 3.49 mA ❌
└─ Battery life: 2000 / 3.49 = 573 hours = 24 days ❌
Result: Batteries died after 3 weeks (not 10 months as Wokwi predicted)
Emergency retrofit: Larger solar panel + disable USB circuitry
What Went Wrong:
Component
Wokwi Estimate
Reality
Difference
Deep sleep current
0.01 mA
2.5 mA
250× worse!
Active duration
1 second
2 seconds
2× longer
Total average
0.28 mA
3.49 mA
12.5× worse
How to Validate Power in Reality:
Step 1: Build Physical Prototype
Even a breadboard prototype is better than pure simulation
Step 2: Measure with Ammeter
# Connect ammeter in series with battery# Use multimeter in µA mode for sleep current# Use oscilloscope current probe for dynamic measurementEquipment needed:├─ Multimeter with µA range (<$50)├─ INA219 current sensor module (<$5)└─ Or: Oscilloscope with current probe (>$500)
Measurement procedure:
1. Measure baseline (full system)
2. Remove one component at a time
3. Measure again
4. Calculate delta (drain from that component)
Example findings:
├─ Baseline: 3.49 mA
├─ Remove status LED: 0.52 mA (LED was 2.97 mA drain!)
├─ Remove USB: 0.15 mA (USB circuitry was 0.37 mA)
├─ Configure pull-ups correctly: 0.08 mA (saved 0.07 mA)
└─ Final: 0.08 mA (43× better than initial!)
Corrected Design:
// Disable all power drains in firmwarevoid setup(){// Disable USB (if not debugging)#ifndef DEBUG USB.end();#endif// Disable status LED pinMode(LED_BUILTIN, INPUT);// High-Z (not driving LED)// Configure unused pins as INPUT with internal pull-downfor(int pin =0; pin <40; pin++){if(pin != USED_PIN_LIST){ pinMode(pin, INPUT_PULLDOWN);}}// Power down ADC adc_power_off();// Enable proper deep sleep esp_sleep_enable_timer_wakeup(5*60*1000000);// 5 minutes gpio_deep_sleep_hold_en();// Hold GPIO state in sleep}
Validation Results After Fixes:
Measured current: 0.08 mA average
Battery life: 2000 / 0.08 = 25,000 hours = 2.85 years ✓
Solar requirement: 0.08 mA × 24h = 1.92 mAh/day
3.3V × 1.92 mAh = 6.3 mWh/day
5W solar panel (5 peak hours) = 25 Wh/day ✓✓ (4,000× margin!)
Best Practices:
Use Wokwi for algorithm validation - Not for power estimates
Measure physical hardware - Always validate with ammeter
Test full duty cycle - Measure for multiple sleep/wake cycles
Account for all peripherals - LEDs, pull-ups, regulators, sensors
Add 2× safety margin - Real deployments are worse than lab
The Rule: Wokwi is excellent for firmware development. It is terrible for power estimation. Always measure actual hardware before finalizing battery/solar sizing.
Matching Exercise: Key Concepts
Order the Steps
Label the Diagram
💻 Code Challenge
11.10 Summary
Wokwi is the recommended starting point for Arduino and ESP32 simulation with Wi-Fi support, extensive component libraries, and shareable project links
Tinkercad Circuits provides beginner-friendly visual block programming ideal for K-12 education and absolute beginners
SimulIDE offers desktop-based real-time simulation with advanced measurement tools for AVR/PIC development
Proteus Design Suite serves professional needs with PCB integration and accurate SPICE simulation
All simulators complement each other: start with browser-based tools, graduate to professional tools as projects mature
Task: Build the same ultrasonic parking sensor in 3 different simulators and compare.
Project Spec: HC-SR04 sensor, LED distance indicator (green >20cm, yellow 10-20cm, red <10cm), serial output.
Part 1 - Tinkercad (20 minutes): - Use block-based programming for beginners - Visual circuit drag-and-drop - What to Observe: Easiest to start, limited to basic Arduino
Part 2 - Wokwi (30 minutes): - Text-based C++ code - Real ESP32 with Wi-Fi simulation - Add MQTT publish of distance readings - What to Observe: Production-ready code, works on real hardware
Part 3 - SimulIDE (30 minutes): - Desktop app with oscilloscope tools - Measure ultrasonic pulse timing on logic analyzer - What to Observe: Most detailed signal-level debugging
Deliverables:
Screenshot of each working simulation
Summary: “I would use [tool] for [scenario] because…”
Bonus: Flash Wokwi code to real Arduino and confirm it works
Expected Learning: Understand which tool fits different development phases.
Common Pitfalls
1. Using Wokwi Simulation Results as Final Performance Data
Wokwi simulates GPIO, I2C, SPI, and UART logically correct but does not model: interrupt latency (measured in CPU cycles), DMA transfer timing, hardware timer jitter, ADC sampling noise, or power consumption. A Wokwi simulation showing 100 Hz sensor sampling rate does not validate that the production firmware achieves 100 Hz on real hardware. Use Wokwi for functional correctness validation and algorithm development; measure timing and power on actual hardware.
2. Not Validating Wokwi Component Library Versions Against Production Hardware
Wokwi simulates specific peripheral variants (BME280, not BME680; MPU-6050, not MPU-6500). Code written for a simulated BME280 may not work with a production PCB using a different sensor variant if the register maps differ. Always verify: exact component model matches production BOM, firmware HAL (Hardware Abstraction Layer) is tested on actual hardware before production, and simulation component version matches production component version.
3. Relying on Online Simulators for Team Collaboration Without Version Control
Wokwi projects stored only in browser local storage or unshared online accounts cannot be version-controlled, peer-reviewed, or reproduced by CI. Export Wokwi projects (diagram.json + sketch files) to git alongside firmware source code. This enables: simulation state review in PRs, reproducible simulation environments across team members, and automated CI using the Wokwi GitHub Actions integration for headless simulation testing.
4. Ignoring Simulator Resource Limits in Complex Projects
Online simulators run in browser JavaScript sandboxes with memory and computation limits. Complex simulations with 10+ active components, large firmware binaries, or high-frequency polling may: run slower than real-time (hiding timing bugs), crash the browser tab, or silently truncate computation. Monitor simulation performance: if simulation speed drops below 0.5× real-time, simplify the simulation model or upgrade to local QEMU/Renode simulation for complex projects.
11.15 What’s Next
Continue to Platform-Specific Emulation to learn about QEMU for Raspberry Pi emulation, Renode for multi-architecture simulation, and advanced debugging techniques including breakpoints, serial monitoring, and GDB integration.