Saturday, November 1, 2008

What you can not measure you can not control

Or, what you did not measure you cannot evaluate, the latest being my own adaptation of the quote. So, as I mentioned in the last post, I am in the process of insulating the attic. Yes, it is still not finished. It is a lot of work and dirty work as well, as it involves crawling in the floor to unaccessible corners to staple the stuff.
I am using a material called Xlmat which is a reflective barrier together with standard wool insulation. it is 3cm thick and composed of 17 layers of materials - reflective layers, plastics and wool. Although as far as I understood you cannot really give a R value to a reflective barrier, I think I read somewhere that this material is equivalent to a material with R=6 (SI).
Meanwhile I have been doing some logging of the temperatures inside and outside the attic - see previous post - so that, as the title indicates, I can control and evaluate the effectiveness of the insulation.
After having the logging on and off for some time, it happened that things were not always working fine, with the contacts and strange values were being read. So I decided to add a display to see what was going on. So I bough a one line, 16 characters LCD and plugged it to the Arduino. Here is my current setup.


AH! almost forgot: plugged the wires for the in and outside lm35 wrong, so in is out and out is in :)

It appears that the display has some particularities, which I will elaborate upon in the next posts. I'll post a graphic with the results soon...but I think there are so many factors in play that I might not be able to conclude anything...While I was preparing this post, I came across this other quote:

"measure what is measurable, make measurable what is not: - Galileo

Sunday, October 26, 2008

Standalone temperature logger with Arduino


As I mentioned in the previous post, I am in the process of insulating the attic. Of course, that couldn't go without some sort of measurement to check the effect of said insulation. Therefore, I decided to check the temperature delta from the inside of the attic to the outside before applying the stuff, and after.
So yesterday I finally decided to connect an LM35 to an arduino board, and get it to log the temperatures. Of course, I needed 2 LM35 connected to it. Luckily, I had 2 around, from Joao (sorry for the lack of the tilde), and one of them was even already on a long lead, this from my initial attempts at reading temperature with the computer - Joao then built a parallel port temperature sensor interface.
I built the circuit in the figure using the arduino. The diode is to enable the setup to read negative temperatures, which was not yet necessary, but will be soon.
Since I didn't want to have a computer running all the time just for that I made the arduino store the values into the EPROM. There are 512 bytes in the EPROM, so, for 2 sensors I could have 256 measurements. I decided to get a measurement every 30 minutes, which would allow the setup to run for about 5 days before running out of place in the memory.
To read the contents of the EPROM, I had initially thought of having a switch which would indicate the mode to run in - log or report - , but went for the easier solution of dumping all the contents of the EPROM upon starting the arduino.

So, yesterday I placed the thing in the attic, tried to get the long sensor outside, didn't quite managed, but it was pretty close to be out in the cold.

This morning I couldn't resist: went to get it, downloaded the data and plotted it in Excel. I get a constant 2 degrees difference between the inside and the outside, which I think is very small, might explain why the house gets cold so quickly.

Here is the arduino code. It is not clean nor pretty, but seams to do the job:





/*
* temperature logger
*
* reads and logs 2 temperature sensors to the EPROM
*

*/
#include

int refPin = 1; // select the input pin for the potentiometer
int potPin = 2; // select the input pin for the potentiometer
int potPin2 = 3; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor
int ref;
int out;
int val2 = 0; // variable to store the value coming from the sensor
int out2;

int avout, avin;
int addr = 0;
int index = 0;
int outtemps[10];
int intemps[10];

int ledPin = 13; // LED connected to digital pin 13
int value = LOW; // previous value of the LED
long previousMillis = 0; // will store last time LED was updated
long logpreviousMillis = 0; // will store last time LED was updated
long interval = 1000; // interval at which to blink (milliseconds)
long loginterval = 1800000; // interval at which to log (milliseconds)

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);

Serial.println("ready to dump! data every 30 minutes");
Serial.println("address \t out \t in");

for (int in = 0; in<256; in++)
{

value = EEPROM.read(in*2);

Serial.print(in);
Serial.print("\t");
Serial.print(value, DEC);
Serial.print("\t");
value = EEPROM.read(in*2 + 1);
Serial.print(value, DEC);
Serial.println();

}


}

void loop() {
ref = analogRead(refPin); // read the value from the sensor
val = analogRead(potPin); // read the value from the sensor
val = val - ref;
out=val*500/1023;
val2 = analogRead(potPin2); // read the value from the sensor
val2 = val2 - ref;
out2=val2*500/1023;

outtemps[index] = out;
intemps[index] = out2;
index++;
if (index == 10)
{
index = 0;
}

delay(100);

// check to see if it's time to blink the LED; that is, is the difference
// between the current time and last time we blinked the LED bigger than
// the interval at which we want to blink the LED.
if (millis() - previousMillis > interval) {
previousMillis = millis(); // remember the last time we blinked the LED

// if the LED is off turn it on and vice-versa.
if (value == LOW)
value = HIGH;
else
value = LOW;

digitalWrite(ledPin, value);
}

//log the temperatures to the eprom
if (millis() - logpreviousMillis > loginterval) {
logpreviousMillis = millis(); // remember the last time we blinked the LED

avout = 0;
avin = 0;
for (int aa = 0; aa<10 ; aa++)
{
avout += outtemps[aa];
avin += intemps[aa];
}
avout = avout/10;
avin = avin/10;


EEPROM.write(addr*2, avout);
EEPROM.write(addr*2+1, avin);
addr = addr + 1;
if (addr == 256)
addr = 0;

Serial.print(avout);
Serial.print(" - ");
Serial.println(avin);

// if the LED is off turn it on and vice-versa.
if (value == LOW)
value = HIGH;
else
value = LOW;

digitalWrite(ledPin, value);
}


}

