Skip navigation.


Syndicate content Hackaday
Fresh hacks every day
Updated: 1 hour 24 min ago

Linux Fu: Better Bash Scripting

2 hours 22 min ago

It is easy to dismiss bash — the typical Linux shell program — as just a command prompt that allows scripting. Bash, however, is a full-blown programming language. I wouldn’t presume to tell you that it is as fast as a compiled C program, but that’s not why it exists. While a lot of people use shell scripts as an analog to a batch file in MSDOS, it can do so much more than that. Contrary to what you might think after a casual glance, it is entirely possible to write scripts that are reliable and robust enough to use in many embedded systems on a Raspberry Pi or similar computer.

I say that because sometimes bash gets a bad reputation. For one thing, it emphasizes ease-of-use. So while it has features that can promote making a robust script, you have to know to turn those features on. Another issue is that a lot of the functionality you’ll use in writing a bash script doesn’t come from bash, it comes from Linux commands (or whatever environment you are using; I’m going to assume some Linux distribution). If those programs do bad things, that isn’t a problem specific to bash.

One other limiting issue to bash is that many people (and I’m one of them) tend to write scripts using constructs that are compatible with older shells. Often times bash can do things better or neater, but we still use the older ways. For example:

if [ $X -gt 0 ]  then .... fi

This works in bash and a lot of other similar shells. However, bash can do better:

if [[ $X > 0 ]] then ... fi Features

Don’t think bash is a programming language? It has arrays, loops, sockets, regular expression matching, file I/O, and lots more. However, there are a few things you should know when writing scripts that you expect to work well. You might add your own items to this list, but this one is what comes to my mind:

  • Use “set -o errexit” to cause the script to exit if any line fails
  • Use “set -o nounset” to cause an error if you use an empty environment variable
  • If you don’t expect a variable to change, declare it readonly
  • Expect variables could have spaces and quote accordingly
  • Use traps to clean up your mess
Exit on Error

If you use “set -o errexit” then any line that returns a non-zero error code will stop script execution. You might object that you want to test for that condition like this:

some_command if [[ $? != 0 ]] then     recover fi

If you use the errexit flag, that test will never occur because once some_command throws the error, you are done. Simply rewrite like this:

some_command || recover

The effect is if some_command returns true (that is, zero), then bash knows the OR operator is satisfied so it doesn’t run any more commands. If it fails, then bash can’t tell if the OR is satisfied or not, so it runs recover. The exit code of the entire thing is either 0 from some_command or the exit code of recover, whatever that is.

Sometimes you have a command that could return an error and you don’t care. That’s easy to fix:

some_other_command || true

By the way, usually, the last item in a pipeline determines the result. For example:

a | b | c

The exit code of that line is whatever c returns. However, you can “set -o pipefail” to cause any error code in the pipe to halt the script. Even better is the $PIPESTATUS variable which is an array with all the exit codes from the last pipeline. So whatever program b returned will be in ${PIPESTATUS[1]}, in the above example.

Unset Variables

Using “set -o nonunset” forces you to initialize all variables. For example, here’s a really bad script (don’t run it):

TOPDIR=tmp #rm -rf /${TOPDIRR}

You can argue this isn’t great code, but regardless, because TOPDIR has a typo in the last line, you’ll erase your root directory if this runs without the protective comment in front of the rm. This works for command line parameters, too, so it will protect you if you had:

bad_cmd /$1


Many times you set a variable and you really need a constant. It shouldn’t change as the script executes and if it does that indicates a bug. You can declare those readonly:

readonly BASEDIR="~/testdir" readonly TIMEOUT_S=10 Expect Spaces

File systems allow spaces and people love to use them. This can lead to unfortunate things like:

rm $2

When $2 is something like “readme.txt” that’s fine. However, if $2 is “The quick red fox” you wind up trying to erase four files named “The,” “quick,” “red,” and “fox.” If you are lucky, none of those files exist and you get errors. If you are unlucky, you just erased the wrong file.

The simple answer is to quote everything.

rm "$2"

If you ever use $@ to get all arguments, you should quote it to prevent problems. Consider this script:

#!/bin/bash function p1 {   echo $1 } p1 $@ p1 "$@"

Try running the script with a quoted argument like “the quick red fox”. The first function call will get four arguments and the second call will get only one, which is almost surely what you intended.


It isn’t uncommon for scripts to create temporary lock files and other things that need cleaning up if the script stops. That’s what the trap command is for. Suppose you are working on building a file called /tmp/ and you want to remove it if you don’t get a chance to complete. Easy:

trap "rm -f /tmp/output; exit" INT TERM EXIT

You can look up the trap command for more details, but this is a great way to make things happen when a script ends for any reason. The exit command in quotes, by the way, is necessary or else the script will attempt to keep running. Of course, in an embedded system, you might want that behavior, too.

You probably want to remove the trap before you are done unless you really want deleted, so:

trap - INT TERM EXIT Wrap Up

You should consider turning off features you don’t need, especially if taking input from outside your script. For example, using “set -o noglob” will prevent bash from expanding wildcards. Of course, if you need wildcards, you can’t do this — at least not for the part of the script that uses them. You can also use “shopt -s failglob” which will cause wildcards to throw an error, if you want to secure your script.

Speaking of security, be very careful running user input as commands. Security is an entirely different topic, but even something that seems innocent can be maniuplated to do bad things if you are not careful. For example, suppose you secure sudo to allow a few commands and you offer the script:

sudo -u protuser "$@"

If sudo is set up right, what’s the harm? Well… the harm is that I can pass the argument “-u root reboot” (for example) and sudo will decide I’m root instead of protuser. Be careful!

There are a lot of tricks to writing bash scripts that are portable. I don’t care about those in this context because if I’m deploying an embedded system on a Raspberry Pi, I will control the configuration so that I know where /tmp is and where bash is located and what version of different programs are available. However, if you are distributing scripts to machines you don’t control, you might consider searching the internet about bash script portability.

If you want to catch a lot of potential errors in scripts (including some portability issues) you can try ShellCheck. You might also appreciate Google’s shell style guide. If you aren’t sure bash is really a programming language, this should convince you.

