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.

https://os.mbed.com/media/uploads/JimCarver/garageopener.jpg

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:

https://os.mbed.com/media/uploads/JimCarver/opener.jpg

This shows how I installed so that the time of flight sensor can detect when the door is open

https://os.mbed.com/media/uploads/JimCarver/opener1.jpg https://os.mbed.com/media/uploads/JimCarver/opener2.jpg

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.

https://os.mbed.com/media/uploads/JimCarver/api_portal.jpg

Now we need to apply that API key to your Node-Red flow.

https://os.mbed.com/media/uploads/JimCarver/api_node-red.jpg

Revision:
15:a0430d40a918
Parent:
13:42b49a0caade
Child:
16:70374ab2404f
--- a/main.cpp	Mon Dec 10 19:06:42 2018 +0000
+++ b/main.cpp	Mon Dec 10 22:06:50 2018 +0000
@@ -33,8 +33,6 @@
 static DigitalOut shutdown_pin(PC_6);
 // static VL53L0X sen_distance(&devI2c, &shutdown_pin, PC_7);
 
-InterruptIn button(USER_BUTTON);
-
 #define SENSORS_POLL_INTERVAL 1.0
 //#define SEND_ALL_SENSORS
 
@@ -50,7 +48,9 @@
 SlicingBlockDevice sd(bd, 0, 2*1024*1024);
 LittleFileSystem fs("fs", &sd);
 
-// Default LED to use for PUT/POST
+// Default User button for GET example
+InterruptIn button(BUTTON1);
+// Default LED to use for PUT/POST example
 DigitalOut led(LED1);
 
 // Declaring pointers for access to Pelion Client resources outside of main()
@@ -220,7 +220,7 @@
 int main(void) {
     printf("Starting Simple Pelion Device Management Client example\n");
 
-    // If the User button is pressed, then format storage.
+    // If the User button is pressed ons start, then format storage.
     const int PRESSED = 0;
     DigitalIn *user_button = new DigitalIn(USER_BUTTON);
     if (user_button->read() == PRESSED) {
@@ -340,8 +340,8 @@
 
     button.fall(eventQueue.event(&button_press));
 
+    // The timer fires on an interrupt context, but debounces it to the eventqueue, so it's safe to do network operations
     Ticker timer;
-    // The timer fires on an interrupt context, but debounces it to the eventqueue, so it's safe to do network operations
     timer.attach(eventQueue.event(&sensors_update), SENSORS_POLL_INTERVAL);
 
     // You can easily run the eventQueue in a separate thread if required