The latest arrivals

So my new parts have turned up!

6 x PIR sensors
6 x temperature sensors
6 x light sensors
1 x Patch shield
1 x Polaroid Android tablet

I’ll start making up a demo system for proof of concept of what I’m trying to do and once that’s complete I’ll then go live! :)

New Arduino

My new Arduino turned up last night, along with the PoE module I ordered. Seems there is a new revision out.

20121007-004506.jpg

The older one is on the left, as you can see the colour has changed, just not sure what else has!

New Parts

Well I’ve made some nice purchases in the past few days, pretty much to complete the monitoring side of my system. I’ve bought PIR motion sensors, temperature and light sensors. I’ve also bought a bolt on module for the Arduino, this allows me to use network cable to connect my sensors to the arduino without too much issue.

I thought about using network cable and wondered if it was possible, even posted on the arduino.cc forums (which was met with the usual we can’t give generic answers we must have exact model numbers of your sensors) – all I asked was it a valid experiment. Well when mooching around on the Internet it seems someone has already done that experiment and created a saleable product.

I’m waiting on my parts turning up, as soon as they do I will be putting up the full list online with photos, I will then start the real work and getting the system up and running.

Oh I almost forgot…..I also bought a 7″ tablet running android to give the house an interface to the system. I will be writing an android app which I will be releasing the source code for in due time.

Oct 3, 2012 - General    No Comments

Getting in Contact

I write this blog not as something to shout about but something to keep me entertained and as you can tell from the lack of updates I didn’t need entertaining. To my surprise I received an email from the contact form on the website from someone who received the exact same error and my resolution fixed their problem.

What transpired is a thought, do people actually find my blog with the lack of content? If they do, are they disappointed with the content? Is there more I can add apart from my own updates on the project which is quite slow (more coming soon with more parts bought!!).

So if you want something covered in a tutorial, a review of a part or something completely random……I’m open to suggestions so please use the contact form on the website, rest assured it goes to an active mailbox :)

Jun 24, 2012 - General    No Comments

Latest Code

Notice: Undefined index: HTTP_64 in /var/www/vhosts/begerk.co.uk/httpdocs/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1947

Well I thought I’d do some programming on the Arduino this weekend to find that my source code is sat at work so I’ve rewritten it and put it through it’s testing by passing over 10,000 values to my website in very quick succession without fault.

 

#include <SPI.h>
#include <Ethernet.h>
 
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,150);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
 
 
 
EthernetClient client;
int totalCount = 0;
int loopCount = 0;
int inChar;
 
void setup() {
  Serial.begin(9600);
 
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
 
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  delay(2000);
  Serial.println("Ready");
}
 
void loop()
{
  client.connect("website.co.uk", 80);
  if(analogRead(5) > 750)
  {
    if (client.connected())
    {
      int reading = analogRead(0);  
 
      float voltage = reading * 5.0;
      voltage /= 1024.0;
 
      float temperatureC = (voltage - 0.5) * 100 ;
      char ascii[32];
      int temp1 = (temperatureC - (int)temperatureC) * 100;
      sprintf(ascii,"%0d.%d", (int)temperatureC, temp1);
      client.println("GET /webpage.php?elec=1&temp=" + String(ascii) +" HTTP/1.1\r\nHost: website.co.uk\r\n");
      totalCount++;
 
 
      Serial.println(temperatureC);
      Serial.println(analogRead(5));
 
      Serial.println(totalCount,DEC);
      while(client.available())
      {
        inChar = client.read();
        Serial.write(inChar);
      }
    }
    else
    {
      Serial.println("Client has failed");
      Serial.println(totalCount,DEC);
      client.connect("website.co.uk", 80);
    }
  }   
 client.stop(); 
}
Jun 21, 2012 - Energy Monitoring    No Comments

A Recap of the Project

Well as per the previous post, the 2 week mark has been and gone with nothing done due to lack of time! At the end of this month I’m going to take a holiday to get some stuff done.

Stage 1 of the project is to do monitoring of the house, during this phase I feel we should not change any of our habits to get a true representation of how we do things around the house. The idea overall is to save money and you may suggest that we should change as soon as possible, my view is without all of this I’d still be doing the same thing so why should a month matter?

