Automação Residencial Inteligente e Sistema de Segurança com 1Sheeld
Componentes Necessários
- 1x Arduino UNO
- 1x Placa 1Sheeld
- 1x Módulo Relé 4 Canais (ex.: YW Robot)
- 2x Buzzers
- 1x Sensor de Temperatura LM35DZ
- 1x Jumpers (fios de conexão)
- 1x Sensor PIR de Movimento
- 2x Interruptores Magnéticos de Porta (SparkFun)
- 1x Display LCD 16x2 (Adafruit, branco sobre azul)
Ferramentas Necessárias
- Cortadora a laser (para corte da estrutura)
Sobre o Projeto
Este projeto combina automação residencial e segurança usando o 1Sheeld, que transforma seu smartphone em mais de 40 shields Arduino diferentes. O sistema permite:
- Controlar lâmpadas da casa por comandos de voz ou SMS.
- Sistema de segurança: ao detectar abertura de portas (via interruptores magnéticos) com o modo segurança ativado, dispara alarme (buzzer) e envia e-mail de alerta.
- Monitoramento de temperatura: se a temperatura exceder 35°C (configurável), aciona buzzer e envia e-mail.
- Feedback por voz (Text-to-Speech) e display LCD.
- Comando de ativação "Jarvis" antes de qualquer comando de voz.
Funcionamento Resumido
O 1Sheeld comunica-se com o smartphone via Bluetooth. O aplicativo 1Sheeld no celular fornece shields de Reconhecimento de Voz, SMS, Texto-para-Fala, Relógio e E-mail. O Arduino processa os comandos e aciona relés, buzzers e sensores.
Montagem Física
- Corte a estrutura da caixa com a cortadora a laser (arquivo CAD fornecido).
- Instale os interruptores magnéticos nas portas (recepção e varanda/cozinha). Calibre para saber leitura aberta/fechada.
- Instale as lâmpadas em paralelo nas paredes.
- Conecte o sensor LM35DZ: VCC ao 5V, GND ao GND, OUT ao pino A0 do Arduino.
- Monte o relé de 4 canais para controlar as 4 lâmpadas (recepção, quarto, banheiro, cozinha).
- Conecte os buzzers: um para alarme de porta (pino A5), outro para alarme de temperatura (pino 10).
- Conecte o LCD nos pinos 2,3,4,5,6,7.
- Empilhe o 1Sheeld sobre o Arduino.
Configuração do 1Sheeld
- Empilhe o 1Sheeld no Arduino.
- Escreva o código usando a biblioteca OneSheeld.
- Carregue o código na IDE Arduino (baud 9600). Importante: Coloque a chave UART em "Uploading mode" antes de carregar.
- Após o upload, volte a chave para "Operating mode". Sem isso, não haverá comunicação entre 1Sheeld e Arduino.
- No smartphone, instale o app 1Sheeld, pareie via Bluetooth (código padrão 1234).
- Selecione os shields: SMS, Voice Recognition, Text To Speech, Clock, Email.
Código Principal
/* Smart Home Automation & Security System - Team SADEE */
#define CUSTOM_SETTINGS
#define INCLUDE_VOICE_RECOGNIZER_SHIELD
#define INCLUDE_TEXT_TO_SPEECH_SHIELD
#define INCLUDE_CLOCK_SHIELD
#define INCLUDE_SMS_SHIELD
#define INCLUDE_EMAIL_SHIELD
#include
#include
// Pinos dos relés (ativos em LOW)
#define receptionLamp A1
#define bedRoomLamp A2
#define pathRoomLamp A3
#define balaconyLamp A4
// Comandos de voz
const char mainCommand[] = "jarvis";
const char receptionCommandOn[] = "reception on";
const char receptionCommandOff[] = "reception off";
const char bedRoomCommandOn[] = "bedroom on";
const char bedRoomCommandOff[] = "bedroom off";
const char pathRoomCommandOn[] = "bathroom on";
const char pathRoomCommandOff[] = "bathroom off";
const char balaconyCommandOn[] = "kitchen on";
const char balaconyCommandOff[] = "kitchen off";
const char whatsUp[] = "good morning";
const char timeCommand[] = "what time is it";
const char securityModeOn[] = "security on";
const char securityModeOff[] = "security off";
// SMS
const char lightsOn[] = "on";
const char lightsOff[] = "off";
// Pinos sensores e buzzers
#define magneticReception 8
#define magneticBalacony 9
int buzzer1 = A5; // alarme porta
int buzzer2 = 10; // alarme temperatura
LiquidCrystal lcd(2,3,4,5,6,7);
byte smile[] = { B00000, B01001, B01001, B00000, B00000, B10001, B01110, B00000 };
int magneticReceptionState, magneticBalaconyState;
bool security = false;
byte state = 0; // controle de fluxo de comando de voz
String noon;
int hours, minutes;
char h[4], m[4];
void setup() {
noTone(buzzer1); noTone(buzzer2);
// Relés começam desligados (HIGH = desligado para relé ativo em LOW)
digitalWrite(receptionLamp, HIGH);
digitalWrite(bedRoomLamp, HIGH);
digitalWrite(pathRoomLamp, HIGH);
digitalWrite(balaconyLamp, HIGH);
lcd.begin(16,2);
OneSheeld.begin();
pinMode(receptionLamp, OUTPUT);
pinMode(bedRoomLamp, OUTPUT);
pinMode(pathRoomLamp, OUTPUT);
pinMode(balaconyLamp, OUTPUT);
pinMode(buzzer1, OUTPUT);
pinMode(buzzer2, OUTPUT);
pinMode(magneticReception, INPUT_PULLUP);
pinMode(magneticBalacony, INPUT_PULLUP);
lcd.createChar(0, smile);
lcd.clear();
lcd.print("Bem-vindo ao");
delay(2000);
lcd.clear();
lcd.print("Smart Home");
lcd.setCursor(0,1);
lcd.print("Automacao e");
delay(2000);
lcd.clear();
lcd.print("Sistema de");
lcd.setCursor(0,1);
lcd.print("Seguranca");
delay(2000);
lcd.clear();
lcd.print("CALIBRANDO...");
delay(10000);
security = false;
}
void loop() {
Clock.queryDateAndTime();
SMS.setOnSmsReceive(&MyFunction);
minutes = Clock.getMinutes();
hours = Clock.getHours();
if (hours > 12) { hours -= 12; noon = "PM"; } else { noon = "AM"; }
String strh = String(hours), strm = String(minutes);
strh.toCharArray(h,4); strm.toCharArray(m,4);
VoiceRecognition.start();
OneSheeld.delay(8000); // janela para comando de voz
if (VoiceRecognition.isNewCommandReceived()) {
if (!strcmp(mainCommand, VoiceRecognition.getLastCommand())) {
TextToSpeech.say("yes sir");
lcd.clear(); lcd.setCursor(8,0); lcd.write(byte(0));
state = 1;
}
// Comandos de lâmpadas (após "jarvis")
handleVoiceCommand(receptionCommandOn, "ok sir lamp in the reception is on", receptionLamp, LOW, "The Hall Lamp Is", "ON");
handleVoiceCommand(receptionCommandOff, "ok sir lamp in the reception is off", receptionLamp, HIGH, "The Hall Lamp Is", "OFF");
handleVoiceCommand(bedRoomCommandOn, "ok sir lamp in the bedroom is on", bedRoomLamp, LOW, "The Bedroom", "lamp Is: ON");
handleVoiceCommand(bedRoomCommandOff, "ok sir lamp in the bedroom is off", bedRoomLamp, HIGH, "The Bedroom", "lamp Is: OFF");
handleVoiceCommand(pathRoomCommandOn, "ok sir lamp in the bathroom is on", pathRoomLamp, LOW, "The Bathroom", "lamp Is: ON");
handleVoiceCommand(pathRoomCommandOff, "ok sir lamp in the bathroom is off", pathRoomLamp, HIGH, "The Bathroom", "lamp Is: OFF");
handleVoiceCommand(balaconyCommandOn, "ok sir lamp in the kitchen is on", balaconyLamp, LOW, "The Kitchen", "Lamp Is: ON");
handleVoiceCommand(balaconyCommandOff, "ok sir lamp in the kitchen is off", balaconyLamp, HIGH, "The Kitchen", "Lamp Is: OFF");
if (!strcmp(whatsUp, VoiceRecognition.getLastCommand()) && state==1) {
lcd.clear(); lcd.print("Good Morning :)"); lcd.setCursor(0,1); lcd.print("Its A Good Day");
TextToSpeech.say("good morning sir"); OneSheeld.delay(1500);
TextToSpeech.say("time in cairo is"); OneSheeld.delay(1500);
TextToSpeech.say(h); OneSheeld.delay(1000);
TextToSpeech.say(m); OneSheeld.delay(1000);
TextToSpeech.say(noon.c_str()); state=0;
}
else if (!strcmp(timeCommand, VoiceRecognition.getLastCommand()) && state==1) {
lcd.clear(); lcd.print("Time In Cairo Is"); lcd.setCursor(0,1);
lcd.print(h); lcd.print(":"); lcd.print(m); lcd.print(" "); lcd.print(noon);
TextToSpeech.say("time in cairo is"); OneSheeld.delay(1500);
TextToSpeech.say(h); OneSheeld.delay(1000);
TextToSpeech.say(m); OneSheeld.delay(1000);
TextToSpeech.say(noon.c_str()); state=0;
}
// Segurança
else if (!strcmp(securityModeOn, VoiceRecognition.getLastCommand()) && state==1) {
lcd.clear(); lcd.print("Ok,Sir Feel Safe"); lcd.setCursor(0,1); lcd.print("Security Mode");
TextToSpeech.say("security system was triggered"); security=true; state=0;
}
else if (!strcmp(securityModeOff, VoiceRecognition.getLastCommand()) && state==1) {
lcd.clear(); lcd.print("Ok,Sir Security"); lcd.setCursor(0,1); lcd.print("is OFF");
TextToSpeech.say("security system was turned off"); security=false; state=0;
}
}
// Sistema de segurança: monitora portas
magneticReceptionState = digitalRead(magneticReception);
magneticBalaconyState = digitalRead(magneticBalacony);
if (security) {
if (magneticReceptionState == HIGH || magneticBalaconyState == HIGH) {
tone(buzzer1, 1500);
Email.send("seu@email.com", "Home Security", "Alguem entrou na sua casa!");
OneSheeld.delay(3500);
} else { noTone(buzzer1); }
} else { noTone(buzzer1); }
// Temperatura (comentado no original; descomente e ajuste se usar)
/*
int voltage = analogRead(A0) * 1100 / 1024;
int degree = voltage / 10;
if (degree >= 35) {
tone(buzzer2,1500);
Email.send("seu@email.com","Home Security","Temperatura alta!");
OneSheeld.delay(5000);
} else { noTone(buzzer2); }
*/
}
// Função auxiliar para comandos de voz de lâmpadas
void handleVoiceCommand(const char* cmd, const char* speech, int pin, int val, const char* lcd1, const char* lcd2) {
if (!strcmp(cmd, VoiceRecognition.getLastCommand()) && state==1) {
TextToSpeech.say(speech); OneSheeld.delay(2500);
digitalWrite(pin, val);
lcd.clear(); lcd.print(lcd1); lcd.setCursor(0,1); lcd.print(lcd2);
state=0;
}
}
// Callback de SMS
void MyFunction(char* phoneNumber, char* messageBody) {
if (!strcmp(lightsOn, messageBody)) {
digitalWrite(receptionLamp,LOW); delay(500);
digitalWrite(pathRoomLamp,LOW); delay(500);
digitalWrite(bedRoomLamp,LOW); delay(500);
digitalWrite(balaconyLamp,LOW); delay(500);
TextToSpeech.say("all lights was turned on");
lcd.clear(); lcd.print("All Lights is ON");
Email.send("seu@email.com","Home Security","Todas luzes LIGADAS"); OneSheeld.delay(3500);
}
else if (!strcmp(lightsOff, messageBody)) {
digitalWrite(receptionLamp,HIGH); delay(500);
digitalWrite(pathRoomLamp,HIGH); delay(500);
digitalWrite(bedRoomLamp,HIGH); delay(500);
digitalWrite(balaconyLamp,HIGH); delay(500);
TextToSpeech.say("all lights was turned off");
lcd.clear(); lcd.print("All Lights Is OFF");
Email.send("seu@email.com","Home Security","Todas luzes DESLIGADAS"); OneSheeld.delay(3500);
}
}
Arquivos Adicionais
- CAD para corte a laser:
drawing_lasser_cutting_lvvsN9X9Xg.dwg - Esquemáticos: duas imagens de ligação (consulte o projeto original).
Observações Finais
- Substitua
seu@email.compelo seu e-mail real nas chamadasEmail.send(). - O código original continha alguns erros de digitação (ex.: "reception of" em vez de "reception off"); foram corrigidos acima.
- Certifique-se de que o smartphone tenha conexão de dados ativa para envio de e-mail/SMS via 1Sheeld.
- O projeto é educacional; para uso real, adicione proteções elétricas (optocopladores, fusíveis) nos relés de rede AC.
Processo de manufatura
- Como Tecnologia de Casa Inteligente Transforma Vida Cotidiana
- Silicon Labs Revela Soluções Wireless Gecko Avançadas para Smart Homes e Building Automation no Embedded World 2019
- Construa um Controlador Doméstico Inteligente 433 MHz com Sensorflare e Raspberry Pi
- Sistema de Segurança Residencial com Raspberry Pi: Detecção PIR + Alertas de Câmera por Email
- Sistema de Presença RFID Confiável com Arduino e Python
- Controle Remoto Universal Android com Arduino, 1Sheeld e IR
- Construa um Pote Inteligente IoT com ESP8266, Arduino e Sensor Ultrassônico – Monitoramento em Tempo Real
- Medição de Distância em Tempo Real com Sonar Arduino e Visualização no Processing
- Braço Robótico Inteligente Controlado por Arduino: Tutorial DIY Fácil
- Purificador de Ar Inteligente com Arduino Yun, Sharp Plasmacluster e IoT AWS