Using Valgrind To Track Down Known And Unknown Bugs In Your Code

We all know what bugs in code are. We don’t like them when they are in programs we use, and they’re even worse when they are in code which we have written. Clearly, the best code is bug-free, but how do we get there?

This isn’t a new question, of course, just one that has become ever more important as the total number of lines of code (LoC) that run modern day society keeps increasing and which is affecting even hobbyists more and more often now that everything has a microcontroller inside.

Although many of us know the smug satisfaction of watching a full row of green result markers light up across the board after running the unit tests for a project, the painful reality is that you don’t know whether the code really is functionally correct until it runs in an environment that is akin to the production environment.  Yet how can one test an application in this situation?

This is where tools like those contained in the Valgrind suite come into play, allowing us to profile, analyze and otherwise nitpick every single opcode and memory read or write. Let’s take a look, shall we?

Continue reading “Using Valgrind To Track Down Known And Unknown Bugs In Your Code”

Raspberry Pi Waters Your Lawn, Serves HTML

It is easy to take a Raspberry Pi and treat it like a cheap Linux PC or server. Running an ad blocker or a VPN gateway is simple and doesn’t require any real interfacing. However, it is a big leap to actually use the Pi to control something and a good example can go a long way to helping you develop your own projects. [Joeseph Luccisano] posted a tutorial with just that aim. The goal: build a low-cost lawn watering system.

It is an interesting project since it has hardware and software components, of course. But it also has a hydraulic part, so you have to deal with all three domains coming together.

Continue reading “Raspberry Pi Waters Your Lawn, Serves HTML”

Cheap Alternative Solvents For PCB Cleaning

If you’re in the habit of using isopropyl alcohol to clean your PCBs after soldering, you probably have a nice big jug of the stuff stashed away. If you don’t, you’re probably out of luck, since the COVID-19 pandemic has pretty much cleared IPA out of the retail market. But don’t fret: depending on where you live, alternative PCB cleaning solutions may be as close as your nearest auto parts store.

[Steven]’s search for a cheaper and perhaps more readily available substitute for his usual dedicated flux cleaner lead him to try automotive brake cleaner on a few test boards. He suspected that they might contain acetone, which is prone to yield unfortunate results with solder resist and silkscreen on PCBs, so some tests were in order. The brand he tried was Normfest Bremsenreiniger MC-1, a German brand that according to its Safety Data Sheet contains only hydrocarbons like alkanes, butane, and propane. It did a fine job cleaning all but the crustiest rosin flux without collateral damage.

In the video below, [Steven] goes through a few more brands with similar results, and we were encouraged enough by his results to check brake cleaners made for the US market. Alas, almost all of the cheap and readily available aerosols have acetone as the principle ingredient, mixed in with methanol, ethanol, and assorted ingredients that together will probably make for a bad day. About the only US-sold brand without acetone that we could find was Keller-Heartt, which lists only naptha and ethanol on its SDS. There may be others, but make sure you test whatever you find.

Aerosol solvents aren’t the only way to clean a PCB, of course. Ultrasonic cleaners do a great job, and as [Steven] discovered, they’re generally safe for most components.

Continue reading “Cheap Alternative Solvents For PCB Cleaning”

Modular Mouse Packs Features

Not only do console gamers complain about the use of a mouse, but PC users themselves often don’t have kind words to say even about some of the higher-end options. Granted, their gripes aren’t about game experience or balance, they’re usually about comfort, features, or longevity of the mice themselves. So far we haven’t seen many people try to solve these problems, but [benw] recently stepped on the scene with a modular mouse that can fit virtually any need.

Called the RX-Modulus, this mouse has been designed from the ground up to be completely open source from hardware to software. Most of the components can be 3D printed to suit an individual’s particular grip style by making adjustments. The electronics can be custom fitted as well. Users can swap out mouse buttons and wheels in any number of positions, and replace them when they wear out. To that end, one of the goals of this project is also to avoid any planned obsolescence that typically goes along with any current consumer-level product.

