22 feb 2015

"Smart" solar water heater - My first Arduino project


Short time ago a friend of mine gave me an Arduino board, a sort of tunable programmer that can suit your needs, relatively low cost and backed up with a community of passionate makers. Electronics for newbies. So this small electronic board came to make my spare time busy. In this video I stand marveled at the stat of the art:



So I decided to try to make reality a basic and simple idea that had been arrounf my head long ago. As it is by everyone well known, a water pipe left to the sun, spetially when black, do tent to heat up the water contained in them, up to temperatures that can burn the skin (when intense radiation conditions are achieved).

The idea would be to actually know when it is suitable to recirculate water from a heat accumulator, know when the pipe would be full of hot water, and know when we can pour cold water to be heated.


For such porpoise was needed:


- Water tank. Better if isolated, but for testing porpoises I wanted it to be with no pressure, that is open air deposit.



- Pipe, better if black, and accessories.


- A water recirculation pump. I am using my good old electric pump that so much weater has been moving around. It fears more staying still (thus rusty) that being operative.


- Two temperature sensor  (I did not get pictures right) and a Relay.


- And nevertheless our Arduino board, wires  -notice I have used conventional network cable RJ45 that allow you to take sensors and relay "just where you need them", and a protoboard usually used to this kind of experiments

Physic connection goes, more or less, as follows:

- Temperature sensors: Both sensors have 5 V line input (the one bringing electricity), an information pin that will be connected to an analog input in order to measure analog readings, and a ground pin that "closes" the electrical flow.

- The Relay: Relay is basicly the same, except that signal will be connected to a digital pin as we will only need to deal with either if is on or off. In my situation relay is normally open (NO). On the other side of it we connect a conventional switch installation governed by the relay. Please excuse there are no pictures but once in its place it was quite hard to make such.

Remark here that I used conventional RJ45 network wire to place the sensors and relay where I needed them to be, and observed to be a simple and effective solution.

And after the code to be loaded in our Arduino board. I simply copypasted code found in references, and last lines "simply came to my mind"... It was very easy to do what I had in mind. Now is on testing stage, to see what it can do, and iI can tune it up. This is that:

//......................................................................
// SOLAR THERMAL ENERGY FOR ALL (S.T.E.F.A. V_0.01)
//......................................................................
// this code allows to activate a relay according to a temperature differential
// the role of this program is to operate a reculation water pumpel
// only when heating conditions are optimal
//......................................................................
int sensorPin1 = 0;
int sensorPin2 = 1;
int Relay = 8;
// we activate both temperature sensor and relay

void setup()
// this code only runs once
{
  Serial.begin(9600);
  // activates "Monitor Serial" in our computer
 
  pinMode(Relay, OUTPUT);
  // defines relay on or off
 
  Serial.println("More sun, more water. Less sun, less water.");
}

void loop()
// this code goes over and over...
{

Serial.println(".....................................");

//......................................................................
// TEMPERATURE SENSOR 1
//......................................................................
int reading1 = analogRead(sensorPin1);
// gets the reading

float voltage1 = reading1 * 5.0;
voltage1 /= 1024.0;
// calculates voltage output

float temperatureC1 = (voltage1 - 0.5) * 100;
// calculates temperature from voltage

Serial.print(temperatureC1); Serial.println(" C degrees...... tank sensor...");
// prints temperature from sensor 1

//......................................................................
// TEMPERATURE SENSOR 2
//......................................................................
int reading2 = analogRead(sensorPin2);
// gets the reading

float voltage2 = reading2 * 5.0;
voltage2 /= 1024.0;
// calculates voltage output

float temperatureC2 = (voltage2 - 0.5) * 100;
// calculates temperature from voltage

Serial.print(temperatureC2); Serial.println(" C degrees ...... pipe sensor");
// prints temperature from sensor 2

//......................................................................
// TEMPERATURE DIFFERENTIAL
//......................................................................
float diferencialT = temperatureC1 - temperatureC2;
// calculates temperature differential

Serial.print(diferencialT); Serial.println(" grados C diferencial temperatura");
// prints temperature differential

//......................................................................
// RELAY CONTROL
//......................................................................
if( temperatureC2 < temperatureC1 + 05.00 )
// Establishes activation on differential temperature. 05.00 is 5 Celsius degrees.
// Tune this value to suit your needs
{
  digitalWrite(Relay, HIGH);
// Activates relay (normally open), thus deactivates circulation
}

else if( temperatureC1 < temperatureC2 +- 99.00 )
//in case wire connexion is lost
{
  digitalWrite(Relay, HIGH);
// thus will not activate on error read.
}

else
{
  digitalWrite(Relay, LOW);
  Serial.println("........WATER RECIRCULATING........");
// makes relay off, Since NO activates electricity flow
// and thus moves water

}

delay(8220);
// waiting time between reading and action

}


