Doorgaan naar hoofdcontent

UHURA update 4: the first real box comes to life

In the previous update I wrote: the software is ready, now Mum needs something with one big button on it. That step has started. For the first time UHURA runs on a real ESP32 board, and it taught me three lessons straight away.

The Sonocotta Louder-ESP32 board with labels: ESP32-WROVER module, CH340 USB-serial bridge, TAS5805M amplifier, speaker terminals and power inputs

The Louder-ESP32 that UHURA now runs on. Photo: Seeed Studio. My board (rev H9) has 8 MB of flash instead of the 16 MB in the photo.

First a board that already exists

Later I will design my own circuit board for Mum's box. But you don't start by soldering; you start with a board that already works. I chose the Louder-ESP32 from Sonocotta: an ESP32 with 8 MB of extra memory and a decent amplifier on board. It is the same board I use for Audio Jarvis.

I set up the software so that my own board can simply be added next to it later. Every board gets one small file with its pins and parts. The core of UHURA, the same code that runs on Linux and Windows, goes onto the ESP32 without a single copied file.

Step by step, not everything at once

It is tempting to switch on Wi-Fi, microphone, amplifier and buttons all at once. But when it crackles or hangs, you have no idea why. So I cut it into four steps. Step 1 is only this: boot, check the memory and measure whether the chip can keep up with the work. The amplifier stays off, so nothing can go bang.

Within ten minutes that small test found three problems that would otherwise have cost hours of searching.

Three hidden bombs

A firmware that was 98 KB too fat. I had given the sound buffers a label to make sure they stayed in the fast internal memory. That label turned out to put them into the firmware as empty data as well. Without the label the linker gets it right by itself, and the firmware became 98 KB smaller.

A sound codec that quietly ate the stack. The Opus codec never asks for memory, but it does put its temporary work on the stack, in a way my project rules forbid. Now Opus gets its own fixed workspace in the extra memory. And if it ever does ask for memory, the program stops at once. That way I know for sure it never happens.

Too slow. With the PC settings the ESP32 needed 33 milliseconds for a 20-millisecond piece of sound. That obviously doesn't work. With a setting meant for speech on a small chip, and faster flash memory, sending now takes 12 ms and receiving 3.5 ms. Well in time, and the box still talks to the laptops as before.

The board knows where its power comes from

A nice detail: the board measures its own supply voltage. On just a USB cable it cannot get enough current for the amplifier at full power. The board sees that by itself and will limit the volume to 25%. On a 12 V adapter it may play loud. For Mum that is exactly right: loud where it can be, safe where it must be.

How much data does it use?

I also worked out how much data UHURA uses when a box stays online through a 4G SIM card. At rest, when nobody talks, it is 165 to 240 MB per month for a circle of three stations. One minute of talking costs about half a megabyte. A cheap 500 MB-per-month SIM is plenty.

What's next?

Step 2: switch the amplifier on in exactly the right order, so there is no pop from the speaker, and play the first UHURA chime. Then come the buttons and the microphone, and then this board will talk to my sister's laptop and mine.

All designs are in the docs folder of chat-l18l/uhura_intercom. You can also follow UHURA on Elektor Labs.

This article is part of the series Building with AI agents: projects I build together with AI agents. That link takes you to every part of the series, including new ones.

Lees dit artikel in het Nederlands: UHURA-update 4: het eerste echte kastje komt tot leven

Reacties

Populaire posts van deze blog

Denon DHT T100 DESIGNED TO FAIL : bad caps (ceramic caps this time)

A friend gave me a Denon DHT-T100 to look at. Do not spend much time on it.. ok. It had a problem, it started clicking and ticking after power on, and after some time. (a so called intermittent problem) Sometimes it did not tick or click, but it was basically not usable. The clicking had a sharp click in one channel and repeated after about a second, then sound recovered and it would click and drop out again. He told me, do not spend any time on it, yeah, right. ;-) like I would give up after 15 minutes. I wanted to know what was going on with this thing, I found some schematic online and started measuring the usual things. The power supply, 24V did it drop down when a tick occurred ? Difficult to find out because sometimes the thing would play for hours without a glitch. I eventually found out the 24 V PSU, the step down SMPS on board and the LDO's were all ok, all power rails remained within spec, but it still glitched sometimes. (while power was ok) I inves...

Fixed voltage on cheap buck converter (MP1584) conversion with single 0805 resistor

Everywhere I look on the Ali and Ebays I see these step down converters based on MP1584. I bought a couple and actually they are not bad at all. The output voltage is set by the trimming-resistor in the left top corner of the picture. This works OK, but.. it is dangerous because it is rather sensitive to the touch. I decided that I wanted fixed output, so I had to figure out how this thing worked. The datasheet looks like this : R1 in the datasheet is what I call "R feedback" in my image. The value of R2 is mostly 8.2K Ohm in the boards I have seen.  So to set some common values for output voltage: change R1 to 27K for 3V3 output (actually 3.4 volt, but 27K is a standard value) or change R1 to 43K0 for 5.0 Volt output. (43 K is a standard value) A standard 0805 size resistor fits precisely, how convenient ;-). Make sure the other resistor is really 8.2K because that determines the feedback ratio. This way you can not burn up your circ...

Raspberry Pi, PyFace Digital, the lost documentation, I found it finally

The Raspberry PI or R-pi from  http://www.raspberrypi.org/  is well known these days. It is not an accident that I have one, I have been doing Linux stuff since 1991, and professionally since 1996 I can not skip over these developments, have to keep up with the new kids. :-) Times have changed, hardware has become very affordable, everybody knows the Arduino , Raspberry Pi and Beagle-Bone-Black (BBB). Not everybody knows the stuff that  http://www.acmesystems.it/  aka Acme-Systems and  https://github.com/OLIMEX/OLINUXINO  aka  Olimex make, so I will endorse them here. Since I am an engineer I expect to connect switches and relays to the boards and some documentation with products, not so with the " PiFace Digital " board, it comes without serious documentation, not a even the schematic. All links on their blog point nowhere. People asked them many times, yet nowhere is the schematic to be found. I finally found some info after hours of googl...