Garden lights and antitheft control with Arduino via Bluetooth

The idea was born a few days ago, I was a guest of a friend in his new villa with pool (lucky him!).
While we were strolling around the garden, we receive a call from another friend who tells us that for a few minutes was out of the gate with another large group of people (we were waiting for a while) who tried in every way (bell and trumpeted the horn) to “notify” their presence.
Once open the gate each of the newcomers has proposed a solution to replicate the sound of the bell, who has proposed to install a siren, who to include strobe lights like a disco and I proposed to replicate the bell, and maybe even open the gate on the computer.
At this point the owner, with an ironic tone, he asked me if I could do better and that the circuit have to be able to control the lights in the garden and irrigation system and check the status of microwave sensors installed to protect the garden.
After returning home I started thinking about how to resolve the issue.

I decided to design a software to run on PC that communicates via Bluetooth with a unit built around the Arduino and interfaced to the main power panel.
This led to the project “Automation Garden”.

Of course I designed the software and firmware for Arduino, although perfectly functional, but should be optimized, for lack of time (August 31 is the deadline for submissions), I send it anyway.
Let me explain briefly how it works:
the PC software communicates via Bluetooth (of course the PC must be equipped with built-in Bluetooth or USB) with another Bluetooth/RS232 HandyWave module connected to Arduino using the UART serial lines available on the pins 0 (RX) and 1 (TX).
To interface Arduino to the electrical panel I used some relay, and for interfacing it to alarm bells I used a circuit with optocouplers to avoid possible problems of shocks and surges that could destroy the Arduino.
I drew the schematic, but due to time constraints, I decided to temporarily mount it all on protoboard.

(Click Image to enlarge)

Before you start the software “Automazione_Giardino” on the PC, we associate, using the appropriate utility on the PC, the PC with the Bluetooth module mounted on the Arduino.
Once paired the Bluetooth and start the software, just select the checkbox associated to Bluetooth serial port and press the “Connect” button in the lower (see the location of these controls in the picture).
At this point, just click on the icon of the light bulbs to activated or deactivated the corresponding relay on the interface connected to the Arduino.
For the gate relay I planned pulse operation. Each time you press the icon associated with the relay opening the gate closes for 1s and then reopen.
To notify the alarm or intervention, even when the software is minimized, I provided a window that opens automatically when the event occurs and overrides any other application open on the PC.
Then just click on it to close.
The firmware installed on the Arduino does nothing more than to receive incoming commands on the serial port, interpret, active o deactive the relay and re-send the new state of the outputs or inputs. As mentioned previously the firmware should be optimized and maybe insert a checksum on the serial communication routines. But it works anyway.
You can use any other Bluetooth module perhaps with TTL output. Using a module with TTL output can eliminate RS232/TTL converter (MAX232 and boundary components) added to interface Arduino with Bluetooth HandyWave.
For those who haven’t a Bluetooth transmitter and want to try the circuit can without problems use Arduino connected via USB to the PC on which you installed the software and select the COM port assigned to the serial of Arduino.

Main Parts:



C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
C11
C12
C13
 
100nF
100uF
0,33uF
0,33uF
0,33uF
100nF
47uF
0,33uF
0,33uF
1uF
1uF
100nF
100nF
 
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
 
1N4007
4,8V
4,8V
1N4007
1N4007
LED
LED
LED
LED
LED
LED
 



J1
K1
K2
K3
K4
K5
K6
K7
K8
K9
K10
K11
K12
U1
U2
U3
U4
U5
 
DB9
RELAY_G5V-2
RELAY_G5V-2
RELAY_G5V-2
RELAY_G5V-2
RELAY_G5V-2
RELAY_G5V-2
CONN_3_V
CONN_3_V
CONN_3_V
CONN_3_V
CONN_3_V
CONN_3_V                                  
7805
PHDARL
PHDARL
MAX232
ULN2803A
 
P1
P2
P3
P4
P5
P6
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
 
CONN_6
CONN_8
CONN_2_V
CONN_8
CONN_2_V
CONN_2_V
10K
10K
270
270
470
470
300
300
300
300
300
300
 

Source Code:
// Sistema Di Automazione Giardino // Felice Pascarelli 2011 // fpascar@tiscali.it long ritardo =300; byte rxrs232; String ricezione = ""; String rele = "0"; String bufferrx = "0"; String uscite = "K"; String rel = "0"; String rel1 = "a"; String rel2 = "b"; String rel3 = "c"; String rel4 = "d"; String rel5 = "e"; String rel6 = "f"; String in1 = "2"; String in2 = "4"; void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, INPUT); pinMode(9, INPUT); pinMode(10, INPUT); pinMode(11, INPUT); pinMode(12, INPUT); Serial.begin(19200); } void loop() { if (Serial.available() > 0) ricevirs232(); ingressi(); delay(ritardo); if(rel == "1") { if (rele == "A") { rel1 = rele; digitalWrite(2, HIGH); } if (rele == "B") { rel2 = rele; digitalWrite(3, HIGH); } if (rele == "C") { rel3 = rele; digitalWrite(4, HIGH); } if (rele == "D") { rel4 = rele; digitalWrite(5, HIGH); } if (rele == "E") { rel5 = rele; digitalWrite(6, HIGH); } if (rele == "F") { rel6 = rele; digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); rel6 = "f"; } if (rele == "a") { rel1 = rele; digitalWrite(2, LOW); } if (rele == "b") { rel2 = rele; digitalWrite(3, LOW); } if (rele == "c") { rel3 = rele; digitalWrite(4, LOW); } if (rele == "d") { rel4 = rele; digitalWrite(5, LOW); } if (rele == "e") { rel5 = rele; digitalWrite(6, LOW); } if (rele == "f") { rel6 = rele; digitalWrite(7, LOW); } rel = "0"; } Serial.print(rel1);Serial.print(rel2);Serial.print(rel3);Serial.print(rel4); Serial.print(rel5);Serial.print(rel6);Serial.print(in1);Serial.print(in2); } void ingressi() { if (digitalRead(8) == 0) { in1 = "1"; } if (digitalRead(8) == 1) { in1 = "2"; } if (digitalRead(9) == 0) { in2 = "3"; } if (digitalRead(9) == 1) { in2 = "4"; } } void ricevirs232() { if (Serial.available() > 0) { rxrs232 = Serial.read(); if (isDigit(rxrs232)) { ricezione += (char)rxrs232; } if(rxrs232 =='A' || rxrs232 =='B'|| rxrs232 =='C'|| rxrs232 =='D'|| rxrs232 =='E'|| rxrs232 =='F' ||rxrs232 =='a'|| rxrs232 =='b'|| rxrs232 =='c'|| rxrs232 =='d'|| rxrs232 =='e'|| rxrs232 =='f') { rele = rxrs232,BYTE; rel = "1"; } } }
Download
Download ZIP File Software
 Download ZIP File Arduino sketch
 Download ZIP File PCB design (Kicad)
1 Comments
Disqus
Fb Comments
Comments :

1 comment: