An open API service indexing awesome lists of open source software.

https://github.com/inductivekickback/hallows

Lego EV3 candy dispenser with a BLE remote control
https://github.com/inductivekickback/hallows

Last synced: 5 months ago
JSON representation

Lego EV3 candy dispenser with a BLE remote control

Awesome Lists containing this project

README

          

The release of the excellent MicroPython tooling for the Lego Mindstorms EV3 was clearly the peak of the evolution of one of my favorite toys, followed a few years later by Lego discontuining the line completely. Along with a Visual Studio Code plugin that allows for interactive debugging the brick also gained proper support for UART communications. This project demonstrates a relatively simple way to expand the capabilities of EV3 using the popular Nordic nRF52840 SoC.


The nRF52840 dongle is inexpensive, breadboard-friendly, and its onboard regulator can run from the ~5V that is supplied to EV3 sensor ports. The nRF52840 will convert the "VBUS" voltage to 1.8V by default (max 3.3V) so a level shifter is still required to translate between the Lego and Nordic serial ports. I keep a few of these little Sparkfun boards for situations like this:





The WHITE wire from the EV3 is not used. Tying the RED and BLACK wires together forms GND. Then the 5V from the EV3 (GREEN wire) is fed into the dongle's "VBUS" pin and the the output from the dongle's "VDD OUT" is used to run the nRF52840 and its peripherals. The level shifter translates the UART RX (BLUE wire) and TX (YELLOW wire) between the two devices.


Image

### BLE Interface

A simple BLE service and client are used to exchange data between a remote control (central) and a candy machine (peripheral). The remote sends a single ASCII byte, ['1', '2', '3', '4'], to select the candy to be dispensed.

## UART interface to EV3

The nRF52840 communicates with the EV3 via two UART pins, through the level shifter, using 115200 8n1 baud rate.

Serialized messages are received by the EV3 over the UART:
- Messages have a fixed len of one byte.
- All messages start with a byte that has the leading bit set.

```
DIRECTION: DD, where command is 10 and response is 11
OPCODE: DDXX
IMMEDIATE: YYYY

OPCODES:
DD00 YYYY STATUS, where YYYY:
0000 - SYNC command, aka keep alive
DD01 YYYY DISPENSE, where YYYY:
[0, 3] - Dispenser index
```