While [benw] currently only has a few prototypes under his belt, he’s far enough along with the project that he’s willing to show it off to the community. His hopes are that there are others that see a need for this type of mouse and can contribute to the final design. After all, there are all kinds of other custom mice out there that would have been much easier builds with [benw]’s designs at hand.

Beam Your Program To Another Computer

If you’ve programmed much in Linux or Unix, you’ve probably run into the fork system call. A call to fork causes your existing process — everything about it — to suddenly split into two complete copies. But they run on the same CPU. [Tristan Hume] had an idea. He wanted to have a call, telefork, that would create the copy on a different machine in a Linux cluster. He couldn’t let the idea go, so he finally wrote the code to do it himself.

If you think about it, parts of the problem are easy while others are very difficult. For example, creating a copy of the process’s code and data isn’t that hard. Since the target is a cluster, the machines are mostly the same — it’s not as though you are trying to move a Linux process to a Windows machine.

Continue reading “Beam Your Program To Another Computer”

A Flag-Waving Hat For All Occasions

When [Taste the Code] saw that his YouTube channel was approaching 1,000 subscribers, it was time to do something special. But celebration is no reason to be wasteful. This flag-waving celebratory hat has endless possibilities for the future.

The build is simple, which is just right for these strange times of scarcity. An Arduino Uno hot-glued to the back of the hat is directly driving a pair of 9g servos on the front. [Taste the Code] made the flags by sticking two stickers back to back with a bamboo skewer in between. The code is flavored such that the flags will wave in one of three randomly-chosen patterns — swing around, swing in reverse, and wild gesticulations.

After the novelty of the whole 1k subs thing wears off, [Taste the Code] can change the flags over to Jolly Rogers to help with social distancing. And someday in the future when things are really looking up, they can be changed over to SARS-CoV-2 victory flags, or fly the colors of a local sports team. We think it would be way cool to program some kind of real semaphore message into the flags, though the mobility might be too limited for that. Check out the build video after the break, which happens picture-in-picture as [Taste the Code] dishes out a channel retrospective and lays out a course for the future.

Even though YouTube messed with subscriber counts, we think it’s still worth making a cool counter. Here’s one with a Tetris twist.

Continue reading “A Flag-Waving Hat For All Occasions”

Get Your Microcontroller Online At The Speed Of Light

When developing a network-enabled project with the ESP8266 or ESP32, the easiest way to handle WiFi credentials is to just hardcode the access point and encryption key into the program. But that means recompiling the firmware if you ever want to use it on a different network, which isn’t really an option if you’re trying to make something that other people can easily use. If you’re expecting grandma to bust out the UART cable, we’ve got bad news for you.

There are various ways around this problem, but we think the one developed by [Pekka Lehtikoski] is particularly clever. With a simple application, network credentials can be literally “flashed” to the waiting microcontroller by rapidly blinking the flash LED on an Android device. This allows the information to be transferred quickly and easily regardless of the user’s technical proficiency. One could even make the argument that it’s more secure than some of the other methods of doing initial setup, since an eavesdropper would literally need to see you do it if they wanted to steal your encryption key.

[Pekka] has made the source code for the Android application and the “Gazerbeam” library open for anyone who wants to include the capability in their own projects. To pick up the blinking light you just need to add a phototransistor, an opamp, and a handful of passives to your circuit; making this solution cheap enough that you could even use it in a small-scale production run. The concept isn’t limited to network credentials either. Whenever we can hold conferences again, it could be an interesting way to let attendees customize their badge.

Of course, [Pekka] isn’t the first person to use this trick. Hackers well versed in the history of WiFi MCUs may recall that the Electric Imp used a very similar method of configuration called BlinkUp. If you ever come across a device that asks you to put your phone’s screen down on a little window to perform the initial setup, there’s a good chance it has an Imp inside.