The blog of 'The Arduino Guy' aka Mike McRoberts, author of Beginning Arduino.

31 October 2014

New Wordpress Blog

Friday, October 31, 2014 By

I am no longer using Blogger. You can find my new Blog by going to or by clicking HERE.

See you there.


29 October 2014

Pin Powered Sensor

In an attempt to increase battery life further I've now got the HTU21D humidity and temperature sensor powered by a digital pin from the ATMega328p. In code the sensor is powered up and then back down again in-between reads in an effort to squeeze some more juice out of the battery. I've left the transmits/reads at every 2 seconds again so I can compare the voltage loss with what I've been having over the last few days to see if there is an improvement.

A test of 24 hours should be enough to ascertain if the voltage loss is the same or less than it was previously. Before I made this change the circuit was losing about 0.27 volts per day which would give the battery a life of about a week with 2 second reads/transmits. Ultimately the sensor will be set to only wake up every 60 seconds, which will give a much greater battery life. 

28 October 2014

Voltage Loss over a week

Tuesday, October 28, 2014 By

I've had the wireless sensor node with sleep functions transmitting every two seconds for a week now to see how fast or slow the power loss was. After about 5 days the battery lost 1 volt which is more than expected.

After reviewing the code it would appear I was powering down the micro-controller but not the radio module. So after amending the code to ensure that the radio module was also placed into sleep mode (using the Lowpowerlab libraries, not the Jeelib libraries) I ran it for testing purposes again. Overnight the voltage has dropped 0.13 volts. Something is obviously still not right.

After some discussion on Twitter it would appear I should also be powering up and down the sensor. So instead of having it powered from the 3.3v power rail it should be powered by an output pin so the power can be turned on and off in-between reads and transmits. So, I will be amending my code to allow for this and then running further tests to see how this impacts the power loss.

I am aware that 2 seconds is a lot and as such the battery is not going to last years like that. However, I would expect even with 2 seconds per reading that the battery should still last a few weeks at least. Once I am happy that I am achieving this then the node will be set to transmit only once every minute to conserve power.

19 October 2014

Change of RFM69 Libraries

Sunday, October 19, 2014 By

Today I decided to change from using the Jeelib library for the RFM69 and instead i've started using the RFM69 library from LowPowerLabs. Not only is it easier to use than the Jeelib library, but it is optimised for using the RFM69 whereas the Jeelib library is designed for use with the RFM12B. I can now set baud rates and other settings which were impossible using the Jeelib library and in decreasing the baud rate down to 9600kbps i'm getting a much increased range (at the expense of slower speeds and slightly more power use).

Along with the RFM69 library they also have a LowPower library for controlling the low power modes of the Arduino. I continue to use the sleep() function for powering down the radio. The RFM69 library also sends the RSSI value which is useful for checking received power over distance.

18 October 2014

Sensor Node Progress

Saturday, October 18, 2014 By

I've made some great progress with the sensor node project over the last two days. After finally getting around the problems I was having with the software bugs and the SPI restrictions I settled on the circuit you can see on the left.

This is a breadboarded Arduino made up of the ATMega328p chip with appropriate resistors and an oscillator. Connected via SPI is the RFM69CW radio Tx/Rx module and via I2C is an HTU21D humidity and temperature sensor.

I've also added an LED to Digital Pin 9 to give a brief flash after each transmission as feedback the unit is working,

Everything is powered by a 3.7v 850mAh lithium rechargeable battery. The battery passes through an MCP1702 voltage regulator to give a nice stable 3.3v for all of the devices. I've added some sleep functions to the code so that in-between transmissions the MCU powers down for 10 seconds before waking and repeating the data transmission. This means for the majority of the time the transmitter is using micro-amps and then only milli-amps for a few milli-seconds. Overall a very efficient state which should easily give a battery life over well over a year.

The data packet contains the node's unique ID number, the battery voltage and the two sensor readings (Temperature and humidity).

