Posts with «featured» label

The Dar es Salaam Hacker Scene and Gamut Detection

We’re on a sort of vacation in Tanzania at the moment and staying in a modest hotel away from the tourist and government district. It’s a district of small shops selling the same things and guys repairing washing machines out on the sidewalk. The guys repairing washing machines are more than happy to talk. Everybody’s amazingly friendly here, the hotel guy grilled us for an hour about our home state. But I really didn’t expect to end up in a conversation about computer vision.

In search of some yogurt and maybe something cooler to wear, we went on a little walk away from the hotel. With incredible luck we found a robotics shop a few blocks away. Mecktonix is a shop about two meters each way, stuffed full of Arduinos, robots, electronics components, servos, and random computer gear, overseen by [Yohanna “Joe” Harembo]. Nearby is another space with a laser engraver and 3D printer. The tiny space doesn’t stop them from being busy. A constant stream of automotive tech students from the nearby National Institute of Transport shuffle in for advice and parts for class assigned projects.

In between students, Joe demos an autonomous car he’s working on. In classic hacker fashion, he first has to reattach the motor driver board and various sensors, but then he demos the car and its problem –  the video frame rate is very slow. We dive in with him and try to get some profiling using time.monotonic_ns(). He’s never done profiling before, so this is a big eye opener. He’s only processing one video frame every 4.3 seconds, using YOLO on a Pi 3, and yup, that’s the problem.  I suggest he change to gamut detection or a Pi 4.

Gamut Detection

If you’re not familiar with gamut detection, it’s one of the simplest of all computer vision techniques, so it’s easy to implement on slow processors and almost trivial to code. Basically, it’s “look for a color”.  If you want your robot to follow you, wear a lime green T shirt. Now the robot just has to look for lime green. Same for catching a ball or following a line. The algorithm is simple – convert each pixel to HSV, where hue corresponds to the direction around the color wheel,  saturation corresponds to how concentrated the color is, and value how bright. Brightness depends on the lighting, so you can throw value away and just set limits for H and S. Anything within those limits is part of our target. The box formed by those limits is our “gamut”.

There are a couple speedups you can apply as well. First, ask yourself how much resolution you need from the camera. If you only want to track a green T shirt that’s never less than 24 pixels on screen, turn the resolution down by a factor of six each way and look for four-pixel T shirts. You now have 1/36th as much data to process and your algorithm runs 36 times faster. If you can’t control the camera resolution, you can shrink the image or just sample every nth pixel. Second, you can often ask for a YUV or YIQ image from the camera. Discard Y and set your limits in IQ or UV coordinates. It’s about the same as HSV.

Joe’s eating this up – he’s had limited chances to talk with somebody else who is into computer vision. As we write this, he’s still trying with YOLO, but at lower resolution. If it doesn’t work he’ll try gamut detection. And it’s not his only project. Passenger carrying motorcycles called pikipikis are common here. A student has a project to enforce passengers wearing a helmet, and we fiddle with the student’s project.

The Dar es Salaam Scene

There’s other tech happening in Tanzania too. A few blocks away is [Ruta Electronics], a similar sugar cube sized shop developing smart meters. Everything from cases to PCB etching happens in the tiny shop. Downtown there are a few tech startups. There’s a fab lab, mostly oriented towards children. And on a quiet side street off the main drag, there’s a tiny shop with three guys who are hacking like crazy.

For us, we’ve had a chance to make a friend from a different culture and play with a robot car together — what could be better?  When you’re traveling, are you on the lookout for other hackers or hackerspaces? It’s worth the effort and brings our community together in a way that even the internet can’t.

How To Build Jenny’s Budget Mixing Desk

Jenny did an Ask Hackaday article earlier this month, all about the quest for a cheap computer-based audio mixer. The first attempt didn’t go so well, with a problem that many of us are familiar with: Linux applications really doesn’t like using multiple audio devices at the same time. Jenny ran into this issue, and didn’t come across a way to merge the soundcards in a single application.

