Arduinos (and other AVRs) Write To Own Flash

In this post on the forums and this blog post, [Majek] announced that he had fooled the AVR microcontroller inside and Arduino into writing user data into its own flash memory during runtime. Wow!

[Majek] has pulled off a very neat hack here. Normally, an AVR microcontroller can’t write to its own flash memory except when it’s in bootloader mode, and you’re stuck using EEPROM when you want to save non-volatile data. But EEPROM is scarce, relative to flash.

Now, under normal circumstances, writing into the flash program memory can get you into trouble. Indeed, the AVR has protections to prevent code that’s not hosted in the bootloader memory block from writing to flash. But of course, the bootloader has to be able to program the chip, so there’s got to be a way in.

The trick is that [Majek] has carefully modified the Arduino’s Optiboot bootloader so that it exposes a flash-write (SPM) command at a known location, so that he can then use this function from outside the bootloader. The AVR doesn’t prevent the SPM from proceeding, because it’s being called from within the bootloader memory, and all is well.

The modified version of the Optiboot bootloader is available on [Majek]’s Github.  If you want to see how he did it, here are the diffs. A particularly nice touch is that this is all wrapped up in easy-to-write code with a working demo. So next time you’ve filled up the EEPROM, you can reach for this hack and log your data into flash program memory.

Thanks [Koepel] for the tip!

Retro-fit old radio with Arduino and FM module

“You can’t put new wine in old bottles” – so the saying goes. But you would if you’re a hacker stuck with a radio built in 2005, which looked like it was put together using technology from 1975. [Marcus Jenkins] did just that, pulling out the innards from his old radio and converting it to an Arduino FM radio.

His cheap, mains powered radio was pretty bad at tuning. It had trouble locating stations, and tended to drift. One look at the insides, and it was obvious that it was not well engineered at all, so any attempts at fixing it would be pointless. Instead, he drew up a simple schematic that used an Arduino Nano, an FM radio module based on the TEA5767, and an audio amplifier based on the LM386.

A single button on the Arduino helps cycle through a range of preset frequencies stored in memory. The Arduino connects to the FM radio module over I2C. The existing antenna was connected to the TEA5767 module. The radio module outputs stereo audio, but [Marcus] was content with using just a mono channel, as it would be used in his workshop. The audio amplifier is pretty straightforward, based on a typical application found in the data sheet. He put it all together on proto-board, although soldering the FM radio module was a bit tricky. The Arduino code is quite simple, and available for download (zip file).

He retained the original tuning knob, which is no longer functional. The AM-FM selector knob was fitted with a micro-switch connected to the Arduino for selecting the preset stations. Almost everything inside was held together with what [Marcus] calls “hot-snot” glue. The whole exercise cost him a few Euros, and parts scavenged from his parts bin. A good radio could probably be had for a few Euros from a yard sale and much less effort, but that wouldn’t be as cool as this.

Go deeper and explore how FM signals are modulated and demodulated for playback.

Hackaday Prize Entry: An SD Card Arduino

About a year ago, Intel announced they’d be launching a new platform stuffed into an SD card. Imagine – an entire computer packaged into an SD card, with nine whole pins for power and I/O. Cooler heads prevailed, the Intel Edison was launched, but the idea stuck; why can’t you fit an Arduino in an SD card?

[kodera2t] found out there’s no real reason why you can’t put a small microcontroller inside an SD card. For his Hackaday Prize entry, he created the SDuino, and it’s exactly what it says on the tin: an ATMega328p stuffed into a microSD adapter.

Unlike the other microcontroller stuffed in an SD card platform — the Electric Imp, [kodera] is, for the most part, respecting the standard pinout for SD cards. The MISO and MOSI signals are reversed, of course, one of the grounds on the SD pinout is tied to an analog input pin on the microcontroller, and the chip select on the SD pinout is ignored completely. Other than that, it’s the closest you’re going to get to an SD card with a microcontroller.

The 2015 Hackaday Prize is sponsored by:

Arduino Controlled Air Conditioner

Now that summer is coming, it’s time to break out the Air Conditioners! There are some old AC units out there that still work just fine, but nowadays we are used to everything being remotely controlled and automatic. [Phil] had an old window-mounted AC unit that still worked but was installed in a not-so-convenient place. To access the AC’s controls, one would have to climb over a large desk. This is a perfect opportunity to use the plethora of widely available hobby electronics to make an automatic AC controller retrofit.

First things first, there needs to be a way to turn the current control knob on the AC. [Phil] modeled up a 3D bracket to hold an RC car servo to the AC control panel. Attached to the servo horn is a slotted cylinder sized appropriately to fit the shape of the control knob. An Arduino measures the temperature of the room via a DS18B20 temperature sensor which then has the servo turn the control knob to the appropriate position, on or off. The Arduino sends temperature data back to a PC via MegunoLink Pro which graphs past data and also displays current temperature data. Using MegunoLink Pro, the min/max temperature points can also be set without uploading a new sketch to the Arduino.

Arduino Controlled AC

From the temp vs time graph, it looks like the room temperature stays a consistent 23 +/- 1 °C. [Phil] did us summer-swelterers a favor and made all his design files available. This is a great idea but wonder if leaving the air conditioner unit switch in the ‘on’ position and turning the unit on/off via a relay connected to the 120vac line would work just as well.

Mimimalist Arduino Gaming Platform

A pretty color LCD screen, an Arduino, a buzzer and a joystick is all you need for a minimalist gaming console for under $20. At least, that’s all [João Vilaça] needed to get this sweet version of Tetris up and running. He’s working on Breakout right now. His Breakout looks even better. See the postscript below for details.

It’s a testament to the current state of the hardware hacking scene that [João] could put this device together in an afternoon for so cheap, presumably after waiting a while for shipments from China. The 320×240 SPI color TFT LCD screen used to cost twice as much as this whole project did. And wiring it up is a simple matter of connecting this pin to that pin. Almost child’s play.

Equally impressive is the state of open source software. A TFT library from Seeed Studios makes the screen interface a piece of cake. [João] wrote his own sound and joystick code, and of course the Tetris gameplay itself, but it’d be much more than a few weeks’ work without standing on the shoulders of giants. Check out [João]’s Github for the project code and stick with us after the break for a demo video and some of our other favorite Arduino gaming hacks.

Continue reading “Mimimalist Arduino Gaming Platform”

Hackaday Prize Entry: Arduino MPPT Controller

Imagine you’re building a small solar installation. The naive solution would be grabbing a solar panel from Horror Freight, getting a car battery and AC inverter, and hoping everything works. This is the dumb solution. To get the most out of a solar you need to match the voltage of the solar cell to the voltage of the battery. How do you do that? With [Debasish]’s entry for The Hackaday Prize, an Arduino MPPT Solar Charge Controller.

This Maximum Power Point Tracker uses a buck converter to step down the voltage from the solar cell to the voltage of the battery. It’s extremely efficient and every proper solar installation will need a charge controller that does something similar.

For his MPPT, [Debasish] is using an Arduino Nano for all the math, a DC to DC buck converter, and a few MOSFETs. Extremely simple, but [Debasish] is connecting the entire controller to the Internet with an ESP8266 module. It’s a great example of building something for much less than it would cost to buy the same thing, and a great example for something that has a chance at making the world a little better.


The 2015 Hackaday Prize is sponsored by:

Arduino vs Arduino: These Are Not The Droids…

We’ve been trying to not pick favorites in the Arduino controversy, or at least remain open-minded to both sides of the story. Some businesses, on the other hand, are clearly aligning themselves.  (Full text of e-mail below.)

Reader [Francisco Zabala], from cool robot-supplies store Acrobotic, got this e-mail from an Amazon distributor where he purchased some Arduinos “ages ago” and was angered enough at the brazen tone to drop us a line.

Thank you for our Arduino purchase from our store. We truly appreciate your business.

We are writing to let you know about an important change in Arduino products. The new website for Arduino is now officially The old website ( should no longer be used.

All new Arduino hardware will be transitioned from the old badging to the new badging. Please be aware that during this transition, you may receive Arduino hardware with either or Both are authentic Arduino-brand hardware.

If you use branded hardware on the old site, you may be presented with an error. Please use the new site.

We know for sure that Arduino SRL sent out a letter to distributors claiming that they were the real Arduino because they’ve been manufacturing the boards. Seeing a distributor recommend against the software at in such stark terms makes us wonder if there have been similar letters sent out concerning the IDE fork. Anyone have anything? Send us a tip if you do.

We find it a little ironic that when added the now-retracted popup that specifically targeted boards made by Smart Projects / Arduino SRL,  that they opened themselves up to this sort of counter-attack: if you see an error popup, just switch over to the “new official” IDE. Oops. Good that it’s gone now.

Finally, we’ve got to say that “the old website should no longer be used” is pretty rich: we’re hackers, we use whatever software / IDE we like, thank you very much! No matter how the legal battles end up, and no matter who tells you to use what codebase, the beauty of open source is that it’s up to you, and not them. Hack on, y’all!

Thanks, [Francisco] for the tip.