I've got the circuit as small as possible on the breadboard (see pic). The next stage would be to transfer it onto a stripboard and solder it all together. Finally i'll design and etch a PCB. I could use SMD parts to make the entire thing even smaller still and swap out the ATMega for an ATTiny which is a smaller chip.

I want to make 2 or 3 different sensor nodes with varying sensors on them (temperature, humidity, pressure, luminosity, etc.) so i've got packets coming in from several nodes. This will then allow me to start writing the code for the base station which will receive the data, time stamp it, store it on an SD Card and then sporadically upload it to a web server.

I've got 433MHz and some 868MHz RFM radio modules and also an SRF radio module from Ciseco which claims to have longer range. These will be all tested out in time to see which is best for penetration through walls, etc. 

17 October 2014

Wireless Sensor Node - successful transmissions

Friday, October 17, 2014 By

If you've been following the blog lately you would have read about the issues I had with transmitting data packets over a wireless netwrok between two Arduinos using an RFM69CW radio transceiver module.

A quick recap - I first had lost packets and lots of CRC errors in transmissions. These turned out to be a bug in the Jeelib library. Then I put an L7805 5v to 3.3v rectifier on and found it wasn't suitable. This caused lots of problems with the radio. Changed that to an MCP1703-33 which is much more stable and better suited to battery operation too. That fixed those issues.

Then I found out that I couldn't connect any other SPI device to the BUS as the RFM69CW also uses SPI and is controlled via timer interrupts. This was corrupting comms over the SPI Bus to any other devices as the interrupt was hijacking the bus on regular intervals. I tried a DS3234 Real Time Clock IC and the data were all wrong.  I could bit-bang another SPI bus on non SPI pins but this is a lot of extra work. Instead I opted to switch to an I2C RTC (DS1307). I'll make sure all the sensors I use are I2C to avoid any further problems.

So, now i've discovered the above limitations with the hardware and software and have a better understanding of what i'm up against i've made a lot of progress. The sensor nodes are now transmitting data successfully with no lost packets or CRC errors. I have yet to do any range tests yet or run them of battery (with power saving sleep modes), that is the next stage in the project..

11 October 2014

RFM69CW - Never ending issues

Saturday, October 11, 2014 By

I have no idea why but my experiments with the RFM69CW have descended into chaos and frustration.

At first I had the units talking to each other and sending out test packets for nearly 24 hours with no issue. Then I started to modify my code and add functionality and they stopped working. So, I presumed I had broken something in the code and so reverted back to the RF12Demo sketch and my original code to test them again and they still didn't work.

So I rebuilt the circuit and started again. This time I had some limited success but it shortly started to fail again then stopped working altogether. I've swapped the radio modules over and still nothing.

I then started to use the RF12_easySend() function instead of RF12_sendNow() and the transmissions started to work. Then the receiver stopped receiving the packets, not even packets that failed CRC, nothing.

I've wasted hours and hours on this and it's nothing but frustration. Is it the Jeelib library? Do I have faulty radio modules? Who knows. I am at a loss what to try next.

09 October 2014

RFM69CW packet loss *solved*

Thursday, October 09, 2014 By

It turns out that all of the CRC errors and the packet loss I was experiencing was nothing to do with interference at all. It was a bug in the library!

After contacting the guys on the Jeelib Cafe forum I was made aware that the CRC errors was a library bug and this had been fixed in a fork to the original Jeelib library (which is now about 2 years old). So, after installing the forked library I was indeed able to confirm that the issues had been solved.

I left two units, one transmitting and one receiving, running overnight sending gibberish test data and this morning it was still running without one single lost packet of data.

A lot of time was wasted with that. Anyway, now it is fixed I am able to get down to the nitty gritty of connecting up a sensor and transmitting real live data over the network.

08 October 2014

RFM69CW issues

Wednesday, October 08, 2014 By