I’ve fought this problem for a while, probably 10 years now. My first collision with this was an attempt to record a piano with three mics, using a couple different USB pre-amps. And of course, just like Jenny, I was quickly frustrated by the problem that my recording software would only see one interface at a time. The easy solution is to buy an interface with more channels. The Tascam US-4x4HR is a great four channel input/output audio interface, and the Behringer U-PHORIA line goes all the way up to eight mic pre-amps, expandable to 16 with a second DAC that can send audio over ADAT. But those are semi-pro interfaces, with price tags to match.

But what about Jenny’s idea, of cobbling multiple super cheap interfaces together? Well yes, that’s possible too. I’ll show you how, but first, let’s talk about how we’re going to control this software mixer monster. Yes, you can just use a mouse or keyboard, but the challenge was to build a mixing desk, and to me, that means physical faders and mute buttons. Now, there are pre-built solutions, with the Behringer X-touch being a popular solution. But again, we’re way above the price-point Jenny set for this problem. So, let’s do what we do best here at Hackaday, and build our own.

The Physical Goods

What we need is a microcontroller that has native USB client support, multiple digital I/O pins, and some analog inputs. I went with the Arduino MKRZero for the small size, decent price, and the fact that it’s actually in stock at Mouser. The other items we’ll need are some faders and buttons. I went for the full-sized 100 mm faders, and some LED toggle buttons made by Adafruit. The incidentals, like wire and resistors, was sourced from the local parts bin in the corner.

My first thought was to design and 3D print the panel, but after doing the layout on a scrap piece of plywood, the resulting size proved a bit too large for my printer. So we’re going retro, and making a “wood-grain” mixing desk. This would be a great project for a CNC router, but as I’m not part of that particular cool club yet, it was a drill press, table saw, and oscillating tool to the rescue. The results aren’t quite as pretty as I wanted, but maybe we’ll get a Mark II of this project one day.

The wiring is relatively straightforward, with a current limiting resistor to protect the LEDs inside the buttons, and a pullup resistor to prevent the digital pin from floating when the button isn’t pushed. Now, that pullup might not be necessary, as I later learned that the Arduino has built-in pullup on its digital pins. And also of note, a 10 Ω resistor is *not* a good choice for a pullup. As Al eloquently put it, that’s a “pull way up resistor”. 10 kΩ is the better choice.

And to finish the build, we’ll need a sketch to run on the Arduino. Thankfully, there’s already a great library for exactly what we want to do: Control Surface. There’s a bunch of ways to set this up, but my sketch is pretty trivial:

#include <Control_Surface.h>
USBMIDI_Interface midi;

