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.

trinket3v

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() {
  pinMode(FLICKER_LED_PIN, OUTPUT);
}
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);
    delayMicroseconds(flicker_random_speed_start);
  }
  
  // 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);
    delayMicroseconds(flicker_random_speed_end);
  }
  
  // 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
4,5c4,5
< static int flicker_low_min = 200;
< static int flicker_low_max = 240;
---
> static int flicker_low_min = 15;
> static int flicker_low_max = 175;
8c8
< static int flicker_high_min = 230;
---
> static int flicker_high_min = 180;
13c13
< static int flicker_hold_min = 40; // milliseconds
---
> static int flicker_hold_min = 20; // milliseconds
22c22
< 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. 🙂

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? 😉

Raspberry PiZero

I managed to get my hands on the much sought after Raspberry PiZero the smallest of the Raspberry Pi line. The PiZero was release with edition number 40 of the MagPi Magazine that included the PiZero board for free! (well you had to buy the magazine!) but now 3rd party distributors have limited stock and I managed to get mine from my favourite electronics supply Little Bird Electronics.

2885-06

I was not quite sure what to do with the PiZero and then it struck me that it’s the perfect thing to host the current official OS Raspbian & the NOOBs bootloader. so it’s currently running Transmission-daemon and is seeding four files.

Screenshot from 2016-01-17 10-54-01

Obviously this won’t be it’s only role but until I find something better this will do!

New Domain Name

I’m currently in the process of transferring my self hosted server to Gandi (domain and hosting) so there’s going to be some content that will no longer be available. I’m used to hosting my own server and have enjoyed it for the last 9 years but the costs of running gear and maintaining it has got to the point where It’s cheaper to off load it to someone else and free up some time on my end.  Things that will go are Gallery3 and the phpBB Forum as I no longer use either and I’ve not been maintaining them anyway.

I was going to make this a fresh start, but there’s some content on this blog that still get hits so I figured that the original content should stay so it’s still available. I’m also hoping that the content with try to stay away from politics as the blog has been pretty much dominated by local and national events that have annoyed me or I’ve felt that I must say something! as with all things there’s no guarantees! 😉

Pictures of Pi

image
RasPi 1

RasPi 1 is T2TAS (APRSC) aka VK7HSE-1/4 (APRX) This is the Raspberry Pi Model B

image
RasPi 2

RasPi 2 is currently setup with Ras Pi Cam Control keeping an eye on the server room! This is the Raspberry Pi Model B+

image
RasPi 3

RasPi 3 is this blog (vk7hse.org) and email.  This is the Raspberry Pi 2 model B

Raspberry Pi(s) Online

I’ve finally got around to completing the transfer of data for my Website, Email, File server, T2TAS & APRS iGate/Digi services. I’m using a model B for the APRS duties with the VHF port using TNCPi kiss tnc and still using the old faithful PK-232MBX & USB to serial converter for the HF port. For the website and email servers I’m using the new model 2B. Both are using 16gb Class10 sdhc. This leaves the third Raspberry Pi for experimenting with whatever suites!

Raspberry Pi Model B+ Raspberry Pi 2 Model B

The motivation behind this was to retire my aging IBM eServer 220 (costs about $100AUD per quarter) that had suffered the loss of 1GB ram due to age and the 10k SCSI drives sounding like they were about to self destruct! So performance may not be comparable from the old server, but that’s not the focus here.

A Work in Progress Raspberry Pi's

I’m in the process of transferring this blog from the old IBM-eSERVER 220 to a Raspberry Pi 2 Model B. So far the website files and mysql tables have been transferred and seems to be working ok. Email has given me some trouble and is still being run from the old server until I can sort out why it refuses to not accept mail for valid users! The next main change will be moving my T2TAS service to another Raspberry Pi Model B with a TNCPi to take over that function.

Work in progress

A third Raspberry Pi Model B+ will be setup with it’s PiNoIR camera and some IR LED’s to take footage of selected objects of interest! This will most likely not be available to the big world as it may end up becoming part of a home security system.

By the time I get this all sorted all my self hosted services will running from Raspberry Pi’s

A Work in Progress Raspberry Pi’s

I’m in the process of transferring this blog from the old IBM-eSERVER 220 to a Raspberry Pi 2 Model B. So far the website files and mysql tables have been transferred and seems to be working ok. Email has given me some trouble and is still being run from the old server until I can sort out why it refuses to not accept mail for valid users! The next main change will be moving my T2TAS service to another Raspberry Pi Model B with a TNCPi to take over that function.

Work in progress

A third Raspberry Pi Model B+ will be setup with it’s PiNoIR camera and some IR LED’s to take footage of selected objects of interest! This will most likely not be available to the big world as it may end up becoming part of a home security system.

By the time I get this all sorted all my self hosted services will running from Raspberry Pi’s

Raspberry Pi SSTV

Here’s an article for using your Raspberry Pi as a SSTV transmitter! (similar to the Raspberry PiFM project)

As mentioned in the article above the source can be downloaded from GitHub

Boring Statistics of 2013

The boring statistics of my blog for 2013!

Now I’ve tried to embed the page into this post, but if it’s not displaying correctly, it can be viewed here