How easy would it be if you could turn ON things just by telling them to turn ON.. With help of Google assistant that's precisely what you can do. Tell google to do it.
Add a security feature to alert you when there is a security breach in your home/room. When there is movement, you get a mail.
The components I have used are:
- Wiznet WIZ750SR serial to Ethernet module
- WIZNET W7500
- Ethernet cable and connections
- lightbulb
- Microwave motion sensor
- Google assistant app in your phone
To get started with home automaton:
Integrate google assistant(GA) with openhab. https://github.com/openhab/openhab-google-assistant#testing--usage-on-google-app is the link for that.
Link for the project demo(Part 1): https://youtu.be/LdSTWMUIu2Y
Initially a bulb is connected with w7500, then this board is connected to w750sr through UART. w750sr is connected to internet using ethernet. MQTT protocol is used for subscribing the status of light from oopenhab and accordingly the light is switched ON/OFF. Similarly other devices can be connected and controlled. I have used a relay in interfacing a bulb because this is a normal lightbulb and would only with AC current.
Google assistant is integrated with OpenHAB, hence when you tell google to turn on light, it is reflected in OpenHAB.
Here is the code for Wiznet W750sr to publisha and subscribe messages :
Subscribes the status of light and publishes security factor.
The openHAB should be updated with UUID secret and UUID password and also with your mailID. Install openhab from google store on your android. Below is the code for writing in openhab/conf/services/rules.
Once the microwave sensor senses a data immidiately the security switch turns ON and a notification is received on phone.
#include "mbed.h"
#include "MFRC522.h"
#include "SPI.h"
#include "MQTTEthernet.h"
#include "MQTTClient.h"
#define ECHO_SERVER_PORT 7
// Nucleo Pin for MFRC522 reset (pick another D pin if you need D8)
//#define MF_RESET D8
#define SPI_MOSI D11
#define SPI_MISO D12
#define SPI_SCK D13
#define SPI_CS D10
#define MF_RESET D9
//Serial connection to PC for output
Serial pc(USBTX, USBRX);
Serial a(D1,D0);
char c[100]="";
int main(void) {
//pc.printf("starting...\n");
Serial pc(USBTX, USBRX);
Serial a(D1,D0);
// pc.baud(115200);
printf("Wait a second...\r\n");
char* topic = "light";
MQTTEthernet ipstack = MQTTEthernet();
MQTT::Client<MQTTEthernet, Countdown> client = MQTT::Client<MQTTEthernet, Countdown>(ipstack);
char* hostname = "172.16.73.4";
int port = 1883;
int rc = ipstack.connect(hostname, port);
if (rc != 0)
printf("rc from TCP connect is %d\n", rc);
printf("Topic: %s\r\n",topic);
MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
data.MQTTVersion = 3;
data.clientID.cstring = "parents";
if ((rc = client.connect(data)) == 0)
printf("rc from MQTT connect is %d\n", rc);
// if ((rc = client.subscribe(topic, MQTT::QOS1, messageArrived)) != 0)
// printf("rc from MQTT subscribe is %d\n", rc);
//
//Init. RC522 Chip
while (true) {
if (a.readable())
{
int i;
c[i]=0;
for(i=0;i<1;i++){
char c1 =a.getc();
c[i] = c1;
}
pc.printf("The value returned is %s ",c);
MQTT::Message message;
char buf[100];
sprintf(buf, "%s", c);
message.qos = MQTT::QOS0;
message.retained = false;
message.dup = false;
message.payload = (void*)c;
message.payloadlen = strlen(c);
rc = client.publish("security", message);
pc.printf("Rc result: %c \n ",rc);
client.yield(60);
}
}
}
Comments