If you’ve ever wanted to learn how to hack a circuit’s firmware, a great beginning point would be SparkFun Electronics. Many of the development, prototyping, and sensor products sold by SparkFun come equipped with a special programming interface. Even better, most of these products feature downloadable firmware. Therefore, with just a modest amount of effort, you can modify one of these products’ firmware, reprogram the circuit, and create your own customized product.
You can add your name to a splash screen, develop a new product feature, or — living life on the edge — rewrite the whole shebang and make an entirely new product: the sky’s the limit when hacking firmware. There is one very important caveat, though: if you don’t know what you’re doing when tinkering with firmware, you could destroy the product.
In this introduction to firmware hacking, let’s try a simple modification. We’ll reformat the output from the USB Weather Board v1 so that it can be meaningfully displayed on a serial-enabled 20×4 LCD.
In its stock configuration, the output from the USB Weather Board is a continuous string of numbers, like
Not very friendly, is it? We’ll modify the firmware so that the output is easier to comprehend. Something like:
1.Humidity=47.25% 2.Temp=81.23F 3.Press=101723Pa
But wait; there’s more. We’ll also add an LCD for displaying this new output and a battery power supply, and wrap everything up in a handheld enclosure. The result is a portable, handheld personalized weather forecasting system. Or, as I’ve dubbed it: the 4Caster 1000.
TIME: 3 hours
USB weather board v1 (SparkFun Electronics #SEN-08765; $99.95)
Serial-enabled 20×4 LCD (SparkFun Electronics #LCD-00462; $32.95)
5V DC-to-DC step-up (SparkFun Electronics #PRT-08248; $10.95)
6x headers (SparkFun Electronics #PRT-00116; $2.50)
SPST push on/off switch (RadioShack #275-011; $1.99)
Project box (All Electronics #1593-YBK; $4.95)
Hookup wire (RadioShack #278-1224; $5.99)
AA battery (locally available; $.50)
Optional (might already be attached to some USB weather boards):
2×5 AVR ICSP male header (SparkFun Electronics #PRT-00778; $0.95)
- Make the firmware accessible by soldering the 2×5 AVR ISCP male header to the USB Weather Board. NOTE: some boards might already have this header attached.
- Solder the 6×1 header to the BlueSMiRF connector on the USB Weather Board.
- Download, install, and start the FREE AVR Studio 4 Integrated Development Environment (IDE). The target AVR on the USB Weather Board is an ATmega8.
- Download the USB Weather Board firmware and create a new AVR Studio 4 project for your hacked firmware. For example, call your project 4Caster and paste the SparkFun Electronics firmware into the main 4Caster program window.
- Modify the firmware. The lines that I added for creating my 4Caster 1000 can be found here.
Take your portable, handheld personalized weather forecasting system with you wherever you go. Just press the pushbutton on the outside of the project box for a quick snapshot of your current weather conditions. By monitoring these weather stats from your hacked firmware, you might be able to make a quick “guess” about upcoming weather changes.
Please note: spurious characters might sometimes appear on the LCD. For example, all “Ps” will suddenly change to “@.” Or, a “0” (zero) will drop out. This distasteful effect usually disappears within 1-2 seconds.