Home automation in the mill
I set out to create a three-wheeled robot that once the charge depleted went to recharge using the kit but given me during the tests because of my mistake is going to smash falling down stairs.
It was almost time to the end of the contest … and now what? … The kit I had it and I want to use it … mumble … mumble … idea !!! … I have a very rough wooden ones kit of a mill … almost … almost as I improve, I give him an attractive appearance and make it home automation …
In practice manage lighting, alarms, the power given me kit …
And here’s what it came out to be as you can see from the image.
In the image on the left is the mill improved aesthetically and equipped with:
1- micromotor that drives the mill wheel.
2 – Buzzer generating the alarm
3 – LED lights that simulate the various environments of the mill.
On the right is the container of the electronic part that handles everything.
Place on top of it is the control panel in I2C bus that allows you to enter the password to access the various commands and home automation.
Top box is always on the voltmeter that allows to control the voltage generated from the kit.
As a first step I wanted to control the change of the output voltage to vary from the input one, to test the stability under load of the kit.
I must say from what you can see from immmagini is extremely stable.
Input 3,6V output 0V
Input 4,7V output 5,2V
Input 5,8V output 5,2V
Input 6,6V output 5,2V
The entire system is managed by an Arduino one I2C interfaced to a panel for the LCD and the keyboard using only two data lines Arduino.
All of course powered by kir wireless power.
The voltmeter has been added to display the behavior of the wireless kit under load especially when you activate the alarm buzzer or the motor that mouovere the mill wheel.
Even under load the kit performs very well.
To drive the motor of the mill I have chosen to use a normally open relay connected to a pair of rechargeable batteries making the most realistic simulation.
The LEDs that simulate the mill lights are connected to the digital outputs of Arduino mediente resistors 220 hom.
To make the connections I used a pair of mini breadoard.
In the movie below it is simulated the attempt several times to force entry with obvious sound alarm activation and bright.
Reset the alarm condition occurs after 6 seconi and then reappears on the LCD the rchiesata the four-digit code.
Once the correct code is entered the operating menu is active.
commands are entered at this point:
1 – turn on the input, 2 – turn it off
3 – turns on the interior, 4 – turns it off
5 – switch on the front of the mill, 6 – turns it off
7 – starts the engine of the mill wheel, 8 – turns it off.
9 – closes the Management menu.
The movie that follows simulates the night.
https://www.youtube.com/watch?v=QoUneQHH-E8
https://youtu.be/gflC2txN0iY
It follows the management source of the whole.
#include <bv4242.h>
#include <Wire.h>
// Simple door entry system as an example; just
// informs user of entering correct key code
// 1,2,3,4 in any order
// **** kept as simple as possible, no error checking
// 7 bit adddress is used, address of pad, address of LCD
BV4242 ui(0x3d);
int stato = 0;
int tt;
void setup()
{
// ui.lcd_contrast(45); // 3V3 contrast
ui.lcd_contrast(25); // 5V contrast
ui.bl(20) ;
ui.clear(); // display
ui.lcd_mode(1); // dual ht
ui.print(“HOME AUTOMATION IN THE MILL”);
delay(1500);
ui.lcd_mode(0); // single ht
/*************************
set output
*/
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
};
void menu()
{
ui.clrBuf(); // keypad buffer
ui.clear(); // display
ui.print(” Door Code “);
ui.setCursor(7, 2);
ui.print(“****”);
ui.setCursor(7, 2);
ui.cursor(); // turn on cursor
}
void menuBS()
{
// ui.clrBuf(); // keypad buffer
// ui.clear(); // display
/***********************
Entrance
stairs
lounge area
external
mill
alarm
*/
ui.setCursor(1, 1);
ui.print(“1=ml-2=en-3=st”);
ui.setCursor(1, 2);
ui.print(“4=ex-5=l.a-6=st”);
// ui.print(“****”);
// ui.setCursor(1, 1);
// ui.cursor(); // turn on cursor
}
// Gets 4 numbers and displays as entered, key 7 will
// clear the display
int get4()
{
char k, count = 4;
int rv = 0;
while (count) {
k = ui.key();
if (k != 0) {
if (k == 6 || k == 7) { // clear
menu();
rv = 0;
count = 4;
} else {
ui.write(‘0’ + k);
count–;
rv += k;
}
}
delay(10); // too many i2c will swamp display
}
return rv;
}
int getM()
{
char k;
// ui.clrBuf();
int count;
count = 99;
while (count) {
k = ui.key();
if (k != 0) {
ui.setCursor(1, 1);
ui.write(‘0’ + k);
//if(k==7) ui.clear(); // clear display key
// else ui.write(k);
ui.setCursor(16, 2);
ui.cursor();
ui.write(k);
if (k == 1) {
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
}
if (k == 2) {
digitalWrite(2, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
if (k == 3) {
digitalWrite(3, HIGH);
digitalWrite(11, HIGH);
}
if (k == 4) {
digitalWrite(3, LOW);
digitalWrite(11, LOW);
}
if (k == 5) {
digitalWrite(9, HIGH);
digitalWrite(4, HIGH);
}
if (k == 6) {
digitalWrite(9, HIGH);
digitalWrite(4, HIGH);
}
if (k == 7) {
digitalWrite(7, HIGH);
}
if (k == 8) {
digitalWrite(7, LOW);
}
if (k == 9) {
return;
}
}
}
delay(200);
delay(10); // too many i2c will swamp display
return 0;
}
void loop()
{
char k, open = 0;
int j;
int l;
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
delay(6900);
digitalWrite(2, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
if (stato == 0) {
menu();
j = get4();
ui.setCursor(1, 2);
if (j == 10) {
ui.print(” Door – Open “);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
stato = 1;
} else {
ui.print(“<key code wrong>”);
for (l = 0; l < 4; l++) {
tone(8, 440);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(300);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(100);
tone(8, 220);
delay(1000);
noTone(8);
stato = 0;
}
}
delay(3000);
} else {
ui.clrBuf();
for (l = 2; l < 10; l++) {
digitalWrite(l, LOW);
// delay(5000);
}
menuBS();
tt = getM();
}
}