How to use the OpenKontrolGateway for Data Logging

The obvious place to look is this post, OpenKontrol Gateway as Data Logger from openmicros.org, which has some sample code, which didn’t work for me. It created the log file but didn’t write any data to it.

I hacked this to make it write the data

unixtime,day/month/year hour:minutes:seconds, LLAPmessage
1352219944,6/11/2012,16:39:4,ECTMPA7.866
1352219992,6/11/2012,16:39:52,EATMPA21.59
1352220052,6/11/2012,16:40:52,EBTMPA20.82

It’s also a bit more tricky to use, compared to a regular data logger. This is because the RF network is unsynchronised – the temperature nodes fire themselves up every 5 minutes, transmit a temperature reading and then go to sleep. This isn’t a polled system, and there may be other transactions on the network. The data logger simply logs all of these transactions, be they temperature readings, status readings or setting up devices – anything starting with an a is logged.

This is why I added the unix timestamp, so that it would be possible to plot these unsynchronised elements onto the same xy plot, with the timestamp along the x axis. Some data might want to be sampled more frequently than every 5 minutes, and some might be reactive, like a PIR sensor.

The receiving application has to pull all this stuff apart, first splitting the streams into the devices, using LEFT(LLAPmessage,3). This will always be aXY with XY being the deviceID

 

Modified program shown below

Continue reading “How to use the OpenKontrolGateway for Data Logging”

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.

 

Minidisc hacking

I used a Hi-MD to trawl for the Robin’s first song of the year. Set it off at 9pm, recording from the mic. Trouble is that it split the file into one group with a bazillion tracks – about 1500. Must have tripped a new track each time the audio dipped below the meter indication and came back. This isn’t useful. There must be a way to can that other than editing all the marks out. I’d really like to not do that again.

Set me thinking to how to record the Wolves Wood sounds later in the year. What’s needed is a remote timed start. Could set all the controls to manually record and pause, then hit the go button on the remote using a timer/alarm clock module etc. Let’s see what’s inside the remote.

MD remote innards
MD remote innards

The worst part is the plug, which is not only Sony proprietary and nonstandard. The pitch of the pins isn’t on a 0.1” grid.

MD remote plug - nothing is standard here
MD remote plug – nothing is standard here

That’s just what you don’t need. Having said that, a stick remote sucks without display, and LCD remotes are on Ebay for about £23. So I could stump up for a remote upgrade and get this one to donate it’s plug to the cause.

Other than that this is a pretty straightforward resistive ladder job – the play/pause button is a 330 ohm resistor across two of the pins. The resistor values used in Sony Minidisc remotesare documented hereWhat I need now is an alarm clock module but Maplin doesn’t seem to do them anymore. Which could be loads of pain using a PIC. Or maybe a 4017 clocked in with a 4060 set to output one hour intervals. On second thoughts the James-Bond-esqueness of the PIC and LED display might be too much to resist 🙂