Filed under: Hackaday Columns, linux hacks, Skills, Software Development
Categories: Hack-a-Day

Electric Skateboard Rocks the Giant LEGO

3 hours 24 min ago

[James Bruton] built an electric skateboard out of oversized LEGO bricks he printed himself, and equipped the board with an excellent re-creation of a classic motor.

He began by downloading brick, gear, and pulley designs from Thingiverse and printing them up five times their normal size, taking 600 hours. The deck consists of 8M Technic bricks lengthwise and 4M bricks crosswise, with plates covering top. There’s even a monster 5×6 plate that’s clearly courtesy of a parametric brick design because you won’t find that configuration among LEGO’s official parts.

The coolest part of the project is probably [James]’ re-creation of an old school LEGO motor. He sized up a 6216M Technic motor originally rated for 4.5V swapping in a 1.5 kW, 24V motor controlled by a 120A ESC and powered pair of Turnigy 5000mAh LiPos wired in series.

[James] had to design his own casing in Blender because couldn’t find a file for the original LEGO part—pro tip for the future, LDraw has the 6216 design and it can be dropped into Blender.

Another nice touch are the wheels, with hubs based off upsized 40-tooth Technic gears with Ninjaflex tires that weigh half-a-kilo each and took 32 hours apiece to print.

We’ve published a lot of [James] ‘ work, including his BB-8 model and some of his other Star Wars models.



Filed under: toy hacks
Categories: Hack-a-Day

Hackaday Eclipse Meetups

Fri, 2017-07-21 23:01

Hackaday is all over this eclipse. There are thousands of members of the Hackaday community headed to a narrow swath of the United States on August 21st to revel in an incredibly rare, scientifically predictable life experience: a total eclipse of the sun.

Do not do it in solitude, get together and celebrate! Check out the Hackaday Eclipse Meetups page which shows where meetups are happening. And adding your own is simple. It’s a great day to meet up with other Hackaday readers and celebrate the day that the moon passed perfectly between you and the sun.

You can’t just stare directly at the sun, you need some eclipse glasses. We’re printing up some in black, adorned with the Jolly Wrencher and sending them out to all organized meetups, so get your event page up today and you’re on the list for a little bit of sweet swag. Look for the button on the Eclipse page that says “Host a meetup”.

I’m Too Cool to Watch an Eclipse

If you don’t get what all the hubbub is, you’re missing out. A total eclipse of the sun is an amazing life experience in so many ways. First off, they’re incredibly rare. There hasn’t been a total eclipse visible in the continental United States since 1979. The majority of the North American readership hasn’t even had the chance to see one in their lifetimes.

This eclipse shadow visualization is incredible. See the entire transit and learn how they produced this from available data

But of course it goes beyond the value of mere scarcity. Being able to understand, and predict an eclipse conveys a great deal about the progress of humanity. For millennia, a solar eclipse was a shocking (perhaps horrifying) experience. But through the scientific process of observation, the advances of record keeping, and the work of untold numbers of early astronomers we learned. Solar and Lunar eclipses were events that challenged thinking and became some of the earliest scientific discoveries.

This type of advancement hasn’t stopped. Even this year the application of the newest technology is present. Just one example that will turn your head is the shadow simulation that we saw in January. The moon isn’t a perfect sphere, and the combination of its landscape and that of the Earth means the outer fringes of totality will not be straight lines, but an undulating path. It’s a small detail realized in a profound way by a citizen scientist so that we may all enjoy it. Isn’t being alive now absolutely stunning?

Boil it Down for Me

So no, watching a rock cast a shadow won’t blow your mind. But understanding that the movement of this shadow isn’t random, that we didn’t always understand it, and that there are huge forces at work here will humble your modern brain and leave you awestruck. It’s a rare chance to observe with your own senses the evidence of huge masses governed by gigantic gravitational forces at incomprehensible distances through the simple act of a shadow racing across the landscape.

Be there, and make it a celebration of science, humanity, and your own life experience. Share your eclipse meetup now!

Filed under: cons, slider
Categories: Hack-a-Day

Serious DX: The Deep Space Network

Fri, 2017-07-21 22:00

Humanity has been a spacefaring species for barely sixty years now. In that brief time, we’ve fairly mastered the business of putting objects into orbit around the Earth, and done so with such gusto that a cloud of both useful and useless objects now surrounds us. Communicating with satellites in Earth orbit is almost trivial; your phone is probably listening to at least half a dozen geosynchronous GPS birds right now, and any ham radio operator can chat with the astronauts aboard the ISS with nothing more that a $30 handy-talkie and a homemade antenna.

But once our spacecraft get much beyond geosynchronous orbit, communications get a little dicier. The inverse square law and the limited power budget available to most interplanetary craft exact a toll on how much RF energy can be sent back home. And yet the science of these missions demands a reliable connection with enough bandwidth to both control the spacecraft and to retrieve its precious cargo of data. That requires a powerful radio network with some mighty big ears, but as we’ll see, NASA isn’t the only one listening to what’s happening out in deep space.

Deep Space Three

The need for a way to talk to satellites was recognized very early on in the US space program, and development of the space communication network that would come to be known as the Deep Space Network (DSN) paralleled developments in space technology that quickly pushed hardware farther and farther from Earth. The DSN was built specifically so that each new mission didn’t need to roll its own communications solutions and could just leverage the current network. Networks for the ESA and for other countries’ space programs have since been built as well, and cooperation between all the network operators is commonplace, especially during emergencies.

Space Flight Operation Facility, “The Center of the Universe” and home of the DSN control center. Source: JPL

Three sites around the globe were selected for the DSN ground stations — Canberra, Australia; Madrid, Spain; and Goldstone, California. The sites are almost perfectly 120° apart, which means that their view of the sky overlaps at an altitude of about 30,000 km; anything farther away from Earth than that is always within view of the DSN regardless of the Earth’s rotation.

