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

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

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

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

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

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

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

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

05 October 2014

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

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.

09 June 2014

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.

*UPDATE*

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.

05 November 2013

Old ATX power supplies are an excellent and cheap way of getting a power supply that can generate 3.3, 5 and 12 Volts in a stable form and with high currents. It's also really easy to convert them into bench power supplies or to power anything that requires 3.3, 5 or 12 Volts. You can either obtain them from an old PC you have lying around, or one that a business is throwing out. Alternatively, they can be bought really cheaply from places like eBay.

Before you open up the PSU unplug it and leave it unplugged for several days prior to opening up the case. Yes, you heard me right. The power supply has great big capacitors inside that can store charge for a long time after you disconnect the power. Fail to do this and you risk getting a nasty jolt. Don't say I didn't warn you. If it's a brand new one or been unplugged for some time then you'll be fine. However, I take no responsibility for you getting a shock. Take precautions first.

Open up the case. Now chop off all of the plastic connectors. Now, the red wires are 5V, the yellow are 12V, the orange are 3.3V and the black is ground. You also have -5V on the white wire and -12V on the blue wire. If you wish to use these then fine. Check out the WIkipedia entry for ATX for the full diagram of outputs and wire colours: http://en.wikipedia.org/wiki/ATX

You will also need the green wire. This is PS_ON and needs to be shorted out by connecting it to one of the blank (ground) wires. Shorting the green wire powers up the device (when plugged in and turned on). Alternatively you could connect this via a switch.

Optionally you can also use the grey PWR_OK cable to power up an LED (via a current limiting resistor and ground) to show the power is on.

For my conversion I used banana plug sockets. Banana plugs are usually rated for at least 10 amps which is more than enough for my usage but check the ratings for your own specifications. Drill some appropriately sized holes in the case for your banana sockets and push them through.

Bundle as many of the red wires together as you can and solder to the base of a red banana socket. This will be your 5V output. Any red wires unused can be cut off as close to the circuit board as possible.

