This project contains MicroPython firmware for the ESP32-based SensePlus device, featuring LED control patterns and sensor abstractions.
- ESP32 with MicroPython: Ensure your ESP32 has MicroPython firmware installed
- Python Tools: Install required tools on your computer:
pip install mpremote rshell
- ESP32 Development Board connected via USB
- Built-in LED on GPIO 2 (most ESP32 boards)
- USB Port:
/dev/tty.usbserial-0001(update indeploy.pyif different)
senseplus_firmware_micro_python/
├── main.py # Main application entry point
├── helper.py # LED pattern helper functions
├── deploy.py # Deployment script for ESP32
├── abstractions/ # Hardware abstraction modules
├── micropythonrc # MicroPython configuration
└── README.md # This file
The deploy.py script provides an easy way to manage your ESP32:
# Interactive menu
python deploy.py
# Command line usage
python deploy.py deploy # Upload files
python deploy.py run # Run main.py
python deploy.py all # Deploy and run
python deploy.py list # List files on ESP32
python deploy.py clean # Remove test files
python deploy.py reset # Reset ESP32# Deploy files
mpremote connect /dev/tty.usbserial-0001 cp main.py :
mpremote connect /dev/tty.usbserial-0001 cp helper.py :
# Run the program
mpremote connect /dev/tty.usbserial-0001 run main.py
# List files
mpremote connect /dev/tty.usbserial-0001 ls# Connect to ESP32
rshell -p /dev/tty.usbserial-0001 -b 115200
# Copy files
cp main.py /pyboard/
cp helper.py /pyboard/
# Exit rshell and run with mpremote
mpremote connect /dev/tty.usbserial-0001 run main.pyThe project includes several LED patterns in helper.py:
-
blink_led(led_pin, count=10, delay=0.5)- Basic on/off blinking
- Configurable count and delay
-
fast_blink(led_pin, count=20, delay=0.1)- Rapid blinking pattern
- Good for status indicators
-
morse_sos(led_pin)- SOS morse code pattern (... --- ...)
- Emergency signal demonstration
-
breathing_led(led_pin, cycles=3)- Smooth PWM fade in/out effect
- Falls back to blinking if PWM unavailable
-
test_all_patterns(led_pin)- Sequential test of all patterns
- Great for demonstrations
import machine
from helper import blink_led, morse_sos, breathing_led
# Initialize LED
led = machine.Pin(2, machine.Pin.OUT)
# Basic blinking
blink_led(led, count=5, delay=0.3)
# SOS signal
morse_sos(led)
# Breathing effect
breathing_led(led, cycles=2)If your ESP32 uses a different GPIO for the built-in LED, update main.py:
# Change from GPIO 2 to your LED pin
led = machine.Pin(YOUR_GPIO_NUMBER, machine.Pin.OUT)Add new functions to helper.py:
def custom_pattern(led_pin):
"""Your custom LED pattern"""
# Implementation here
passThen import and use in main.py:
from helper import custom_pattern
# ... in main function ...
custom_pattern(led)-
"ImportError: no module named 'helper'"
- Ensure
helper.pyis uploaded to ESP32 - Use deployment script:
python deploy.py deploy
- Ensure
-
"mpremote: could not read file"
- File path might be incorrect
- Use relative filenames:
main.pynot/pyboard/main.py
-
"ImportError: no module named 'pycom'"
- You're using PyCom-specific code on standard ESP32
- This project uses standard MicroPython (no pycom library needed)
-
Connection issues
- Check USB cable and port
- Verify ESP32 has MicroPython firmware
- Update port in
deploy.pyif needed - Try different baud rate:
rshell -p /dev/tty.usbserial-0001 -b 921600
-
Check connection:
python deploy.py check
-
List files on ESP32:
mpremote connect /dev/tty.usbserial-0001 ls
-
Test REPL access:
mpremote connect /dev/tty.usbserial-0001 repl # Press Ctrl+D to exit
- Add Sensors: Implement sensor reading in
abstractions/folder - Networking: Add WiFi connectivity for IoT features
- Data Logging: Implement sensor data collection
- Web Interface: Create web-based control panel