Showing posts with label automation. Show all posts
Showing posts with label automation. Show all posts
19 April 2016
Open the blinds in your home with the voice with Arduino and Alexa

Components
- Servo
- Servo Horn
- laser cut gears
- Arduino uno
- Servo controll shield
The left gear and ended up being ranked higher in the white hat was seen to fit the gear, so little by little I was able to break off pieces. Not pretty, but it works.
Assembled servo horn
Here loaded gears servos. These horns are not so great - the offset screw attachment is a bit funky. But they are inexpensive, come in a pack of 5, shipped via Amazon Prime (most important).

This is what blind situation was before doing any modification.

The horizontal rod in this picture only rotate 180 degrees, but a connection to a vertical rod is geared. So if you turn the vertical rod, it takes like 8-10 full turn to do the same as an 180 degree turn of the horizontal rod.

The first step is the removal of the rod. This will allow the perpendicular rod to rotate freely, without resistance. We do not need anyway, once the system is controlled by voice / phone.

Removing the plastic interface between the vertical and horizontal bars

Now that the horizontal rod is free to rotate, now is the time to install the gear on the shaft

Here is a photo of the (now ugly) gear shaft. Oh well.

Here the servo is fully installed and held in place with some small pieces of the acrylic double tape end face on the inner face

His is what the whole mechanism seems that with the blinds installed backup window. The servo that stands out is very convenient because it makes it easier for us to open the blinds manually if the power goes out or the internet is down.

Here it is the Arduino used to control blinds. I wanted to be connected to other intelligent devices in my house, so I used a smart thing Arduino shield. Welding is not pretty but does the job.

Although the bottom of the screen is not very clean, the top is quite neat. The way you configure it supports three servos (one for each of my main curtains in the living room).

Here the Arduino is fed through the outlet, and each of the three blondes (and servos) is connected to the shield

