Domotic Arduino

by robertodelle in Circuits > Arduino

14307 Views, 33 Favorites, 0 Comments

Domotic Arduino

DSC02126.JPG
DSC02128.JPG
DSC02129.JPG
DSC02132.JPG
DSC02135.JPG
DSC02136.JPG
DSC02137.JPG
DSC02143.JPG
DSC02146.JPG
DSC02148.JPG
In this introduction I will show you a overview of this project whit Arduino Uno.  The purpose of this instructable is move a electric roller shutter by Arduino Uno. The prototype that I made is my first electronic project with Arduino and I hope this instructable and the solutions that I found are useful for your own Arduino's and electronic's projects. My aim was to transform a simple electric roller shutter in a domotic roller shutter; also, a possible development, could be a complex domotic system for a house: a central microcontroller (another Arduino) that control all electric roller shutters connectet to it whit the possibility to create for example some scenes. This project is limited only to realize a prototype and after so many years I wanted to return to build electronic circuits.




Feutures:
- Move the roller shutter when push the button
- Stop the roller shutter when it is completely open or closed 
- Stop the roller shutter when push the button up while it's moving down
- Stop the roller shutter when push the button down while it's moving up

Operation principle
Arduino counts the holes on the roller shutter with the infrared receiver; the infrared diode is positioned on the other side of the roller shutter. When the hole is aligned with them, Arduino increment or decrement a counter to determinate the position of the roller shutter. To connect the actuators and the sensor to Arduino I used two LAN cables (see last step)

Scheme

Scheme1.jpeg
ArduinoUnoFront.jpg
TSOP1138.png
To draw the scheme I used  Dia program. It is very simple to learn, avalaible for Linux and Windows (also portable), and freeware. You can download it here dia-installer.de/download/index.html. The ne555 is configured as an astable multivibrator to generate a square wave wtih 38khertz frequency for the infrared diode. The infrared receiver is TSOP1138 with internal filter for 38 khertz frequency and the demodulated output signal can be directly connected to a microprocessor. For best safety of arduino I connected the two arduino's output to two optoisolators (but this is not primary). Finally I made two actuators by two old 14v relays and few old components such as two 2N1711 transistors, two diodes and a 12v power supply.

Downloads

Software

sketch.png

I hope comments are exhaustive:

// costants:
const int sm = 2; // moviment sensor
const int buttonPin_t3 = 5; // button up
const int buttonPin_t2 = 4; // button down
const int ledPin = 13; // LED for check buttons
const int d1 = 11; // motor UP
const int d0 = 12; // motor DOWN

// variables
int ContatoreSensoreMovimento = 0; // counter move sensor
int Contatore_t3_t2 = 0;
int RegistroOutputd1 = 0;
int RegistroOutputd0 = 0;

// variables sm:
int State_sm = 0; // state
int lastState_sm = 0; // last state
// variabili t3:
int buttonState_t3 = 0; // state
int lastButtonState_t3 = 0; // last state
// variabili t2:
int buttonState_t2 = 0; // state
int lastButtonState_t2 = 0; // last state

void setup() {
// initialization input pin:
pinMode(sm, INPUT);
pinMode(buttonPin_t2, INPUT);
pinMode(buttonPin_t3, INPUT);
// initialization output pin:
pinMode(d1, OUTPUT);
pinMode(d0, OUTPUT);
pinMode(ledPin, OUTPUT);
// iinitialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// sm
// read pin:
State_sm = digitalRead(sm);
// compare the buttonState to its previous state
if (State_sm != lastState_sm) {
// if the state has changed, increment the counter
if (State_sm == LOW) {
// if the current state is LOW then
// wend from off to on:
if (RegistroOutputd1 == 1) {
ContatoreSensoreMovimento++;

}
if (RegistroOutputd0 == 1) {
ContatoreSensoreMovimento--;

}


Serial.println("on_sm");
Serial.print("ContatoreSensoreMovimento: ");
Serial.println(ContatoreSensoreMovimento, DEC);
}
else {
// wend from off to on:
Serial.println("off_sm");
}
}
// save the current state as the last state
// for next time through the loop
lastState_sm = State_sm;

if (ContatoreSensoreMovimento % 4 == 0) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}

// t3
// read pin:
buttonState_t3 = digitalRead(buttonPin_t3);
// compare the buttonState to its previous state
if (buttonState_t3 != lastButtonState_t3) {
// if the current state is HIGH then:
if (buttonState_t3 == HIGH) {
// if counter is <1:
if (Contatore_t3_t2 < 1) {
// increment the counter
// wend from off to on:
Contatore_t3_t2++;
Serial.println("on_t3");
Serial.print("Contatore_t3_t2: ");
Serial.println(Contatore_t3_t2, DEC);
}
}
else {
// if the current state is LOW then
// wend from on to off
Serial.println("off_t3");
}
}
// save the current state as the last state
// for next time through the loop
lastButtonState_t3 = buttonState_t3;
//valore massimo contatore 1

// t2
// lettura del pin:
buttonState_t2 = digitalRead(buttonPin_t2);
// compare the buttonState to its previous state
if (buttonState_t2 != lastButtonState_t2) {
// if the current state is HIGH then:
if (buttonState_t2 == HIGH) {
// if counter is >-1:
if (Contatore_t3_t2 > -1) {
// increment the counter
// wend from off to on:
Contatore_t3_t2--;
Serial.println("on_t2");
Serial.print("Contatore_t3_t2: ");
Serial.println(Contatore_t3_t2, DEC);
}
}
else {
// if the current state is LOW then
// wend from on to off:
Serial.println("off_t2");
}
}
// save the current state as the last state
// for next time through the loop
lastButtonState_t2 = buttonState_t2;

if (ContatoreSensoreMovimento < 35 && Contatore_t3_t2 == 1) {
digitalWrite (d1, HIGH);
RegistroOutputd1 = 1;
}
else {
digitalWrite (d1, LOW);
RegistroOutputd1 = 0;
if (ContatoreSensoreMovimento == 35 && Contatore_t3_t2 == 1) {
Contatore_t3_t2 = 0;
}
}
if (ContatoreSensoreMovimento > 0 && Contatore_t3_t2 == -1) {
digitalWrite (d0, HIGH);
RegistroOutputd0 = 1;
}
else {
digitalWrite (d0, LOW);
RegistroOutputd0 = 0;
if (ContatoreSensoreMovimento == 0 && Contatore_t3_t2 == -1) {
Contatore_t3_t2 = 0;
}
}
}

Final

DSC02162.JPG
DSC02152.JPG
DSC02133.JPG
DSC02171.JPG
DSC02170.JPG
DSC02169.JPG
DSC02168.JPG
DSC02167.JPG
DSC02163.JPG
DSC02139.JPG
DSC02245.JPG
DSC02246.JPG
DSC02247.JPG
DSC02248.JPG
DSC02249.JPG
DSC02251.JPG
DSC02252.JPG
DSC02253.JPG
DSC02254.JPG
DSC02255.JPG
DSC02256.JPG
DSC02257.JPG
DSC02258.JPG
DSC02259.JPG
DSC02260.JPG
DSC02261.JPG
DSC02262.JPG
DSC02266.JPG
In this step I show you the other photos of this project for a best explanation.