25 KiB
Troubleshooting Guide
This guide helps you solve common problems when working with the IoT for Beginners curriculum. Issues are organized by category for easy navigation.
Table of Contents
- Installation Issues
- Hardware Issues
- Connectivity Issues
- Sensor and Actuator Issues
- Development Environment Issues
- Performance Issues
- Common Error Messages
- Getting Help
Installation Issues
Python Installation
Problem: Python version is too old
Error: Python 3.6 or higher is required
Solution:
- Download the latest Python 3 from python.org
- During installation on Windows, check "Add Python to PATH"
- Verify installation:
python3 --version
Problem: Multiple Python versions causing conflicts
Symptoms: Wrong Python version runs, packages install to wrong location
Solution:
- Windows: Use
py -3instead ofpythonto explicitly call Python 3 - macOS/Linux: Use
python3instead ofpython - Always create and use virtual environments for projects
Problem: pip command not found
Error: 'pip' is not recognized as an internal or external command
Solution:
- Try
pip3instead ofpip - Or use
python -m piporpython3 -m pip - Ensure Python is added to PATH (reinstall Python and check the option)
VS Code and Extensions
Problem: Pylance extension not working
Symptoms: No Python IntelliSense, code completion, or type checking
Solution:
- Open VS Code Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Run "Python: Select Interpreter"
- Choose the correct Python interpreter (virtual environment if using one)
- Reload VS Code window
Problem: VS Code not detecting virtual environment
Symptoms: Wrong Python interpreter selected
Solution:
- Ensure you've activated the virtual environment in the terminal
- Open Command Palette and run "Python: Select Interpreter"
- Select the interpreter from
.venvfolder - Check the status bar (bottom left) shows the correct Python version
PlatformIO (Wio Terminal)
Problem: PlatformIO installation fails
Error: Various errors during PlatformIO installation
Solution:
- Ensure VS Code is up to date
- Install the C/C++ extension first
- Restart VS Code after installing PlatformIO
- Check your internet connection (PlatformIO downloads large files)
Problem: Board not detected by PlatformIO
Symptoms: Cannot upload code to Wio Terminal
Solution:
- Try a different USB cable (some cables are charge-only)
- Check Device Manager (Windows) or
ls /dev/tty*(macOS/Linux) - Install or update USB drivers
- Try a different USB port
- Slide the power switch on the Wio Terminal twice quickly to enter bootloader mode
Problem: Compilation errors in PlatformIO
Error: fatal error: Arduino.h: No such file or directory
Solution:
- Delete
.piofolder in your project - Run "PlatformIO: Rebuild" from Command Palette
- Ensure
platformio.inihas correct board configuration:[env:seeed_wio_terminal] platform = atmelsam board = seeed_wio_terminal framework = arduino
Grove Libraries
Problem: Grove library import fails on Raspberry Pi
Error: ModuleNotFoundError: No module named 'grove'
Solution:
- Reinstall Grove libraries:
cd ~ git clone https://github.com/Seeed-Studio/grove.py cd grove.py sudo pip3 install . - If using virtual environment, you may need to install globally or copy libraries
- Verify I2C is enabled:
sudo raspi-config nonint do_i2c 0
Problem: Grove sensor not detected
Error: IOError: [Errno 121] Remote I/O error
Solution:
- Check physical connections (ensure Grove cable is fully inserted)
- Verify sensor is connected to correct port (analog, digital, I2C, UART)
- Run
i2cdetect -y 1to see if device appears on I2C bus - Try a different Grove cable
- Ensure Grove Base Hat is properly seated on Raspberry Pi GPIO pins
Hardware Issues
Raspberry Pi
Problem: Raspberry Pi won't boot
Symptoms: No display, no LED activity, or rainbow screen
Solution:
- Check power supply: Use official 5V 3A USB-C power supply for Pi 4
- SD card issues:
- Reformat SD card and reinstall Raspberry Pi OS
- Try a different SD card (use recommended brands)
- Ensure SD card is properly inserted
- Check HDMI connection: Try both HDMI ports on Pi 4, use HDMI port closest to power
Problem: Cannot SSH to Raspberry Pi
Symptoms: Connection refused or timeout
Solution:
- Enable SSH:
- When flashing SD card with Raspberry Pi Imager, configure SSH in advanced options
- Or create empty file named
ssh(no extension) in boot partition
- Find Pi's IP address:
- Check your router's connected devices
- Use
ping raspberrypi.local(if mDNS works) - Use network scanning tools like
nmapor Angry IP Scanner
- Check network:
- Ensure Pi is on same network as your computer
- Try ethernet connection instead of WiFi
- Verify username/password (default: username
pi, passwordraspberry)
Problem: Grove Base Hat not recognized
Symptoms: Sensors not working, I2C errors
Solution:
- Ensure Base Hat is properly seated on all GPIO pins
- Check for bent pins on Pi or Base Hat
- Enable I2C interface:
sudo raspi-config nonint do_i2c 0 sudo reboot - Verify I2C is working:
i2cdetect -y 1
Problem: Raspberry Pi running slow
Symptoms: Laggy UI, slow response
Solution:
- Check SD card speed (use Class 10 or better, or SSD via USB)
- Free up disk space:
df -hto check, delete unnecessary files - Reduce GPU memory in
raspi-configif not using camera/display heavily - Close unnecessary applications
- Consider upgrading to Pi 4 with more RAM if using Pi 3 or older
Wio Terminal
Problem: Wio Terminal screen stays blank
Symptoms: No display output after uploading code
Solution:
- Check if code initializes the display (TFT_eSPI library)
- Update Wio Terminal firmware from Seeed Wiki
- Add display initialization code:
#include <TFT_eSPI.h> TFT_eSPI tft; tft.begin(); tft.fillScreen(TFT_BLACK); - Try uploading example sketch from PlatformIO to test hardware
Problem: WiFi not working on Wio Terminal
Symptoms: Cannot connect to WiFi, network errors
Solution:
- Update WiFi firmware: Follow Wio Terminal WiFi firmware update guide
- Check WiFi credentials: Ensure SSID and password are correct
- WiFi band: Wio Terminal only supports 2.4GHz WiFi (not 5GHz)
- Signal strength: Move closer to router
- Router settings: Some enterprise/WPA-Enterprise networks may not work
Problem: Wio Terminal not recognized by computer
Symptoms: USB device not detected
Solution:
- Try different USB cable: Use data cable, not charge-only cable
- Enter bootloader mode: Slide power switch down twice quickly
- Blue LED should pulse, device appears as "Arduino" in Device Manager
- Install drivers (Windows):
- Download and install Seeed USB driver
- Try different USB port: Avoid USB hubs, use direct connection
- Update system USB drivers
Problem: Sensors not working on Wio Terminal
Symptoms: Grove sensors not reading data
Solution:
- Check Grove cable connections
- Verify you're using correct Grove port (left or right)
- Include correct libraries for sensor
- Check sensor power requirements
- Test sensor with example code from library
Virtual Device (CounterFit)
Problem: CounterFit app won't start
Error: Various Python errors when starting CounterFit
Solution:
- Ensure virtual environment is activated
- Install/reinstall CounterFit:
pip install CounterFit - Check port 5000 is not already in use:
- Windows:
netstat -ano | findstr :5000 - macOS/Linux:
lsof -i :5000
- Windows:
- Kill process using port 5000 or use different port:
counterfit --port 5001
Problem: Cannot connect to CounterFit from code
Error: Connection refused or timeout
Solution:
- Verify CounterFit is running: Open browser to
http://127.0.0.1:5000 - Check connection URL in code matches CounterFit address
- Ensure firewall isn't blocking connection
- Try restarting both CounterFit app and your code
Problem: Sensors not appearing in CounterFit
Symptoms: Created sensors don't show in CounterFit UI
Solution:
- Create sensors in CounterFit UI before running code
- Refresh browser page
- Check sensor type matches what code expects
- Clear browser cache
Connectivity Issues
WiFi Connection
Problem: Device can't connect to WiFi
Symptoms: Connection timeout, authentication failed
Solution:
- Check SSID and password: Verify credentials are correct
- WiFi band: Most IoT devices only support 2.4GHz (not 5GHz)
- Router settings:
- Disable AP isolation if enabled
- Use WPA2-PSK security (avoid WPA3, WEP, or open networks)
- Ensure DHCP is enabled
- Hidden networks: If SSID is hidden, you may need to explicitly configure it
- Signal strength: Move device closer to router
- Interference: Other devices, microwaves, or walls can interfere
Problem: WiFi connection drops frequently
Symptoms: Intermittent connectivity
Solution:
- Check router stability and consider reboot
- Update device firmware
- Use static IP instead of DHCP
- Reduce distance to router or add WiFi extender
- Check for interference from other devices
- Verify power supply is adequate (especially for Raspberry Pi)
Cloud Services
Problem: Cannot connect to Azure IoT Hub
Error: Authentication failed, connection refused
Solution:
- Verify credentials:
- Check connection string is correct
- Ensure no extra spaces or line breaks in connection string
- Check device registration: Device must be registered in IoT Hub
- Firewall/proxy: Ensure outbound MQTT (port 8883) or HTTPS (port 443) is allowed
- IoT Hub region: Ensure IoT Hub is running and not in different region causing latency
- Quota limits: Check if free tier limits are exceeded
- Test connection:
az iot hub device-identity show-connection-string --hub-name YourIoTHub --device-id YourDevice
Problem: Azure Functions not triggering
Symptoms: Messages sent but function doesn't execute
Solution:
- Check Function App is running (not stopped)
- Verify connection string in Function App settings
- Check function logs in Azure Portal
- Ensure Event Hub compatible endpoint is configured correctly
- Verify message format matches function expectations
- Check Function App service plan (consumption vs. dedicated)
MQTT
Problem: MQTT connection fails
Error: Connection refused, authentication failed
Solution:
- Broker address: Verify broker URL/IP is correct
- Port: Check port number (1883 for unencrypted, 8883 for TLS)
- Authentication: Verify username/password if required
- TLS/SSL: Ensure certificates are valid and trusted
- Firewall: Check port is not blocked
- Test with MQTT client: Use MQTT Explorer or mosquitto_pub/sub to test
Problem: MQTT messages not received
Symptoms: Messages published but not received by subscribers
Solution:
- Topic names: Verify subscriber topic matches publisher topic exactly
- QoS level: Try QoS 1 or 2 instead of 0
- Wildcards: Check topic wildcards are used correctly (
+for single level,#for multi-level) - Retained messages: Publisher can set retain flag to keep last message
- Connection timing: Ensure subscriber connects before messages are published
Sensor and Actuator Issues
Grove Sensors
Problem: Sensor returns incorrect values
Symptoms: Readings are 0, -1, or nonsensical values
Solution:
- Check connections: Ensure sensor is properly connected
- Correct port: Verify sensor is in correct port type:
- Analog sensors → Analog ports (A0, A2, A4)
- Digital sensors → Digital ports (D5, D16, D18, etc.)
- I2C sensors → I2C ports
- Calibration: Some sensors need calibration (soil moisture, light)
- Power cycle: Disconnect and reconnect sensor
- Sensor datasheet: Check sensor specifications and requirements
Problem: Capacitive soil moisture sensor always reads wet
Symptoms: Sensor reads high moisture even when dry
Solution:
- Calibration needed: Soil sensors require calibration:
- Read value in air (dry baseline)
- Read value in water (wet baseline)
- Map readings between these values
- Check sensor coating: Moisture sensors can degrade if coating damaged
- Placement: Ensure sensor is fully inserted in soil
Problem: Temperature/humidity sensor readings incorrect
Symptoms: DHT11/DHT22 shows wrong temperature or humidity
Solution:
- Sensor placement: Avoid direct sunlight, heat sources, or airflow
- Warm-up time: Allow sensor 2 seconds after power-on before reading
- Read frequency: DHT sensors need time between reads (at least 2 seconds)
- Check for condensation: Can affect readings
- Sensor quality: DHT11 is less accurate than DHT22
Camera
Problem: Camera not detected on Raspberry Pi
Error: mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera'
Solution:
- Enable camera interface:
Go to Interface Options → Camera → Enablesudo raspi-config - Check ribbon cable: Ensure camera cable is properly inserted
- Blue side faces USB ports on Pi Zero
- Blue side faces away from USB ports on Pi 4
- Update firmware:
sudo apt update sudo apt full-upgrade sudo reboot - Test camera:
raspistill -o test.jpg
Problem: Camera images are poor quality
Symptoms: Blurry, dark, or washed out images
Solution:
- Focus: Remove protective film from lens, adjust focus if adjustable
- Lighting: Ensure adequate lighting
- Camera settings: Adjust exposure, ISO, white balance in code
- Stability: Keep camera steady, use tripod if needed
- Resolution: Don't exceed camera's maximum resolution
Microphone and Speaker
Problem: No audio input/output
Symptoms: Microphone not recording, speaker not playing
Solution:
- Check connections: Verify audio devices are properly connected
- Test hardware:
- Speaker:
speaker-test -t wav -c 2 - Microphone:
arecord -lto list,arecord test.wavto record
- Speaker:
- Volume settings: Check and adjust volume:
alsamixer - Select audio device: Specify correct audio device in code
- Driver issues: Update ALSA or reinstall audio drivers
Problem: ReSpeaker hat not working
Symptoms: Audio device not detected
Solution:
- Install drivers:
git clone https://github.com/HinTak/seeed-voicecard cd seeed-voicecard sudo ./install.sh sudo reboot - Check installation:
arecord -lshould list ReSpeaker - Update firmware: Some Pi OS versions need driver updates
- Check seating: Ensure hat is properly connected to GPIO pins
Development Environment Issues
VS Code
Problem: Terminal not activating virtual environment automatically
Symptoms: Terminal opens but venv not activated
Solution:
- Set Python interpreter: Command Palette → "Python: Select Interpreter" → Choose venv
- Restart VS Code after selecting interpreter
- Check settings: In
settings.json, add:"python.terminal.activateEnvironment": true
Problem: Code not running on device
Symptoms: Code runs but nothing happens on device
Solution:
- Verify code is saved (check dot on file tab)
- Check which Python is running:
which pythonorwhere python - For Wio Terminal: Ensure code is uploaded via PlatformIO (click upload button)
- For Raspberry Pi: SSH into Pi and run code there
- Check output window for errors
Problem: IntelliSense not showing library functions
Symptoms: No autocomplete for imported modules
Solution:
- Ensure library is installed in current environment
- Reload VS Code window
- Check Python interpreter is correct
- Install type stubs if available:
pip install types-<library-name>
Python Virtual Environments
Problem: Cannot create virtual environment
Error: The virtual environment was not created successfully
Solution:
- Install venv module:
- Ubuntu/Debian:
sudo apt install python3-venv - macOS: Should be included with Python
- Windows: Reinstall Python with all components
- Ubuntu/Debian:
- Check Python installation: Verify Python is properly installed
- Use full path: Try
python3 -m venv .venvwith explicit python3 call
Problem: Packages installed in wrong location
Symptoms: Import error after installing package
Solution:
- Verify venv is activated: Command prompt should show
(.venv) - Check pip location:
which pipshould point to.venv/bin/pip - Reinstall in venv: Activate venv, then
pip install <package> - Don't use sudo with pip in virtual environment
Problem: Virtual environment not portable
Symptoms: Venv doesn't work after moving or on different computer
Solution:
- Don't move venvs: Delete and recreate in new location
- Use requirements.txt:
pip freeze > requirements.txt pip install -r requirements.txt - Recreate venv:
python3 -m venv .venv source .venv/bin/activate # or activate.bat on Windows pip install -r requirements.txt
Dependencies
Problem: Package installation fails
Error: Various pip errors during installation
Solution:
- Update pip:
pip install --upgrade pip - Install build tools:
- Ubuntu/Debian:
sudo apt install build-essential python3-dev - macOS:
xcode-select --install - Windows: Install Visual Studio Build Tools
- Ubuntu/Debian:
- Check internet connection
- Try different package index:
pip install --index-url https://pypi.org/simple/ <package> - Install specific version:
pip install <package>==<version>
Problem: Dependency conflicts
Error: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed
Solution:
- Use fresh virtual environment for each project
- Update packages:
pip install --upgrade <package> - Check requirements: Use
pip checkto find conflicts - Install compatible versions: Specify version ranges in requirements.txt
Performance Issues
Problem: Code runs slowly
Symptoms: Delays, timeouts, unresponsive behavior
Solution:
- Reduce sensor read frequency: Don't read sensors too often
- Optimize loops: Avoid busy-waiting, use sleep() or delays
- Memory issues:
- Close unnecessary applications
- Free up storage space
- Monitor with
toporhtopon Pi
- SD card speed: Use faster SD card or SSD for Raspberry Pi
- Network delays: Use async operations for network calls
Problem: Out of memory errors
Error: MemoryError or system freezing
Solution:
- For Raspberry Pi:
- Close unnecessary applications
- Increase swap space
- Use lighter OS (Lite version)
- Upgrade RAM (Pi 4 has 2/4/8GB options)
- For Wio Terminal:
- Reduce buffer sizes
- Use smaller images
- Optimize string usage
- Check for memory leaks (unreleased memory)
Problem: Data loss or corruption
Symptoms: Missing messages, corrupted files
Solution:
- SD card issues:
- Use quality SD cards (avoid cheap/counterfeit)
- Regular backups
- Clean shutdown (don't pull power)
- Buffer overflow: Increase buffer sizes in code
- Network reliability: Implement retry logic and error handling
- Quality of Service: Use MQTT QoS 1 or 2 for important messages
Common Error Messages
ModuleNotFoundError: No module named 'X'
Cause: Package not installed or virtual environment not activated
Solution:
pip install X
Ensure virtual environment is activated first.
Permission denied on Linux/macOS
Cause: Need elevated permissions or file permissions issue
Solution:
- For system operations: Use
sudo - For pip: DON'T use sudo with venv, activate venv first
- For serial port: Add user to dialout group:
sudo usermod -a -G dialout $USER, then logout/login
OSError: [Errno 98] Address already in use
Cause: Port is already being used by another process
Solution:
- Find process using port:
lsof -i :<port>ornetstat -ano | findstr :<port> - Kill process or use different port in your code
SSL: CERTIFICATE_VERIFY_FAILED
Cause: SSL certificate validation failing
Solution:
- Update certificates:
pip install --upgrade certifi - Check system time is correct:
date - For development only (not production): Disable verification in code
IndentationError: unexpected indent
Cause: Python indentation issues (mixing tabs/spaces)
Solution:
- Use consistent indentation (4 spaces is Python standard)
- Configure editor to use spaces instead of tabs
- VS Code: Set
"editor.insertSpaces": trueand"editor.tabSize": 4
UnicodeDecodeError or UnicodeEncodeError
Cause: Character encoding issues
Solution:
# When reading files
with open('file.txt', 'r', encoding='utf-8') as f:
content = f.read()
# When writing files
with open('file.txt', 'w', encoding='utf-8') as f:
f.write(content)
Getting Help
If you've tried these troubleshooting steps and still have issues:
1. Check Existing Resources
- Documentation: Review the README and lesson instructions
- Hardware guides: Check hardware.md for hardware-specific info
- Seeed Studio Wiki: Seeed Studio Wiki for Grove components
2. Search for Similar Issues
- GitHub Issues: Search existing issues
- Stack Overflow: Search for error messages
- Device forums: Check Raspberry Pi forums or Arduino forums
3. Create a GitHub Issue
If you can't find a solution:
- Go to GitHub Issues
- Click "New Issue"
- Provide:
- Clear description of the problem
- Steps to reproduce
- Error messages (full text)
- Hardware/software versions
- What you've already tried
- Screenshots if relevant
4. Join the Community
- Discord: Microsoft Foundry Discord
- Microsoft Learn: Microsoft Learn IoT
5. Provide Good Bug Reports
A good bug report includes:
- Environment: OS, Python version, hardware used
- Steps to reproduce: Exact steps that cause the issue
- Expected behavior: What should happen
- Actual behavior: What actually happens
- Error messages: Complete error text, not screenshots
- Code: Minimal code example that reproduces the issue
Tips for Prevention
General Best Practices
- Keep backups: Regular backups of working SD cards/code
- Document changes: Note what works in comments
- Version control: Use git to track code changes
- Test incrementally: Test small changes before combining
- Read error messages: They often tell you exactly what's wrong
- Update regularly: Keep software/firmware up to date
- Use quality components: Avoid cheap cables/power supplies
- Stable power: Use appropriate power supply (especially Pi)
Development Workflow
- Start simple: Begin with example code that works
- One change at a time: Easier to find what breaks
- Test frequently: Catch issues early
- Keep it clean: Organize files and code logically
- Comment code: Future you will appreciate it
This troubleshooting guide is maintained by the community. If you find a solution to a problem not listed here, please consider contributing to help others!