Tuesday, July 29, 2014

Fireflys in a jar

New! Webinterface

A toy webinterface for a similar jar can be found here:
Note that it is the real deal and the jar, standing next to my window, will actually start flashing if you click any of the buttons

 Ingredients

  • A large jam jar (Ikea)
  • Mini USB Nano V3.0 ATmega328 5V Microcontroller Board (eBay)
  • FTDI serial cable for flashing (eBay)
  • Solar cell, 5.5 V, 50 mA or larger (eBay)
  • Lipo - battery cell, 100 mAh - 600 mAh (eBay / old laptop / old cellphone, etc.)
  • 12 x tiny LEDs, different colors, the smaller the better, with ~80 - 200 Ohm series resistors, depending on how bright you want it (kit from eBay)
  • Very thin magnet wire from the coil of a miniature relais
  • SMD resistors with 1 % tolerance: 2 x 560 kOhm,  2 x 160 kOhm. For two voltage dividers to sample the solar cell and battery voltage
  • SMD ceramic capacitors, 2 x 100 nF, to stabilize the analog inputs of the AVR
  • Some circuit board, glue, prototyping wires, sticky tape 
The making-of after the click ...


 Making-Of

The AVR board has been modified in the following way for very low power operation:
  • The voltage regulator has been removed and VCC has been connected directly to the battery
  • The Schottky diode, which is already on the board, has been rewired to be in series with the solar cell. It only has 0.2 V forward voltage drop, which is excellent!
  • 2 Voltage dividers with the 560k and 160k resistors and 100nF capacitors have been made and connected to Vsolar and Vbattery. The AVR uses the internal 1.1 V reference voltage for the ADC, which allows to measure voltages up to 4.95 V
  • The onboard serial bootloader has been rebuilt to work at 8 MHz and 38400 Baud
  • The fuses have been reprogrammed to use the 8 MHz internal oscillator instead of the 16 MHz onboard crystal. This significantly speeds up the processor wake up time from sleep and hence saves power

Pinout

Note that this pinout allows to connect an optional nRF24 module to PORTB. So far this has not been utilized in the firmware though.


 Silkscreen, Firmw. Ch.    AVR               (*) = on LED board
 2,          6             PD2   LED   y      *  + GND pin
 3,          7             PD3   LED   o      *
 4,          8             PD4   LED   r      *
 5,          9             PD5   LED   w      *
 6,          10            PD6.  Led   g      *
 7,          11            PD7.  Led   b      *
 8                         PB0   Rf ce        *   (No LED)
 9                         PB1   Rf irq       *   (No LED)
 -------------------------------------------- 
 10                        PB2   Rf csn
 11                        PB3.  Rf Mosi 
 12                        PB4.  Rf Miso 
 13                        PB5.  Rf Sck 
 A0,         0             PC0   LED   w      *
 A1,         1             PC1   LED   r      *
 A2,         2             PC2   LED   y      *
 A3,         3             PC3   LED   g      *
 A4,         4             PC4   led   w      *
 A5,         5             PC5   led   b      *
 A6                        ADC6  Vbatt
 A7                        ADC7  Vsolar

 

Construction

The battery and AVR board have been fixed with superglue and some engineering tape to the backside of the solar cell. The female headers on the LED board will connect to the male ones on the AVR board.



The LED board breaks out the Port pins to different locations and incorporates a series resistor for each LED







The solar cell is clamped in place within the lid of the jam jar by a loop of thick magnet wire. The loop, having a cut, has been placed in a groove of the jar, then soldered together, which clamps it into place.


The magnet wire for the LEDs has been scavenged from a miniature relay. Two wirestrands, about 3 m long, have been tightly twisted together using a portable drill and then fixated with superglue. The resulting wire has been cut to various lengths and soldere to the SMD LEDs on one side and to the LED board on the other.


 

 Results


Firmware

The sourcecode for the AVR has been tentatively uploaded to GitHub.
It is based on hand-optimized assembler code, which does "Binary Code Modulation". The shortest bit-period is only 2 machine cycles long.

The flashing patterns have been crafted in iPython Notebook and exported as a C header file.

This project has been inspired by (and parts of the firmware have been shamelessly copied from) the Firefly project of Hagen Re


More on the software part soon ...

No comments:

Post a Comment