Category Archives: electronics

pine64+ 1G SoC 64bit computer

So, I know it has been absolute ages since I posted last, mainly due to life, illness or study getting the way. So, I thought it was time for an update, and what better way to update than to discuss my latest toys, or projects.

So, I have recently become involved in four kickstarter projects. One scored me a 3D printer, another was for a more stable ESP8266 wireless MCU, and the other two were for some ‘cheap’ SoC (System on a Chip) computer boards – one for $9, and the other for $29.

For this post, I’ll focus on the last one. So you’ve probably heard of the Raspberry Pi by now… these days, just about everyone has. It really is a great board… small, inexpensive, well documented, and is more than just a computer. With the GPIO pins on the Raspberry Pi, you can also dabble with some electronics, and make things like home automation projects. It is especially good when you would want the beefier processing power of a computer, but don’t want the size and power-hungriness of it. However, unless your needs are relatively undemanding, it won’t be replacing your desktop computer anytime soon… it’s not THAT powerful… but it is getting better with every revision.

Pine64+ 1GB with a MCP23017 attached to the I2C bus for testing

So what’s so special with the $29 computer board I gottten (shown right) since the Raspberry Pi’s so great? Well, a couple of things. But to clear something up first, technically it was a $15 board, but I got the one with double the memory, and with the wifi module, hence $29. And in doing so, I have hinted at one of the advantages the Pine64 has over the Raspberry Pi – it has a a built-in wifi module. One of the things a lot of people get for the Raspberry Pi is a Wifi adapter, and in doing so, depending on which model you get, you loose 1 of 2 or 1 of 4 USB ports immediately. Not so bad with the 4 USB port models, but can be painful for the 2 port models.

Then you say “but most of the Raspberry Pis have an ethernet port”… so connecting to a network is easy if you have a ethernet cable nearby. That is true, but there is another catch… the ethernet and USB share the same chip (I’m not sure if this changed for the Raspberry Pi 3, but this was the case until at least then)… meaning if you had wanted to do something like have a raspberry pi share files over a network from a USB drive… then don’t hold your breath… not only was it slow… but the ethernet would shut down every now and then. The pine64 doesn’t have this issue as it has a separate ethernet control chip (as does the Cubietruck, which is the board I currently use as as network attached storage (NAS) drive).

Another advantage is hinted in the name. The pine64 has a 64bit processor, whereas the Raspberry Pi, and most other SoC boards have a 32bit processor. This is starting to change, as there are a few other boards starting to come out on the market now. However, the pine64 is one of the first, cheapest, and feature rich I have seen to date. Why does 64bit matter? Well, it only matters if you want to be able to proces a lot more data more quickly, or be more power efficient than it’s 32bit cousins when processing the same amount of data.

Just like the Raspberry Pi, the Pine64 has support for a directly connect LCD and camera, so you don’t loose those options if you want them. It has a Raspberry Pi compatible header (the 40 pinout), as well as it’s own Euler bus and an expansion header for power switches, LEDs and the serial console. It boots from a microSD card, so that makes switching operating systems as easy as swapping out the microSD card. If you need to be able to run it from a battery, there is even built-in support for that… just plug in a compatible batter, and move a jumper, and you’re set.

So, I’ve been singing praises about the Pine64, so what’s the catch? Well, the Raspberry Pi header isn’t 100% compatible, but so far, the variances are only minor once you’re know about them, and can be easily remedied. The gigabit ethernet (another big plus if you want to transfer a lot of data fast) appears to have issues with some setups – if this is software fixable is yet to be determined. Probably the biggest failing point of the Pine64 is the documentation, or the lack thereof. For instance… unlike other boards… the new user will probably get the board, and then go to the forum asking “where do I start?”. There is no “getting started” guide. There is no friendly walk-throughs on getting your new toy up and running. Not even a video tutorial to show you what all the different ports and sockets do. What you will find is a random collection of information scattered all throughout the forum, two wiki pages, and a site that backer created which will hopefully fill a lot of that gap up.

Now, since this was a kickstarter project, the thing that happens to nearly 90% of tech related kickstarters happens… they were way behind schedule. And providing timely updates wasn’t a strong point of this project, so there are several threads where people are understandably upset over why they don’t have their board, and hadn’t received any responses to emails. However, shipments are nearly done, so that phase is nearly over. People have their boards, and are starting to ask questions about how to get this and that working. This is unfortunately another problem arises… whilst some people on the forum are very helpful, some others just aren’t. They think they are, and they do have a lot of valuable experience to share, but also can give beginners completely wrong, conflicting information, or sometimes respond when they don’t know anything, but want to make it appear that they do. Unfortunately, this individual is a moderator, and when confronted, likes to wave that authority. So until the dust settles, and more people come on board, the forum is a bit of a train wreck waiting to happen.

