Edge Impulse logo
Blog Post

The Best Thing Since Sliced Bread

Embedded Devices, Machine Learning, TinyMLShawn Hymel' Perfect Toast Machine uses gas sensors and embedded machine learning to smell when a piece of toast is done.

Nick Bild

September 22, 2022

    You might remember a running joke from back in the early Internet of Things days — when it seemed that anything and everything was being connected to the internet because, you know, reasons — that one day your toaster would be connected to the internet. It seemed like the height of absurdity to give such a capability to an appliance that only serves to toast slices of bread. The mockery that this idea received clearly demonstrates that people like their toasters simple, and if anyone should dare to try and build some smarts into a toaster, they had better be prepared to be the subject of many a meme.

    Surely no one would cross this line, right? You might not think so, but Edge Impulse’s very own Shawn Hymel, apparently drunk with the power one can feel after designing a successful machine learning algorithm, decided to throw caution to the wind and bring toasters into the twenty-first century. He built an AI-powered toaster that makes the perfect piece of toast every single time. And we are glad that he did; the toaster works great and many people would find it quite useful in their own homes. Even the scoffing toaster-Luddites would have their mouths silenced by a piece of toast browned to perfection by the aptly named Perfect Toast Machine.​​

    Hacking a toaster

    The goal of the project is to toast a piece of bread just the right amount — that is, before it becomes burned (i.e. damaged). That sounded a lot like a predictive maintenance problem to Hymel, so he decided to approach the task with a collection of gas sensors, along with temperature and humidity sensors, that can provide information about changes in the bread as it is heated. Making sense of these sensor measurements is by no means straightforward because there are complex interactions between many variables, so Hymel used the Edge Impulse machine learning platform to build an analysis pipeline that can learn these relationships and how they correspond with delicious, golden brown toast.

    As a first step, Hymel needed to hack a toaster to get access to the control signals that start and stop the toasting process so that it could be controlled automatically by his device. He then created a wire structure that was used to position the sensors above the toaster. A small fan was also installed here to make sure a large quantity of the gasses exiting the toaster were passed over the gas sensors. A powerful Seeed Studio Wio Terminal was positioned to the side of the toaster, where it would be safe from getting itself toasted. The Wio Terminal provided the processing power with its Arm Cortex-M4F processor, and also gave some insight into what the Perfect Toast Machine was doing with its built-in display.

    The sensing platform

    After assembly was finished, Hymel wrote a Python script to collect the data needed to train a machine learning model. As bread was toasted, he used his biological sensors (nose, eyes) to determine the condition of the toast. Samples were manually labeled (by pressing a button on the Wio Terminal) as not toasting, toasting, or burned. The script saved the measurements as CSV-formatted files. After having a look at the results and calculating some basic summary statistics, the data was uploaded to Edge Impulse Studio so that the machine learning magic could get underway.

    Hymel created an impulse with a preprocessing step that extracts the most informative features from the input data. Beginning in this way reduces the computational resources required by the model, and can also help to improve accuracy. Next, a regression model was added to the impulse to give precise information about how much longer the bread should be toasted. Specifically, the model predicts the number of seconds left until the toast burns.

    Validating the model in Edge Impulse Studio

    With the impulse complete, the model was then trained using the previously uploaded training data (over 14 hours worth — that is a lot of bread!). Next the model was validated using the model testing tool and Hymel found that it generally was able to predict the time until burned within a few seconds. That should do just fine, so the machine learning pipeline was deployed to the Wio Terminal. This was accomplished by exporting the pipeline from Edge Impulse as an Arduino library, then uploading it to the Wio Terminal via Arduino IDE.

    Hymel ran some further tests to determine the optimal number of seconds before a piece of toast burns to stop the toasting process. Using the prediction of the regression model, some simple math, and the hacked toaster, all of the pieces came together to produce consistently perfect toast. If you have a hankering for some perfectly browned toast, you can read up on Hymel’s documentation and then build your own Perfect Toast Machine. He also provided a link to his Edge Impulse project to give any fellow toast aficionados a jump start on their own build. And if toast is not exactly what you had in mind, Hymel points out that the same basic principles employed in this project could also be used to, for example, determine if a piece of industrial machinery is likely to fail soon.


    Want to see Edge Impulse in action? Schedule a demo today. 

    Subscribe

    Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

    Subscribe to our newsletter