Python Will Soon Support Switch Statements

Rejoice! Gone are the long chains of ifelse statements, because switch statements will soon be here — sort of. What the Python gods are actually giving us are match statements. match statements are awfully similar to switch statements, but have a few really cool and unique features, which I’ll attempt to illustrate below.

Continue reading “Python Will Soon Support Switch Statements”

Bringing Some Coulter To The Bench: Measuring Tiny Particles With Nanopore Sensing

We’ve all been there: you’re sitting at your bench, with a beaker full of some conductive fluid with a bunch of tiny particles suspended in it, and you want to measure the sizes of each particle.

Okay, maybe this isn’t a shared experience we’ve all had, but It’s at least an ordeal Hackaday alum [Nava Whiteford] has been through, and he was able to carry out the measurements in question using a neat apparatus known as a Coulter counter.

Imagine a container full of a conductive fluid. If you place an electrode at each end, the fluid will carry a current. Now, drop an insulating divider in the middle of the container, and the current will stop flowing. Finally, poke a small hole (or nanopore) in the divider. Huzzah! The current is flowing again… but how does this let us measure particle sizes? Well, now think about a tiny particle moving through the hole in the divider. As the particle passes through, the hole will be partially blocked, and the current flow will be partially interrupted. It turns out, the resulting dip in current is proportional to the volume of the particle — a fun property known as the Coulter principle.

[Nava] built a great demo of the system with a macropore in place of the nanopore. The pore in question was a hole melted into a bottle cap, which was suspended in a beaker by two toothpicks. [Nava] used small chips of Acrylic as the particles to be measured, which they pipetted into the solution of KCl. They then passed a current through the solution and used an oscilloscope to sense the interruptions. Be sure to check out their write up for a video of the system in action!

Of course, this technique has a much wider range of applications than measuring little bits of plastic — obtaining blood cell counts, for one. We’ve seen particle counters for use in the air before, but it’s great to see that there’s a way to measure particles in an aqueous solution —  you know, in case we ever find ourselves in such a situation.

Sea Level: How Do We Measure Global Ocean Levels And Do Rising Oceans Change That Benchmark?

Every summer you go down the shore, but lately you’ve begun to notice that the beach seems narrower each time you visit. Is that the sea level rising, or is the sand just being swept away? Speaking of sea levels, you keep hearing that they rise higher every year — but how exactly is that measured? After all, you can’t exactly use a ruler. As it turns out, there are a number of clever systems in place that can accurately measure the global sea level down to less than an inch and a half.

Not only are waves always rippling across the ocean’s surface, but tides periodically roll in and out, making any single instantaneous measurement of sea level hopelessly inaccurate. Even if you plan to take hundreds or thousands of measurements over the course of weeks or months, taking the individual measurements is still difficult. Pick a nice, stable rock in the surf, mark a line on it, and return every hour for two weeks to hold a tape measure up to it. At best you’ll get within six inches on each reading, no matter what you’ll get wet, and at worst the rock will move and you’ll get a damp notebook full of useless numbers. So let’s take a look at how the pros do it.

Continue reading “Sea Level: How Do We Measure Global Ocean Levels And Do Rising Oceans Change That Benchmark?”

Continuous Excitation Piano Machine Looks Nervous, Sounds Grand

It’s not every day we see a grand piano with a Raspberry Pi inside, let alone one with 96 motors, but sometimes we get lucky. The contraption in question is one developed by [Konstantin Leonenko], as part of a collaboration with composer [Patricia Alessandrini] for a piece she created inspired by Ada Lovelace. Specifically, [Patricia] was inspired by Ada’s idea that an “analytical machine” would, someday, be able to create music on its own. [Konstantin] and [Patricia] worked together to make a machine that would learn from it’s human co-performers and create music with them.

Their creation, rather than just one tricked-out keyboard, is actually a portable attachment that can be easily fitted to any grand piano. Each of the device’s 96 motors drives a plastic “finger” that excites the piano’s strings. The result is a sound unlike any other — and you really need to experience it so click through that link at the top for the demo video.

Rather cleverly, the fingers are designed such that their dynamics help to mask the sound of the motor (a must for performances) while simultaneously enhancing the string’s timbre. Like any project, this one went through a number of iterations over the two-year design process, and even spun off into an entirely new, glove-based version.

We’ve seen some awesome music tech hacks, and this one fits right in with the rest. It’s always exciting to see an instrument as ubiquitous as the piano be used in new and refreshing ways. Be sure to check out the link at the top for a video of this incredible instrument in action!

Hacking Hardware Bitcoin Wallets: Extracting The Cryptographic Seed From A Trezor

It’s long been common wisdom that one of the safest places to keep your cryptocurrency holdings is in a hardware wallet. These are small, portable devices that encrypt your keys and offer a bit more peace of mind than holding your coins in a soft or web wallet.

But of course, as we know, nothing is totally secure.

And we were reminded of this fact by Kraken Security Labs, when they showed us how they bypassed all of the safeguards in a popular wallet, the Trezor, to dump and decrypt it’s seed.

