Skip to main content


Micropython BLE and ESP32 - SwitchBot (Part 1)

SwitchBot is a device which allows a non-internet-connected device to be automated. It has a mechanical arm that can switch on or a device. At my home, I have a few remote controls that operate on weird frequencies. An example is one of my ceiling fan which operates a 300MHz remote. In order to switch on/off the fan, I have stuck a SwitchBot to the remote.

The Micropython ESP32 BLE feature has come to a stable state but the documentation is still sparse. There is a link to the Micropython APIs doc which describes the APIs and the different roles for BLE devices and the examples can be found here
I have been trying the BLE Central Role to build an interesting project to control the smart home devices. For part 1 of the series of blogpost, I shall start with SwitchBot.
I was happy for a short while and then realised that it will be better for me to switch on/off using the remote than to use a roundabout method to control my fan. I wanted to control the fan using my Openhab setup as part …
Recent posts

Post-training Quantization for Edge TPU

In Tensorflow website, there is quite a bit of explanation for post-training quantization but there is not much on transfer learning. The sample shown on Coral website is using Tensorflow 1.x and requires to execute the transfer learning inside a docker.

In this blog post, I am going to demonstrate on how to perform post-training quantization using Tensorflow 2.0 for Mobilenet V1 and V2. All the steps can be performed on Colab notebook (thus making use of free GPU from Google, Thank you Google!!!). The steps are almost the same for both versions except at the base model I have changed the model. The tflite model is then converted to Edge TPU tflite model which can be used for realtime inferencing.

For both the models, I am using the flower dataset to perform the transfer learning. Readers can use this as a base for another class of classification. In the future blog post, I may try more advanced models such as Inception, Resnet etc. A lot depends on the Edge TPU compiler because the c…

SiPeed AI at the Edge

Edge AI looks like going to be the next big things. In this blog post, I am going to introduce a very cheap and yet power AI chip based on Kendryte K210. K210 is based on open source RISC-V instructions set. According to WikipediaRISC-V started in 2010 and in the recent 2 years, actual chips are produced with prototyping boards.

A few China companies have started to build prototyping kits around this chip. One of these company is SiPeed. They have produced a few form factors of prototyping board and I have gotten hold of the Maixpy GO board.
The Maixpy Go has the following features:

2.8 inch touch LCDCameraTF card slotMicRGB LEDSpeakerWIFIRechargeable batteryPowered via USB C. The USB-C also act as Uart for transferring of codes and flashing of firmware. There are a few ways to program the kit, micropython, Arduino IDE or Platform IO. For micropython, there is Maixpy IDE which is a port of OpenMV IDE.
Sipeed also has 2 interesting peripherals, microphone array and binocular camera. …

Transfer Learning (Image Classification) in Colab for Edge TPU

Most visual deep learning applications used an existing model and performed transfer learning to classify the images or detect the objects within the image. To use the Coral USB accelerator for these operations, the model has to be converted to Tensorflow lite model and then to model understood by Edge TPU.

There is a good article on model optimisation but for this blog post, I am using the Quantization Aware approach for the transfer learning. In Google example, it is required to install a docker and perform the transfer learning within docker. In this blog post, I have moved the retraining process to Colab and only the final step of converting to Edge TPU format is done on the local machine.

Coral USB Accelerator first impression.

Google has released its edge AI devices notably the Coral Dev Board and the USB Accelerator recently and I managed to buy the USB accelerator from Seeed Studio before it was sold out. I find that there is a bit of irony that China is listed as one of the countries that have restricted export but my Accelerator was shipped out of Shenzhen and luckily I do not stay in one of the countries listed that has export restrictions.

This is really a tiny piece of device. It is has a silver heat sink wrapped with rubbery plastic and comes with a USB 3.0 USB-C interface. I cannot imagine that this edge TPU only consumed about 2.5W but packed enough computation power to perform object detection and image classification in real-time. I decided to do my initial test on a Linux desktop that has USB 3 supports instead of Raspberry Pi in order to make sure that the USB port is not the bottleneck.

Installation was brisk, I have followed the Get Started Guide and I managed to get the demo app up and runn…

Xiaomi Mi Flora Chinese and International version comparison

Xiaomi Miflora sensor allows monitoring of the surrounding environment of the plant. It can monitor temperature, soil moisture, conductivity (acidity of the soil), ambience light. There are 2 versions of the sensor, international and Chinese version. Realistically, I cannot see the difference between the 2 versions.

The left-hand side is the Chinese version and the right is the international version. Other than the packaging, the main difference is the price of the sensor. The International version cost 2x more.

In other forums, there are discussions that the Chinese version cannot connect to the MiHome App. I have set my MiHome app to connect to China server and it is able to register the sensor correctly.

For my usage, I will be connecting to Openhab to monitor the plants andusing Thomas Dietrich MiFlora mqtt daemon as the bridge between Openhab and the sensor.

The International version is detected as Flower care and the firmware version is 3.1.9 while the Chinese version is detecte…