Put APIs To Work Wth This ArduinoJson Walkthrough

One of the things this community is famous for is the degree to which people will pitch in to fill an obvious need. Look at the vast array of libraries available for Arduino as an example of how people are willing to devote their time to making difficult tasks easier, often for little more than a virtual pat on the back.

One level up from the library writers are those who go through the trouble of explaining how all these libraries work in real-world applications. [Brian Lough] recently rose to that challenge with a thorough explanation of the use of the ArduinoJSON library, a very useful but often confusing library that makes IoT projects easier.

The need for an ArduinoJSON explainer no knock on its author, [Benoît Blanchon], who has done excellent work documenting the library; it’s more of a realization that the nature of JSON itself means a library that works with it is going to be complex. [Brian]’s contribution here is sharing his insights into getting ArduinoJSON up and running in a real-world ESP32 example, and dealing with the potential pitfalls of parsing a human-readable text file that can be used to represent almost any data object using the limited resources of a microcontroller. Along with the basics, we found the warning about how pointers refer back to the dynamic JSON document object particularly helpful; the bit about using filters to winnow down a large data set was useful too.

Thanks to [Brian] for taking the time to put this valuable information out there. Here’s hoping this encourages others to share the wealth of hard-earned knowledge in a similarly clear and concise manner.

Continue reading “Put APIs To Work Wth This ArduinoJson Walkthrough”

Speech Recognition On An Arduino Nano?

Like most of us, [Peter] had a bit of extra time on his hands during quarantine and decided to take a look back at speech recognition technology in the 1970s. Quickly, he started thinking to himself, “Hmm…I wonder if I could do this with an Arduino Nano?” We’ve all probably had similar thoughts, but [Peter] really put his theory to the test.

The hardware itself is pretty straightforward. There is an Arduino Nano to run the speech recognition algorithm and a MAX9814 microphone amplifier to capture the voice commands. However, the beauty of [Peter’s] approach, lies in his software implementation. [Peter] has a bit of an interplay between a custom PC program he wrote and the Arduino Nano. The learning aspect of his algorithm is done on a PC, but the implementation is done in real-time on the Arduino Nano, a typical approach for really any machine learning algorithm deployed on a microcontroller. To capture sample audio commands, or utterances, [Peter] first had to optimize the Nano’s ADC so he could get sufficient sample rates for speech processing. Doing a bit of low-level programming, he achieved a sample rate of 9ksps, which is plenty fast for audio processing.

To analyze the utterances, he first divided each sample utterance into 50 ms segments. Think of dividing a single spoken word into its different syllables. Like analyzing the “se-” in “seven” separate from the “-ven.” 50 ms might be too long or too short to capture each syllable cleanly, but hopefully, that gives you a good mental picture of what [Peter’s] program is doing. He then calculated the energy of 5 different frequency bands, for every segment of every utterance. Normally that’s done using a Fourier transform, but the Nano doesn’t have enough processing power to compute the Fourier transform in real-time, so Peter tried a different approach. Instead, he implemented 5 sets of digital bandpass filters, allowing him to more easily compute the energy of the signal in each frequency band.

The energy of each frequency band for every segment is then sent to a PC where a custom-written program creates “templates” based on the sample utterances he generates. The crux of his algorithm is comparing how closely the energy of each frequency band for each utterance (and for each segment) is to the template. The PC program produces a .h file that can be compiled directly on the Nano. He uses the example of being able to recognize the numbers 0-9, but you could change those commands to “start” or “stop,” for example, if you would like to.

[Peter] admits that you can’t implement the type of speech recognition on an Arduino Nano that we’ve come to expect from those covert listening devices, but he mentions small, hands-free devices like a head-mounted multimeter could benefit from a single word or single phrase voice command. And maybe it could put your mind at ease knowing everything you say isn’t immediately getting beamed into the cloud and given to our AI overlords. Or maybe we’re all starting to get used to this. Whatever your position is on the current state of AI, hopefully, you’ve gained some inspiration for your next project.

Hackaday Podcast 117: Chiptunes In An RCA Plug, An Arduino Floppy Drive, $50 CNC, And Wireless Switches

Hackaday editors Mike Szczys and Elliot Williams discuss the latest hacks from around the Internet. 3D-Printed linear rails don’t sound like a recipe for a functional CNC machine but there was one this week that really surprised us. We were delighted by the procedurally generated music from a $0.03 microcontroller inside of an RCA plug (the clever flexible PCB may be the coolest part of that one). There’s an interesting trick to reverse engineering Bluetooth comms of Android apps by running in a VM and echoing to WireShark. And we look at what the buzz is all about with genetically engineered mosquito experiments taking place down in the Florida Keys.

New this week is a game of “What’s that sound?”. Use the form link on the show notes below to send in your answer, one winner will receive a podcast T-shirt.