Each site has fully steerable parabolic reflector antennas ranging in size from 26 meters to a whopping 70 meters. Sensitive receivers and digital signal processing gear can still pick up the vanishingly faint signals from the Voyager spacecraft, currently more than 30 light-hours away from Earth. Uplink transmitter power vary depending on frequency. The S- and X-band transmitters generally have 20-kW amplifiers, but there’s also a 400-kW amplifier that sometimes gets called into service for the S-band transmitter on the Canberra 70 m dish with special coordination with aviation authorities so that no planes fly through the beam, and with dish elevation limited to 17° above the horizon to avoid frying anyone on the ground.

JPL has a very cool interactive page that lists the current status of all the antennas in the DSN and what each one is doing. While I’m writing this, the 70 m dish in Madrid is sending a 19 kW signal to Voyager 1 and getting back a -154.27 dBm signal. That’s about 370 zeptowatts, but still enough signal to pull out 159 bits/second of data.

Listening In

With all this specialized hardware it would be natural to assume that there’s nothing the average hacker can do to listen to the inbound DSN signals. And indeed, the good folks at the JPL have answered that question with a definitive “No.” They appear not to have checked in with an avid bunch of radio enthusiasts who routinely turn homemade dish antennas to the sky and do their best to pull in the ultimate in DX signals.

Cassini calling home from Saturn. Source: UHF-Satcom [M0EYT] (click to enlarge)One such hobbyist, amateur radio operator Paul Marsh (M0EYT), has enough deep space contacts to populate an active Twitter feed. Sprinkled in among the many images he routinely captures from weather satellites are waterfall displays showing the characteristic diagonal line caused by Doppler-shifted signals from spacecraft far from Earth. He recently bagged the Cassini probe, currently making its final orbits of Saturn before plunging into the gas giant in September. He and his cohorts have listened to plenty of other deep space probes too, including the Mars Reconnaissance Orbiter, the OSIRIS-REx mission in the asteroid belt, the STEREO-A and STEREO-B solar observatories, and the Juno mission to Jupiter.

M0EYT’s 1.8-meter dish, now fully steerable.

The gear that Paul uses to accomplish all this is deceptively simple compared to the big rigs of the DSN. His dish is an off-the-shelf 1.8 m prime focus satellite dish with extender wings to bring it out to 2.4 meters in diameter. Until recently the dish was manually positioned, but is now fully motorized using a Royal Navy surplus altazimuth mount. His receive gear is what you’d expect in any microwave enthusiast’s shack — low-noise amplifiers, mixers, filters — but mostly custom built and optimized for deep space work. A spreadsheet inside the shack calculates the frequency to listen on for any given spacecraft based on its Doppler shift due to its relative velocity. From there, patience and experience lets him pull the faintest of signals.

And what of Voyager, that most remote outpost of humanity? Calling home from interstellar space with an 18 watt signal, it would seem that only the big ears of the DSN could possible pick that up. But Dr. Achim Vollhardt, DH2VA, actually heard Voyager 1 in 2007 at a distance of 9.5 billion miles using a 20 meter dish. So it’s possible, and other deep space listeners may well be able to replicate the feat, but they’d better hurry — Voyager 1’s radioisotope thermal generator is only rated for another three years.

As a ham and a shortwave listener, I can attest to the thrill of working a weak contact through noise and interference, chasing it up and down the dial until the stars align and you’re finally able to copy a callsign from the other side of the planet. How much more thrilling must it be to be able to point a dish at the right location and calculate the correct frequency to tune, and to see that diagonal line on the waterfall indicating a signal from across the solar system!

Title images: Jet Propulsion Lab

Filed under: Featured, Interest, Original Art, radio hacks
Categories: Hack-a-Day

Push Button, Receive Beverage!

Fri, 2017-07-21 19:00

Here’s a rec-room ready hack: an automatic drink dispenser.

[truebassB]’s dispenser operates around a 555 timer, adjusted by a potentiometer. Push a button and a cup pours in a few seconds, or hold the other button to dispense as much as you want.

The dispenser is made from MDF and particle board glued together, with some LEDs and paper prints to spruce it up. Just don’t forget a small spill sink for any miscalculated pours. You needn’t fret over the internals either, as the parts are easily acquired: a pair of momentary switches, a 12V micro air pump, a brass nozzle, food-safe pvc tube,  a custom 555 timing circuit — otherwise readily available online — a toggle switch, a power supply plug plus adapter and a 12V battery.

[truebassB] is using a 1.5L cola bottle, so adapt your build as necessary, or scale it up to include a bar fridge and whatever beverages you want. Cutting holes in the bottle cap slightly smaller than the pvc tube and hot gluing them in place for creates an airtight seal. Once it’s all soldered together and installed, it will probably be time for a well-earned drink!

We’ve featured a few other simple yet ingenious beverage dispensers, and some that might make you question what you’re about to imbibe.

Filed under: how-to, misc hacks
Categories: Hack-a-Day

DC Motor Whirligig Generates Power

Fri, 2017-07-21 16:00

Everyone knows that if you spin the shaft of a DC motor, it will generate power. [Vapsvus] has found a novel way to do this with no direct mechanical connection to the shaft. He simply taped a loop of string around to the motor can. This effectively turns the motor into a whirligig. Flip the motor to give the string a few twists, then pull on the two loops. The string unwinds and then winds back up, just like the toy we all grew up with.

The interesting thing is that the motor generates usable power when being spun like this. [Vapsvus] connected two LEDs to the motor’s leads to show what’s happening. The white LED glows when current travels from positive to negative, and the red LED glows when current travels from negative to positive.

What’s going on under the hood is all about momentum. As the motor can starts to spin, the heavy iron rotor remains still. Power is generated. Eventually, friction and torque from back EMF cause the rotor to spin as well. By the time the rotor is spinning, the motor can is already reversing direction.This generates even more power with current traveling in reverse.

Sure, this isn’t exactly practical, but we’d love to see how far it could be taken. Add a super capacitor, and we bet it would be more efficient than the magnetic shake lights which were popular a few years back.

Whirligigs are usefully little devices. Not only do they keep children entertained, you can use them as centrifuges.

