Re-blogging my own post from another blog on using a Raspberry Pi to retrieve California state highway road conditions.
I was trying to determine if it is possible to remotely flash firmware on an ATmega2560 microcontroller using a micro SD card. I came across this repository of an ATmega2560 bootloader that flashes the microcontroller’s flash memory when a particular address on the EEPROM (Address: 0x1FF) is set to the value ‘0xF0′.
When the microcontroller is reset, if the EEPROM value(at address ‘0x1FF’) is set to ‘0xF0′, the bootloader looks for a file ‘firmware.bin’ on the SD card and flashes the microcontroller with the new firmware.
I had to make minor modifications to make use of this bootloader. I changed the Chip Select pin number of the micro SD Card (there are tutorials that explain how SD cards are interfaced to microcontrollers) in the macro definition to match that of the Adafruit Music Maker shield (the micro SD holder’s chip select pin is connected to Digital Pin 4 of the Arduino. This corresponds to pin 5, PORTG on the ATmega2560. Source: Arduino Mega 2560 schematic).
In the file asmfunc.S, I changed the CS pin to pin 5 on PORTG:
I also had to change the pin number of the LED used to indicate the progress of flashing the microcontroller by the bootloader.
After recompiling the bootloader’s source files, I flashed the new bootloader using AVR ISP MK II. I also had to make sure that the BOOTRST fuse was set in the ATmega2560’s fuse settings.
I compiled an LED blinking sketch and converted it into a binary file by executing the following command:
Note: The Arduino IDE compiles and stores its hex files in a temporary directory. In order to save the hex file upon compilation, edit the IDE preferences after closing the IDE. The preferences text file can be located at File–>Preferences
A line build.path has to be added to the preferences file. I included the path where the output of the compiled Arduino sketch would be located. I used Atmel Studio to convert the Arduino sketch’s hex file to a binary file (the avr-objcopy command shown in the above code snippet). I copied the binary file onto a micro SD card and inserted into the music maker shield’s micro SD card holder.
I made use of this sketch to set the value ‘0xF0′ at the address ‘0x1FF’. Upon reset, the bootloader flashed the microcontroller with the binary file located on the SD card.
Things to investigate:
1) When I was looking for a bootloader that would flash a microcontroller from an SD card, I read about problems encountered by others. I found out that people had problems using certain types of micro SD cards. I did have a hard time getting the bootloader working but it was due to the fact that I did not set the BOOTRST fuse.
Do let me know if you have used this bootloader or something similar in the past.
Reblogging my own post from another site: I am traveling this memorial day weekend and I wrote a post on setting up your Raspberry Pi in a motel room to verify something quickly for a presentation etc.
I own a couple of multimeters and I am never able to find one when I need them. I relocate my residence constantly and hence end up leaving the multimeter in one of the random boxes and forget where I put it (next time, I plan to mark my boxes clearly) and I never unpack my boxes due to my laziness.
My brother shared this USD 8 multimeter deal on Newegg. I decided to get one as I find Radioshack multimeters to ridiculously overpriced. I consider the deal to be a steal and comes with a backlight (apologies for the low quality picture). The multimeter is available on sale from here.
Silicon Labs has announced an Internet of Things (IoT) contest recently. The contest revolves around building an application around the SIlicon Labs microcontroller. The winning project gets USD10K worth of components for building your own product
Interested in participating in the contest?
I was definitely interested though I was not sure if I had any chances of winning the contest. The first step is the purchase of the kit. The cheapest kit available was the EFM8 Universal Bee kit(shown in the picture below). It costs USD 30 and according to the documentation, this microcontroller is USB capable. I will let you know how my experiment goes..
I recently came across this contest from the makers of the PiFace Control and Display. The PiFace Control and Display is a stackable hardware board that comes with tactile switches, IR receiver for remote control applications and a small LCD.
I had less than a day to make something using the display. The theme of the contest is to countdown to a target date. I decided to use the Google coder image for the Raspberry Pi. The Google coder is a platform meant for beginners in web development and enables building our own website on a local network. A step-by-step instruction of the Google coder setup is available on the Google Coder page. The instructions are more or less similar to the Raspbian setup for the Raspberry Pi.
Accessing the Google coder platform from a Windows desktop requires the installation of the Bonjour drivers for Windows. The Google coder desktop can be accessed from a browser at the following address is http://coder.local. I downloaded the digital clock application from the Google Coder repository and modified the same to display the countdown timer on the PiFace Control and Display.
I modified the clock such that it is possible to pick a date to count down. I used pickadate.js to pick a date from the calendar. for the countdown selection. The clock pings a web.py framework based webpage with the countdown data which is consequently displayed on the LCD.
I also wrote a couple of lines to control the LPD8806 LED strip lighting using a TV remote control. Based on the number pressed on the TV remote, the python script reading the PICAD’s IR receiver, sends a control word to the Arduino controlling the LED strip to switch the LED sequence.
The Google Coder and the PiFace Control and Display setup instructions are available over the web. The modifications to the clock application and the python script are available from my github account.
I recently bought a Pi Lite board from Ciseco PLC, UK. The Pi Lite is an add-on hardware board for the Raspberry Pi. It comes with 126 LEDs and is controlled by an Atmega328p microcontroller (The one used in the Arduino Uno platform). The Pi-Lite uses the BCM chipset’s serial port for its communication to the Raspberry Pi.
Since the Pi Lite is a stackable add-on hardware, they have provided access to the Pi’s GPIO pins on the add-on board. It is possible to scroll messages on the Pi-Lite display by sending messages via the serial port on the Raspberry Pi. A simple step-by-step guide to setup the serial port to transmit messages to the Pi-Lite is available here.
I was able to run a simple program that fetches the currency exchange rate from the web and scroll the same on the Pi-Lite Display in two simple steps.
I got started by fetching currency exchange rate data:
import requests import json data = requests.get('http://rate-exchange.appspot.com/currency?from=USD&to=INR') jsondata = json.loads(data.content) retrieved_data = jsondata['rate'] print(retrieved_data)
We can scroll the retrieved data on the display by simply opening the serial port (The port at which the Pi-Lite is connected) and writing the string to it.
baud = 9600 port = '/dev/ttyAMA0' ser = serial.Serial(port,baud) ser.timeout = 0 ser.flushInput() ser.write(str(retrieved_data))
Combining the above two steps, we have:
import requests import json import serial from time import sleep baud = 9600 port = '/dev/ttyAMA0' ser = serial.Serial(port,baud) ser.timeout = 0 ser.flushInput() while True: data = requests.get('http://rate-exchange.appspot.com/currency?from=USD&to=INR') jsondata = json.loads(data.content) retrieved_data = jsondata['rate'] print(retrieved_data) ser.write(str(retrieved_data)) sleep(10)
I was not able to take a good picture due to the brightness of the LEDs. Hence, I am sharing a black and white video of the currency exchange rate being updated every 10 seconds:
Note: I am not promoting the Pi-Lite board!