Timers and Flickering LEDs!

Recently back to work on a 12V RGB LED colour controller that I haven’t worked on in a while as a break from study (actually, read as avoidance of doing any study for a day). After finally finding the current version of the code (that was an ordeal and a half  – had the newer copy in a different folder). I had gotten basic colour selection, brightness control and a seven colour strobe sequence working. Now it was time to do the rest of the colours and get the ‘colour wheel’ / fade  working. Easy. Well, I did a complete re-write of the code, and changed to colour mapping from hard coded RGB to using HSI, which I will talk about in another post. In a nutshell, it let me separate the colour I wanted to set from the brightness or intensity, and as a result, I can easy just set the colour, and change the brightness – and it will re-calculate the new colour codes automatically.

Also made the colour wheel exceptionally easy. So, moving from the small 9 led test strip to the full length 3m ceiling mounted strip and the moment of truth. Switched it on, and chose white. Grea…. aw… what the flicker? It’s pulsing… and quite noticably. So, is there a glitch in the code, or fluctuation of the power supply meaning I really do need to put some filter caps on it. Try some of the other colours… they’re all fine… just white, but some combinations show the flicker also.

Back to google, and a general search for ‘rgb led arduino flicker’ and ‘rgb led arduino pwm flicker’. I suspected the issue was related to the particular pwm duty cycle, so that’s why I looked for PWM related results as well. I saw a few posts which suggested the original posters problems were power related, but then I saw two posts by a chap who has done some great articles on Arduino stuff in the past. And he was having the same problem. He said he though some of his trouble was power supply related, but when he tested the output of the PWM control signals for the LEDs, he noticed that they weren’t what they should have been… and one channel was going in and out of phase… and visibly so! Great… so I wasn’t my imagination. And in his follow-up post, he had the solution… just one line of code in the setup function, and the PWM signal to the three pins in use would be in perfect sync! Eureka! The miraculous line of code is as follows:

bitSet(TCCR1B, WGM12);

Do I hear you ask “What does it do?” Excellent question. In a nutshell, it changes the Timer 1 setting from Phase Correct PWM to Fast PWM, which is what Timer 0 is set to. Although Phase Correct PWM may be the better quality / higher accuracy PWM mode, due to the fact that we are both using RGB leds that are connected to pins controlled by Timer 0 (5 & 6) & Timer 1 (9 & 10), they need to be set to the same mode. Otherwise, the difference in operation will result in a visible flicker. For a much clearer and detailed explanation, please check out Jean-Claude’s postings which I linked above.

After adding just this one line of code, I can happily report that the colour controller is now running without a single flicker. Now I just have to fine tune the colours and add the final touches!

DigiSpark Pro has arrived!

After a long wait (although with study and other stuff happening I didn’t really notice), today’s post was the Digistump Digispark Pro! Plus several addon shields including an OLED display, GPS, Wifi and nrf24L01+ 2.4Ghz transceiver. And the obligatory LEDs to make blinking lights!

Digispark Pro and shields

Digispark Pro and shields

Read the rest of this entry

DIY i2c LCD backpack

What do you get when you add all of these parts plus a 16 x 2 LCD together? A do-it-yourself I2C LCD backpack which only needs four connections to an arduino or any other micro controller to work… and only two of those connections are data connections!

Parts for I2C backpack

Based around the MCP23008, which is a I2C 8-Bit I/O Expander, this little board allows me to control a LCD from the I2C bus of an Arduino, and even use those two pins to also talk to a real time clock (RTC) and other I2C devices! This variation of the design allows for the LCD backlight to be controlled digitally, with the contrast being set using the potentiometer and jumpers to allow one of eight hardware addresses to be set. I didn’t come up with this idea

The finished board

And here is a picture of the board nestled on the back of a 16×2 LCD which it now controls.

16 x 2 LCD with I2C controller attached

To finish off, for more information on this design, including schematics so you can create your own, visit the Arduino Playground and this forum article. My variation to this was to use a BS170 mosfet to control the backlight, and add jumpers to allow for the I2C hardware address to be changed. I use the Adafruit LiquidCrystal library to control it using a breadboard Arduino. Has been running 24 x 7 for approx two months without any issues as yet.

