Category Archives: Tutorial

AI on the Edge LESSON 10: Make Your Raspberry Pi Listen to You with Voice Commands

In this video lesson you will learn how to train the Raspberry Pi to take voice commands from you. We do this through the Fusion AI+ hat’s microphone, and a Speech to Text (STT) model. Our goal is to develop the ability to interact with our projects through spoken words. We give commands to the project, and then it responds intelligently with words.

Remember these lessons depend on you using the AI Educational OS, a special version of bookworm that has all the libraries, modules, and models already installed for you. See LESSON #2 in this class for instructions on flashing that OS.

Below is the simple demonstration code we developed to give simple voice commands:

Similar to our Speech to Text example, the first time you run this program you will get a permissions error. You need to open a terminal, and put these commands in one at a time to enable permissions. This only has to be done once, and after that this and all STT programs should run properly.

 

AI on the Edge LESSON 8: Text to Speech (TTS) on the Raspberry Pi

In this video lesson I will show you how to get the Raspberry Pi to speak to you in plain English. This is our first dabbling with AI. In earlier lessons we have discussed that one of our first objectives will be to begin to audibly interact with our project through speech. The first step will be to get the Pi to talk to us. Then in future lessons we will show how to get the Pi to listen to us.

In this lesson we demonstrated simple Text to Speech (TTS) with this code.

Remember this program requires use of the AI Educational OS we flashed in LESSON #2.

As we say in the video, the first time you run the program you will get a permission error. This is because the model folders are inside a system folder and must be created as a ‘superuser’ using ‘sudo’. As shown in the video, you need to open a terminal window, and type in these commands at the command prompt (Put them in one at a time):

You only need to do that one time. Next time you run the program, all will work properly.

Then, in order to hear all the different voice models Piper offers, you can run this program, and each voice will introduce itself to you.

 

Remember in these early lessons we are using this circuit to demo our programs. Please leave this circuit put together.

Fusion Hat Circuit Diagram
This is the circuit we will use moving forward in the class

AI on the Edge LESSON 7: Homework Solution for Dimmable LED

In Lesson 6, I gave you a homework challenge: build a dimmable LED using a potentiometer. In today’s Lesson 7, we go through the solution together step-by-step.

This lesson is all about taking analog input from a potentiometer and converting it into smooth PWM output to control the brightness of an LED. It’s a very practical project because it teaches you how to read real-world analog values and turn them into useful control signals — skills we’ll use again and again as we build smarter AI-powered projects.

In the video, I walk you through the complete working code. You’ll see how we read the potentiometer value (0 to 4095), convert that raw number into a proper brightness percentage using a bit of math (with a nice logarithmic curve so the brightness feels natural to the human eye), and then send that value to the LED using PWM. The result is a very smooth, responsive dimmer that feels professional.

Even though this seems like a simple project, it’s actually an important stepping stone. Understanding how to read sensors and smoothly control outputs is fundamental to building real AI on the Edge systems — whether you’re controlling motors, adjusting screen brightness, or varying the speed of a robot based on sensor input.

By the end of this lesson, you should have a solid understanding of how to combine the ADC (Analog to Digital Converter) with PWM output, and more importantly, how to think about mapping real-world inputs to useful outputs.

So if you did the homework, great job! If you got stuck, don’t worry — we go through the full solution together. And as always, I strongly encourage you to take the code and make it your own. Try changing the response curve, add multiple LEDs with different colors, or combine it with things we’ve learned in earlier lessons.

This is the kind of foundational hardware skill that will serve you well as we continue moving deeper into the AI on the Edge class. You’re doing great — keep going!

We are still using the schematic from our earlier project.

Fusion Hat Circuit Diagram
This is the circuit we will use moving forward in the class

In this lesson, this is the code which we came up with:

 

Tilt Compensated Digital Compass

In this video lesson we show how to create a tilt compensated digital compass. Calculating heading based simply on the measured magnetometer values  in the X and Y directions only works accurately when the compass is sitting flat, or horizontal with the earth’s surface. If we introduce a tilt, either by applying pitch or roll to the system, calculated heading, or yaw will no longer be accurate. In the video above, we show you how to mathematically ‘un-tilt’ the sensor to get accurate heading  readings when the device is not perfectly flat.

We are working with a GY-87 9-axis IMU, and an Arduino Uno R4 WiFi. Below is the schematic we are using in this project:

MPU6050
Schematic for connecting the GY-87 module to the Arduino

For your convenience, the code developed in this video lesson is included below. Please notice that the calibration constants in the code below are for my GY-87 module. You need to calibrate your own module, as my numbers below would likely be different from your numbers. We showed how to do the calibration in THIS LESSON.

 

Using Arduino and MPU6050 to Measure Rotational Velocity with the Gyros

In this video lesson I show you how you can measure rotational velocity using the gyroscopes on the MPU6050 IMU module on the GY-87 board.

MPU6050
Schematic for connecting the GY-87 module to the Arduino

Below is the code which we develop in this lesson.