LED Tea Light

With Xmas not far away I’d ordered some LED tea Lights for the wife to make some decorations to give away to the family.  I was interested to find out what was driving the LED, but because all the candles were required I was not able to autopsy one to find out.  This got me thinking, I have an Adafruit Trinket that would be great to drive an LED via PWM and create the desired flame effect.


Now after searching the web for examples of what it was I wanted to do, I finally settled on this one from .ledhacker This is pretty much what I was after! Here’s a copy of that original code…

#define FLICKER_LED_PIN 10
// the start of the flicker (low)
static int flicker_low_min = 200;
static int flicker_low_max = 240;
// the end value of the flicker (high)
static int flicker_high_min = 230;
static int flicker_high_max = 256;
// delay between each low-high-low cycle
// low->high |flicker_hold| high->low
static int flicker_hold_min = 40; // milliseconds
static int flicker_hold_max = 80; // milliseconds
// delay after each low-high-low cycle
// low->high->low |flicker_pause| low->high...
static int flicker_pause_min = 100; // milliseconds
static int flicker_pause_max = 200;  // milliseconds
// delay low to high and high to low cycle
static int flicker_speed_min = 900; // microseconds
static int flicker_speed_max = 1000; // microseconds
void setup() {
int flicker_random_low_start = 0;
int flicker_random_low_end = 0;
int flicker_random_high = 0;
int flicker_random_speed_start = 0;
int flicker_random_speed_end = 0;
void loop() {
  // random time for low
  flicker_random_low_start = random(flicker_low_min, flicker_low_max);
  flicker_random_low_end = random(flicker_low_min, flicker_low_max);
  // random time for high
  flicker_random_high = random(flicker_high_min, flicker_high_max);
  // random time for speed
  flicker_random_speed_start = random(flicker_speed_min, flicker_speed_max);
  flicker_random_speed_end = random(flicker_speed_min, flicker_speed_max);
  // low -> high
  for (int i = flicker_random_low_start; i<flicker_random_high; <span="" class="hiddenGrammarError" pre="" data-mce-bogus="1">i++) {
    analogWrite(FLICKER_LED_PIN, i);
  // hold
  delay(random(flicker_hold_min, flicker_hold_max));
  // high -> low
  for (int i = flicker_random_high; i>=flicker_random_low_end; i--) {
    analogWrite(FLICKER_LED_PIN, i);
  // pause
  delay(random(flicker_pause_min, flicker_pause_max));

So I loaded this on the Trinket and at first I didn’t include a current limiting resistor and the LED showed a slight flicker, but not anything like a flickering tea light! After adding the current limiting resistor (220Ω)and that didn’t really change much except for dim the LED ever so slightly.  So obviously I needed to tweak the code and see what I end up with..

Now my first thoughts on why it didn’t work out as expected is that the code was obviously written for a 5v logic, however this trinket is 3.3v logic. I made the following changes (after a little fiddling)and got more of what I was after  🙂

< #define FLICKER_LED_PIN 10
> #define FLICKER_LED_PIN 0
< static int flicker_low_min = 200;
< static int flicker_low_max = 240;
> static int flicker_low_min = 15;
> static int flicker_low_max = 175;
< static int flicker_high_min = 230;
> static int flicker_high_min = 180;
< static int flicker_hold_min = 40; // milliseconds
> static int flicker_hold_min = 20; // milliseconds
< static int flicker_speed_min = 900; // microseconds
> static int flicker_speed_min = 800; // microseconds

As you can see I only made small changes to some timings and they seemed to work better for the 3.3v logic

The next thing was how long would this run on a 1000mah lipo battery? well, somewhere between 4 to 5 days!

I’ve placed the code and supplement files on github should you wish to make one. 🙂

Flattr this!

Migrating to HTPPS

Over the next coming weeks I’ll be gradually updating old blog posts to be fully compliant to https, Should I find anything that can’t be done then depending on the content I’ll most like just delete it!

For now I’ve forced a redirect from http to https at the server level, hence why some content may not display correctly (especially links to external sites that are http only)

So I suppose just watch this space? 😉

Flattr this!

Kickstarter or not? 

I’ve only ever backed one project on Kickstarter, and so far I’ve never seen the product and just keep getting updates claiming that things are going well, oops no there’s a problem with X…  Ok we’re back on track…  Nope now there’s problems with Y. 

So I backed the ZNAPS project in July 2015 and the initial statement made was that a product would be delivered by December (2015) so here we are now August 2016 and still nothing has even been confirmed as being complete and ready to ship.  Ok so this isn’t an issue with Kickstarter, because they are just a means of advertising your product and gaining funds (they take a percentage) so the problem solely lies with the people who are ZNAPS. If you read through the comments on Kickstarter you’ll see comments after comment all stating their dissatisfaction with the way the whole thing has unfolded. 

Flattr this!

The Demise of Medicare 

​$61 to visit my GP when this used to be bulk billed. That’s almost half of my weekly DSP income! #auspol #lnpkillingmedicare 

Flattr this!

Disappointed Doesn’t Even Come Close… 

Well the election results are in and…  Fuck me,  how stupid are people? 

Flattr this!

Enter the Nexus 5X

It’s that time again where my phone contract had expired and my Nexus 5 battery was spending more time on the charger than active use. So I was going to look into replacing the battery, but the last time I got a so-called OEM battery (Galaxy Nexus) I got something that said one thing but its actual capacity was something totally different.  So I was cautious about getting stung again, plus there was the possibility that I’d bugger up the replacement process and end up with a phone that’s only good for a paperweight!
So I decided to look at what my provider had on offer and was surprised to see that they had the Google Nexus 5X and 6P. I’m not interested in a phone that is borderline to the size of a tablet so we went with the Nexus 5X. I was a little hesitant at first about the Nexus 5X because I initially just thought it would be just a re-release of the original Nexus 5. I was wrong! it’s a new phone altogether and with some noticeable differences.

imageThe next thing to decide on was a suitable case to protect the phone from the day-to-day abuse it will endure. After looking at what was available from the Google Play Store. I was surprised at the costs! really they were expensive with prices ranging from $34AUD to $59AUD. Because you have to purchase them sight unseen, I wasn’t keen to shell out for say the most expensive without seeing some kind of review or similar. Now this is where YouTube is your friend! so after watching several videos on all of the cases, I opted to go with the Adopted Case.


Flattr this!

Adafruit WICED Feather

Adafruit like experimenting with products to see what will inspire the electronics enthusiasts around the world. Now I’ve been after the ESP8266 Feather, however they have been unavailable for some time (so damn popular!) so I started looking for something else that had a wifi option. Released on March 23rd was the WICED Feather and I thought that should do the trick and give a challenge as it’s using a cpu I’ve not had much experience with. I’m kind of hooked on Neopixels and from version 1.0.5 of the Adafruit Neopixel Library includes support for the WICED Feather (STM32F2 MCU)

2016-04-23 20.59.07
Neopixel Feather Wing

Flattr this!

Tasmanian Internet (or lack of)

This started back on December 21st 2015 when it was reported there was a failure in the Basslink HVDC cable.  This links between Loy Yang Victoria to Georgetown Tasmania.  At first Hydro Tasmania believed the issue would be resolved within 60 days.  So all should be good… not to be, after delays in locating the cable, then not being able to ascertain where the fault was, the initial cutting was delayed until a better idea of where the fault was.  When the Basslink HVDC cable was laid down, this also included a Dark Fibre cable that would be run by Basslink Telecoms. This was to be a crucial new link for Tasmania as a way of not being held to ransom by Telstra, who have a monopoly on the wholesale of data passing to & from the state at the time. Basslink announced on February 22nd that the revised timeline for the cable repair was unknown.

basslink_1 basslink_2 Examples of Basslink Cable

So we jump forward to March 11th, this is where things get interesting! Basslink Telecom switched off the fibre at 08:15 and services that had made prior arrangements with Telstra were transferred. This is the moment when Tasmania’s internet slowed to a crawl, with customers on iinet, Internode, Westnet affected the worst. This naturally sparked an immediate social network backlash on Twitter and Facebook with customers venting their complaints.

2016-03-14 10-04-25 2016-03-13 18-54-46 Speed Tests

So how did it come to this? How could a situation that’s been known about be left like a last minute suck it a see approach? The fibre line had to be cut so repairs could take place on the HVDC line. It’s not like it was going to be left in situ while the other was repaired, after all the HVDC cable is 60kg/meter so it’s heavy and requires special teams to do the work  Well this is where things get a little messy, there’s been claims that helpdesk staff have been saying that the problem has nothing to do with Basslink, or that the helpdesk staff had no idea about Basslink and it’s effect it was to have.  Now I can’t vouch for such, I mean after all you can’t believe everything you read on the internet right? 😉

Will Hodgman announcement

Flattr this!

Weather Underground Webcam

Over the years I’ve tinkered with having a live webcam taking a picture of the weather conditions in my local area. Recently I rediscovered an old Logitech E3500 webcam that I figured would serve the purpose quite well. There’s a limitation with USB on a Raspberry Pi, some things will work as expected without any trouble and some things not so well. It turns out that the E3500 camera suffers from over exposure and the sensor simply gives you a blank image! at first I figured is was a v4l2 driver issue but the webcam behaves just fine on my notebook (both in Linux & Windows) so some further experimenting with things simply didn’t work out to well, so basically provided there wasn’t too much light or too much glare you’d get a good image captured using fswebcam and when things weren’t you’d just have a plain black image being produced. So I decided to abandon the idea of using the E3500 and turned to the PiNoIR camera for raspberry pi. this camera although lacking a UV filter produces a good picture. I decided to place the included blue filter over the lens to see if that makes much difference with the captured image.

Raspberry Pi Model A+ and PiNoIR Camera

This is the PiNoIR camera facing south and upwards, yes it’s and overcast day with patches of drizzle! anyway you’ll notice that there’s some foliage from a plant on the next door neighbours property that looks a little strange that’s because you’re seeing the effects of photosynthesis and can only be seen in the IR band of light (normally filtered out) So that picture is acceptable so I’ve started uploading and image every 5 minutes.

Logitech E3500 captured using fswebcam

This is a capture done with the Logitech E3500, mid morning and facing south-east with yet another overcast day! but it wasn’t long after this picture and the remainder of the day was just a black image. so it was a FAIL!

Raspberry Pi Model A+ and PiNoIR Camera

The Raspberry Pi is resting on the window seal with a ball of Blu-Tack preventing it from moving or falling off. One of the problems with pointing cameras outside in a suburban area is making sure that you don’t have it facing directly into your neighbours window (or similar)


The Raspberry Pi is using Raspbian Jessie Lite and this is missing ftp so that will need to be installed before you can start to sending your pictures. I have the following two scripts running from crontab, pinoir.sh captures the image and saves it locally in /tmp  Then wuftp.sh uploads the image to weather underground via ftp. The “MAILTO=” prevents crontab from flooding you with an email for every time its run! However there’s no mail server on the raspberry pi but if you were going to use something like on a standard Debian install you’ll soon like that “MAILTO=” trick! also the “>/dev/null 2>&1” should also prevent anything from triggering an email as it’s piping all stdout to the bit bucket of /dev/null


 # m h dom mon dow command
 14,29,44,59 * * * * /usr/local/bin/pinoir.sh >/dev/null 2>&1
 */15 * * * * /usr/local/bin/wuftp.sh >/dev/null 2>&1


 /usr/bin/ftp -n -v $HOST << END_SCRIPT
 put $FILE image.jpg
 exit 0


 raspistill -w 640 -h 480 -q 100 -x -dt -bm -n -o /tmp/pinoir.jpg


Things to do… put an overlay on the captured image with a time/date stamp or similar and possibly get the standard raspberry pi camera so that the images are true colour instead of the slightly washed out type they currently are. 😉

Flattr this!

Raspberry Pi Addiction!

I think it’s fair to say that I’ve got a little attraction for the Raspberry Pi.  I got my first in early 2013 at a time when I wasn’t able to play with it straight away due to other commitments (it was bushfire season and I was volunteering for the Tasmanian Fire Service. Since then I’ve got a small collection! they have been used for different things and at one point I was hosting this blog until after six months of MySql queries finally killed the sdcard (thank you backups!) so I no longer self host this blog but the experiment proved that it can be done however it’s better to not rely on SDCard media as there’s a limit to the amount of read/write cycles and eventually it will fail! so back up, back up back up if you are keeping anything important.

So I currently have the following Raspberry Pi’s, 1x Pi1 Model B, 1x Pi1 Model B+, 1x Pi1 Model A+, 2x Pi2 Model B and 1x Pi Zero and the current arrangement for the Pi’s is as follows…

So I’ve gone a bit link crazy but at least if you don’t know about something I’ve linked it to save your google foo! 😉

Posted from WordPress for Android

Flattr this!