TensorFlow Lite for Microcontrollers Kit Quickstart
2019-08-15 | By Adafruit Industries
License: See Original Project Programmers
Courtesy of Adafruit
Guide by Lady Ada
Get going quickly with your TensorFlow Lite kit!
Overview
Machine learning has come to the 'edge' - small microcontrollers that can run a very miniature version of TensorFlow Lite to do ML computations.
But you don't need super complex hardware to start developing your own TensorFlow models! We've curated a simple kit to dip your toes into machine learning waters.
Kit includes:
- Adafruit PyBadge with SAMD51 Cortex M4F processor @ 120MHz, with display, speaker and buttons
- Electret Microphone Amplifier - MAX4466 with Adjustable Gain
- JST PH 3-Pin to Female Socket Cable - 200mm
- Lithium Ion Polymer Battery with Short Cable - 3.7V 350mAh
The kit uses our PyBadge as your edge processor. It's a compact board - it's credit card sized. It's powered by our favorite chip, the ATSAMD51, with 512KB of flash and 192KB of RAM. We add 2 MB of QSPI flash for file storage, handy for TensorFlow Lite files, images, fonts, sounds, or other assets.
You can plug in a microphone into the ports at the bottom, to add microphone input for micro speech recognition. Our Arduino library has some demos you can get started with to recognize various word pairs like "yes/no", "up/down" and "cat/dog". TensorFlow Lite for microcontrollers is very cutting-edge so expect to see a lot of development happening in this area, with lots of code and process changes.
Parts required
You can get everything you need minus tools in this kit:
Or as individual parts:
- Adafruit PyBadge for MakeCode Arcade, CircuitPython or Arduino
- JST PH 3-Pin to Female Socket Cable - 200mm
- Electret Microphone Amplifier - MAX4466 with Adjustable Gain
- Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh
Assembly
Step 1 - Solder Headers onto Microphone
You'll need to plug into your microphone, so visit this guide for step by step instructions on soldering the headers on
Step 2 - Connect JST PH Cable to Microphone
Connect Red to VCC, Black to GND and White to OUT
Step 3 - Cut and solder the 3V selection jumper on the back of the PyBadge or PyGamer
On the back of your board, find the STEMMA cable voltage selection jumper. Cut the trace from Vcc to 5V
Then solder in the Vcc to 3V pads
Step 4 - Plug in Microphone into D2
Software Setup
We're going to be using the popular Arduino IDE to compile and load code. Start by following the PyBadge setup guide to
- Install the latest desktop Arduino IDE
- Install Adafruit SAMD board support package
- Install all the Arcada Libraries
Once that's all done, also install the TFLite Micro Speech library
Try loading the JSON demo version of the code
Select from the Tools menu
- Board: Adafruit PyBadge M4 Express
- CPU Speed: 200 MHz
- Optimize: Fastest
- USB Stack: TinyUSB
- Port: Correct Serial/COM port
And compile upload to the PyBadge
After its done uploading, you should see a new disk drive on your computer called CIRCUITPY (or similar) it will be 8 MB large
Unzip this folder and drag the tflite_config.json and yesno.tflite files to the disk drive
Eject the disk drive via the operating system (Eject or move it to the trash on MacOS)
Press Reset on the back of the board to restart
You'll get a boot screen telling you what model it loaded (thats the tflite file)
Press the A button to record up to 1.5 seconds of audio, the first neopixel will light up red to let you know
Try saying "yes"
Or "no"
You can also get a silence output if nothing is heard at all