Setting the Real Time clock Arduino based OpenKontrolGateway

The OpenKontrolGateway a board like an Arduino Uno, but with a SD card interface, three RF board interfaces, an Ethernet board module slot and a DS1307 Real Time Clock with battery backup. It’s a nice collection of all the stuff you need to make a datalogger. If you want to retrofit a DS1307 RTC to an Arduino project Seedstudio’s Grove RTC board features the SMD version of of the chip and saves you the tiresome surface mount wrangling.

Ciseco OKG
Ciseco OKG

The OKG bundle at £25 gives you everything needed to box it up but I added the RTC kit and SRAM which added £12 to the cost, since a data logger without an RTC is always going to be a pain, where you have to connect up a PC to set it. That’s OK at home but no fun at the farm.

The RTC gave me a hard time right off the bat. There are a few gotchas.

  • You have to set the damn thing,
  • you need to do that to even see it started, since it can need initialisation from the SPI bus before the oscillator will start
  • You need a 2032 coin cell present for it to be able to work too, so no testing that without and thinking you’ll fit that later 😉

So if you ‘scope the crystal and think  ‘ah, that’s why it isn’t working’ then not so fast, you may need to initialise and set it before you see any action there. I found all of this out the hard way. This is what I used to set it, which I largely pinched from LadyAda’s tutorial. One of the nice things about that is it lets you set the clock to the time the sketch was compiled, which save a whole load of faff. What you must not do then is to press reset, or switch off and on again, else it will do that all over again, setting the RTC back to the time it was compiled. You must comment out the line

    // RTC.adjust(DateTime(__DATE__, __TIME__));

and re-upload it. This listing has that line commented out, so you must uncomment it to set the clock, then recomment it.

Continue reading “Setting the Real Time clock Arduino based OpenKontrolGateway”

Project Overview – what I’m trying to do with the sensors

I have two applications for sensor networks. One is at home, where I’ve focused on temperature monitoring. I am trying to reduce gas costs by using a 6kW wood burner in the living room to heat the house, and it’s interesting to see how the heat propagates to the various rooms. Insulation is good and I achived this last year. It’s a fairly standard application of the IoT idea, so probably not of much wider interest.

The second is for gathering data over a 12 acre smallholding, the Oak Tree Low Carbon Farm. This is more challenegin as it is an island site without mains power or data communications. Remote sensing has a lot to offer a smallholding – temperature and light logging are interesting. Monitoring the state of the various 12V batteries used on site could make life easier, and control applications for managing the irrigation pumps may be feasible.

Initially I am using a Ciseco OpenKontrol Gateway to log the data. I’m not particularly using it as a gateway, more a generic Arduino kit connected to the sensors that happens to have a SD card interface and RTC on it. Eventually that could be used as its name indicates, to groom more significant status changes and alarm via SMS if necessary, for instance low battery or low water for the chickens.

At the moment I am using it as a straight datalogger for temperatures at home, to gain familiarity with the sensor and Arduino stuff. I will probably move to an EVE device for that, and move the OKG to the farm.

The first thing to do is get the OKG datalogging working right for a sensor network, in particular writing the data in a format that is usable for me. When I loaded the original version of the datalogger it didn’t work as I’d expected, specifically it didn’t log data. Some hacking was required.

How to change a LLAP device ID using Teraterm script

Note: after doing this I found you should be able to change the Device ID directly via the serial connection to the device using the AT command ATMY, so I guess that would be ATMYEB here.

You have to send an ack from the control node (usually your PC) within 1/10s of the a–STARTED– message showing up to config a LLAP node. That’s way too fast for me to type. I used Teraterm (the BSD licensed V4.75), which is a SSH and serial terminal program. It also supports scripting, and I used a previous version years and years ago in the old Win95 days.

Here’s a teraterm script to switch ORIGID to DEVID. Start Teraterm connected to your FTDI USB port

Start Teraterm in serial mode on your FTDI cable USB port

 

Power up a XRF on an XBBO board and connect to it via serial. Once it’s running and in range, ie you see the

a--STARTED--

message repeated five times when you power up your remote device, power off the device you want to configure. Start the macro,

How to start a Teraterm macro
How to start a Teraterm macro

Here’s the macro

; start of macro
DEVID="EB"
ORIGID="--"
dispstr #$1B"[2J"
wait "a"ORIGID"STARTED"
dispstr 10 13 "a"ORIGID"ACK------"
send "a"ORIGID"ACK------"
pause 2
dispstr  10 13 "a"ORIGID"CHDEVID"DEVID
send "a"ORIGID"CHDEVID"DEVID
wait "a"ORIGID"CHDEVID"DEVID
dispstr  10 13 "a"ORIGID"REBOOT---"
send "a"ORIGID"REBOOT---"
wait "a"DEVID"STARTED--"
dispstr  10 13 "a"DEVID"STARTED--"
; end of macro

Your device should be set to the new DEVID

 

Remote sensing and the Internet of Things

Wires. That’s the problem with remote sensing, at least it has been until recently. You needed wire to get the signal back to where you wanted to view it, and often to power your sensor too. That’s a grand PITA. The last time I looked at this, about a decade ago, you could get little RF modules running at around 433MHz but these presented the raw demodulated FM signal. Great for voice but you then needed a modem to wrap around the project. And some sort of protocol stack, possibly.

That exchanged the signal wiring problem for a sensor powering issue, and these radio modules were send or receive so everything would end up fire and forget.