Filed under: classic hacks
Categories: Hack-a-Day

RF Noise Floor Concerns From Both Sides Of The Atlantic

Fri, 2017-07-21 13:00

Our feed is full of stories about the RF noise floor today, and with good reason. The ARRL reports on the International Amateur Radio Union Region 1 president, [Don Beattie, G3BJ] warning that in densely populated parts of Europe there is a danger that parts of the RF spectrum have become so swamped with noise as to be rendered unusable, while on the other side of the Atlantic we have RadioWorld reporting on similar problems facing AM broadcasting in the USA.

At issue are the usual suspects, interference from poorly shielded or suppressed domestic electronic devices, VDSL broadband, power-over-Ethernet, solar and wind power systems, and a host of other RF-spewing electronics. The combined emissions from all these sources have raised the noise level at some frequencies to the point at which it conceals all but the strongest signals. Any radio amateur will tell you that a station in a rural location will be electrically much quieter than one in a city, it seems that this effect has now reached a crescendo.

In the RadioWorld article, the author [Tom F. King] and his collaborator [Jack Sellmeyer] detail a series of tests they performed on a selection of lighting products from a quality brand, bought at a local Home Depot store. They were gathering data for a submission to the FCC enquiry on the noise floor issue we reported on last year. What they found was unsurprising, significant emissions from all the products they tested. They make some stiff recommendations to the FCC and other bodies concerned with radio spectrum to get tough with offending devices, to stay on top of future developments, and for operators of AM stations to pursue sources of interference.

It could be that there is so much equipment contributing to the noise floor that this battle is lost, but it doesn’t have to be this way. Anyone who has had to prepare a product to pass a properly carried out EMC test will tell you that the requirements are stringent, and it is thus obvious that many manufacturers are shipping products unworthy of the certification they display. It is to be hoped that the authorities will begin to take it seriously before it becomes an order of magnitude worse.

Compliance label image, Moppet65535 [CC BY-SA 3.0].

Filed under: news, radio hacks
Categories: Hack-a-Day

Robot Car Follows Wherever You Go

Fri, 2017-07-21 10:00

Having a pet can really make a difference to your happiness at the end of the day, but they’re also a lot of work. This project by [Ioannis Stoltidis] does something similar — minus all the responsibility. The Smart Car Follower Project is designed to track people using Bluetooth and IR and follow them around from room to room.

Submitted as part of a Master’s thesis, this project hacks a toy car and uses a key chain transmitter that sends the tracking signals. A Raspberry Pi 3 combines the Bluetooth RSSI and IR signals to make create an estimate of the position of the beacon. Arduinos facilitate the IR signaling as well as the motor control allowing the robot to chase the user around like a puppy. The whole thing also comes with obstacle avoidance using ultrasonic sensors on all sides which are good if you have a lot of furniture in the house.

You can also choose to go manual-mode and drive it around the block using a PC and gamepad. A webcam connected to the onboard computer allows a first person view of the vehicle by sending the video feed over wifi to a PC application. OpenCV is used to create the final GUI which allows you to see and control the project remotely. The source code is available for download for anyone who wants to replicate the project. Check out the video of it in action below.

The use of OpenCV means that the design can be reused to make a robot with vision later on. The Raspberry Pi has been proven to be an able platform for image processing however for instances where you need that extra muscle, this project may be a good starting point. For more ambitious uses of OpenCV, check out this Laser Firing Robot.

Filed under: toy hacks
Categories: Hack-a-Day

Charge Your Phone on an Iron Throne

Fri, 2017-07-21 07:00

Game of Thrones season 7 is finally here! [Hoecrux] is celebrating by building a GoT inspired cell phone charger. No, this isn’t a 3D print, nor is it vacuum molded. This iron throne was hand made from hundreds of cocktail swords. The frame of the chair is made from medium density fiberboard (MDF). The frame is covered with upholstery foam, then a layer of thin gray foam which forms the surface of the chair.

[Hoecrux] then began the painstaking process of hot gluing 600 cocktail swords to her creation. Each sword had to be modified by cutting off the loop guard. Some of the swords are bent, which was achieved with a heat gun. The completed chair was finished with a coat of black spray paint, followed by dry brushing with acrylic silver paint.

This particular iron throne charger is built for an android phone. [Hoecrux] embedded a micro USB cable in the base of the seat. If you’re of the iOS persuasion, you can substitute a lightning cable.

Check out the video after the link, and while you’re at it, get a look at this beach ready solar charger setup.

Filed under: classic hacks, iphone hacks
Categories: Hack-a-Day

DIY Air Cannon Snags Drones from the Sky

Fri, 2017-07-21 04:00

Who hasn’t had the experience of a pesky drone buzzing around that family picnic, or hovering over a suburban backyard where bikini-clad daughters are trying to sunbathe in peace? A shotgun used to suffice for such occasions, but with this compressed-air powered drone catcher, there’s no need to worry about illegally discharging a firearm to secure some privacy.

Before the comment line lights up with outrage, the above scenarios are presented entirely in jest. We do not condone the use of force on a drone, nor do we look favorably on those who use drones in a way that even hints at an invasion of privacy. We can all get along, and even though we hope [Make It Extreme]’s anti-drone gun will never be used in anger, it’s still a neat build that gives us lots of ideas. The rig is essentially four coaxial narrow-bore compressed-air cannons, each launching a slug attached to the corner of a lightweight net. A fairly complex set of linkages sets the spread of the barrels, and a pair of old oxygen tanks serve as reservoirs for the compressed air. A fast-acting dump valve is tripped by an interesting trigger mechanism mounted to a complicated stock and grip; we’d have liked to see more on the fabrication of that bit. The video below shows a test firing that results in a clean takedown of a drone, although we doubt the owner of the quad would characterize it as such.

This build is a bit of a departure from [Make It Extreme]’s usual fare of DIY tools like a shop-built vise or big belt sander, or their unusual vehicles like an off-road hoverboard. But it’s always great to watch a good fabrication video, no matter what the subject.

Thanks to [Itay Ramot] for the tip.

