Build a Key for the Copenhagen Wheel With an ESP32 Microcontroller

by slviajero in Circuits > Reuse

718 Views, 2 Favorites, 0 Comments

Build a Key for the Copenhagen Wheel With an ESP32 Microcontroller

IMG_1294.jpeg
IMG_8741.png

The Copenhagen Wheel was a big thing when it came out in 2017. Crowdfunded, the stylish red wheel came out as a solution for urban mobility. An existing bike could be reused as an electric city bike. The users smartphone was the control panel and the battery was in the wheel. Putting the wheel into a bike was done quickly.

I liked the sustainability of the concept. An existing bike would be used to build something new. That's why I contributed early in the crows funding campaign.

In the highly competitive market of electric bikes, the Copenhagen wheel never became popular. It was discontinued. Then, by the end of 2023, the manufacturer Superpedestrian went bankrupt and the app backend was switched off. All users where locked out of their wheels as the app was needed to start the wheel.

This instructable is how to build a key to start the wheel again with an ESP32 microcontroller board. The software is not mine. Very knowledgeable people build the code. Big kudos to them. I just took the ESP32 code and tried it out.

The intention of this text is a step by step tutorial how to implement the key for people with a bit of Arduino know how. I will write more software for the wheel on the basis of the existing code. This will be published later.

Remark: more details on the hardware side of the project can be found in the wiki of the project.

Supplies

3AC32C19-1E99-4E9F-8F79-62E1FA370DEA_1_201_a.jpeg
1AFA75FB-961B-4A48-B8FC-C54ED5BE1AAE_1_105_c.jpeg

To build this you need of course a bicycle with a Copenhagen wheel.

For the key you need a ESP32 microcontroller board. I started with the ESP32 Wemos D1 board. It is rather big for a key but I had it laying around. Any other board will do as well. Later in this instructable there will be an idea for a small form factor build.

You need the Arduino IDE. I use version 1.8.x here which is outdated. Still, it is so common and so many people have it, that it is still standard for Arduino projects. The IDE 2.x works fine as well. See here: Software | Arduino

The ESP32 controller needs the current ESP32 core. This can be downloaded from the Expressif website. There is also a detailed instruction on how to download this: Installing - - — Arduino ESP32 latest documentation (espressif.com)

Then, you also need the sketch slviajero/cphw-esp32 (github.com) with the key software.

A power bar and a cable can be used as power supply.

Get the Arduino and ESP32 Software

Basis for using Arduino type microcontrollers is the Arduino IDE. There is an old 1.8.19 version with a simple user interface and the modern 2.x version. Both can be downloaded from the official Arduino website.

Go to Software | Arduino and download the version for your OS. Windows, Mac and Linux are supported.

After this you will need the ESP32 core. In the past it was not included in the Arduino distribution. As Arduino now also supports ESP32 boards, this might change in the future. If you want to use one of the many ESP32 boards on the market, you will need the core anyway.

Follow the instructions in Installing - - — Arduino ESP32 latest documentation (espressif.com)

In the 2.x IDE the ESP32 core can be installed from the IDE directly. Select the core in the board menu and tell the IDE to install.

After a successful install, you should see the many ESP32 board in the ESP32 boards menu in the IDE.

Some platforms still need a COM: or Serial driver install. You might need a UART driver like this CP210x USB to UART Bridge VCP Drivers - Silicon Labs (silabs.com).

Get the Key Software

Once you have a working IDE, you can import the sketch. Currently it is just one file in the repo

slviajero/cphw-esp32 (github.com)

Download BLE_client.ino and place it in a folder BLE_client. Then open the IDE and open this folder.

You should be able to compile the sketch now. If this works, connect the board, select the right port and upload the sketch.

There are a few pitfall here. The sketch is pretty big. It doesn't fit into a standard flash layout of the controller. You might need to select "No OTA" in the Partition Scheme menu of the Arduino IDE. If you happen to have ArduinoBLE installed in your IDE, the sketch will not compile because the tool chain wants to use this library. Deinstall ArduinoBLE to make sure the ESP32 builtin BLE stack is used.

In the serial monitor of the Arduino IDE you should the the status messages of the sketch if you have set the board rate correctly to 115000 baud.

Find Your Wheel Characteristic

Once the sketch is uploaded, start the wheel and then reset the controller. It should report a connection to the wheel and then you get a string called wheel characteristic.

The wheel characteristic is a number like 00403160970202 or J144800550. It identifies your wheel.

Look into the file passcodes.csv in the repo and search for your wheel. You will find lines like this

00403160970202,E3EFD15276F93B7ECE0C532558214FAF

The code behind the comma is the passcode of your wheel.

Open the sketch again and modify these lines

// REPLACE THIS WITH YOUR PASSCODE
#define PASSCODE "101112131415161718191A1B1C1D1E1F"

adding your passcode.

Then upload the software again on the controller and reset it.

Use the Key

FMVIDI2LX0ETNHE.jpg

Now you have a key that unlocks your wheel. I use a power bar to start the controller.

Power it up, bring it close to the wheel and switch it on. The wheel should start now with the default run mode. Maybe a reset of the board is needed sometimes.

The board will blink three times very briefly with the built in LED if the connection is successful. A failed connection is one brief blink.

Once the wheel is stated you can power off the controller and enjoy riding. As long as the wheel moves, the key is not needed any more.

Making the Key Smaller

IMG_8740.png
IMG_8738.png
IMG_8739.png
IMG_8737.png

Running around with a power bar and an Arduino UNO size microcontroller board plus cable is not something for everyday life. I build a quick and dirty version of a smaller key.

Basis board is the Wemos Lolin32 lite board (currently available at Alibaba here: https://de.aliexpress.com/item/4000038780903.html). It is small and it has a plug for a standard lithium ion battery. The charging logic is on the board. Select Wemos Lolin32 Lite in the Arduino IDE as board type. If there are upload problems, reduce the upload baud rate.

Make sure to get a matching battery with the right polarity. Plugs are standardised.

In addition you need a small switch. The switch is placed between the battery and the controller. One has to cut one of the leads of the battery to put the switch into the circuit.

Once switched on the controller board boots, builds up the Bluetooth connection and sends the passcode. It blinks three times and you can switch the key off again. Make sure to keep the switch on if you charge the battery. This is done by plugging in the USB cable. The energy consumption of the board is very low, you will probably go for weeks without charging.

If you do not want to spend the money for the lithium ion battery, a normal 3V CR2032 cell will also do. In this case you need a battery holder which is connected directly to the boards VIN and GND pins.

I put everything in a small box used for screws and parts. One hole is for the charging plug another for the switch. Any small box will do. There are some with a builtin switch in electronics stores.

What's Next

Currently the app is very basic. I am working on a better app with a display and buttons to change the wheel run mode.

I also work on a master key that has all the passcodes uploaded. This way the step with finding the characteristic will become obsolete.

Wheel users, join us in our facebook group Copenhagen Wheel Users | Facebook