Blinds "in" (I know, it seems odd to speak of blinds regarding "on" and "off" instead of open and closed, but that's just the way it is for now.
PROGRAMMABLE THERMOSTAT WITH ARDUINO
What I'm about to describe is a thicker design of the previous year. The idea came analyzing the consumption related to heating my house. Unfortunately, the thermostat is currently installed does not allow a change of time in fiction temperature of the day and night, also fear that the probe does not acquire a very precise temperature, for this reason, consumption is higher than necessary. So I decided to build one, which allows to automatically vary the temperature for the day and the night, and that indicates the temperature and humidity of the room in a precise manner.


the following components are required:
- an Arduino UNO
- an RTC I2C module
- a relay module
- a humidity and temperature sensor DHT11
- a 16 × 2 LCD compatible with the library LiquidCrystal
- a 10K trimmer for LCD contrast
- a potentiometer with Ring 10K
- an RGB LED
- resistance from 330 ohms to the LED
- one shield proto SparkFun
- a container for electronic projects (the one that you like, compatible with the size of the cards and display)
- jumper cables
and the following libraries:
Connections to the LCD module is for information only, connect it according to the model you choose, as described in the library.
The thermostat will only interface to the user via the potentiometer dial, the display, and the RGB LED. For this reason, it is necessary to leave the accessible USB port of the Arduino also closed container module, to allow the RTC module programming and updating of the code.
The only user-editable variable is the daily temperature; the LED indicates by GREEN light when the heating is on, and through the RED off the same. The night temperature is the intervention zone are set through code; the operation hysteresis is always set by 1 ° C code. To schedule the time in the RTC module is required uncomment the section in the code.
Source code
*/
#include “Arduino.h”
#include “Wire.h”
#include "DS1307.h"
#include "LiquidCrystal.h"
#include "idDHT11.h"
int relay = 4;
int pot_pin = 1;
int red_led = 5;
int green_led = 3;
int lcd_bkl = 13;
float act_temp = 0.0;
float set_temp = 15.0;
int hum = 0;
int last_time = 0;
int hys = 1;
int night_temp = 17;
int prev_temp = 0;
int prev_time = 0;
int delay_set = 5;
byte degree[8] = {
B01000,
B10100,
B01000,
B00011,
B00100,
B00100,
B00011,
};
//INITS
LiquidCrystal lcd(12, 11, 10, 7, 8, 9, 6); //LCD
init
int idDHT11pin = 2;
//Digital pin for comunications DHT11
int idDHT11intNumber = 0;
//interrupt number (must be the one that use the previus defined pin (see
table above) DHT11
void dht11_wrapper(); //
must be declared before the lib initialization
idDHT11 DHT11(idDHT11pin,idDHT11intNumber,dht11_wrapper);
DS1307 clock;
//define a object of DS1307 class
void setup()
{
Serial.begin(9600);
pinMode(relay, OUTPUT);
pinMode(green_led, OUTPUT);
pinMode(red_led, OUTPUT);
pinMode(lcd_bkl, OUTPUT);
clock.begin();
lcd.createChar(0, degree);
/* *******************SET DATE-TIME******************
clock.fillByYMD(2013,11,20);//Jan 19,2013
clock.fillByHMS(02,03,00);//15:28 30"
clock.fillDayOfWeek(TUE);//Saturday
clock.setTime();//write time to the RTC chip
// ****************************************************/
lcd.begin(16, 2); // start the LCD library
lcd.setCursor(0,0); // set cursor to 0 pos
}
void dht11_wrapper() //necessary to initialize the idDHT11 library
{
DHT11.isrCallback();
}
void stop_pump() //turn off the relay and set the LED to RED
{
digitalWrite(relay, 0);
analogWrite(red_led, 255);
analogWrite(green_led, 0);
}
void start_pump() //turn on the relay and set the LED to GREEN
{
digitalWrite(relay, 1);
analogWrite(red_led, 0);
analogWrite(green_led, 255);
}
void print_LCD() //Print status on 16x2 LCD display
{ //line0
lcd.setCursor(0,0);
lcd.print(act_temp, 0);
lcd.setCursor(2,0);
lcd.write(byte(0));
lcd.setCursor(4,0);
lcd.print("|");
lcd.setCursor(5,0);
if(clock.hour < 10) // print 0 before hour < 10
{
lcd.print("0");
lcd.setCursor(6,0);
lcd.print(clock.hour, DEC);
} else (
lcd.print(clock.hour, DEC));
lcd.setCursor(7,0);
lcd.print(":");
lcd.setCursor(8,0);
if(clock.minute < 10) // print 0 before minutes < 10
{
lcd.print("0");
lcd.setCursor(9,0);
lcd.print(clock.minute, DEC);
} else (
lcd.print(clock.minute, DEC));
lcd.setCursor(10,0);
lcd.print("|");
lcd.setCursor(12,0);
lcd.setCursor(12,1);
lcd.print(set_temp, 1);
//line1
lcd.setCursor(2,1);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print(DHT11.getHumidity(), 0);
lcd.setCursor(4,1);
lcd.print("|");
lcd.setCursor(5,1);
lcd.print(clock.dayOfMonth, DEC);
lcd.setCursor(7,1);
lcd.print("/");
lcd.setCursor(8,1);
lcd.print(clock.month, DEC);
lcd.setCursor(10,1);
lcd.print("|");
lcd.setCursor(12,1);
lcd.print(set_temp, 1);
lcd.setCursor(4,0);
}
void DHT11_acquiring() // get informations from DHT11 sensor
{
DHT11.acquire();
while (DHT11.acquiring());
int result = DHT11.getStatus();
switch (result)
{
case IDDHTLIB_OK:
Serial.println("OK");
break;
case IDDHTLIB_ERROR_CHECKSUM:
Serial.println("Error\n\r\tChecksum error");
break;
case IDDHTLIB_ERROR_ISR_TIMEOUT:
Serial.println("Error\n\r\tISR Time out error");
break;
case IDDHTLIB_ERROR_RESPONSE_TIMEOUT:
Serial.println("Error\n\r\tResponse time out error");
break;
case IDDHTLIB_ERROR_DATA_TIMEOUT:
Serial.println("Error\n\r\tData time out error");
break;
case IDDHTLIB_ERROR_ACQUIRING:
Serial.println("Error\n\r\tAcquiring");
break;
case IDDHTLIB_ERROR_DELTA:
Serial.println("Error\n\r\tDelta time to small");
break;
case IDDHTLIB_ERROR_NOTSTARTED:
Serial.println("Error\n\r\tNot started");
break;
default:
Serial.println("Unknown error");
break;
}
}
int day_time() //set the value according to day - hour
{
int x = (clock.hour);
if(x > 6 && x < 23)
return 1; //if daytime set 1
else
return 2; //if nighttime set 2
}
int seconds_elapsed()
{
int elapsed_secs = 0;
if(prev_time > clock.second) //necessary to work with
60 base count
{ elapsed_secs =
(
60-prev_time)+clock.second;
}
else
{ elapsed_secs =
clock.second -
prev_time;
}
return elapsed_secs;
}
int minutes_elapsed()
{
int elapsed_mins = 0;
if(last_time > clock.minute) //necessary to work
with 60 base count
{ elapsed_mins =
(
60-last_time)+clock.minute;
}
else
{ elapsed_mins =
clock.minute - last_time;
}
return elapsed_mins;
}
void loop()
{
int x = 0;
bool change_temp = 0;
//get temp and date-time
DHT11_acquiring();
act_temp = (DHT11.getCelsius());
clock.getTime();
//Read pot pin
x = analogRead(pot_pin);
x = map(x, 0, 1023, 15, 45);
//if temp is set to the minumum turn off the control and backlight
if (x == 15)
{ stop_pump();
print_LCD();
lcd.setCursor(11,0);
lcd.print("-OFF-");
digitalWrite(lcd_bkl, 0);
goto stop;
}
//5 seconds after the last set turn off backlight
if(seconds_elapsed() >= delay_set)
digitalWrite(lcd_bkl, 0);
//if the potentiometer is turn set a new target temp and turn on backlight
if(x != prev_temp)
{ digitalWrite(lcd_bkl, 1);
prev_time = (clock.second);
change_temp = 1;
delay(100);
}
//if is daytime set the target temp by the potentiometer
if (day_time() == 1)
{ set_temp =
(((x+15)*10)/2)/10.00; // set temperature by
potentiometer in 0.5°C
lcd.setCursor(11,0);
lcd.print(" set");
lcd.setCursor(15,0);
lcd.write(byte(0));
}
//else if is night time set the temp to night_temp value
else if (day_time() == 2)
{ set_temp =
night_temp;
lcd.setCursor(11,0);
lcd.print("sleep");
}
//if delay_time is past turn on the temp control
if (minutes_elapsed() >= delay_set || change_temp == 1)
{ if (
act_temp <
(
set_temp -
hys)) //if room is cold turn on the
heater
{ start_pump();
last_time = (clock.minute);
}
else //else if room is warm keep off the heater
{ stop_pump();
last_time = (clock.minute);
}
change_temp = 0;
}
// print SET on LCD, set prev_temp value
print_LCD();
prev_temp = x;
delay(100);
stop:
delay(500);
}
The thermostat is working well, I can be satisfied. Definitely improved in various aspects, perhaps with a future integration for control via LAN or WiFi, but for now does what little he should do.
Subscribe to:
Posts
(
Atom
)