Filed under: drone hacks, misc hacks
Categories: Hack-a-Day

Hackaday Prize Entry: Disaster Recovery WiFi

Fri, 2017-07-21 02:30

The Meshpoint project originated in Croatia during the 2015 Syrian refugee crisis, when [Valent Turkovic] and other volunteers noticed that first responders, including NGOs like Greenpeace and the Red Cross, often struggled to set up communications in the field. They came to the conclusion that they couldn’t rely on the normal communications infrastructure because it was either damaged or overloaded.

The solution is a net of open source, autonomous WiFi mesh routers, scalable from a single team to serving thousands of people. Responders who won’t have time for a difficult login process, should find setup as easy as signing in to a social media site.

The physical nodes would consist of a router robust for up to 150 connections, all run by an ESP8266 and protected by a weatherproof enclosure. They would feature 6-8 hour battery lives with recharging via solar/wind, AC from wall current or generators, or simply DC car batteries.

You can learn more about the project or download their code from GitHub.

The HackadayPrize2017 is Sponsored by:
Filed under: The Hackaday Prize
Categories: Hack-a-Day

Books You Should Read: The Idea Factory

Fri, 2017-07-21 01:01

You’ve heard of Bell Labs, but likely you can’t go far beyond naming the most well-known of discoveries from the Lab: the invention of the transistor. It’s a remarkable accomplishment of technological research, the electronic switch on which all of our modern digital society has been built. But the Bell Labs story goes so far beyond that singular discovery. In fact, the development of the transistor is a microcosm of the Labs themselves.

The pursuit of pure science laid the foundation for great discovery. Yes, the transistor was conceived, prototyped, proven, and then reliably manufactured at the Labs. But the framework that made this possible was the material researchers and prototyping ninjas who bridged the gap between the theory and the physical. The technology was built on what is now a common material; semiconducting substances which would not have been possible without the Labs refinement of the process for developing perfectly pure substances reliably doped to produce the n-type and p-type substances that made diode and transistor possible.

The first point-contact transistor [via ]It’s important to consider why semiconductor devices were necessary in the first place, and author Gertner masterfully tells that tale. AT&T is a communications company whose early accomplishment was to traverse the continent with wire-based communications. The distances traveled posed the problem of signal decay caused by the increasing resistance with every foot of copper in the system. The only way to make such a link work is by relaying the signal through a series of amplifiers originally built using vacuum tubes, and an immense number of them. The secret to making this possible, and equally important to make it profitable, was to perfect a manufacturing process that resulted in long-lasting and predictably performing tubes. Bell Labs delivered.

Even with this leap in reliability, the tubes still used quite a bit of power to operate and needed replacing on a regular basis. On a transcontinental line, replacing vacuum tubes is possible. But trans-oceanic lines are another thing entirely. Although successful connections between North America and Europe were laid with vacuum tube amplifiers integrated in the cable, its construction again depending heavily on the material science of the Labs, the need for something far more reliable was clear and this led to the semiconductor efforts resulting in the solid state transistor.

Incidentally, the rest of history interfered in the effort. It appears that the transistor could have been in place decades earlier than it was had World War II not occurred, which diverted the Labs attention elsewhere. But as the book details, even this led to amazing discoveries that built our modern world as huge numbers of scientists from Bell Labs joined the war effort and moved the mountains of radio technology with advancement in both wireless communications and perhaps more importantly, radar.

Document, Document, Document

Perhaps most remarkable about the Bell Labs story is the recording of its history. It’s not a stable of historians that makes the retelling possible, but the enforcement of documentation by every engineer that was followed like religion. Every researcher was issued leather bound engineering notebooks with a simple set of guidelines.

At Bell Labs there was no such thing as a back of the napkin calculation. Everything was recorded in these notebooks. Every idea was documented and any that were felt to be promising were then witnessed by signature from another member of the labs. Pages were neither added, nor torn out, and incorrect information was neatly crossed out and initialed by the one doing so. This was done for the purpose of the patent process. But the result is an amazing library of the process that led to some of the greatest scientific leaps forward in all of human history.

Head-Spinning Talent

The talent that passed through the Labs is a roll-call of great minds. Part of this is a product of the times; the most brilliant minds graduating from University during and after the great depression could find no better way to make a living. With a critical mass of talent it wasn’t just the money or stability, but the urge to join the best collection of thinkers and technicians ever assembled.

The Pedagogy of Bell Labs

Jon Gertner has a real knack for humanizing the people who made these discoveries. To share one anecdote, I had reread a few paragraphs of one story about a promising young student taking piloting lessons in the 1930’s. His professors at MIT heard about his extra-curricular activities — somewhat dangerous for the times — and considered asking him to knock it off lest his great mind be lost to humanity. This is the introduction of Claude Shannon, the father of information theory.

The sharing of knowledge and experience both inside and outside of the organization was integral to the culture of Bell Labs. It was commonplace to have interdisciplinary seminars during the work week, and at private residences. Engineers and technicians were encouraged to work outside of their strict assignments, and trips throughout the country and abroad to both present and attend seminars pollinated the scientific community rather than locking up the information in a walled garden.

The stories go beyond Bell Labs themselves, to things like the formation of Intel by Labs alum Bill Shockley. He had a habit of spotting talent and brought Gordon Moore on board when starting the new company. Gordon’s namesake is of course Moore’s Law. The book is sprinkled with too many of these connective mentions to count. Those who worked at the labs went on to found and forward the companies that accelerated the technology revolution.

The History of Communications

The story of AT&T was the story of communications. From a wire, to a microwave relay network made possible by the transistor, it seemed the writing was on the wall for direct connections. Bell Labs developed the first communications satellite in the form of a reflector that bounced signals from one coast to the other. This was followed by active relay satellites which are the earliest ancestors of those that we use today.

But the bandwidth of direct connection was still desirable, and for me it was remarkable to hear the story of a vast network of waveguide technology that was nearly implemented before being shoved aside by the remarkable performance of fiber optics. Two things made fiber possible. One was the perfection of fast-switching laser technology. The laser itself wasn’t invented by Bell Labs, but the technology that allowed fast switching, durable lasers was. The second development was an external perfection of glass fiber manufacturing envisioned at the Labs but made possible by the institutional knowledge of Corning.