Cosm Local Environment (Weather) Logger


  • 30-12-2012 – Posts to every 15 minutes (as opposed to every 30 minutes)
  • 30-12-2013 – Multiply atmospheric pressure value by 10 to report hPa rather than kPa (breaks historical data)
  • 30-12-2012 – Changed analog LDR sensor for digital lux light sensor (breaks historical data)
  • 27-12-2012 – Now running from a 5v mains powerpack rather than a 12v SLA battery with maintenance charger. 


  • LCD to display data locally
  • SD card to log data locally for analysis
  • Post to twitter when downtime occurs (with explanation codes – ie. loss of network connection)

Brains of the unit (microcontroller) = Atmel ATmega328

Programmed with Arduino 1.5 (C++) 

Connection to the outside world = WIZ820io
  • Plug-in Network Module having W5200 & Mag Jack
  • Usable without H/W design for W5200, Transformer and RJ-45
Temperature & Humidity = DHT22 temperature-humidity sensor
  • Good for 0-100% humidity readings with 2-5% accuracy
  • Good for -40 to 80°C temperature readings ±0.5°C accuracy 

Atmospehric Pressure = BMP085 Barometric Pressure/Temperature/Altitude Sensor
  • Pressure sensing range: 300-1100 hPa (9000m to -500m above sea level)
  • Up to 0.03hPa / 0.25m resolution

Light = TSL2561 digital luminosity / lux / light sensor

  • Approximates Human eye Response
  • Precisely Measures Illuminance in Diverse Lighting Conditions
  • Dynamic range (Lux): 0.1 to 40,000 Lux

Unusual projects

I have recently been having fun with a solar-energy power monitoring system, some friends live in a remote area without access to grid power. They are currently using two banks of old Telcom v2 SLA cells, with pair of solar panels on the roof for charging. There is a 600w inverter providing 240v power for the house, and a solar management unit to ensure peak charge from the solar panels. There is a 240v petrol generator providing backup power and also charging the batteries via a intelligent SLA 25A charger. To make life easier, there is also a automatic change-over switcher which will run the house off the generator whilst it is running, and automatically drop back to the batteries / inverter when it stops.

To monitor the state of the batteries and system, we have installed a Arduino clone board (Freetronics EtherMega) with a RTC, MicroSD card and custom op-amp and shunt sense board. This allows for the battery voltage, load and charge status to be tracked via a 20×4 LCD screen, as well as over the network via a custom website. Plus with data capture, the state of the batteries can be analysed on a excel graph. 

This is where I came. As a result of about three weeks of off-and-on work on the system, I have taken it from a system which simply displayed the voltage, load and charge current of the batteries to a system which is network capable, with a custom website which allows access to this information plus more. There is now a real-time clock onboard as well, so the system knows the current date and time. There is also a MicroSD card which is being used to capture data for later analysis. The website allows the user to grab the data in CSV format, and easily graph it using Microsoft Excel, thus easily visualise the data over time and assess the condition of the batteries.

The website also allows for calibration of the unit, formatting of the MicroSD card, saving of calibration data and resetting to default settings. Next up is to refine and make the code more bullet-proof, and also add the ability to set the time! Then, time to work out how to track the capacity of the batteries in a reliable manner.

Electronics, podcasts and it’s cold!

My Arduino is currently sat on the table next to me with a LCD screen and two analog sensors (a photodiode and thermistor – light and temperature sensors). It’s currently very dark, and approximately 21 C… not nice! I’m currently catching up on episodes of ‘The Amp Hour‘. I found the podcast a couple of weeks, back and am listening to it from the start. Currently listening to #13, only 33 to go!!

Arduino Uno with yellow backlight LCD, thermistor (for temperature)
and photodiode (for light). There is a three colour LED on the
breadboard but it’s not being used at the moment

My latest toy

I haven’t posted for a while due to study, life and other commitments in general… so I thought it was time for an update.

I’m currently playing with a micro-controller prototyping system known as Arduino, which allows you to do just about anything once you get started … what you have access to and your imagination is your only limitation!!! You can make a simply program and circuit to flash a LED, or run a LCD screen that shows the current temperature and light levels, or perhaps a notifier to let you know ‘You’ve Got Mail!’?! The choice is yours (and btw, I’ve done all three and more). Next up will be motor control and switching things like lights and other circuits off and on… Stay tuned!!!