When one thinks of the Arduino Uno, one thinks of a capable 8-bit microcontroller platform that nonetheless doesn’t set the world alight with its performance. Unlike more modern parts like the ESP32, it has just a single core and no real multitasking abilities. But what if one wanted to run many threads on an Uno all at once? [Adam] whipped up some code to do just that.
Threads are useful for when you have multiple jobs that need to be done at the same time without interfering with each other. The magic of [Adam]’s ThreadHandler library is that it’s designed to run many threads and do so in real time, with priority management as well. On the Arduino Uno, certainly no speed demon, it can run up to 57 threads concurrently at 6ms intervals with a minumum timing error of 556 µs and a maximum of 952 µs. With a more reasonable number of 7 threads, the minimum error drops to just 120 µs. Each thread comes with an estimated overhead of 1.3% CPU load and 26 bytes of RAM usage.
While we struggle to think of what we could do with more than a handful of threads on an Arduino Uno, we’re sure you might have some ideas – sound off in the comments. ThreadHandler is available for your perusal here, and runs on SAMD21 boards as well as any AVR-based boards that are compatible with TimerOne. We’ve seen other work in the same space before, such as ChibiOS for the Arduino platform. Video after the break.
Continue reading “Running 57 Threads At Once On The Arduino Uno”
Remember the TiVo? The set-top DVR that was once so popular of a hacking target that Hackaday had a dedicated subdomain for it has today largely faded into obscurity as time-shifted viewing has given way to Internet streaming services like Netflix and Hulu. But make no mistake, while the TiVo may no longer be the centerpiece of the average home entertainment center, there’s a diehard group of antennaed aficionados that are still rocking (and hacking) them.
One such TiVotee is [Thomas McQueen], who recently discovered his TiVo-powered Virgin Media V6 DVR was listening for commands on the network. After finding some official documentation for the protocol and firing off a couple of test commands from his computer’s telnet client, he realized he had an opportunity to flex his microcontroller muscle and create a library that would allow controlling the set-top box with the ESP8266 or other network-capable MCU.
[Thomas] built his project on-top of the basic Arduino WiFi library, making every effort to make it as generalized as possible so it could work on a multitude of platforms and with various targets. He even made sure to give all his functions friendly names that won’t leave users scratching their head when they read through example code down the road. We’ve seen far too many software projects that were poorly documented or obtusely programmed, so it’s always good to see somebody putting some forethought into their code.
The library makes it easy to add TiVo control to your project, but [Thomas] went one step further and came up with an example application that provides a web interface on the ESP8266 or ESP32. Any device with a web browser, such as a smartphone, can connect to the UI and fire off commands to the TiVo. His next step is to combine his library with some code to talk to Amazon’s Alexa so he’ll be able to control playback with his voice.
We’ll hand it to these TiVo users, they’re a tenacious lot. Earlier in the year, we covered how one dedicated TiVo fan managed to brute-force the child lock on his DVR using the Arduino and an IR LED.
The readability of your code can make the difference between your project being a joy to work on, or an absolute headache. This goes double when collaborating with others. Having easily parsed code reduces your cognitive load and makes solving problems easier. To try and help with this, [PTS93] developed the Stator library to make certain common tasks simpler to read.
The aim of the library is to get rid of piles of state tracking variables and endless if/else statements – hence the name. It’s designed primarily for the Arduino IDE but doesn’t have any dependencies on the API, so can be used in other C++ environments. It comes with a variety of neat tools for common jobs, such as reading an analog sensor with hysteresis around a trigger point, as well as easy ways to track state changes across multiple variables. By using basic English terms instead of condition checks and mathematical operators, it can make things more readable and easier to follow.
The power of the Arduino platform has always been in its easy to use libraries that make everything easier, from interfacing LCDs to working with Amazon Dash buttons.
Amazon Dash is a handy service, and when Amazon released their AWS IoT platform, [Brian Carbonette] felt that it left out all the hardware hackers from the tinkering fun. Seeking justice, he put together a guide for an Arduino Dash button aimed at hardware hackers and those who are still easing into the world.
For his build, [Carbonette] used an Arduino MKR1000, laying out a few different configuration options for building your button. He has also gone to great lengths to help all comers tackle the Arduino-Dash API communication process by building an AmazonDRS Arduino Library, which handles all the “boring details,” so you can focus on the hardware. With the warning that the software-side setup is tedious the first time around, [Carbonette] has included a detailed manual for setting up the aforementioned AmazonDRS library, some example code, and a breakdown thereof. He also suggests implementing other features — such as a notification if the item is out of stock on Amazon — to tie the project together.
Continue reading “Dash With Arduino”