Connecting the system together were the first field-programmable computers. They replaced mechanical switching and, in a brilliant leap in future-proofing, made the AT&T system an information network instead of merely a telephone system. They were key in the formation of the early cellular network that came into being near the end of Bell Labs’ glory days.

A Government Supported Monopoly

Woven throughout the story is the tale of Ma Bell, the AT&T monopoly that was in place for decades, first with the blessing of the American government and then ultimately broken up by the same. This review is far too brief to cover everything but in at lest a couple of ways the monopoly made this scientific research possible.

As a monopoly, AT&T had an abundance of funds to support their research and development. The first day of work for all Bell Labs engineers included a $1 payment for all patents they were awarded through their work. As a concession to maintain the monopoly the company licensed all of its patents to any other American company, royalty free in almost all cases. Think on that for a while.

Technically, there is still an ancestor of Bell Labs around today. But this book is not actually a story of the company itself. It’s a tale of the collection of people, and the circumstances that brought them together and challenged them to change all of humanity through their work. You live in the world that they enabled. Reading The Idea Factory by Jon Gertner will stitch together myriad tales you’ve heard, but never understood how tightly interconnected and fascinating they are as a whole.

Filed under: Hackaday Columns, History
Categories: Hack-a-Day

Heads-Up Display Turns Car Into Fighter Jet

Thu, 2017-07-20 23:30

While most of us will never set foot in a fighter jet, some of us can still try to get as close as possible. One of the most eye-catching features of a fighter jet (at least from the pilot’s point-of-view) is the heads-up display, so that’s exactly what [Frank] decided to build into his car to give it that touch of fighter jet style.

Heads-up displays use the small reflectivity of a transparent surface to work. In this case, [Frank] uses an LED strip placed on the dashboard to shine up into the windshield. A small amount of light is reflected back to the driver which is able to communicate vehicle statues without obscuring view of the road. [Frank]’s system is able to display information reported over the CAN bus, including voltage, engine RPM, and speed.

This display seems to account for all the issues we could think up. It automatically cycles through modes depending on driving style (revving the engine at a stoplight switches it to engine RPM mode, for example), the LEDs automatically dim at night to avoid blinding the driver, and it interfaces with the CAN bus which means the ability to display any other information in the future should be relatively straightforward. [Frank] does note some rough edges, though, namely with the power supply and the fact that there’s a large amount of data on the CAN bus that the Teensy microcontroller has a hard time sorting out.

That being said, the build is well polished and definitely adds a fighter jet quality to the car. And if [Frank] ever wants even more aviation cred for his ground transportation, he should be able to make use of a 747 controller for something on the dashboard, too.

Filed under: car hacks
Categories: Hack-a-Day

Beyond a Boot Print: The Lasting Effect of Apollo on Humanity

Thu, 2017-07-20 22:01

July 20th, 1969 was the day that people from Earth set foot on different soil for the first time. Here we are 48 years later, and the world’s space programs are — well — not very close to returning to the moon. If you aren’t old enough to remember, it was really amazing. The world was in a lot of turmoil in the 1960s (and still is, of course) but everyone stopped to look at the sky and listen to the sound of [Neil Armstrong] taking that first step. It was shocking in a good way and almost universally observed. Practically everyone in the world was focused on that one event. You can see some of that in the NASA video, below.

Space flight was an incredible accomplishment, but it paled in comparison with the push to actually landing a person on the moon and bringing them home safely. The effort is a credit to the ability of people to work together (on the order of thousands of minds) to overcome a difficult challenge. We can learn a lot from that alone, and it makes a compelling argument to continue taking on tough problems. Today, as we remember the Apollo landings, let’s take a moment to recognize what came of it beyond an iconic boot-print in the floury lunar soil.

If you did miss it, you can relive a lot of the landing at a really interesting site called First Men on the Moon. It isn’t a new site, but it has audio from both the ground and the spacecraft synchronized with a transcript, some graphics, video, and telemetry. Watch [Aldrin’s] heart rate when the guidance computer goes wonky (starts about 102:42). Some of the voices on the ground sound a little uptight, too. Seriously, this is one of the most amazing sites ever so if you haven’t seen it, check it out. NASA also has some interesting 3D imaging of the historic landing site, courtesy of more modern gear now orbiting the moon.

Lost Legacy

In 1960 there had never been a person in space, and barely even any man-made equipment (Sputnik launched in 1957). In 1969, some guy is stepping out on the moon. That was an amazing timeline and it made the 1968 movie 2001: A Space Oddessy seem like it was overly pessimistic about what human spaceflight would look like in 33 years. Very few people thought the space program would stall out.

Sure, we had the Space Shuttle, but it barely made orbit and certainly couldn’t go to the moon, Hollywood movies notwithstanding. We’ve had a few space stations both international and from specific countries. However, since the end of Apollo, there hasn’t been a lot of inspiring manned missions. Even the shuttle was a pared down version of an entire fleet of vehicles that NASA wanted.

Why Space?

Most people who read a site like Hackaday are interested in manned spaceflight. You might not agree how one particular country or another is going about it, but I’m willing to bet the majority see the value of having humans in space. If you haven’t noticed, though, we aren’t the majority. A lot of people don’t know why we spend money in space. In addition, in the United States, polls consistently show that people think NASA has a giant chunk of the Federal budget when, in fact, it runs about 0.5% of the total up to around 1%. A 1997 poll found that on average people estimate NASA’s budget at 20% of federal expenditures. Even at the height of the space race, it was well under 5%. It’s a paradox of promoting what is a very amazing engineering program which can be appreciated by the layman, while putting the program in the crosshairs for budget cuts since people assume if it’s a household word it must cost a bundle.

