Showing posts with label I2C display. Show all posts
Showing posts with label I2C display. Show all posts

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 nathan.chantrell.net 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.

Saturday, 26 October 2013

Updated wide.HK OLED 1602 Library

Thanks to Nathan from http://nathan.chantrell.net/ there is now a scrolling function in the Library.

This allows you to specify some text, the line to display it on and the speed to scroll it at.

Sample code by Nathan (modified by me to remove the scrollString function as it's now in the library).

/*
Scrolling demo on the OLED 1602 display from Wide.HK.
Uses Library by Phil Grant http://www.gadjet.co.uk
Scrolling by Nathan Chantrell http://nathan.chantrell.net
*/

#include  "Wire.h"
#include  "OLedI2C.h" // http://www.gadjetsblog.blogspot.co.uk/2013/09/oled-1602-display-and-library-for.html

OLedI2C LCD;

void setup() {
Wire.begin();
LCD.init();
LCD.clearLcd();
}

void loop() {
scrollString("Slowly scrolling text on line one...",0,200);
scrollString("and faster on line two...",1,100);
}


Download here: Updated OLED 1602 Library

Now on GitHub

Sunday, 29 September 2013

OLED 1602 Display and library for the SSD1311

Following on from the last post, the OLED 2 line 16 character display arrived from Hong Kong.




The display uses I2C to connect to the host and will work at 3.3 or 5V so is ideal to use with an Arduino board.

The supplier WIDE.HK supplies some sample code to get it running in the form of a QR code on the packaging that links to the the code and a couple of PDF datasheets.

The code uses a long winded method to initialise and write to the display, but it gets it working.

I have been thinking it was about time I learned how to create a library and this gave me the reason to give it a go, as well as not being able to find a library for this device anywhere on the web.

The very basic Library can be downloaded here, please remember this is my first attempt at creating a library, it works but I imagine it needs more functions adding before it becomes very useful.

Library updated 7/11/13 see here.

Here is the demo code I wrote using the library: -
/*
Demo sketch to display text on the OLED 1602 display
from Wide.HK. This uses a Lbrary that I've put together
containing some basic functions.
The I2C Address is set to 0x3C in OLedI2C.cpp
Phil Grant 2013 www.gadjet.co.uk

Sketch updated to work with new library 7/11/13
*/
#include  "Wire.h"    
#include  "OLedI2C.h"  
OLedI2C LCD;
void setup()
{
  Wire.begin();
  LCD.init();  
}
void loop()
{
  //Set cursor position to col and row, top row is 0, first col is 0
  // no longer required LCD.cursPos(4,0); //(col,row)
  LCD.sendString("Gadjet's", 4, 0);    //("String", col, row)
  // no longer required LCD.cursPos(6,1); //Set cursor position to col and row 
  LCD.sendString("BLOG", 6, 1);   //("String", col, row)
  while(1);
}

As usual, feedback welcomed, use the comments if you found this library useful ...... or not.


Testing LoRA transmitters and receivers

I've wanted to have a play with 868MHz LoRA transmitters for some time now but never got around to it until,  a while ago, I did an hard...

Popular Posts