//......................................................................
//......................................................................
// Luis Rodriguez Alonso. February 2015. habitainer@gmail.com
// http://habican.blogspot.com.es/
// published under GNU GENERAL PUBLIC LICENSE
// https://gnu.org/licenses/gpl-3.0.en.html
// this document has been made up with information and code from:
// http://descargas.cetronic.es/TMP36.pdf
// http://tech.yeesiang.com/control-real-devices-using-relay/
// http://arduino.cc/en/pmwiki.php?n=Reference/Else
//......................................................................
//......................................................................


And, could not be otherwise, a small 3D capture of water tank and pipe:


20 feb 2015

Colector solar para agua caliente "inteligente" - Mi primer proyecto de Arduino


Hace poco tiempo un amigo me regaló una placa de Arduino, una especie de programador tuneable para tus intereses, de relativo bajo coste, y con una comunidad de usuarios y apasionados de lo mas variopinta. Electrónica para profanos. Y así vino esta maravillosa plaquita a ocupar mi tiempo de recreo. En este vídeo aparezco maravillado ante el estado de la técnica:



Así pues decidí animarme a hacer realidad una simple idea que tenía desde hacía ya tiempo rondando la cabeza. Como es por todos conocido, las mangueras al sol, especialmente las negras, tienden a calentar el agua que contienen hasta temperaturas que incluso queman al tacto (en los días de intensa radiación solar directa).

El caso sería entonces saber cuando es bueno recircular el agua de un termo o acumulador de calor, cuando la manguera está llena de agua caliente, y cuando podemos poner mas de la fría a calentar.

Para ello fue necesario:

- Bidón de agua. Mejor un termo, pero para esta prueba de depósito sin presión (un termo eléctrico convencional tiene siempre presión de abasto. Estoy por verlo)


- Manguera, preferiblemente negra, y accesorios.


- Una bomba para recircular el agua. En mi caso utilicé la vieja bomba que tanta agua a movido en estos últimos años, a la cual le da mas miedo estar parada (porque se oxida y tranca) que estar activa.


- Dos sensores de temperatura (no saqué fotos pues no se veían bien) y un relé.


- y nuestra plaquita de Arduino, cables para empatar -observa que el cable de red convencional permite alejar los sensores y el relé "hasta donde necesites"-, y una protoboard de esas que se estilan para este tipo de cacharreo.

La conexión física es, mas o menos, como sigue:

- Los sensores de temperatura: Los dos sensores tienen una toma de 5V (la linea que lleva electricidad), un pin de información, que conectamos en este caso cada uno a una entrada analógica, ya que necesitaremos para poder medir cosas como la temperatura, y otro pin que se llama Ground y que es por donde "vuelve" la electricidad.

- El "Relay": El relé es esencialmente lo mismo, solo que la señal la conectamos a una entrada digital pues tan solo necesitamos saber si estará encendido o apagado. En mi caso esta normalmente abierto (NO). Por el otro lado del relé conectaremos una instalación normal de interruptor, pero disponiendo el propio relé. Disculpen que no hay fotos clara pero los cables estaban un poco liados ya en su sitio.

Comentar que empleé cable RJ45 o el llamado "de red" para alejar de la placa el relé y los sensores, que necesitaba quedaran "afuera", y me pareció una solución simple y efectiva para tal fin.