There are a lot of good arguments for space. A lot of spinoff technology either came from manned spaceflight programs or were enhanced or accelerated because of the different manned programs worldwide. You can argue that we need to learn to live off the planet so we can spread out and have some resilience against an asteroid strike or screwing up the ecology permanently. We are a long way from where we could self-sustain on another planet, but you have to start somewhere and the ancillary discoveries in material science and other technologies are well worth the work.

But those are not the best reasons, in my mind. The best reasons are the human reasons.

The Best Reasons

A whole generation of engineers and scientists got interested in those subjects because we watched humanity reaching for the moon. Sure, the media made heroes out of the astronauts and cosmonauts. But we kind of knew that those men and women were supported by a legion of technical experts and innovators and — in the case of some high-profile mishaps like Apollo 13, and a Skylab incident — hackers.

We wanted to be in that legion. Well… most of us wanted to be astronauts, but reality sets in pretty early if you aren’t winning the rope climb in PE class. Some of us did go on to work on space-related projects. But a lot of us just became engineers and scientists and had productive careers somewhere else.

That’s the best reason, as far as I’m concerned. I can’t think of any one or anything that inspires young people today in quite the same way. You’d think that would be worth less than a penny per dollar in the Federal budget.

The other human reason is creating those focal points for humanity. In an age where far too often the world’s attention is only brought into a focus by a terror attack or a natural disaster, we need to see uplifting efforts to create rather than destroy. We need to bring the world’s attention to acts that are constructive and wondrous.


In the United States, manned spaceflight is going commercial, with several companies building manned vehicles to carry people to the International Space Station. That’s still not going to get us to the moon and beyond. There are plans to go to Mars, although they seemed to be stalled. The only country making big strides in manned spaceflight these days seems to be China and we applaud them for prioritizing the effort.

In 1969, no one could imagine what the reality of 2001 would be. We can’t imagine what it is going to be like in another 40 or 50 years as far as space travel goes. But one thing is certain. It will be a very long time before the events of July 20, 1969 are forgotten. It was truly one of the great moments in human history.

The moment has passed, but many of the people who made it possible are still here. If you are interested in the computers that let Apollo land on the moon, you really should read this explanation of the software from someone who helped write it. And if you can connect us with anyone else who has a story to tell about that age, we want to hear from you!

Filed under: Featured, History
Categories: Hack-a-Day

SCiO “Pocket Molecular Scanner” Teardown

Thu, 2017-07-20 19:00

Some of you may remember the SCiO, originally a Kickstarter darling back in 2014 that promised people a pocket-sized micro spectrometer. It was claimed to be able to scan and determine the composition of everything from fruits and produce to your own body. The road from successful crowdsourcing to production was uncertain and never free from skepticism regarding the promised capabilities, but the folks at [Sparkfun] obtained a unit and promptly decided to tear it down to see what was inside, and share what they found.

The main feature inside the SCiO is the optical sensor, which consists of a custom-made NIR spectrometer. By analyzing the different wavelengths that reflect off an object, the unit can make judgments about what the object is made of. The SCiO was clearly never built to be disassembled, but [Sparkfun] pulls everything apart and provides some interesting photos of a custom-made optical unit with an array of different sensors, various filters, apertures, and a microlens array.

It’s pretty interesting to see inside the SCiO’s hardware, which unfortunately required destructive disassembly of the unit in question. The basic concept of portable spectroscopy is solid, as shown by projects such as the Farmcorder which is intended to measure plant health, and the DIY USB spectrometer which uses a webcam as the sensor.

Filed under: chemistry hacks, teardown
Categories: Hack-a-Day

Old Intercom Gets Googled with Raspberry Pi and AIY Hat

Thu, 2017-07-20 16:00

Old Radio Shack intercom; brand new Google Voice interface for a Raspberry Pi. One of these things is not like the other, but they ended up together in this retro-look Google Voice interface, and the results are pretty slick.

The recipient of the Google hive-mind transplant was one of three wireless FM intercoms [MisterM] scored for a measly £4. Looking much as they did when they were the must-have office tool or home accessory for your modern mid-80s lifestyle, the intercom case was the perfect host for the Pi and the Google AIY hat. Only the case was used — not even the original speaker made it into the finished product. The case got a good scrubbing, a fresh coat of paint to perk up the gone-green plastic, and an accent strip of Google’s logo colors over the now-deprecated station selector switch. [MisterM] provided a white LED behind the speaker grille for subtle feedback. A tap of the original talk bar gets Google’s attention for answers to quick questions, and integration into the family’s existing home automation platform turns the lights on and off. See it in action after the break.

[MisterM] was lucky enough to score an AIY hat for free, and as far as we know they’re still hard to come by. If you’re itching to try out the board, fear not — turns out you can roll your own.

Filed under: classic hacks, google hacks
Categories: Hack-a-Day

Take Control Of Your Cheap Laser Cutter

Thu, 2017-07-20 13:00

The relatively inexpensive K40 laser cutter/engraver machines from China have brought laser cutting to the masses, but they are not without their faults. Sure, they’re only powerful enough for the lightest cutting tasks, but on top of that, their bundled software is inflexible and disappointing. If your workshop or hackspace has one of these machines languishing in the corner, then the release of a new piece of software, K40 Whisperer from [Scorch], is an interesting and welcome development.

He tells us that the reverse engineering process required to understand the K40’s protocol was non-trivial, given that it does not use handy decimal numbers to issue commands. A spreadsheet was used to collate data packets and spot repeating patterns to analyse the inner workings. Feature-wise, the software reads SVG and DXF files, and can split SVGs by colour. It has a halftone algorithm for rendering grey scales, and cuts from the inside of each shape first to avoid pieces of work dropping out of the piece of material. Currently it works with the stock M2 Nano controller board and is available as a Windows download, though it can also be compiled for Linux distributions, or MacOS, and he is asking owners to test it with as many machines as possible to ensure compatibility with other boards.

He has posted a video of K40 Whisperer in action, which you can see below the break.

This isn’t the only way to improve your K40, you can drop in a new controller, or even increase the size of its bed.

Filed under: software hacks
Categories: Hack-a-Day

Lethal LED Lantern Leaks Lotsa ‘Leccy