It’s worth noting that the hack does require physical access to the wallet — albeit only about fifteen minutes worth. And by “physical access” we mean that the hack leaves the device thoroughly mutilated. The Kraken team started by desoldering the heart of the wallet, a STM32 processor. They then dropped it into a socket on an interface board, and got to glitching.

The hack relies on an attack known as voltage glitching. Essentially, at a precisely-timed moment during the device’s boot sequence, the supply voltage is fluctuated. This enables the chip’s factory bootloader, which can read out the contents of it’s onboard flash memory. The memory is read-protected, but can be accessed 256 bytes at a time through a second voltage glitch. Neither of these attacks work 100% of the time, so if the device fails to boot or the memory remains locked, the FPGA performing the attacks simply tries again. After enough iterations, the Kraken team was able to fully dump the chip’s flash memory.

Continue reading “Hacking Hardware Bitcoin Wallets: Extracting The Cryptographic Seed From A Trezor”

Bringing Modern Control To An Old Radio

The modern ham radio shack can take many forms. Some are shrines the “boat anchor” radios of old, named for their considerable weight. Others are simply a small, unassuming software-defined radio (SDR) hooked up to a laptop. Nowadays, many shacks fall somewhere in the middle. It’s not uncommon to find a sleek Icom IC-7300 sitting atop an ancient Hallicrafters SX-115 (which sounds suspiciously like the author’s setup). When a ham wants to work a digital mode such as FT-8, they will undoubtedly reach for a newer radio complete with USB (Universal Serial Bus in this case, not Upper Sideband) rig control — but what if the newest piece of equipment they have is a thirty-year-old Kenwood?

If that sounds like you, then fear not because [Steve Bossert] has you covered. He took his trusty Kenwood TS-50, a classic radio from 1993 whose most advanced feature is fuzzy logic, and upgraded it with USB (again, the serial bus) control.

When Kenwood designed the TS-50, they had computer control in mind. There’s a hidden port on the bottom of the unit which reveals a connector that mates with Kenwood’s proprietary (and expensive) set of serial control cables. Thankfully, the engineers over at Kenwood decided to use UART for PC communication, so slapping a USB port in the radio’s case isn’t as daunting as it may sound. [Steve] picked up a CP2104 USB-TTL UART Serial Adapter and wired it up to the radio’s control port. After a bit of drilling, screwing, and gluing, the radio had an upgraded (and non-proprietary!) interface compatible with the ever-popular hamlib. While this doesn’t cover all radio control functions, it gets you tuning, which is pretty important. For a fully modern radio experience, [Steve] suggests using the 8-pin mic connector along with an interface such as Rigblaster or Signalink. This adds PTT and audio signal routing.

If you want to try this for yourself, be sure to check out [Steve]’s extremely well-documented writeup. You could even take this a step further and control your TS-50 from your smartphone with this HTML5 interface we saw a few months back.

Webcam Heart Rate Monitor Brings Photoplethysmography To Your PC

It seems like within the last ten years, every other gadget to be released has some sort of heart rate monitoring capability. Most modern smartwatches can report your BPMs, and we’ve even seen some headphones with the same ability hitting the market. Most of these devices use an optical measurement method in which skin is illuminated (usually by an LED) and a sensor records changes in skin color and light absorption. This method is called Photoplethysmography (PPG), and has even been implemented (in a simple form) in smartphone apps in which the data is generated by video of your finger covering the phone camera.

The basic theory of operation here has its roots in an experiment you probably undertook as a child. Did you ever hold a flashlight up to your hand to see the light, filtered red by your blood, shine through? That’s exactly what’s happening here. One key detail that is hard to perceive when a flashlight is illuminating your entire hand, however, is that deoxygenated blood is darker in color than oxygenated blood. By observing the frequency of the light-dark color change, we can back out the heart rate.

This is exactly how [Andy Kong] approached two methods of measuring heart rate from a webcam.

Method 1: The Cover-Up

The first detection scheme [Andy] tried is what he refers to as the “phone flashlight trick”. Essentially, you cover the webcam lens entirely with your finger. Ambient light shines through your skin and produces a video stream that looks like a dark red rectangle. Though it may be imperceptible to us, the color changes ever-so-slightly as your heart beats. An FFT of the raw data gives us a heart rate that’s surprisingly accurate. [Andy] even has a live demo up that you can try for yourself (just remember to clean the smudges off your webcam afterwards).

Method 2: Remote Sensing

Now things are getting a bit more advanced. What if you don’t want to clean your webcam after each time you measure your heart rate? Well thankfully there’s a remote sensing option as well.

For this method, [Andy] is actually using OpenCV to measure the cyclical swelling and shrinking of blood vessels in your skin by measuring the color change in your face. It’s absolutely mind-blowing that this works, considering the resolution of a standard webcam. He found the most success by focusing on fleshy patches of skin right below the eyes, though he says others recommend taking a look at the forehead.

Every now and then we see something that works even though it really seems like it shouldn’t. How is a webcam sensitive enough to measure these minute changes in facial color? Why isn’t the signal uselessly noisy? This project is in good company with other neat heart rate measurement tricks we’ve seen. It’s amazing that this works at all, and even more incredible that it works so well.