Take a look at the links below if you want to follow along, and as always, tell us what you think about this episode in the comments!

Direct download (~55 MB)

Places to follow Hackaday podcasts:

Continue reading “Hackaday Podcast 117: Chiptunes In An RCA Plug, An Arduino Floppy Drive, $50 CNC, And Wireless Switches”

An Arduino With A Floppy Drive

For many of us the passing of the floppy disk is unlamented, but there remains a corps of experimenters for whom the classic removable storage format still holds some fascination. The interface for a floppy drive might have required some complexity back in the days of 8-bit microcomputers, but even for today’s less accomplished microcontrollers it’s a surprisingly straightforward hardware prospect. [David Hansel] shows us this in style, with a floppy interface, software library, and even a rudimentary DOS, for the humble Arduino Uno.

The library provides functions to allow low level work with floppy disks, to read them sector by sector. In addition it incorporates the FatFS library for MS-DOS FAT file-level access, and finally the ArduDOS environment which allows browsing of files on a floppy. The pictures show a 3.5″ drive, but it also supports 5.25″ units and both DD and HD drives. We can see that it will be extremely useful to anyone working with retrocomputer software who is trying to retrieve old disks, and we look forward to seeing it incorporated in some retrocomputer projects.

Of course, Arduino owners needn’t have all the fun when it comes to floppy disks, the Raspberry Pi gets a look-in too.

Arduino MKR Makes Nespresso Monitoring Easy

Monitoring an appliance with a microcontroller usually follows a well-worn path of diving inside and finding somewhere in the electrical circuitry that can be connected through some kind of interface to a microcontroller. For his Nespresso pod coffee machine, [Steadman] eschewed tearing into the device, and instead chose to monitor the sound it makes. A commodity sound threshold sensor board is hooked up to an Arduino MKR Zero, and this set-up logs coffee consumption. It’s important to note how this generation of Arduino is no longer one of the simple boards of old, instead it sports an RTC and SD card alongside its SAMD21 Cortex-M0+ processor so it is perfect for just such a datalogging project. The coffee data can be saved into a CSV file viewable by a spreadsheet, for which code is provided.

We like this project for its non-invasive simplicity, and we can see that there could be plenty of other similar machines that could benefit from an analagous technique for non-invasive monitoring. While the pages of Hackaday are full of coffee machine projects we see surprisingly few pod coffeemakers, perhaps because our readers are a canny bunch who balk at paying a premium for their caffeine. If you do happen to have a Nespresso machine though, perhaps you’d like some help identifying the capsules.

Ooohhh, That Smell: Arduino Monitors Air Quality

According to [Dr. Tom Lehrer’s] song Pollution, “Wear a gas mask and a veil. Then you can breathe, long as you don’t inhale!” While the air quality in most of the world hasn’t gotten that bad, there is a lot of concern about long-term exposure to particulates in the air causing health problems. [Ashish Choudhary] married an Arduino with a display and a pollution sensor to give readings of the PM2.5 and PM10 levels in the air.

The sensor uses a laser diode and a photodiode to detect and count particles, while a fan moves air through the system. If you aren’t up on pollution metrics, PM2.5 is a count of very fine particles (under 2.5 microns) and PM10 is a count of particles for 10 microns. You can find a datasheet for the device online.

Continue reading “Ooohhh, That Smell: Arduino Monitors Air Quality”

Arduino Plots Your Portrait With Style

Around these parts, we see plenty of plotter builds. They’re a great way to learn about CNC machines and you get to have fun making pictures along the way. [Ben Lucy] was undertaking just such a build of his own, but wanted to do something standalone that served a purpose. The result is the impressive Portable Portrait Painter.

What sets [Ben]’s project apart is how complete it is. Unlike other plotters that simply follow G-code instructions or process external images, the Portable Portrait Painter is a completely standalone machine. Fitted out with an OV7670 camera, hooked up to an Arduino, it’s capable of taking its own photos and then drawing them out as well.

Through some clever code from [Indrek Luuk], the Arduino Mega2560 is able to display a 20fps video preview on a color LCD screen. When the user presses a button, the current frame is captured and sent to the pen plotter. The plotting algorithm is particularly impressive, with images first processed with histogram compensation to maximise contrast. The pen is then drawn across the page line by line, and pressed into the page by varying amounts depending on the color value of each pixel. The darker the pixel, the thicker the stroke made by the pen. This more analog approach produces a much more detailed image than more basic plotters which either leave a mark or don’t.

The portraits produced by the plotter are impressive, and we like the edge-of-page artifacts, which add a little style to the final results. The Portrait Painter would make a great conversation piece at any Maker Faire or hackerspace night.

It’s a project that reminds us of some of the painting robots we’ve seen over the years. Video after the break.

Continue reading “Arduino Plots Your Portrait With Style”