mbed: Bike proximity lock

We have introduced how to use an accelerometer on mbed. More than that, we could build a simple proximity lock for a bike. There are two simple functions – detecting and alerting if anyone touches the bike, and locking it when you are leaving it. Let us look at it.

In the previous tutorial,  we got familiar with how to build a motion sensor on the mbed platform. Not only raw measurement data, the sensor kit comes with advanced functions, too. We can use motion detection to indicate movements, then create a light to alert or a sound like a siren. We have a quick demo::

So, here we go.

Prepare

In this example, we will build a simple proximity lock. The hardware preparation is the same as with the previous mbed tutorial, two kits – Motion Sensor Kit and DIPDAP debug probe. If you are not familiar with this, read me!motion-sensor-kitmtc04s-mbed-connected

Build

Open the repository page of the proximity example. Click on Import into Compiler.mbed-proximity-repo

mbed will open the Compiler page in another browser tab and a dialog will pop up. Select Import. You will then see the source code.mbed-proximity-compiler

Everything is good to go, so click on Compile. It will start to compile. When it is done, the browser will download a .hex file automatically. You can save it anywhere you want. It is the firmware binary which we will run on MtConnect04S.

If you are familiar with Nordic SDK, the .hex file downloaded is both application and SoftDevice.

Run

Drag the .hex file to the USB Drive MTCONNEC04S. The DIPDAP will program MtConnect04S. When it is done, the drive will be removed automatically, and you may see an unexpected removing drive message. Then push the button on DIPDAP, or replug the USB to re-power up the kit.

Motion Alert

When the kit just initializes or powers up, it shows a RED light. If you shake or move the kit, it will alert you by blinking.

Proximity Lock

It is implemented by a simple BLE connection. When MtConnect04S is connected to a smartphone nearby, it will enter the unlock mode and disable the motion alert. Use the BLE app on your smartphone, e.g. nRF Connect for Android or LightBlue Explorer on iOS to connect MtConnect04S. When you leave the bike, it will enable the motion alert. mbed-bike-proximity-lock

This tutorial is applicable with
 ✅MtConnect03
 ✅MtConnect04
 ✅MtConnect04S

Please feel free to contact us, if you need further information