FabioBatSilva / TinyWheel

TinyWheel
GNU General Public License v3.0
10 stars 1 forks source link
arduino ble bluetooth cpp wheel

TinyWheel

PlatformIO/Development

NOTICE: THIS IS UNDER ACTIVE DEVELOPMENT, USE AT YOUR OWN RISK

image

The TinyWheel allows you to check your battery, speed and some other stats from your wheel using a ESP32 device.

Supported Devices

Setup

First of all, install PlatformIO with your favourite IDE (i.e. VSCode). Follow this instructions.

Clone the repo

git clone https://github.com/FabioBatSilva/TinyWheel.git

Open cloned folder with your PlatformIO IDE (in the example, with VSCode)

cd /path/to/TinyWheel

code .

The first step to flash the TinyWheel firmware is to configure your wheel.

Copy the file .env.dist to .env

cp .env.dist .env

And update the variable WHEEL_DEVICE_TYPE according to the type of wheel you have.

To validate that your instalation is correct run the following command:

platformio run

  # Environment    Status    Duration
  # -------------  --------  ------------
  # tdisplay       SUCCESS   00:00:54.047
  # twristband     SUCCESS   00:00:58.448

Generate the key

Before you can flash TinyWheel to your device you need to generate a key for your wheel.

This key is used to unlock your wheel, without this TinyWheel won't be able to connect to your wheel.

Wheel scanner

The first step to generate the key is to retreive some information from your wheel. While running on scanner mode the TinyWheel will look for your wheel and retreive the name, bluetooth address and the secret that you need to generate the key.

Run the following command to flash TinyWheel in scanner mode

APP=APP_SCANNER platformio run -t upload -e twristband

After the firmware is flashed in APP_SCANNER mode open the serial monitor to retreive the the following values. WHEEL_DEVICE_NAME WHEEL_DEVICE_ADDRESS WHEEL_DEVICE_API_KEY

platformio device monitor --baud 115200

  # Found 1 wheel
  # // ...
  # WHEEL_DEVICE_NAME=ow123456
  # WHEEL_DEVICE_ADDRESS=0a:0b:0c:0d:0e:0f
  # WHEEL_DEVICE_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  # Done...
  # Going to sleep

Copy the values from your serial monitor and update .env accordingly.

Wheel activation

The last step to generate the key is using the activation API from FM.

Run the following command invoke the API.

python activation.py

  # // ..
  #
  # Are you sure : [y/n]y
  #
  # // ..
  #
  # WHEEL_DEVICE_TYPE    : pint
  # WHEEL_DEVICE_NAME    : ow123456
  # WHEEL_DEVICE_API_KEY : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  # WHEEL_DEVICE_KEY     : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Now you have the key and you can flash the TinyWheel firmware to your device. Update the .env file with the WHEEL_DEVICE_KEY you got from activation.py

Flash the firmware

Now that you have a .env configured with WHEEL_DEVICE_KEY and all the other parameters you are ready to flash.

Run the following command to flash the TinyWheel firmware

platformio run -t upload -e twristband

  # Wrote 1035376 bytes (580781 compressed) at 0x00010000 in 14.5 seconds (effective 572.6 kbit/s)...
  # Hash of data verified.

  # Leaving...
  # Hard resetting via RTS pin...
  # ============= [SUCCESS] Took 25.74 seconds =============

  # Environment    Status    Duration
  # -------------  --------  ------------
  # tdisplay       IGNORED
  # twristband     SUCCESS   00:00:25.742

If everyting was sucessfull the project will compile and upload to the wristband.

ToDo list