Over the last few days I've had two RFM69CW radio modules hooked up to two Arduino Uno's. They both have correct length 1/4 wave antenna and I've been running tests sending data from one unit to another. Seems like a simple test and yet I have had no end of problems.

Firstly, the receiver unit was correctly receiving packets for a while and would then stop receiving altogether or have large gaps where no packets were received. Then there were periods when the message kept failing the CRC error checks over and over. Despite the fact the units are only about a metre apart, I would expect perfect packets with minimal error and yet this is not the case.

I can only presume there is some kind of weird interference where I am testing. I did try to reduce the baud rate but when I attempt to use the RF12_control() command to set the baud rate I am getting compile errors. Some kind of issue with the RFM12 driver and Arduino 1.5.8

Overall it has been very frustrating.

05 October 2014

Arduino Yun and the RFM69CW

Sunday, October 05, 2014 By

I've been playing around with  RFM69CW radio tx/rx modules lately for an environmental sensor node monitoring project. Using the Jeelibs RFM12 library I was trying to get the Arduino Yun to talk to and configure the device over SPI to no avail. No amount of messing around solved the problem. I finally tried swapping out the Yun for an Uno and voila! It worked!

After doing a little bit of research it turns out that the Yun does not have its SPI pins broken out to the digital I/O pins as they are on the Uno and instead are only connected to the ICSP connector. So no wonder it wasn't working. After hooking up two modules to two Uno's they were able to communicate to each other successfully.

I have no idea why the ISP pins are not broken out on the Yun like they are on the previous Arduinos but i'm sure there is a valid reason for it.

So, now I have two device communicating the next stage in this project is to hook up some sensors to one of the device and have it sending the data back to the base station device. After that, the circuit will be powered by battery and using sleep modes will sleep in-between sending data to conserve energy.

11 August 2014

Wireless Environmental Monitoring

Monday, August 11, 2014 By

I've been asked to get involved in an Arduino based environmental monitoring project recently. I'm looking forward to it as it's been a while since I dusted off my Arduino's and actually did anything with them. it's also a good excuse to get my lab up and running and used for it's intended purpose.

The basic premise of the project is to have sensor nodes monitoring things such as temperature, pressure, humidity, light levels and so on and then send that data wirelessly back to a base station which will upload it to a web server. Nothing that hasn't been done before in one way or another but a nice project to get involved with.

So i'm currently researching various types of radio units, sensors, methods of battery conservation and so on that will be needed in the project. I will of course keep you updated with my project as time goes on.

10 July 2014

Lifehacker mention

Thursday, July 10, 2014 By

Lifehacker recently featured, briefly, my new Electronics Lab/Home Office build. You can see it HERE.

You can also see the Flickr album for the entire build HERE.

09 June 2014

New Electronics Lab Build

Monday, June 09, 2014 By , , No comments

So the build of my new Electronics lab/workshop/home office has begun. I'm starting completely from scratch and building a complete wrap around curved desk that covers 3.5 walls in a roughly square room. It's quite ambitious and will no doubt be a lot of hard work but I wanted something special instead of just square desks.

The plan is to have 3 work areas, one for me, one for Petra and a third larger maker space for our projects.

The room and desk will be white with hidden LED lighting to give it a bright and modern look. I want a kind of Tron flavour to it.

I've got all the wood and tools I need to get started so I'll be making a start tonight. I'll post photos of my progress as I go along.


Started to build the frame and then to cut out the worktops but found a problem with my router. The chuck wouldn't let go of the round over bit I was using and no amount of force would release it. The mechanism for locking/unlocking the bit is clearly faulty. So, the build is on hold whilst I take the router back to the shop to be replaced (plus get a replacement bit for the one that is stuck). Building will resume once I have my tools back.

10 May 2014

Long time no post

Saturday, May 10, 2014 By

Sorry for the big delay in posts guys. It's been a tumultuous 6 months for me and a lot going on in my life.

I'll have a new workshop over the next month or so and will be active again in electronics so watch this space.