- Factory reset the device
- Install UF2 bootloader
- Follow QT Py ESP32-S3 CircuitPython Guide
- Use Adafruit Web Serial ESPTool for flashing
Copy all files from the microcontroller/ directory to the device, excluding the setup_circuitpython/ folder.
microcontroller/
├── code.py # Main program file
├── ble_json_service.py # BLE service implementation
├── config.json # User configuration file
├── default_config.json # Default configuration file
└── lib/ # Required libraries
├── adafruit_ble/
├── adafruit_bus_device/
├── adafruit_register/
├── adafruit_pixelbuf.mpy
├── cedargrove_nau7802.mpy
└── neopixel.mpy
To monitor the serial output while usb-c connected:
- Find the device ID:
ls /dev/tty.*- Connect to the serial console:
screen [device_id]For more information on using the serial console, see the CircuitPython Advanced Serial Console Guide
The onboard NeoPixel LED indicates the device's current status:
- Red: Error state or initializing
- Yellow: Waiting for BLE connection
- Green: Connected to a BLE device
The device provides two sensor measurements:
- Weight Sensor: Uses the NAU7802 load cell amplifier to measure weight. The raw values are averaged over multiple samples (configurable) and scaled according to the configuration.
- Voltage Sensor: Reads analog voltage from pin A2, converts it to a percentage based on configured offset and scale factors.
The device advertises a custom BLE service with the following characteristics:
-
Sensors Characteristic (Read-only)
- UUID: 528ff74b-fdb8-444c-9c64-3dd5da4135ae
- Provides real-time sensor data in JSON format:
{ "weight": <value>, "voltage": "<percentage>%" }
-
Settings Characteristic (Read/Write)
- UUID: e077bdec-f18b-4944-9e9e-8b3a815162b4
- Allows reading and updating device settings
The device uses a configuration file (config.json) with fallback to default_config.json. Configuration options include:
device_name: BLE advertisement nameweight_samples: Number of samples to average for weight measurementweight_scale_factor: Scaling factor for weight measurementsvoltage: Configuration for voltage sensor:offset: Voltage reading offsetscale_factor: Voltage scaling factor