Thu, 2017-07-20 10:00

When you take an item with you on a camping trip and it fails, you are not normally in a position to replace it immediately, thus you have the choice of fixing it there and then, or doing without it. When his LED camping lantern failed, [Mark Smith] was in the lucky position of camping at a friend’s compound equipped with all the tools, so of course he set about fixing it. What he found shocked him metaphorically, but anyone who handles it while it is charging can expect the more literal variation.

The lamp was an LED lantern with built-in mains and solar chargers for its Ni-Cd battery pack, and a USB charger circuit that provided a 5 volt output for charging phones and the like. The problem [Mark] discovered was that the mains charger circuit did not have any mains isolation, being a simple capacitive voltage dropper feeding a rectifier. These circuits are very common because they are extremely cheap, and are perfectly safe when concealed within insulated mains-powered products with no external connections. In the case of [Mark]’s lantern though the USB charging socket provided that external connection, and thus access to a potential 120 VAC shock for anyone touching it while charging.

Plainly this lamp doesn’t conform to any of the required safety standards for mains-powered equipment, and we’re guessing that its design might have come about by an existing safe lamp being manufactured with an upgrade in the form of the USB charger. The write-up gives it a full examination, and includes a modification to safely charge it from a wall-wart or similar safe power supply. Definitely one to watch out for!

If you were wondering what the fault was with Mark’s lamp, it was those cheap NiCd batteries failing. He replaced them, but there are plenty of techniques to rejuvenate old NiCds, both backyard, and refined.

Filed under: teardown
Categories: Hack-a-Day

Innovating A Backyard Solar Battery System

Thu, 2017-07-20 07:00

Ever on the lookout for creative applications for tech, [Andres Leon] built a solar powered battery system to keep his Christmas lights shining. It worked, but — pushing for innovation — it is now capable of so much more.

The shorthand of this system is two, 100 amp-hour, deep-cycle AGM batteries charged by four, 100 W solar panels mounted on an adjustable angle wood frame. Once back at the drawing board, however, [Leon] wanted to be able track real-time statistics of power collected, stored and discharged, and the ability to control it remotely. So, he introduced a Raspberry Pi running Raspbian Jessie Lite that publishes all the collected data to Home Assistant to be accessed and enable control of the system from the convenience of his smartphone. A pair of Arduino Deuemilanoves reporting to the Pi control a solid state relay powering a 12 V, 800 W DC-to-AC inverter and monitor a linear current sensor — although the latter still needs some tinkering. A in-depth video tour of the system follows after the break!

All the electronics are housed in a climate-controlled box which kicks on when the Pi’s CPU heats up — this is in a Florida backyard, folks — and powered off the battery system, with a handful of 40amp breakers between the components keep things safe. [Leon] has helpfully provided links to all the resources he used, as well as his code on GitHub.

We love homebrew solar power systems, but if only there was some way to take them on the road with us.

Filed under: Arduino Hacks, Raspberry Pi, solar hacks
Categories: Hack-a-Day

DEF CON Badgelife: The ESP Rules All

Thu, 2017-07-20 04:00

Badgelife is the celebration of independent hardware creators, working for months at a time to bring custom electronic badges to conferences around the world. This year at DEF CON, Badgelife is huge. It’s not just because this year was supposed to feature a non-electronic badge, and it’s not because the official badge imploded last month — Badgelife is all about people spending most of the year designing, and manufacturing hardware, culminating in one very special weekend.

[Garrett] owns Hacker Warehouse, a store providing all kinds of neat hacker tools ranging from software-defined radios to lock pick sets to side channel analysis toolkits. This year, [Garrett] decided he wanted to branch out his business and get involved in a little bit of hardware creation. He’s been curious about this for some time and figured a limited edition DEF CON badge made sense. What he wound up with is a beautiful little badge with games, blinkies, graphics, and potential to cause a lot of wireless mischief.

Would you look at that. RF design on an independent badge.

The design of the Hacker Warehouse badge is surprisingly simple compared to the Bender Badges and puzzling crypto badges that are also part of this year’s Badgelife hardware celebration. On board is an ESP8266 with a custom PCB implementation that includes a larger Flash chip. The other side of the board is loaded up with four tact switches in a D-pad arrangement. On top is a 96 x 64 pixel full-color OLED display, and blinkies are provided by fourteen mini WS2812 RGB LEDs. Power is provided by two AA cells and what looks to be a nice fancy switching regulator. This is real hardware, not just a few modules thrown together with a bunch of LEDs.

Oh, what wireless fun

This badge is built around the ESP8266, a very interesting WiFi-enabled microcontroller that has more features than it should. [Garrett] is using the ESP as a WiFi scanner of sorts, allowing anyone with this badge to monitor WiFi channels, APs, packets, and — this is important — deauth packets.

Over the last year, there have been a number of projects around the Internet that take an ESP8266 and spew deauthorization frames into the spectrum. These frames cause a WiFi client to stop using an access point, and basically shuts down all the WiFi in an area. It’s well documented, and people have been doing it for years, but the ESP8266 makes deauth attacks so very, very easy. We’re going to see a lot of deauth frames this year at DEF CON, and the Hacker Warehouse badge will be able to detect them. It can also generate these frames, but that capability is locked for now.

Blinking and glowing

An electronic conference badge isn’t cool unless it has obnoxiously bright and glowy LEDs, and the Hacker Warehouse badge is very cool.

Onboard the Hacker Warehouse badge are 14 RGB LEDs, programmed with 46 different patterns that are certainly bright enough to annoy someone. This is what you need for a badge, and it’s beautiful.

This is a truly fantastic badge that’s also a great development board for the ESP8266. Everything you need for portable WiFi gaming fun is already there — you have blinky LEDs, an OLED, what seems to be a fairly nice power supply, and enough buttons to do something interesting. All you need to do to program this badge is attach a USB to serial adapter to the pre-populated header and you really have something. It’s a great badge, and we can’t wait to see the hacks for this great piece of hardware next week at DEF CON.

Filed under: cons, reviews
Categories: Hack-a-Day