Garage Door Monitor and Opener
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Introduction
This system implements a simple garage door opener and environmental monitor. The hardware connects to the internet using Wi-Fi then on to the Pelion Device Management Platform which provides device monitoring and secure firmware updates over the air (FOTA). Pelion Device Management provides a flexible set of REST APIs which we will use to communicate to a web application running on an EC-2 instance in AWS. The web application will serve a web page where we can monitor and control our garage..
This project is intended to work on the DISCO-L475VG-IOT01A from ST Microelectronics It implements a simple actuator to drive a relay to simulate pushing the "open" button on older style garage doors which do not use a rolling code interface.
The system is designed to be mounted over the door so that the on board time of flight sensor can be used to detect if the door is open or closed.
The system also monitors temperature, humidity and barometric pressure.
Hardware Requirements:
DISCO-L475G-IOT01A https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/
Seeed Studio Grove Relay module https://www.seeedstudio.com/Grove-Relay.html
Seeed Studio Grove cable, I used this one: https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-5-PCs-per-Pack.html
Connect to the PMOD connector like this:
This shows how I installed so that the time of flight sensor can detect when the door is open
To use the project:
You will also need a Pelion developers account.
I suggest you first use the Pelion quick state to become familiar with Pelion Device Management. https://os.mbed.com/guides/connect-device-to-pelion/1/?board=ST-Discovery-L475E-IOT01A
Web Interface
For my web interface I am running node-red under Ubuntu in an EC2 instance on AWS. This can run for 12 month within the constraints of their free tier. Here is a tutorial: https://nodered.org/docs/getting-started/aws
You will also need to install several node-red add ons:
sudo npm install -g node-red-dashboard
sudo npm install -g node-red-contrib-mbed-cloud
sudo npm istall -g node-red-contrib-moment
After starting node-red import the contents of GarageFlow.txt from the project, pin the flow into the page.
To enable your web app to access your Pelion account you need an API key.
First you will neet to use your Pelion account to create an API key.
Now we need to apply that API key to your Node-Red flow.
Revision 37:ec1124e5ec1f, committed 2019-12-05
- Comitter:
- JimCarver
- Date:
- Thu Dec 05 19:03:48 2019 +0000
- Parent:
- 36:b93393bb0e6d
- Commit message:
- Bug fix
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Nov 27 01:33:50 2019 +0000 +++ b/main.cpp Thu Dec 05 19:03:48 2019 +0000 @@ -99,7 +99,7 @@ strcpy(DoorCode, newValue.c_str()); printf("%s\r\n", DoorCode); if(!strcmp(DoorCode, DoorPassword )) { - DoorActivate = 1; * Activate relay for 1500ms */ + DoorActivate = 1; /* Activate relay for 1500ms */ wait_ms(1500); DoorActivate = 0; DoorCode[0] = NULL; @@ -179,18 +179,16 @@ * This function is called periodically. */ void sensors_update() { - float temp1_value, temp2_value, humid_value, pressure_value; + float temp1_value, humid_value, pressure_value; uint32_t distance_value, distance_reading; if(!dflag++) { /* Only update the sensors once a minute */ sen_hum_temp.get_humidity(&humid_value); sen_hum_temp.get_temperature(&temp1_value); sen_press_temp.get_pressure(&pressure_value); - sen_press_temp.get_temperature(&temp2_value); res_humidity->set_value(humid_value); res_temperature->set_value(temp1_value); res_pressure->set_value(pressure_value); - res_temperature2->set_value(temp2_value); if(ErrorLockoutTime != 0) { ErrorLockoutTime--; if(ErrorLockoutTime == 0) { @@ -295,11 +293,6 @@ res_humidity->methods(M2MMethod::GET); res_humidity->observable(true); - res_temperature2 = client.create_resource("3303/1/5700", "Temperature LPS22HB (C)"); - res_temperature2->set_value(0); - res_temperature2->methods(M2MMethod::GET); - res_temperature2->observable(true); - res_pressure = client.create_resource("3323/0/5700", "Pressure"); res_pressure->set_value(0); res_pressure->methods(M2MMethod::GET);