Change the way you operate your garage!
Things used in this project
Story
First of all project requires a bit of explanation on my side and the history behind it. Few months ago I faced problem of losing my remote to garage doors. This happened for the second time and I got really frustrated, also one more thing that always annoyed me was the need to pass remote to any family member who would need an access to garage door.
This inspired me to design my own system, I know there are some ready of the shelf solutions but they didn’t satisfy me and also it would be to easy? My first prototype that is still working is based on ESP connected to relay and HC-SR04, while it’s fairly good solution and reliable it has some issues. First of all during doors opening HC sensor gets crazy and gives false readings. Lastly the whole system lacks nice GUI and access from anywhere in the world it’s local only (you need to connect to the same WiFi).
Based on this improved version of the system would work following way:
This is when we get to the major problem that affected my project and which didn’t allow me to finish it. We need all 4 tasks to run at the same time more or less. Multitasking usually is achieved on MCUs using RTOS, on MKR1000 we don’t have direct port of any RTOS at the moment. The only project that seems to be available is FreeRTOS for Arduino Zero but it has some issues and semi bricked my MKR1000. Because I was on holiday when trying to finish my project I ended up stocked in one point without the option to fix MKR1000 (you need JTAG/SWD debugger to flash MKR1000 directly with OpenOCD).
As I discussed it with WLAC people they advised me to upload project in current state as it might be good lesson to other people working on something similar. So if you want to replicate my idea more or less or further develop it lets start from the beginning.
First you need to set up Azure IOT Hub this can be done using following tutorial it’s great and it’s the same place I started, you need to configure your IOT Hub on Azure and get all necessary keys.
http://mohanp.com/mkr1000-azure-iot-hub-how-to/
http://mohanp.com/complete-reject-abandon-mkr1000-azure-iot-hub-how-to-part2/
After complete setup you can start using code attached in the post some things have comments, some doesn’t as it is in early stage. Please be advised that MKR1000 crashed when using this code as it’s most likely related to wrong config and some other issues. If you happen to own JTAG/SWD or are using Zero with on board debugger you should be good to go.
To connect HC SR04 please use voltage divider as below as MKR1000 uses 3.3v logic(GPIO pins can be defined in source).
This is current stage of the project and as of today there is no UWA app available as I wouldn’t be able to test everything anyway. As soon as I will fix MKR1000 I will work further and update this project.
SSD1306 display is used to display some debug info as well as current time (uses RTC capability of MKR1000).
Schematics
Code
Source : ‘Smart Garage