Y luego el código a cargar en nuestra placa de arduino. Simplemente copie y pegué el código que encontré en las referencias, y las últimas lineas "se me ocurrieron solas"... Es bastante sencillo pero consigue hacer lo que tenía en la cabeza. Ahora lo tengo en "periodo de pruebas", a ver que tal lo hace, y si lo puedo afinar. Ahí queda eso:

//......................................................................
// SOLAR THERMAL ENERGY FOR ALL (S.T.E.F.A. V_0.01)
//......................................................................
// este código permite activar un relé según un determinado diferencial de temperatura
// el objeto de este programa es poder activar una bomba de recirculación de agua
// tan solo cuando las condiciones de calentamiento solar sean óptimas
//......................................................................
int sensorPin1 = 0;
int sensorPin2 = 1;
int Relay = 8;
// activamos los dos sensores de temperatura y el relé

void setup()
// este código corre solo una vez
{
  Serial.begin(9600);
  // activa "Monitor Serial" en nuestra computadora
 
  pinMode(Relay, OUTPUT);
  // define activar-desactivar el relé
 
  Serial.println("Mas Sol, mas agua. Menos sol, menos agua.");
}

void loop()
// este código comienza una y otra vez en bucle
{

Serial.println(".....................................");

//......................................................................
// SENSOR TEMPERATURA 1
//......................................................................
int reading1 = analogRead(sensorPin1);
// obtiene la lectura

float voltage1 = reading1 * 5.0;
voltage1 /= 1024.0;
// calcula el voltaje de salida

float temperatureC1 = (voltage1 - 0.5) * 100;
// calcula la temperatura desde el voltaje

Serial.print(temperatureC1); Serial.println(" grados C ...... sensor bidon...");
// imprime la temperatura del sensor 1

//......................................................................
// SENSOR TEMPERATURA 2
//......................................................................
int reading2 = analogRead(sensorPin2);
// obtiene la lectura

float voltage2 = reading2 * 5.0;
voltage2 /= 1024.0;
// calcular el voltaje de salida

float temperatureC2 = (voltage2 - 0.5) * 100;
// calcula la temperatura desde el voltaje

Serial.print(temperatureC2); Serial.println(" grados C ...... sensor manguera");
// imprime la temperatura del sensor 2

//......................................................................
// DIFERENCIAL DE TEMPERATURA
//......................................................................
float diferencialT = temperatureC1 - temperatureC2;
// calcula el diferencial de temperatura

Serial.print(diferencialT); Serial.println(" grados C diferencial temperatura");
// imprime el diferencial de temperatura

//......................................................................
// CONTROL DEL RELÉ
//......................................................................
if( temperatureC2 < temperatureC1 + 05.00 )
// Define el diferencial de temperatura. 05.00 corresponde a 5 grados centígrados.
// Modifica este valor para adaptarlo a tus necesidades
{
  digitalWrite(Relay, HIGH);
// activa el relé (que esta normalmente abierto), desactiva la recirculación.
}

else if( temperatureC1 < temperatureC2 +- 99.00 )
//si por algo pierde la lectura del sensor,
{
  digitalWrite(Relay, HIGH);
// así no se activa por error.
}

else
{
  digitalWrite(Relay, LOW);
  Serial.println("........RECIRCULANDO AGUA........");
// desactiva el relé. Funciona a la inversa ya que
// el relé esta en NO (normalmente abierto), pues activa la bomba y mueve agua.

}

delay(8220);
// tiempo de espera entre lecturas y acción.

}


//......................................................................
//......................................................................
// Luis Rodriguez Alonso. Febrero 2015. habitainer@gmail.com
// http://habican.blogspot.com.es/
// publicado bajo GNU GENERAL PUBLIC LICENSE
// https://gnu.org/licenses/gpl-3.0.en.html
// documento realizado con información y código modificado desde:
// http://descargas.cetronic.es/TMP36.pdf
// http://tech.yeesiang.com/control-real-devices-using-relay/
// http://arduino.cc/en/pmwiki.php?n=Reference/Else
//......................................................................
//......................................................................


Y como no, la captura en 3D del bochinche: