Arduinos (and other AVRs) Write To Own Flash

In this post on the Arduino.cc 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!

Vibrating Distance Torch Illuminates the Dark without Light

If you’ve ever had to move around in a dark room before, you know how frustrating it can be. This is especially true if you are in an unfamiliar place. [Brian] has attempted to help solve this problem by building a vibrating distance sensor that is intuitive to use.

The main circuit is rather simple. An Arduino is hooked up to both an ultrasonic distance sensor and a vibrating motor. The distance sensor uses sound to determine the distance of an object by calculating how long it takes for an emitted sound to return to the sensor. The sensor uses sounds that are above the range of human hearing, so no one in the vicinity will hear it. The Arduino then vibrates a motor quickly if the object is very close, or slowly if it is far away. The whole circuit is powered by a 9V battery.

The real trick to this project is that the entire thing is housed inside of an old flashlight. [Brian] used OpenSCAD to design a custom plastic mount. This mount replaces the flashlight lens and allows the ultrasonic sensor to be secured to the front of the flashlight. The flashlight housing makes the device very intuitive to use. You simply point the flashlight in front of you and press the button. Instead of shining a bright light, the flashlight vibrates to let you know if the way ahead is clear. This way the user can more easily navigate around in the dark without the risk of being seen or waking up people in the area.

This reminds us of project Tacit, which used two of these ultrasonic sensors mounted on a fingerless glove.

Hackaday Prize Entry: Saving Water with the Vinduino

[Reinier van der Lee] owns a vineyard in southern California – a state that is in a bit of a water crisis. [Reinier van der Lee] also owns an arduino and a soldering iron. He put together a project the reduces his water usage by 25%, and has moved it to open source land. It’s called the Vinduino.

water animationIts operation is straight forward. You put a water sensor in the dirt. You turn on the water. When the water hits the sensor, you turn the water off. This was not, however, the most efficient method. The problem is by the time the sensor goes off, the soil is saturated to the point that the plant cannot take it all up, and water is wasted.

The problem was solved by using three sensors. The lowest most sensor is placed below the roots. So it should never go off. If it does, the plant is not taking in all the water, and you can reduce the output. The two sensors above it monitor the water as it transitions through the soil, so it knows when to decrease the water amount and watering cycle times.

Be sure to check out the project details. All code and build files are available on his github under the GNU General Public License 3.0


The 2015 Hackaday Prize is sponsored by:

Too Hot for Fido? Get Alerted!

Meet project Oro, the temperature monitoring watchdog. Err… the watchdog monitoring temperature probe. Well, it’s both actually!

[Richard Deininger] built the project after having the AC system go down in his company’s server room. That environmental cooling is imperative if you don’t want your server hardware turned to slag. The idea is a separate piece of hardware that monitors the room temperature and will alert the on-call staff if it climbs too high. He was successful, and showing the hacked hardware around the office came up with a second idea: a temperature sensor for your car to ensure it’s not too hot for your dog.

Anyone who has a canine friend living with them knows you don’t utter the word “ride” out loud lest a barking, whimpering, whining frenzy ensue. But jingle those keys and they’ll be at the door in no time. During the summer you can still take them with you for short errands thanks to the peace of mind [Richard’s] build provides. It’s simply an Arduino, DHT22 temp/humidity probe, and a SIM900 GSM modem. Set your temperature threshold and you’ll get an alert if temperatures are climbing to unsafe levels for Fido.

While you have your tools out, we recommend building auto-watering and auto-feeding systems for the family pets. What’s that? You hate domesticated animals? There’s a hack you can use to chase them from your yard.

Codename Colossus: The HMC Boudicca

[Michael Sng], founder of [Machination Studio], wanted to create a toy line unlike anything the world has seen.  He has recently completed the first production prototype in the Codename Colossus toy line: the HMC Boudicca. The egg-shaped HMC Boudicca is tank-like with a definite Metal Slug vibe, but it’s almost a disservice calling it a toy.

The HMC Boudicca is over 20″ tall. It is composed of over 400 parts, a majority of which are 3D-printed or laser-cut. Internal parts are FDM while the external pieces are SLS printed. It is a kinetic piece that walks in a hexapodal fashion, so there are lots of servos, motors, sensors, and LEDs, that are controlled by an Arduino. A lot of work and attention to detail was put into this prototype. The HMC Boudicca was designed to be easily disassembled with a Phillips screwdriver. The electronic components are all plug-in devices, so no soldering is required when it comes time to replace a sensor or servo.

Codename Colossus is a toy line that is made to order and intended to be artisanal in nature. Each piece will be individually hand-painted and assembled like the HMC Boudicca. While no official prices are posted yet on the site, we assume these are not going to be cheap. In fact, the site states that each piece will have a 2% markup from the previously sold price to help maintain the value of the pieces and control cost inflation. This could be a source of contention for potential buyers. It underscores [Michael’s] philosophy that Codename Colossus is meant to be a collectible work of art, an antithesis to mass production.

Regardless of the business strategy, we are interested in seeing any additional designs for this series. It would be fun to see a whole bunch of these marching as one robot army!

Continue reading “Codename Colossus: The HMC Boudicca”

Motion Sensing Water Gun Tweets Photos To Embarrass Enemies

[Ashish] is bringing office warfare to the next level with a motion sensing water gun. Not only does this water gun automatically fire when it detects motion, but it also takes a photo of the victim and publishes it on Twitter.

This hack began with the watergun. [Ashish] used a Super Soaker Thunderstorm motorized water gun. He pulled the case apart and cut one of the battery wires. he then lengthened the exposed ends and ran them out of the gun to his control circuit. He also placed a protection diode to help prevent any reverse EMF from damaging his more sensitive electronics. The new control wires run to a MOSFET on a bread board.

[Ashish] is using a Lightblue Bean board as a microcontroller. The Bean is Arduino compatible and can be programmed via low energy Bluetooth. The Bean uses an external PIR sensor to detect motion in the room. When it senses the motion, it activates the MOSFET which then turns on the water gun.

[Ashish] decided to use Node-RED and Python to link the Bean to a Twitter account. The system runs on a computer and monitor’s the Bean’s serial output. If it detects the proper command, it launches a Python script which takes a photo using a webcam. A second script will upload that photo to a Twitter account. The Node-RED server can also monitor the Twitter account for incoming direct messages. If it detects a message with the correct password, it can use the rest of the message as a command to enable or disable the gun.

Visualizing Magnetic Fields In 3D Space

[John] is working on his PhD in experimental earthquake physics, and with that comes all the trials of becoming a PhD; tuning students into the cool stuff in the field, and demonstrating tech created after 1970 to his advisers. One of the biggest advancements in his line of work in the last 30 or 40 years is all those sensors you can find in your cell phone. The three-axis magnetometer in your phone is easily capable of measuring the Earth’s magnetic field, and this chip only costs a few dollars. To demonstrate this, [John] built a 3D compass to show off the capability of these sensors, and have a pretty light show for the undergrads.

The magnetometer [John] is using is just a simple I2C magnetometer that can be found on Adafruit or Sparkfun. It’s not really anything special, but with a little bit of code, [John] can read the magnetic field strength in the x, y, and z axes.

Having a microcontroller spit out a bunch of numbers related to the local magnetic field just doesn’t seem fun, so [John] picked up two neopixel rings – one inside the other, and set 90 degrees out of plane with each other. This turns his magnetometer and Arduino setup into a real 3D compass. With this device, the local magnetic field can be visualized in the x, y, and z axes. It looks cool, which is great for undergrads, and it’s a great demonstration of what you can do with small, cheap electronic sensors.

[John] put up a screencast of a talk he gave at the American Geophysical Union meeting last year. You can check that out below.

Continue reading “Visualizing Magnetic Fields In 3D Space”