My Secure Everything Journey
I wonder where I should begin. I have had so many successes and failures I don’t know where to start. But, isn’t that the idea? I learned a ton of new things and I learned how much MORE I need to learn in order to do this right next time. I have designed and built several small projects with my Raspberry Pi and Arduino boards but none of them have ever been as complex as this project (and none of them used the Azure Sphere). That was what was so appealing to me about this project. I knew about the capabilities of the Azure Sphere but I had never used one, so this project gave me that opportunity. As a “Maker” I couldn’t pass it up.
Initial Stages:
My idea for a Secure Everything Project was to design and build an open-source security system called “Opensecure”. It is an in-dorm security system for college students to put in their dorm rooms. I am kinda obsessed with security type stuff and over the summer my family had a lot of friends and cousins that were going off to college. As I talked to them they said that they were buying a bunch of stuff to keep their laptops and cell phones and personal stuff safe from theft in their dorm rooms. They were buying small lock boxes, safes, laptop locks, etc. The lockboxes are great for small things like phones, watches, jewelry, etc. but not for anything of any size. This really bothered me the more I thought about it because I am only 11 and in about 7 years I would be heading off to college also. The only difference is I am a tech geek. I have more than one computer, servers, multiple monitors, phones that I use for testing apps, etc. Not to mention a lot of little microcontrollers that could be stolen very easily as well as video games & consoles. If I go off to college and I take a fraction of the electronics that I have at home I would like a better security solution than a lockbox.
My solution was an in-dorm security system. According to my research dorm burglaries are the top college dorm security threat, accounting for 70% of the total crimes? It said it only takes like 10 seconds to enter a dorm and grab valuables and exit. I am hoping that my solution would help prevent burglaries in the first place. College students could make an affordable security system using my instructions or even purchase my security system if I ever designed a marketable one. They would be able to install the security panel on the wall of their dorm room and plug it into an outlet. This allows for the security system to be easily removed and relocated and with no damage to the dorm room wall. The system would have a touch screen control panel, door & window sensors and siren (the siren could be automatically activated or remotely activated to cut down on accidental activations). You would be to create a single access pin code (or multiple if you have roommates and want to keep track of who is using the system). It would also be able to connect with 3rdparty devices such as a camera to catch the thief in the act. I would later want to enhance my security system by making in work like a hub to control other devices for security. Such as turning on a Zigbee light when away from the dorm so that someone thinks you are home. Also using a Zigbee door lock that would allow you to remotely lock your door if you forgot or unlock your door for the maintenance technician working on your HVAC. Ideally, I would want to develop a campus-wide version of my security system for the college to implement for all dorm rooms on campus. This system would link the control panel ID back to the campus security system to immediately notify campus police to respond to an alarm.
One thing I have learned is having a good idea and executing that idea is easier said than done.
1st Configuration:
My original idea was to buy Grove products to attach to the Sphere board, especially since I am terrible at soldering the grove connections just made sense. I purchased a Grove: fingerprint reader, I2C display, keypad and buzzer. Unfortunately, I didn’t realize when I purchased the Grove components that there would NOT be any Azure Sphere libraries for them. I even contacted Seed Studio about this and didn’t hear back from them. Since I had never used a Sphere before I just assumed, they would have libraries already developed and unfortunately I am not skilled enough to create my own. So on to my next idea.
Well, I did have a budget for this project and since I had just wasted most of it on the Grove components that I can't use now. I would have to use a lot of components I already had in my personal inventory. In my first configuration, I used a 4x4 keypad, 20x4 alphanumeric LCD with a Potentiometer to control the backlight for the control panel (see Figure 1 & 2). I needed so many I/O pins that I was using my Arduino Mega to accommodate them. However, I needed wifi capability in order to communicate with the Sphere so I bought a wifi shield from a local electronics shop. The store owner assured me it was compatible with my board but I could never get it to work. So now I was back to no wifi. So on to my next idea.
Figure 1 (This was a very basic design concept that I started out with and then it morphed into my second configuration I mention later.)
Figure 2
NOTE: (Figure 2) Wiring diagram of my first configuration concept. Door contact sensor, Azure Sphere, Click Relay and siren not shown here. Circuito.io didn’t have all the correct components but this gives you an idea of what I was thinking for my first configuration.
2ndConfiguration:
My second configuration used an Arduino Yun with wifi capability and I purchased a Nextion touch screen display. I also added a Wyze Cam and a magnetic door contact sensor (See Figure 3). (This configuration cut out the need to use the keypad and 20x4 alphanumeric display and saved me a ton of I/O pins, so I didn’t need to use the Mega anymore or a wifi shield.) Next, I created a UI for the Nextion display that allowed you to create user pin codes, arm & disarm the alarm and control my IoT devices (i.e. the siren-connected to the Sphere via a Click Relay (See Figure 4), a smart plug that I had controlling a fan, and smart bulb I had in a lamp). Then I created a Blink server and a cell phone app that I used to remotely arm and disarm the security system (See Figure 5 & 6). However, I didn't like the way it looked so I decided to create a NodeRed server instead. The NodeRed sever handled my connection to IFTTT which allowed me to control my IoT devices (i.e. camera, fan, and bulb). See the picture of my NodeRed Flow in Figure 6A. (I actually created a few apps, this is just one of them. I included the APK file for you here http://bit.ly/opensecureapk2019 the demo app link is here http://bit.ly/opensecureapp2019). I developed this app in DropSource and used Backendless to handle the backend operations.
I made the Wyze Cam begin recording when the door sensor was tripped and send me a push notification to my phone app. I then could view the Wyze Cam and trigger the alarm remotely if I saw an intruder in my room (or I could disarm is also if it was just my roommate and they typed in their pin code wrong and set off the alarm.) At this point I was doing pretty good. However, shortly after getting this far I ran into a road block. I began trying to connect the Nextion to my Arduino Yun and I was having a hard time navigating the Nextion libraries and code. I felt like they were poorly designed and cryptic, not user-friendly, at least for a self-taught amateur like me. I spent hours troubleshooting the code for the Nextion display. Honestly, this is where I spent the majority of my time. I worked on this up until the last week of the deadline. I was just not proficient enough on how to develop the code. I was so close but this was an obstacle I couldn't get past. In a last-ditch effort to complete my project. I decided to switch to a Nokia 5110 display to see if I could understand it better and see if it may be easier to connect to my Yun. However, when I wired it up the first time, it damaged my Yun board (and yes the voltages were compatible). My Yun was no longer connecting over the com port and soon after that I couldn’t even get it to connect over the network. So call it bad luck or whatever but the only board I had to use for this project, just crapped out on me.
Figure 3
Figure 4
Figure 5
Figure 6
Figure 6A
Nearing the End:
So with no other viable options and two days left until the deadline. I created a powerpoint presentation to show how I had the Nextion display setup and I am attaching some pictures of my Azure Sphere with Click Relay and siren (See Figure 4). I also attached my Microsoft Azure Device Twin code with personal info removed (See Figure 7 & 8).
Although I didn’t get to submit the project I wanted to submit, due to my Yun dying and countless other coding inadequacies on my part and I failed more times than I succeded, I still feel like I came out pretty good on this. I did some things I never thought I could do and this project gave me the excuse to do them. Throughout the project, I had to upgrade to Windows 10 Home to run the Sphere and then to Pro in order to run Hyper V Sever. I also had to upgrade my SSD because I needed more space. I ran out of money on my budget otherwise I could have bought some components like an ESP32 to replace my Yun, but when your mom and dad are footing the bill you don’t really get a say in that. Budget or no budget this was a priceless experience. Hope this document kinda explains my thoughts and how hard I worked to get my project across the finish line.
Thanks,
Brenden Stahle
Figure 7
Figure 8
Figure 9 - (IoT Central before I switched to IoT Hub)
Comments