Introduction to Google TensorFlowTensorFlow (TF) is an end-to-end open-source platform for machine learning.
It has a comprehensive, flexible ecosystem of tools, libraries, and community resources that lets researchers push the state-of-the-art in ML,
and developers easily build and deploy ML-powered applications.
TensorFlow Lite for MicrocontrollersWhile TensorFlow Lite (TFL) for Microcontrollers is designed to run machine learning models on microcontrollers and other devices with only a
few kilobytes of memory. The core runtime just fits in 16 KB on an Arm Cortex M3 and can run many basic models. It doesn't require
operating system support, any standard C or C++ libraries, or dynamic memory allocation.
Ameba and TFL for MicrocontrollersAmeba is an easy-to-program platform for developing all kinds of IoT applications. AmebaD is equipped with various peripheral interfaces, including
WiFi, GPIO INT, I2C, UART, SPI, PWM, ADC. Through these interfaces, AmebaD can connect with electronic components such as LED, switches,
manometer, hygrometer, PM2.5 dust sensors, …etc.
Magic Wand Example Running on Ameba RTL8722DMMaterials• Ameba D [RTL8722 CSM/DM] x 1
• Adafruit LSM9DS1 accelerometer
• LED x 2
Example ProcedureConnect the accelerometer and LEDs to the RTL8722 board following the diagram.
Download the Ameba customized version of TensorFlow Lite for Microcontrollers library at
https://github.com/ambiot/ambd_arduino/tree/master/Arduino_zip_libraries.
Follow the instructions at
https://www.arduino.cc/en/guide/libraries to install it.
Ensure that the patch files found at
https://github.com/ambiot/ambd_arduino/tree/master/Ameba_misc/ are also installed.
In the Arduino IDE library manager, install the Arduino_LSM9DS1 library. This example has been tested with version 1.1.0 of the LSM9DS1 library.
Open the example,
“Files” -> “Examples” -> “TensorFlowLite_Ameba” -> “magic_wand”. Upload the code and press the reset button on Ameba once the upload is finished.
Holding the accelerometer steady, with the positive x-axis pointing to the right and the positive z-axis pointing upwards, move it following the shapes
as shown, moving it in a smooth motion over 1 to 2 seconds, avoiding any sharp movements.
If the movement is recognized by the Tensorflow Lite model, you should see the same shape output to the Arduino serial monitor. Different LEDs will
light up corresponding to different recognized gestures.
Note that the wing shape is easy to achieve, while the slope and ring shapes tend to be harder to get right.
Reference and Q&A