Monday, 27 January 2014

Monitoring Data with the Arduino and ThingSpeak

In conjunction with my last post I thought I would monitor my hot water tank to track the temperature variations throughout the day, mainly to use the temp change to identify when someone has taken a shower and judge the need to heat the water up so there is some left for bed time (this will be done automatically by the Arduino code).

First I searched around for a free cloud data storage solution, I'd used Pachube/COSM previously but COSM had changed hands again and I found it was always a bit unreliable for me anyway.

I tried first of all but found it quite difficult to get the UNO working with the code on offer and the help information was a bit of a mismatch with sample code not being up-to date with the latest API, having said that the forum was well supported and I got quick answers to my questions.  The main problem is that when I got it working my data on the graph contained random values which made the chart useless, I thoroughly checked the values that I was posting and the spurious data was not coming from me.  One plus was that they had an Android app on the Appstore so viewing the data was easy.

I then tried ThingSpeak, getting the UNO/Ethernet shield up and running was a lot quicker and I was posting temperature values within minutes.  Another nice feature was the ability to clear the current data from the channel, ideal when logging data during development that's not relevant to you actual job.

The chart looks nice, updates continuously and if you hover over the points a nice panel pops up with the data point details.

I've only just scratched the surface of ThingSpeak so there's still loads of stuff I just don't know about but it definitely enabled me to get up and running very quickly.  One thing missing from ThingSpeak was a dedicated Android App but after a couple of hours with App inventor I was able to put together a usable App that lets me view the data whilst out and about (sad I know).
It is also possible to embed the charts into other web pages using an Iframe.
There are plugins that can be created, there is a sample of a Google gauge but I still can't get it to work.  The forum doesn't seem to be as well supported as the one on nimbits, maybe there are less users.

The App inventor source can be found here. (updated to appinventor 2, import the aia file to app inventor 2)
The APK file can be downloaded here.
After running just type in your channel number and read key and click "set" and then "update"

Tuesday, 21 January 2014

Central heating control using SMS and the Arduino

One of the things I set out to do after discovering the world of Arduino was to make myself a clever controller for my central heating but, not unusually for me, my focus wandered here and there finding new and probably easier things do do with all these little gadjets.

I got back into air rifles which meant most of the blog, over the last few months, has been full of my various versions of a chronograph! I've tried loads of different displays and even Bluetooth to get the speed of the pellet to my phone.

Anyway, the weather turned cold again and thoughts drifted toward the central heating again but this time something a bit simpler, something to switch the heating or water on for a period of time without leaving the comfort of my arm chair.... yes I'm that lazy.

I'd dabbled with the 868MHz RF links, Bluetooth links but after coming across a post on I found a source for a cheap GSM modem.

My original thoughts were to bow to the latest fashion of "IoT" but my dealings so far with the Arduino and Ethernet interfaces had been less than perfect, quite randomly the data flow would just stop and I never got to the bottom of it.  The SMS solution appealed because I don't need a data connection or even a smartphone and can switch the heating on before I get home even if the raspberry pi and the arduino etc. are switched off when I'm on holiday.  The SMS route seemed like a good solid proven technology.

The Modem was an ex-equipment modem from some old BT security line monitoring equipment (search "redcare GSM" on Ebay) and I picked up mine for £4 including delivery, not too expensive, the SIM card was an old Giffgaff card from a previous phone which still had few quid in credit and my contract phone had unlimited texts ... so I thought I would give it a go.

The overall system laid out on the desk
The modem came with an external antenna and the 2x50 header still attached to the PCB which was quite lucky because the connector is a 1.27mm pitch IDC on a ribbon cable, to get connections to the modem I used a hot air gun to sweat off the SMD connector from the PCB.

I made the connections to a standard pitch connector so I could interface to the rest of the system, the pins are very small and it wasn't easy.

The idea was to connect the the relays in parallel to the existing relays in the controller so that the current timer based operations would continue but I could switch on the heating or water remotely.  The relays would be switched by the Arduino Mini Pro via a soft serial connection from the modem, there was also an I2C OLED status display and a remote temperature sensor for the hot water tank.  Initially the temp sensor would just monitor the water temp and be sent to the phone on request but I intend to use it later to give a finer control to the water temp (I might log temp to and SD card for a while to get an idea of usage).

The SMS control takes the form of a simple short message coded for heat or water and a duration, heat on for an hour would be H60 whereas heat for 2 hours would be H120 ... I said it was simple. Hot water just uses a "W" instead of a "H".  There is also the function to request the temperature of the water, this causes the Arduino to send an SMS containing the temperature of the water.

The control is done by an App on my Android phone but could be done just as easily by sending a text normally or there are some automation apps that would allow a pre-defined text message to be sent from an icon on your home screen.  Actually I suppose you could control your central heating system from within an app such as Tasker, Tasker would allow you to setup timed text messages to carry out the operation, this would only make sense if you get free text messages though.

The Arduino code checks the incoming phone number to make sure it matches the one(s) you allow to control the heating and the response to the hot water temp request is sent back to the requestor's phone.

I'm also thinking of connecting in to my alarm system to send out an SMS when it gets triggered.
That's all for now, I'll post a link to the Arduino code and the Android app in the next post.

There's plenty of technical information on the modem and links to a SMS messaging library on nathan's blog post here.

Please feel free to ask any questions or make suggestions in the comments below.

Hot water control using a Raspberry Pi Zero W

Following on from the first blog about the hot water heating control here's what I put together for the mounting. Whilst looking for a...

Popular Posts