Friday, October 24, 2008



Just got my yearly report from the utilities company, and once again managed to get some money back by saving energy! In the last 2 years I have reduced my energy consumption by about half! From almost 3500KWh in 2006 to a bit more than 1500KWh this year, and from almost 4000m3 of gas in 2006 to less than 2000m3 this year! You can see the graphics provided by the company that compare my consumption with that of the neighbors.

In terms of gas I am now at the same level as the neighbors, but most neighbors have smaller houses that I do...so I hope that that explains it...anyway, I am currently in the process of properly insulation the attic. More of that soon! Also in the plan is to acquire a new, more efficient boiler. I would like to get the consumption below the 1000m3/year.

In terms of electricity I don't really know what to do further to save electricity...

In the plans for this season is also to finally reuse rain water to flush the toilets. This year we spent about 90 liters of water per person per day. I would like to reduce that!

Monday, October 6, 2008

Hello again!

The door bell project is working in full swing! although not many people seem to ring it...next project: detect bangs from people using the door knock.

On another note, I got my wife a small tablet (wacom bamboo) and it is really nice! to celebrate, I decided to make a handmade schematic of my circuit to read the electricity meter. So here it is on the right. On the bottom is the LDR which has a value of about 20K ohm when in the dark and goes down to 200 or less in bright light. So I get the little LDR, which is about 3mm in diameter right in front of the blinking led on my new digital electric meter and every time it blinks the input of the arduino goes down, signaling one watthour having been consumed. The Arduino then communicates that to the computer which dumps the time into a database, from which I can then generate graphics and check consumption.
On the next post, and to try to improve my tablet skills, I'll describe the circuit used to read the gas meter.

Furthermore, I just got a new Arduino today, the Diecimila, ordered by Joao, so I'll try to get the thermometer and other environment variables going.

Wednesday, September 24, 2008

First ring!!


Finally someone rang the bell, besides me that is! Since I enabled the logging no one rang the bell, until today!

Yesterday I improved the web list of events to enable to remove the ones I have seen, so now each door bell ring appears as a link which, upon clicking is removed from the list. It does stay in the database (MySQL) and I will do a page to display the old ones.

The next step is the web cam taking pictures. I hacked a cheap web cam which couldn't handle the street - to bright - and the darkness, and turned it into a IR web cam, which works great at night with IR led illumination provided by a remote control. It still doesn't handle the street light that well, so I think I'll have 2 cameras: one visible for the day pictures, and an IR one for the nights...or I might try to find a decent web cam that can handle it all, and works with linux out of the box.


Update: Just finished getting the house to Twit, and report to twitter whenever anybody rings the bell! check it here! well, in fact it is not really real time, every hour it checks if anyone did and puts it to twitter, this because I switch the modems off whenever they are not in use. The script turn on the modems, reports to twitter and the modems get turned off again automatically after a few minutes.
As an extra it also reports to twitter if the electricity consumption was over 1Kwh in the last hour!

Monday, September 15, 2008

Computerized Door Bell

Link
Finally I managed to get the door bell to be connected to the computer!! and make a schematic from it! I used a arduino shield that a friend lent me to check the functioning and then made a small board using those prototyping boards! I'll upload a photo later on! I drew the schematic using http://draw.labs.autodesk.com/ADDraw/draw.html

It was difficult to find a nice tool to make a schematic using free software...
Now, each time someone rings my bell, an entry gets added to a database. Nothing else happens yet, but the plan is to get a ring tone (stereo!!), but I found out that the audio out of the server is not enough to make noise via a small un-amplified speaker, so I am now investigating the possibilities!

I hope the transistor is the correct one - the library at the site doesn't have that many!

Friday, August 29, 2008

Update


A long time has passed since that initial post...and indeed I managed to finalize the reading of the utility meters with an arduino connect to the home server.

I now have a real time graphic of each watt hour and each hundredst of cubic meter of gas used in the house. I did switch it off during the holidays, but the system was then synchronous with the numbers on the real meters. Enclosed is an image of the graphic for the last 24 hours of electricity usage.
When the winter comes and the gas starts burning, I hope that the gas graphic becomes more interesting. Now it only shows little bars when we take shower and cook.
I'll add the schematics soon.

Next step is to connect the doorbell to the server and broadcast to the network whenever someone rings, as well as taking a snapshot of course.