Stage 1 will consist of the following:

  • Monitoring electricity usage – As you should be able to see I’m well on my way to having this up and running, it’s just a matter of finding the time to get it finished and logging data.
  • Monitoring the temperature outside – As part of the electricity usage monitoring, I’ll also be monitoring the temperature. The reason why I am doing these at the same time is due to my meter being located outside in a sheltered area which means the sensor will not be adversely affected by the sun shine or strong winds etc.
  • Monitoring the temperature inside – I’ve chosen that this will be done in the same location as my current thermostat, someone designed my house and chose that this was the optimal location for checking the temperature…..I hope! Plus this location is a run of about a meter of cable to the same Arduino being used above.
  • Monitoring the lights in each room – This one I’m going to struggle without actually monitoring the switches themselves, I first thought about using just light sensors however the light outside would affect the reading, as a test I may run the cabling into the light shades and block all light apart from a pin hole to the sensor, with the light on this may give me a high enough reading to determine that the light is on rather than it being a sunny day. An easy test for this is to have a halogen light shining on the light shade from the window.
  • Monitoring movement in each room – This will be done with PIR sensors, as we do not have pets I have no concern about ignoring certain movements.
  • Monitoring the weather from a trusted source – I’ll be using this for future predictions
  • Monitoring the usage of devices  plugged into sockets – I’d like to know what’s running in the house to generate my electricity usage.
All the above will be logged to a MySQL database which will have a script performing the logging functions. The data will be validated within the script to confirm the data is within the agreed limits based on certain parameters and it’s a valid source. I’ll also be doing calculations on costs etc for electricity.
Storing all this data will allow me to have some ability to predict bills, both for past and future weeks. For example weather websites give forecasts, based on previous data I’ll know what temperature it was in my house when it was 12 degrees outside and how much electricity I used in that day, so any future days I can predict I’ll use a similar amount.
Stage 2 will bring together that I’ve learnt during stage 1 and tweak where necessary, maybe implement anything new I’ve thought about or others have raised as good ideas.
Stage 3 will look into automation of the house, such as turning lights on and off where required. Controlling the central heating based on temperatures etc.
Jun 5, 2012 - General, Home Automation    No Comments

A Quick Update

This is just a very quick update to the progress of the project. I’ve put in the networking to reach from my loft (attic for the US) down to the electricity meter – stupidly I did this on one of the hottest days the UK has had so I was pouring with sweat and itchy as hell from the insulation!

My Arduino code has been tested with random data and I successfully posted 18,802 random values from my test bed and this was running around every 24 seconds for 5 days straight without issue so it appears my connection issues have finally gone!

Personal time has been very limited due to my work commitments resulting in less time with my family, which meant I couldn’t do much work on this, I reckon I’ve have the live graphs running in about 2 weeks time and I’ll be moving onto the next stage of the project which is tracking the movements in my house – which in turn will be used to control the lights.

May 19, 2012 - General    Comments Off

Failure Again

Notice: Undefined index: HTTP_64 in /var/www/vhosts/begerk.co.uk/httpdocs/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1947

It seems that even though the Arduino lasted longer (longer than I continued to check the website) reporting, it failed again. After some Googling I seem to have found the problem. The Wiznet chip only supports 4 concurrent connections.

My code is simply doing a loop, if the connection is not connected then create a connection. I think I’m hitting this 4 connection limit. I’ll be adding a new line at the bottom of my code.

client.disconnect();

I think this will resolve the issue but I need to confirm that this will work as expected.

May 18, 2012 - General    Comments Off

ser_send(): write error: sorry no info avail

As part of my testing I’ve hit the error within the Arduino when trying to upload a sketch.

I’ve found that this issue was caused by not connecting my Arduino directly to a USB port on the motherboard of my PC. My PC monitor has a USB hub built into it which I connected to, removing this out of the equation and going direct to the motherboard resolved the issue.

May 18, 2012 - Energy Monitoring    Comments Off

And dead…..not permanently

Notice: Undefined index: HTTP_64 in /var/www/vhosts/begerk.co.uk/httpdocs/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1947

It seems my coding had a slight issue in the fact I was not constantly checking to make sure the Arduino was connected to the website. I’d create the connection and simply leave it and constantly try write to the database. This morning I got up to find that my graph had very little data in it.

I’ve now implemented a check to see if the connection is true, if it is then write to the database, if not then connect and then write to the database.

 

Below is the current code:

#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;
 
byte mac[] = { (byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF,(byte)  0xFE, (byte) 0xED };
EthernetClient client;
 
void setup()
{
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
delay(1000); //Give ethernet time to connect
client.connect("mywebsite.com", 80);
delay(1000);
}
 
void loop()
{
if (client.connected() == false) {
Serial.println("Connection lost - trying to reestablish");
client.connect("mywebsite.com", 80);
delay(1000);
}
int reading = analogRead(0);
 
float voltage = reading * 5.0;
voltage /= 1024.0;
 
float temperatureC = (voltage - 0.5) * 100 ;
char ascii[32];
int temp1 = (temperatureC - (int)temperatureC) * 100;
sprintf(ascii,"%0d.%d", (int)temperatureC, temp1);
Serial.println("Writing to the database");
client.println("GET /mypage?elec=0&amp;temp=" + String(ascii) + " HTTP/1.1\r\nHost: mywebsite.com\r\n\r\n");
delay(10000);
}
Pages:12»