I was chuffed to find there’s been a lot of movement in this field. A lot of it seems Arduino based and I selected PICs when getting into micros, so it is a new learning curve. In researching this I came across JeeLabs and Ciseco. The latter had some £12 bidirectional RF to serial cards, the XRF, which I expected to attach a PIC. However, they seeme ot also have used the microcontroller on the RF board to do some signal conditioning for a few sensors, including temperature via the Dallas 18B20 or a thermistor. Since temperature and battery voltage/contact status are some of the things I want to remote sense that saves me a load of programming grunt-work.

They have also documented a simple serial sensor protocol, LLAP, which fitted my needs. The Internet of Things is all very well but if you need a TCP/IP stack for each battery powered node you need a lot of processing power and electrical power, which is back to wiring again.

So I ordered four XRF boards, a couple of thermistor boards and a XBBO carrier board to interface to an FTDI cable to USB. Assembling the thermistor boards and the XBBO were easy enough, now it was time to test it all out and getting some readings. To do that you have to set your LLAP sensor device to some particular address. and this is where is started getting hard. You have to program them over the air, and you have 100ms to respond to the started command.

Ciseco XBBO board for LLAP devices

That’s great for security, but I don’t type that fast 🙂 Which is why I use this script to do that job.

 

Fairground roundabout and another sound recordist at Ipswich Maritime Festival

I was making a binaural recording of this fairground roundabout when another sound recordist arrived to get a clip from the ride itself – he asked the proprietor if it was okay at the beginning of the clip.

The actual fairground organ is a recording played out of speakers either side of the organ facade. The giveaway, apart from no moving parts, was when the operator fiddled with the volume control 😉

fellow sound recordist on fairground ride

OK kids, knock it off before you end up in Casualty

An exasperated mother has to take a big kid and a little kid to task after Dad pushes his child’s scooter too fast. Overheard on the way to the Ipswich Beer festival by the docks.

Borough Market, London

Borough Market is under the arches leading in to London Bridge Station, and this trader was hawking snacks and decent fast food, like wild boar sausages and hare. I couldn’t work out what the heck he was calling out when I was there and I still can’t work out what his exhortation is.

At  the beginning of the track there is the shrill call of starlings. I was chuffed, because something really bad has happened to London’s birdlife over the last thirty years, as many once common birds are common no more. There used to be thousands of starlings in London, there was an enormous roost at Charing Cross station decades ago.

Most tragically, the humble house sparrow seems to have surrendered the fight. As a child growing up in London they were everywhere, in the parks you could sometimes see some old boy feeding hundreds, in the ways tourists feed the sparrows outside Notre Dame in Paris.You’d walk past the hedges in suburban London and be chided with the peremptory chirp of a house sparrow. No more – in the last three decades the chirp has fallen silent as the cockney sparrows have abandoned the city. Central London is now pretty much a bird-free zone apart for the ubiquitous pigeon.

Starlings have also abandoned the city, so it was a treat to hear their call. Perhaps these have worked their way up the river, for Borough market is near the river at London Bridge.

 

Going beyond field recording

Nikita from soundtrip has a great mini-series of articles on the philosophy of sound recording different cities and locations. He goes beyond field recording, putting together his recording shot with a 10 minute mini-programme in mind. I’ve listed his four articles here as some of the links end up in Russian

  1. soundtrips – reasons, aims, ways
  2. practice of silence
  3. Sounds around
  4. creating a soundtrip

I’ve never done any combined recordings. I’ve attempted to be an observer, nether adding or taking away, with only editing and volume control, the equivalent of foundview in photography. That’s largely because I don’t feel I currently have any talent for that side of things. Nikita’s posts gave me some pointers. Like the point about not using an ipod but listening to the word around you.

I have a short commute so I don’t do that, indeed I don’t have an iPod, or listen to music on the move after getting off a plane and firing up my MD player with some music on. It was horrifying to hear how loud it was set to overcome the sound of the engines.

You have to be more careful as you get older to minimise loud sounds, because the middle ear loses the ability to tighten the eardrum using the tensor muscle and to separate the stirrup from the oval window via the stapedial muscle, so a valuable automatic gain control mechanism becomes less effective at reducing the transmission of loud sounds to the inner ear.

So I’ve managed to avoid the isolation due to music, perhaps more by luck than judgement.

I may get the opportunity to do more recording in a few months, and perhaps I need to move beyond the limitations of my thinking about the recording process.

Another landmark article was Des Coulam’s concept of the sound map when making recordings

  1. soundlandscapes’ street recording tips
  2. soundlandscapes on the concept of the sound map

These are my favourite articles about the art and vision of field recording. I’m generally okay on the technical stuff, but it’s the art of field recording that I haven’t yet got right, and these made me think. It’s easy for some people writing about sounds to go all luvvie and float off into fluffy clouds of art-school speak, it’s good to avoid that and get real ideas from real people out there doing it!

 

New Year 2012 Felixstowe Ship Horns

Even in Ipswich you get to hear the boat horns sounding on New Year’s day, so this time I went to Shotley Peninsula, between the large container port at Felixstowe and another port at Harwich to record the ship horns sounding the New Year in.

A nice touch was the Shotley residents have a sense of timing. Unlike in Ipswich, where people start releasing fireworks all the time as soon as it gets dark, in Shotley (and Felixstowe and Harwich by the looks of it) they wait for the New Year. In the foreground are the sounds of some Shotley residents celebrating at the pub, but it is the ship foghorns that make this for me.

Note the fireworks are quite loud after the horns 🙂