Skip to content

lemio/esp32_ble_wedo

Repository files navigation

esp32_ble_wedo

A library to control LEGO wedo with the ESP32 through Bluetooth low energy

Version 2.0.0 - Now using NimBLE-Arduino! 🎉

This library has been completely refactored to use the modern NimBLE-Arduino library for improved performance, stability, and reduced memory usage. The public API remains 100% compatible with previous versions.

Requirements

  • ESP32 board
  • NimBLE-Arduino library (automatically installed via Arduino Library Manager or add to platformio.ini)

Installation

Arduino IDE

  1. Install NimBLE-Arduino from Library Manager (search for "NimBLE-Arduino" by h2zero)
  2. Install this library from Library Manager or download from GitHub

PlatformIO

Add to your platformio.ini:

lib_deps = 
    h2zero/NimBLE-Arduino @ ^1.4.0
    lemio/esp32_ble_wedo @ ^2.0.0

API Reference

myWedo(char* name)

Connect to a WEDO2.0 that is advertising with the defined name.

myWedo.connect()

Start connecting to the WEDO2.0 (do this after the wifi is initialized, if you're using wifi)

myWedo.writeMotor(uint8_t wedo_port,int wedo_speed)

Writes a certain speed (-100,100) to the specified port.

If you look in front of the WEDO ports; the back of the wedo, this is the port overview

 _________________
|  port2 | port1  |
|________|________|
|                 |
|                 |
|_________________|

myWedo.writeIndexColor(uint8_t color)

Sets the color of the RGB led on the wedo, you can choose from the list below

#define LEGO_COLOR_BLACK 0
#define LEGO_COLOR_PINK 1
#define LEGO_COLOR_PURPLE 2
#define LEGO_COLOR_BLUE 3
#define LEGO_COLOR_CYAN 4
#define LEGO_COLOR_LIGHTGREEN 5
#define LEGO_COLOR_GREEN 6
#define LEGO_COLOR_YELLOW 7
#define LEGO_COLOR_ORANGE 8
#define LEGO_COLOR_RED 9
#define LEGO_COLOR_WHITE 10

myWedo.writeSound(unsigned int frequency, unsigned int length)

Let's the piezo in the WEDO make some noise, I'm not sure if the freqency and length are set correctly

myWedo.writeOutputCommand(uint8_t* command)

Sends a direct output command to the WEDO2.0

Examples

  • wifi_control.ino (it let's you set the direction of the motor connected to the wedo).
  • button_motor.ino (it let's you controll the motor with the build in button on the ESP). (Nice start if you want to make a remote for you WEDO creation)

Prior art

About

A library to control LEGO wedo 2.0 with the ESP32 through Bluetooth low energy

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published