CCButtonLatching button1 {11, {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1}, };
CCButtonLatching button2 {10, {MIDI_CC::General_Purpose_Controller_2, CHANNEL_1}, };
CCButtonLatching button3 {9, {MIDI_CC::General_Purpose_Controller_3, CHANNEL_1}, };
CCButtonLatching button4 {8, {MIDI_CC::General_Purpose_Controller_4, CHANNEL_1}, };
CCButtonLatching button5 {7, {MIDI_CC::General_Purpose_Controller_5, CHANNEL_1}, };
CCButtonLatching button6 {6, {MIDI_CC::General_Purpose_Controller_6, CHANNEL_1}, };
CCPotentiometer volumePotentiometers[] {
  {A0, {MIDI_CC::Sound_Controller_1, CHANNEL_1} },
  {A1, {MIDI_CC::Sound_Controller_2, CHANNEL_1} },
  {A2, {MIDI_CC::Sound_Controller_3, CHANNEL_1} },
  {A3, {MIDI_CC::Sound_Controller_4, CHANNEL_1} },
  {A4, {MIDI_CC::Sound_Controller_5, CHANNEL_1} },
  {A5, {MIDI_CC::Sound_Controller_6, CHANNEL_1} },
void setup() {
void loop() {

Pipewire to the Rescue

And now on to the meat and potatoes of this project. How do we convince an application to see inputs from multiple devices, and actually do some mixing? The problem here is de-sync. Each device runs on a different clock source, and so the bitstream from each may wander and go out of sync. That’s a serious enough problem that older sound solutions didn’t implement much in the way of card combining. Not long ago, the process of resampling those audio streams to get them to properly sync would have been a very CPU intensive procedure. But these days we all have multi-core behemoths, practical super-computers compared to 20 years ago.

So when Wim Taymans wrote Pipewire, he took a different approach. We have enough cycles to resample, so Pipewire will transparently do so when needed. Pipewire sees all your audio interfaces at once, and implements both the Jack and Pulseaudio APIs. Different distros handle this a bit differently, but generally you need the Pipewire packages, as well as the pipewire-jack and pipewire-pulseaudio packages to get that working.

And here’s the secret: The Jack routing tools work with Pipewire. The big three options are qjackctl, carla, and qpwgraph, though note that qpwgraph is actually Pipewire native. So even if an application can only select a single device at a time, if that app uses the Jack, Pulseaudio, or Pipewire API, you can use one of those routing control programs to arbitrary connect inputs and outputs.

So let’s start with the simplest solution: jack_mixer. Launch the application, and then using your preferred routing controllers, take the MIDI output from our Arduino control surface, and connect it into jack_mixer‘s MIDI input. In jack_mixer, add a new input channel, and give it an appropriate name. Let’s call it “tape deck”, since I have a USB tape deck I’m testing this with. Now the controller magic kicks in: hit the “learn” button for the volume control, and wiggle the first fader on that controller. Then follow with the mute button, and save the new channel. We’ll want to add an output channel, too. Feel free to assign one of your faders to this one, too.

And finally, back to the routing program, and connect your tape deck’s output to jack_mixer input, and route jack_mixer‘s output to your speakers. Play a tape, and enjoy the full control you have over volume and muting! Want to add a Youtube video to the mix? Start the video playing, and just use the routing controller to disconnect it from your speakers, and feed it into a second channel on jack_mixer. Repeat with each of those five cheap and nasty sound cards. Profit!

You Want More?

There’s one more application to mention here. Instead of using jack_mixer, we can use Ardour to do the heavy lifting. To set it up this way, there are two primary Ardour settings, found under preferences: Under the monitoring tab make sure “Record monitoring handled by” is set to Ardour, and the “auto Input does talkback” option is checked. Then add your tracks, set the track input to the appropriate input hardware, and the track output to the master bus. Make sure the master bus is routed to where you want it, and you should be able to live mix with Ardour, too.

This gives you all sorts of goodies to play with, in the form of plugins. Want a compressor or EQ on a sound source? No problem. Want to autotune a source? X42 has a plugin that does that. And of course, Ardour brings recording, looping, and all sorts of other options to the party.

Ardour supports our custom mixing interface, too. Also under preferences, look for the Control Surfaces tab, and make sure General MIDI is checked. Then highlight that and click the “Show Protocol Settings” button. Incoming MIDI should be set to our Arduino device. You can then use the Ctrl + Middle Click shortcut on the channel faders and mute buttons, to put them in learn mode. Wiggle a control to assign it to that task. Or alternatively you can add a .map file to Ardour’s midi_maps directory. Mine looks like this:

  <?xml version="1.0" encoding="UTF-8"?>
<ArdourMIDIBindings version="1.1.0" name="Arduino Mapping">
  <Binding channel="1" ctl="16" uri="/route/mute B1"/>
  <Binding channel="1" ctl="70" uri="/route/gain B1"/>
  <Binding channel="1" ctl="17" uri="/route/mute B2"/>
  <Binding channel="1" ctl="71" uri="/route/gain B2"/>
  <Binding channel="1" ctl="18" uri="/route/mute B3"/>
  <Binding channel="1" ctl="72" uri="/route/gain B3"/>
  <Binding channel="1" ctl="19" uri="/route/mute B4"/>
  <Binding channel="1" ctl="73" uri="/route/gain B4"/>
  <Binding channel="1" ctl="80" uri="/route/mute B5"/>
  <Binding channel="1" ctl="74" uri="/route/gain B5"/>
  <Binding channel="1" ctl="81" uri="/route/mute B6"/>
  <Binding channel="1" ctl="75" uri="/route/gain B6"/>

The Caveats

Now before you get too excited, and go sink a bunch of money and/or time into a Linux audio setup, there are some things you should know. First is latency. It’s really challenging to get a Pipewire system set up to achieve really low latency, particularly when you’re using USB-based hardware. It’s possible, and work is ongoing on the topic. But so far the best I’ve managed to run stable is a 22 millisecond round-trip measurement — and that took a lot of fiddling with the Pipewire config files to avoid garbled audio. That’s just about usable for self monitoring and live music, and for playing anything pre-recorded, that’s perfectly fine.

The second thing to know is that this was awesome. It’s a bit concerning how much fun it is to combine some decent audio hardware with the amazing free tools that are available. Want to auto-tune your voice for your next Zoom meeting? Easy. Build a tiny MIDI keyboard into your desk? Just a microcontroller and some soldering away. The sky’s the limit. And the future is bright, too. Tools like Pipewire and Ardour are under very active development, and the realtime kernel patches are just about to make it over the finish line. Go nuts, create cool stuff, and then be sure to tell us about it!

The Medieval History Of Your Favourite Dev Board

It’s become something of a trope in our community, that the simplest way to bestow a level of automation or smarts to a project is to reach for an Arduino. The genesis of the popular ecosystem of boards and associated bootloader and IDE combination is well known, coming from the work of a team at the Interaction Design Institute Ivrea, in Northern Italy. The name “Arduino” comes from their favourite watering hole, the Bar di Re Arduino, in turn named for Arduin of Ivrea, an early-mediaeval king.

As far as we can see the bar no longer exists and has been replaced by a café, which appears on the left in this Google Street View link. The bar named for Arduin of Ivrea is always mentioned as a side note in the Arduino microcontroller story, but for the curious electronics enthusiast it spawns the question: who was Arduin, and why was there a bar named after him in the first place?

The short answer is that Arduin was the Margrave of Ivrea, an Italian nobleman who became king of Italy in 1002 and abdicated in 1014. The longer answer requires a bit of background knowledge of European politics around the end of the first millennium, so if you’re ready we’ll take Hackaday into a rare tour of medieval history.

Defying An Empire

The Holy Roman Empire at the turn of the second millennium. Sémhur derivative work: OwenBlacker, CC BY-SA 3.0

Western Europe’s dominant power at the turn of the first millennium was the Holy Roman Empire, a German-ruled agglomeration of states which though not a direct successor to the Roman Empire had received the recognition of the Papacy as such following the accession of a female ruler as empress of the former Eastern Roman empire in Byzantium. Its young Emperor Otto III died unexpectedly in 1002 without an heir, and in the power vacuum that followed the Italian nobility sought to re-establish their control and break away from German influence. Thus they elected one of their own to become King of Italy, selecting Arduin for the throne.

The tumultuous politics of 10th and 11th century Italy seem to revolve around the struggles between the forces controlled by the bishops, largely aligned with or appointed by the Holy Roman Emperor, and those of the nobility who seem to have been alternately on the side of — or fighting against — the Emperor. Arduin had been excommunicated twice, once in Rome before Otto himself and his Papal appointment Sylvester II, after burning the cathedral of Vercelli and killing its bishop.

The Empire Strikes Back

There seem to be no contemporary depictions of Arduin, this stylised one is from a later century. Marilynmerlo, CC BY-SA 3.0.

When the newly crowned Emperor Henry II immediately sent a force to depose Arduin, it was repulsed, leading to Henry himself leading a larger army and defeating him in 1004. This and Henry’s subsequent coronation as King of Italy in the city of Pavia might have been the end of the story, but as the newly crowned king and his retinue were driven from the city by rioting it is evident that he did so without the support of his populace. Thus while Arduin had lost control of part of his claimed kingdom he continued to hold power from his base in Ivrea and spent the next decade still asserting himself as King of Italy despite Henry also holding the crown. He was eventually defeated and forced to abdicate in 1013, and died the following year.

If there’s something to take away from this tale of European politics a millennium past, it’s the surprise at how little he leaves us. For other medieval figures there might be a statue or perhaps a fresco in a church, but for Arduin beyond the stylised portrait evidently drawn centuries later we have no depiction of him. If the town of which he was once ruler had not memorialised him in a street name that in turn prompted the owner of a bar to use his name, it’s possible nobody but a few historians would ever have known about him. Perhaps here is a lesson in measuring the legacies of our politicians here in the 21st century.

So we have the love of some Italian post-grads for their favourite watering hole to thank for our familiarity with the name of an obscure medieval king, and now we know a little more about him and his life. Perhaps we should all turn to our local pub for inspiration when naming our projects, though in my case I’m not sure that The Sow And Pigs would be as edifying an appellation.

Header image: SimonWaldherr, CC BY-SA 4.0.

Hack a Day 01 Dec 18:01

The Wash-A-Lot-Bot is a DIY handwashing timer

With the current coronavirus situation, we’ve been encouraged to wash our hands regularly for 20 seconds – or approximately how long it takes you to hum “Happy Birthday” from beginning to end twice. That sounds easy enough, but do you really do this every time? What you need is some sort of automatic timer, perhaps with a dial gauge for easy visual reference. 

As it just so happens, Gautam Bose and Lucas Ochoa built such a device with an Arduino Uno. The aptly named Wash-A-Lot-Bot detects a person’s hands in front of it via an ultrasonic sensor, then ticks a dial timer from 0 to 20 (or rather 20 to DONE!) using a micro servo. 

This simple setup can be made with little more than scissors and tape, making it a great way to learn about Arduino and programming while you’re stuck indoors.

Arduino Blog 29 Mar 18:07
arduino  featured  uno  

1,156 LEDs make up these dual acrylic light-up panels

What does one do with over 1,000 LEDs, white acrylic, and 288 IR sensors? If you’re Redditor “jordy_essen,” you create an interactive light panel.

In one mode, the user pull a reflective tool across the sensors to draw a paths, with potentiometers implemented to select the color. It can also be set up to play a sort of whack-a-mole game, where one has to activate the sensor in the same area where it illuminates.

For this amazing device, jordy_essen uses not one, or even two, but six Arduino Mega boards to drive the LEDs directly — in turn controlled by a webpage running on a Raspberry Pi. If that wasn’t enough hardware, an Uno is tasked with taking inputs from the color potentiometers. 

It’s a brilliant project in any sense of the word!

Arduino response to the Covid-19 outbreak

For the latest update regarding Arduino’s response to the Covid-19 outbreak please click here.

Priority Service for the Design & Production of Essential Medical and Personal Protective Equipment (PPE)

As companies around the globe rapidly react to governments’ calls to produce critical medical equipment like ventilators and PPE, Arduino is prioritizing stock allocation for these urgent needs.

If your company urgently requires any Arduino hardware or software to facilitate the prototyping and production of any equipment or solution to lessen the impact of Covid-19 please contact us.

A dedicated team will work to ensure we support your needs through ensuring the fastest possible delivery (either directly or via sub-distribution) and/or expediting production as required. We will also provide increased levels of design support and help for those designing such critical equipment. 

Tune in to the official Arduino Day 2020 livestream

We’re just hours away from (virtually) celebrating Arduino Day! Join us on Saturday for our official livestream, starting at 2pm CET. We’ll connect with community events from all around the world as well as hear from Arduino team members like Fabio Violante, Massimo Banzi, and David Cuartielles.

Be sure to set a reminder and tune in!

Work remotely with Arduino Create – get a free upgrade now

To help individuals work remotely and share their designs with team members, we’re providing a free 3-month upgrade to the Arduino Create Maker plan to all 1.4 million users of Create as well as new subscribers to the service. With Arduino Create everything is ready to go; there is no need to install libraries and you can quickly share your sketch with teammates via just a URL. 

To gain your free 3-month upgrade* all you need to do is go to Arduino Create choose the “Maker” plan with the default monthly option and enter the voucher code “CREATE4FREE” during the purchase process.

Arduino Create enables users to write code, access content, configure boards and share projects. Features such as an always up-to-date online IDE and the ability to share builds and receive feedback from other facilities means you can work from home efficiently and effectively. If you don’t want to start a project from scratch there’s always the option to tap into the power of the community on the Arduino Project Hub by browsing projects and making them your own. 

The ‘Maker’ plan comes with the added benefits of up to 250 sketches allowed in your sketchbook along with 200MB space to store those sketches and libraries. You can manage more connected objects (5 ‘things’) with up to 20 properties per ‘thing’, enabling the development of complete IoT solutions. Automating processes remotely is further enabled by the Maker plan including access to set up and remotely control 5 of each cloud enabled Arduino board, 3 cloud-enabled Linux devices, and 1 cloud-enabled generic third-party board.

Find out more details about Arduino Create and all the features included in the Maker plan here.

*The ‘free 3-month upgrade to Create Maker is applicable to the monthly plan and is limited to new subscribers only. Voucher code “CREATE4FREE” expires 30th June 2020. 

Please note the first monthly payment will start 3 months after you purchase the plan, and you are able to cancel your subscription at any time.

This acoustic sensing system localizes touch and senses force on everyday surfaces

Researchers from the University of Auckland in New Zealand’s are exploring a new way to construct interactive touch surfaces using finger-mounted audio transducers. 

VersaTouch — which works on everyday surfaces — uses one or more receivers to measure sound waves emanating from the wearer’s “augmented” fingers, allowing it to calculate their positions and/or movements. The plug-and-play system can also sense force based on a changing audio signature and track individual digits by alternating each one’s sonic outputs. 

Importantly, VersaTouch can be configured without permanent modification to the newly interactive surface. The setup includes an Arduino Due to receive signals, a Teensy 3.6 to control the transducers, and a MacBook to process the data and calculate the touch positions with a Java program.

More information on the project can be found in the team’s research paper, and you can see it demonstrated in the video below. 

VersaTouch is a portable, plug-and-play system that uses active acoustic sensing to track fine-grained touch locations as well as touch force of multiple fingers on everyday surfaces without having to permanently instrument them or do an extensive calibration. Our system is versatile in multiple aspects. First, with simple calibration, VersaTouch can be arranged in arbitrary layouts in order to fit into crowded surfaces while retaining its accuracy. Second, various modalities of touch input, such as distance and position, can be supported depending on the number of sensors used to suit the interaction scenario. Third, VersaTouch can sense multi-finger touch, touch force, as well as identify the touch source. Last, VersaTouch is capable of providing vibrotactile feedback to fingertips through the same actuators used for touch sensing.

Thales, Telstra, Microsoft and Arduino deliver scalable trust for easy-to-deploy IoT Applications

We’ve partnered with Thales, Telstra and Microsoft to pave the way for scalable security for connected IoT devices, by implementing a solution that enables trusted and secure end-to-end communication between device and cloud.

The solution enables instant and standardized mutual authentication between a device and a cloud platform via cellular networks, while fully-complying with GSMA IoT SAFE security specifications.

Within the IoT ecosystem, billions of devices collect, process and send data to the cloud, where a range of different IoT services are executed. To enable security, the IoT cloud service must have absolute trust in data received from connected devices. Equally, devices need to trust the cloud. This is only possible if the device and server are mutually authenticated. However, the IoT devices market is so fragmented — with a patchwork of different operating systems and chips being utilized — that security services scalability and duplication are very limited.

That’s why Thales, Telstra, Microsoft[1]and Arduino[2] have decided to team up to work on a solution that addresses the challenge of securely and efficiently connecting IoT devices to clouds in the most simplified way and through cellular networks. The level of trust required is enabled by a sophisticated ‘security-by-design’ approach for any IoT devices based on field-proven and standardized SIM or eSIM technology.

As a result, as soon as an IoT device is switched on, any SIM or eSIM featuring Thales’s IoT SAFE application is automatically and securely provisioned. Once the IoT device gets a proper Digital Certificate created and stored in the SIM/eSIM, then a trusted communication between the device and the server is permitted, in full respect of data integrity and confidentiality.  

We are very pleased to be part of the dream team composed by Thales, Telstra and Microsoft,” said Fabio Violante, Arduino CEO. “The development of this tool was a teamwork and a proof that Arduino is a great partner to create solid, reliable and easy to integrate hardware and software IoT solutions.

[1] Microsoft integrated the IoT SAFE solution with their Azure IoT Hub and also provided Azure Stream Analytics, Cosmos DB and Power BI services to quickly enable the development of an example end-to-end IoT application.

[2] We developed a library (under an open source license) that implements the security mechanism of the GSMA IoT Safe standard on our MKR NB 1500 boards and provides a valid alternative to the usage of the crypto chip already present on the Arduino board. The project has been a great example of collaborations with companies operating in various IoT sectors through our brand new Arduino Pro division.