Skip to content

quentingit/IoT-xiaomiM365

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xiaomi M365 SecureBOX

Introduction

Turn signal and blind spot detection for Xiaomi M365

Hardware requirements

  • Wemos D1 Mini (ESP8266, Arduino-compatible layout, wifi, 80/160Mhz, 4Mb flash)

  • Led strip composed of 14 leds (5V)

  • Sonar HC-SR04 or DYP-ME007V1 (5V)

  • The Android application, used to control remotly the electric scooter

The application connect to the Xiaomi M365 with the bluetooth protocol.
This allow the Wemos (the web server) to retreive the speed of the electric scooter.
Here is a screenshot with the interface with the blinking controls, the electric scooter battery and the speed in real time :

Software requirements

Arduino IDE with ESP8266 platform installed

If you use windows / OSx you will probably need drivers: Wemos Driver

Library

  • Adafruit_NeoPixel (for the leds)
  • ESP8266WiFi (for the Wifi)
  • QuickMedianLib (for the median filter)

External library

Android app library

Links usefuls for the androidapp:

How does it work ?

The electric scooter Xiaomi M365 have a bluetooth connection that can be used to get some informations like the actual speed, the battery. This is sent to the android application.
The Wemos is connected to the phone wifi hotspot, and so the can connect it via the android application from a webview. The android application is a bridge from the bluetooth to the web interface.

Wiring

Firstly, the Arduino card connect on a WiFi network. Modify the SSID and Password at the top of the code.
Secondly, use the diagram bellow the connect the sonar (enabling blind spot detection) and the led strip (enabling turn signal and warning signal)

Conneciton schema You can found the original file in ressources/Connection.fzz

Issues

The sonar HC-SR04 / DYP-ME007V1 filtering


While using the sonar HC-SR04 or DYP-ME007V1 we had problems with the echo signal. The original signal had random peaks (green signal on the picture bellow), like noise. We do not want this peaks as it is generating a bad blind spot detection randomly, even when we put a condition at 120CM or less to engage the blind spot signal.

To solve this problem, we put 2 additionnal signals :
-The median of the 15 last values of the original signal (blue)
-The moving average of the 15 last values of the original signal (red)

Problem sonar


As we can see on the picture above, an array of 15 values is not enought for making the signal flat and removing the noise we do not want. Let's try with 30 values :

Problem sonar 2


While trying to simulate an obstacle, we saw that it was slow to detect the signal, almost 2/3 of the real signal (green) is lost because of the median filter if we use it.
We have been searching the perfect value and we have found that 20 is a good value :

Problem sonar 3


Both the moving average and the median are removing most of the peaks that we do not want here. As the median is more "flat", we used this signal to solve the problem.

Building the SecureBox

Video of the prototype

Click here to see the video

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published