Do the same with the yellow wires for 12V, orange wires for 3.3V (I didn't require these on my PSU as I am using it to power my astrophotography equipment which only needs 5V and 12V. I did however leave some orange wires inside, just in case.) and then black wires for ground. If you wish you can also use the white for -5V and blue for -12V.

Optionally solder a switch and LED to the grey PWR_OK wire. Also solder the green PS_ON wire to ground.

Make sure all of your connections are solid and then wrap electricians tape around any exposed wires. Screw your case back on and power up. Voilà, you now have a stable bench PSU able to provide nicely regulated voltages at high current. Check the outputs with a multimeter prior to use.

I've heard of people building the outputs into their desk for easy access, which is a great idea if you do a lot of electronics. My conversion is going to be used to power my astronomy equipment such as the motorised mount, filter wheel, camera, dew heaters, USB hub and so on. I can get rid of the numerous power supplies I need to power these and use this single PSU for them all. As I have used banana plugs, which can be daisy chained by inserting into each other, I can power as many 12v or 5v devices as I wish from the one PSU.

The following advice about this project has been offered from Brad Levy:

Using an ATX supply as an inexpensive powerful lab supply is a good idea, but there are a couple of things you need to watch out for.

Many ATX power supplies are not designed to be operated with less than a certain minimum load. If run with a load lighter than that minimum load, the supply may shut down or may output voltages outside the regulated range. The minimum load specification varies depending on which version of the ATX spec the supply adheres to.

The early ATX supplies (circa 1995) had a minimum load requirement of 1 amp on the 5V line and 0.3 amp on the 3.3V line. This can be achieved by loading the 5V line with a 5 ohm 5 watt power resistor, and the 3.3V line with a 10 ohm 2 watt power resistor.

The ATX12V spec v1.1 (circa 2000) specifies a minimum load of 0.1 amp on the 5V line and 0.3 amp on the 3.3V line. This corresponds to a 50 ohm 1 watt resistor on the 5V line, and 10 ohm 2 watt power resistor on the 3.3V line.

The ATX12V spec v2.2 (circa 2006) specifies minimum load currents of 1 amp on the +12V line, 0.3 amp on the 5V line, and 0.5 amp on the 3.3V line. A 12 ohm 16 watt power resistor (such as TE Connectivity p/n 7-1625966-9 ) would suffice on the +12 line, with a 16 ohm 2 watt resistor on the 5V line and a 6.2 ohm 2 watt resistor on the 3.3V line.

For other versions of these and other supplies, check the supply manufacturer's specification for the minimum load ratings.

I've rounded down resistor values and rounded up the resistor power ratings above to give a little bit of margin and reasonable life. Don't forget that a 12 ohm 16 watt power resistor is going to get warm in the continuous operation, so should be mounted in air flow.

The other caution is to add a fuse or circuit breaker in series with each of the output jacks.
The ATX supplies are designed to be able to provide a lot of power - 20 amps or more on the 5 volt line, for example, which is likely far more than your intended load. This is enough to allow a miswired circuit being powered to seriously overheat or start a fire. (Think how hot a 100 watt light bulb gets - some of the ATX outputs can double that power.) You should use a fuse or circuit breaker value in comparable to a little more than your expected maximum load.

03 November 2013

If you have read my previous post you will know that I recently made a digital temperature controller to turn a cheap crock pot into a sous vide cooker. Well, I got myself a cheap vacuum sealer from eBay for use with the sous vide cooker recently. It arrived

The same model vacuum sealer I bought.

the other day and it works very well. It works by sucking the air out of the bag and then a heated wire seals and cuts the bag leaving you with the food sealed inside.

The reason I purchased it was when I first tried the sous vide cooker it was obvious that having the food in a vacuum sealed bag would make life much easier. The first time I used the cooker I put the steaks into a normal gripseal bag, tried to suck out as much air as possible and then put it in the cooker. Not ideal, but the best I could do whilst lacking a vacuum sealer. As I knew the seal wasn't perfect I left the steaks in for two hours instead of one to make sure they were cooked through, They were cooked perfectly and tasted amazing, but the outside had dark and pink patches prior to frying. Also, the bag filled up with air again and the bags eventually floated.

Vacuum sealed steaks ready to go in the sous vide cooker.

For correct sous vide cooking the food should be vacuum sealed so that the water bath is able to get its heat to every part of the meat.

The picture on the right shows two steaks that I did today in the vacuum sealer. They will be cooked in the sous vide cooker later today for dinner so I will be able to compare how these cook compared to the first time. I will also try cooking them for a shorter time period this time around as they are vacuum sealed and so the heat will transfer to the meat more efficiently. I have also bought a cheap steak this time, the cheapest one I could find in the thickness I wanted. On the first steak I cooked even the parts that are usually chewy were soft and tender so i'm convinced that steaks done the sous vide way will always be soft and tender even if the original steak was on the tough side. I will let you know what they taste like later today once they are inside my belly.

21 October 2013

I had seen plenty of websites or videos of people making their own sous vide cookers so thought I would give it a go myself. If you don't already know, sous vide is a method of cooking food in sealed bags in a water bath with the water held at a very precise temperature. The food is cooked for a long time and means the food is cooked perfectly evenly throughout instead of cooked well on the edges and not so well in the centre. A perfect steak for example would be the exact shade of pink you wish from edge to centre. As a huge steak fan and having had some fantastic steaks in expensive restaurants but been unable to reproduce them at home I wanted to try this out.

I already had a slow cooker and at first intended to hack it for temperature control. But after using an Arduino and a DS18B20 temperature sensor I was able to determine it was capable of reaching the target sous vide temperatures easily and beyond. So I decide to make an external temperature controller box instead. I was originally going to use an Arduino and a relay, but found out you can buy temperature controllers cheaply on eBay for a lot less than the cost of an Arduino and a relay. So I bought a cheap PID temperature controller for about £10, a project box and a few other parts and set about making the unit.

These units are fully controllable with either a high or low temperature setting, temperature alarms, time delays and so on. They are very easy to wire up (despite the crappy instructions you always get with Chinese made electronics).

The steak I cooked on the very first time I used the unit was cooked perfectly throughout and was, without exaggeration or bias, the most tender and delicious steak I have ever had outside of a top London restaurant. Even my partner, who was very sceptical about the whole thing, admitted that the steak was the most delicious she had ever had and was very impressed. For a total cost of around £35 I have made my own sous vide cooker and cooked an amazing steak without shelling out the £100's it would normally cost to buy a domestic sous vide cooker. I will definitely be cooking all of my steaks the sous vide way from now on.

A lot of people use rice cookers instead of slow cookers as the thin walls mean you are able to control the temperature more precisely. If I didn't already have a slow cooker I would have purchased a rice cooker. However, the slow cooker works extremely well also.

As I made an external controller instead of hacking the slow cooker this means the cooker is still fit for purpose and is still safe. Also, I can plug anything I want into the unit and give it temperature control, such as a heater, fridge, freezer, home brew kit, aquarium, etc.

I've made a video (see below) that shows the full build and if you want further information then contact me on Twitter, G+ or Facebook using one of the methods listed at the end of the video.

04 October 2013

One of my hobbies is astronomy and more specifically, astro-photogaphy. I have a pretty sophisticated setup with a computerised GoTo mount with a cooled CCD camera, motorised filter wheel, guide camera, etc. Most of the gear is automated and can be controlled remotely (i.e. it is out in the cold while I sit in the 'control room' indoors and operate it. however, the one thing that still has to be operated manually is the focuser. I have no choice but to focus the kit out in the cold then come indoors. Not only will automating the entire kit make it more comfortable to image when i'm at home, but it will also save a lot of time and time is precious when doing astro-photography, especially in windy and rainy old England.

Me & my astro gear - Brecon Beacons Astrocamp, Sept 2013

Now a commercial motorised focuser isn't cheap. They can cost a lot of money and most of the cost is unnecessary. After all, it is simply a stepper motor attached somehow to the focus knob and then controlled with a 'box of tricks' connected to a PC. So in the hacker spirit I decide to make my own. I had an old 3.15v Sanyo stepper motor somewhere that I scavenged from a printer or scanner or something so decide to use that. I also had an Easy Driver 3.1 board (i've also got Adafruit motor shields and the official Arduino Motor Shield).

As the completed product needs to be small and light I went for the Easy Driver motor control board as it is tiny and easy to use.

So far I have hooked it up to the motor and have it stepping in tiny 1/8th microsteps. The next stage is to create a control box with knobs and buttons to select the motor speed and to focus in and out (Stage 1). This will also have a USB interface so I can connect it to a PC and control it from software (Stage 2). This will have a temperature sensor so it can automatically compensate for the changing temperature throughout the night as the telescope cools down and heats up.

Once I can control it from a PC I can then operate it remotely over VPN and sit in the warm whilst imaging.

Stage 3 of the project will be to write some ASCOM complaint drivers for the device so I can hook it up to either FocusMax or my imaging software (APT & MaximDL) so the focussing procedure can then be fully automated.

As you can see in the picture I am providing the motor with 6.2 volts. The motor is a 3.15v motor. However, that's 3.15v per coil and so double that is needed to get it going. Powering it with just 3.15v volts and it goes nowhere. When running continuously it was using about 500ma.

Next I am going to make a hand control unit. The plan is there will be a knob to select the step speed and number of steps. Then buttons for focus in/out, another for selecting continuous operation or one iteration of number_of_steps and another for selecting either speed or steps. This will be displayed on either a 7-segment display or an LCD.

Below is an example video showing the motor in micro-stepping mode. it is doing 1/8th micro-steps controlled by an EasyDriver 3.1 motor control board. The motor is a 3.15v Sanyo stepper motor salvaged from a printer or scanner. I am running it at 6.2v (3.1v per coil) and have dialled down the ED3.1 so it is being given no more than 100-150mA. Any less and it stalls and any more and it gets too hot. This current is enough to give me the torque I need. Next I am prototyping the circuit and testing it out. I will post an update soon.

So, if you haven't already heard of Sous Vide cooking I'd highly recommend reading a bit about it. In a nutshell, it is cooking food in a water bath at a certain temperature with the idea being that the food cooks slowly and evenly resulting in a perfect steak, or whatever it is you are cooking.

With a steak for example, you will usually have a temperature gradient across the meat resulting in a pink centre and increasingly darker and cooked meat towards the edge. With sous vide cooking, the steak is cooked exactly to your specifications throughout the meat evenly. You then finish off the crust of the steak quickly with a blowtorch or in a pan.

However, sous vide cookers for domestic use are very expensive indeed. But, with a bit of time and not a great deal of effort you can make your own for a fraction of the price. Many people hack slow cookers, crock pots or rice cookers into DIY Sous Vide cookers. I happen to own a slow cooker that rarely gets used so I thought I would see if I could repurpose it into a Sous Vide cooker to make the perfect steaks.
So the first thing to do was to find out if the slow cooker could reach the temperatures necessary for cooking sous vide style. Typically you want temperatures ranging between 50-60°C for the perfect steak and up to 80° for other items. So I had a DS18B20 temperature probe lying around so I hooked it up to an Arduino and set it to take a temperature reading every 5 minutes and print that to the serial monitor. That way I could see over time how long it took to get to temperature and if it could reach at least the temperatures necessary for a perfect steak.

Over the next 2 hours the cold water I put into the pot was heated slowly up to around 65°C so I knew it would be ideal for how I like my steak (rare). I decided to leave it on overnight and see just how hot it got. The next morning the temperature was just over 97°C, which was a surprise.

So, I now know that the cooker can be used to cook meat sous vide. All I need to do next is to create a control unit that keeps the water bath at the exact temperature necessary. I will work on that at some point in the not too distant future and will give you all an update.

About Me

Author of "Beginning Arduino" by Apress. Now in its second edition. Observing Officer for Orpington Astronomical Society. Astronomer/Astrophotographer. GSX-1400 Motorcycle owner. Newly joined member of Medway Makers..