# Build a simple (but not very secure) alarm system for your home or dorm room
**Author:** Berntzone (ab225hz)
This is a project for the course ['Applied IoT'](https://lnu.se/kurs/tillampad-internet-of-things-introduktion/distans-sommar/) at the Linnaeus University. The principles on which this project is based upon was taught during the first half of the course and then this project was started. The project took around 2 weeks and was completed in July of 2020.

The project aims to create a simple **motion detection alarm system** for home use, which notifies a desired user of the trigger. It won't necessarily scare off burglars, but will hopefully keep nosy roommates at bay.
From start to finish, the project takes around **10 hours** to complete for an amateur like yours truly, but heavily depends on your level of ambition. It takes even longer if you write the code from scratch, but good thing you won't have to do that in this tutorial.

## Objective
The purpose of the project is to be a little adventure for complete novices in the world of IoT. It aims to be a fun and somewhat useful build that gives a more concrete experience of concepts such as MQTT publishing, subscription, IoT platforms, webhooks etc to showcase some of the power of IoT.
The project is also supposed to be easy to expand upon at a later stage and this is a big part of why I chose it. Features that could be added for someone that wants to explore more could be:
* Add an **LCD screen** and a **rotary encoder** to make a more secure system that requires the user to input a combination before the alarm goes off in order to disable it. Design and 3D-print a neat old-school safe style case for the Lopy to finish it off.
* Connect it to **Google Home** via their API to turn on the lights when you enter the room on 'Home mode' and function as an alarm on 'Away mode'.
* Add **LoRaWAN** functionality and **Li-Po battery backup** to have multiple ways of communication and power delivery. This makes it harder to tamper with and lowers power consumption. Redundancy is king.
The basic project gives insight on how to power and interface with a PIR (Passive Infrared sensor) over a serial connection. It also gives the the creator a brief exploration of MicroPython and IoT architechture, and aims to be a good first step into the universe of IoT (and can lead into more steps hopefully).
## Material
In this project I have chosen to work with the Pycom LoPy4 device as seen in the picture below. It’s a neat little device programmed by MicroPython and has several bands of connectivity. The device has many digital and analog input and outputs and is well suited for an IoT project. Other types of microcontrollers can do the same job, but for this tutorial we will stick with the LoPy4.

| Material | Price | Where? | Comment |
| -------- | -------- | ------- |------|
| Lopy4 | 34.95€ | [Link](https://www.pycom.io/product/lopy4/) | Microcontroller (the brain)
| Expansion board | 16.00€ | [Link](https://www.pycom.io/product/expansion-board-3-0) | Enables USB power and simplifies cable connection. |
| 37-in-1 Sensor kit | 29.00€ | [Link](https://www.amazon.de/Elegoo-aufgerüsteter-Sensormodul-Bausatz-Anleitung/dp/B01M30ZWQR/) | PIR-sensor, Buzzer and much more. |
| Micro-USB cable | cheap | Already had one lying around. | For power and uploading the code.
| 5V USB PSU | ~ 10€ | Used my old iPhone charger. | For power.
| Breadboard | ~ 6€ | [Link](https://www.electrokit.com/produkt/kopplingsdack-400-anslutningar/) | Simplifies cable connection when developing.
| DuPont wires (male-female) | cheap | Already had some at home. | Connection of sensors to LoPy.
| **Total** | **70-100€** | | Will be cheaper if you buy Buzzer and PIR separate and not in a kit. You also dont really need a breadboard, but it can simplify the electrical work.
Now that you have all the stuff we need, let's get started setting up our equipment. In addition to the above material, you will also need a computer to interface with the pycom device. Already got one? Let's go!
**Side note:** A 3D printer is required to make a nice case for the device. In all honesty a small cardboard box should work (almost) just as good if you don't have access to such a device.
## Computer & Pycom setup
For this walkthrough, we'll use a **LoPy4** board and **Expansion board V3.1**. Other boards, such as FiPy might also work but you might have to tweak some things.
### Step 1: Flash the expansion board
Before getting started, it's recommended to flash the firmware on the expansion board to the latest version. I am on **macOS Catalina** and as I'm writing this there's a known bug which hinders me from updating the board. If you are on Linux or Windows 10, there shouldn't be any issues with this step.
Luckily for me my board already had pretty recent firmware, so I got awat without flashing. If yours don't, [follow this guide](https://docs.pycom.io/pytrackpysense/installation/firmware/.) to get it done.
### Step 2: Update the firmware on your LoPy4
After you flashed the board (or not) it's time for the LoPy4 to get fresh firmware. Just download the [Pycom Updater](https://docs.pycom.io/gettingstarted/installation/firmwaretool/) to get started. If you're not on Mac or Linux, you might also need to install drivers from [this page](https://docs.pycom.io/gettingstarted/installation/drivers/) to get things working the way they should.
After that is done, connect the **LoPy4** to the **Expansion board** and plug them in to your computer via the USB cable and follow the [guide](https://docs.pycom.io/gettingstarted/installation/firmwaretool/) linked above to update your pycom device. It's important to line up the LoPy and the Expansion board the right way before connecting them. Make sure you can read "Pycom" the direction way on both units before you push them together.
### Step 3: Installing your IDE
If you're not familiar with IDEs, this is the software in which you write your code and communicate with the pycom device. As I'm writing this, there are **two** different IDEs available that work with the Pycom: **Atom.io** or **Visual Studio Code**. Both are free, cross platform and work great, but my allegiance is with Atom.
After you have installed either IDE, you also need to install the **Pymakr** plugin. This is very easy, but here's a [guide from Pycom themselves](https://docs.pycom.io/gettingstarted/installation/pymakr/). Pymakr requires **Node.js** to work, so [install](https://nodejs.org/) that too if you haven't already. Once you've installed that; great! We now have everything we need to control and talk to the Pycom. Via the USB cable, you can now easily upload your code to your device.
### Step 4: Check that everything works (optional)
To make sure that everything works and is going to run smoothly, I would recommend following [this guide](https://docs.pycom.io/gettingstarted/programming/first-project/) to create your first project. It's a simple program that makes your LoPy4 blink in different colors.
Great, you now know the basics of communicating with your pycom device!
## Putting everything together
Putting everything together is easier than it looks. You may at first feel a little overwhelmed with all the wires and sensors and different abbreviations all over. I'm here to tell you that it's all right. You can do this.
The most important part before connecting things together is reading the documentation of your sensors and devices. Pycom has extensive documentation on their [website](https://docs.pycom.io/gitbook/assets/specsheets/Pycom_002_Specsheets_LoPy4_v2.pdf) with everything you need and more. Depending on the sensors you have purchased, you will need to find the documentation for those too. I found mine [here](https://www.elegoo.com/tutorial/Elegoo%2037%20Sensor%20Kit%20Tutorial%20for%20UNO%20R3%20and%20Mega%202560%20V2.0.0.2020.03.10.zip), but you might have to look elsewhere if you have another sensor.
### General principles
All sensors generally has one or more pins for power. They need to be connected to a voltage source to power the sensor. Typically this can be the **3V3** or **VIN** pin on the LoPy depending on what voltage the sensor needs.
The sensors also need to be connected to ground to allow a current to flow. This is also necessary for the sensor to be powered. Typically this is the **GND** pin on the Lopy.
In addition to these two types of pins, a sensor often has one or more pins for data. A data pin, depending on type, can either be used to **control** the sensor, or **collect data** from it. Have a look in the documentation for your sensor to read up on how it works. A data pin can generally also be either **analogue** or **digital**:
* An analogue pin can send different values depending on the voltage level from the pin. This might be useful for i.e. a temperature sensor.
* A digital pin has a threshold voltage that decides whether the pin should be interpreted as **HIGH** or **LOW**. Everything above the voltage threshold will be HIGH and vice versa. This translates to a **1** or **0** to the Pycom device.
### Passive Infrared sensor (PIR)
In the sensor kit I bought, there was a PIR sensor included. This was a HC-SR501 sensor which is a common one for these types of projects. This sensor captures the passive infrared radiation of the environment, and detects motion through changes in this typ of radiation.
This sensor can be adjusted in three ways, using the two potentiometers located on the back of the sensor and via the jumper to the right in the picture below:
* **Left potentiometer**
Adjust time delay of the sensor. Through some quick testing I found my sensor to behave appropriately, so I left it the way it was.
* **Right potentiometer**
Adjust sensitivity of the sensor on a scale of **3-7 meters**. Depending on where you plan on mounting your sensor, this can be a good idea to adjust to the environment and trim in to avoid accidental triggers. A clockwise rotation decreases sensitivity and vice versa.
* **Jumper**
Depending on position of the jumper, the sensor can behave in two ways. One position allows only single triggers of the sensor, whereas the other position allows continuous triggers as long as there is something in the way.

According to the documentation, the PIR needs **4.5-20V** so we connect the power pin on the sensor to the **VIN** on the expansion board and power the whole thing via USB. This gives the PIR around 5V, which is all right. The **ground** is connected to **GND** on the expansion board. The **output** pin is connected to **PIN 4** on the expansion board.
### Passive Buzzer
In the kit linked in Material, there was also a Passive Piezoelectric buzzer included. This seemed like a fun thing to include as well, so I decided to use it to scare off my room mates.

According to the documentation, the buzzer needs **3.3V** so we connect the power pin on the sensor to the **3V3** on the expansion board. The **ground** is of course also connected to **GND**. The **output** pin is connected to **PIN 10** on the expansion board, which is a pin that supports **PWM**. This means that this pin for example can simulate a sinus signal which can be fed into our buzzer. One of the DAC pins on the pycom could have also been used, and would probably have been easier now that I think about it.
After reading up on how Piezo buzzers work, I also tried disconnecting the power cable from the component. I noticed no difference in functionality, but left it connected since the datasheet clearly says so.
### Circuit
All in all, the circuit should look something like this when both components are plugged in. To make sure, double check your documentation that your sensors have the same kind of layout as mine before connecting the wires.

It's generally pretty easy to make the majority of this circuit. The tricky part is to strip a wire on the middle and solder another end to it. This is required because the Pycom device only has one ground pin.
If you decide to go with a breadboard for the final product this isn't an issue, but I wish to fit everything inside a neat case later on and the breadboard takes a lot of space.
**Note:** This project is not meant for industrial application. The way things are wired, it's easy to take it apart again if you want to try another project. This is mainly thanks to the Male-Female DuPont cables. Love 'em.
### Electrical calculations
After measuring the current through both the PIR and the Piezoelectric buzzer respectively with a multimeter, none of them drew a noticeable amount of current. The voltage was on appropriate levels as well.
Since current is low, and voltage is stable that means resistance already is high enough (at least on an ok level) according to Ohm's law:
**U = R * I**
I therefore decided not to connect resistors in series with them to save some space. It would probably have been a good idea to do this as it doesn't really hurt, and is a great way of making sure your components make it in the long run.
## Platform
There are multiple different platforms to choose from when it comes to IoT projects. I tried three different ones, each with their own pros and cons, but there are a lot more great platforms out there depending on your preferences. These were the one I explored:
* [**Pybytes**](https://pybytes.pycom.io)
Easiest, but it's a very new platform that possibly has a couple of kinks that are not straightened out as of yet. Still a good choice with many possibilites. Not recommended if you wish to learn more about what happens behind the scenes as much of the configuration is done for you. Pybytes works as both mqtt client, broker, database and platform – all in one neat package.
* [**TIG-stack**](https://hackmd.io/@lnu-iot/tig-stack)
Local platform, which consists of **Telegraf**, **InfluxDB** and **Grafana**. This solution gives more control, but needs a computer or server to run 24/7, which might be impractical and power consuming. Could be a good choice if you own a Raspberry Pi on which you can run the TIG-stack. Gives a bit of insight into what happens server-side if you're interested in that. It also has great integration with other services such as **Discord** or **Pushover** through Grafana, which is neat.
* [**Ubidots**](https://ubidots.com/stem/)
A great platform free for use if you're a STEM student. Relatively easy integration and opens the door to many powerful plugins, dashboard widgets and actions based on events. It also has lots of documentation and guides, which makes it pretty beginner-friendly as well.
In the end I chose **Ubidots** for the easy integration with other apps and actions. For example, I can easily create webhooks or make it send an email to myself when the alarm is triggered. Basically, with this choice I got almost as much functionality as with TIG, but didn't have to host it myself. It's also a great choice if I would want to scale up the operation in the future (ie pay for it).
In the future I'm probably moving the whole operation to a TIG-stack on a Raspberry Pi4 to get more control over my platform. That would also give me access to powerful integration with services such as Node-RED.
## The code
The code is structured into a couple of different files to make it easier to read and understand. The whole code can be found on [github](https://github.com/Berntzone/home_alarm.git), but the main code can also be found below.
To replicate the project, download the whole project folder from github to your computer and import it to Atom or VSCode. Upload it to your pycom device and voila!

*Schematic image in swedish unfortunately. Sorry.*
### Structure
```
main.py
boot.py
/lib/keys.py
/lib/urequests.py
/lib/pir.py
/lib/sound.py
/lib/communicate_ubidots.py
/lib/time_handler.py
```
| File | Description |
| -------- | -------- |
| boot | Runs when the LoPy is started up. Connects WiFi etc. |
| main | The main code. |
| keys | A file in which you put SSID, WiFi password, ubidots token etc. |
| urequests | A lean library that simplifies the process of connecting to ubidots. It's great. |
| pir | Handles functions related to the PIR sensor. |
| sound | A library that translates musical notes to frequencies. |
| communicate_ubidots | Functions for even neater communication with ubidots from my program. |
| time_handler | Handles different time-related functions. |
### Boot
The boot file basically connects the LoPy to WiFi and preps the device for communication with ubidots. That's it!
```python=1
from machine import UART
from network import WLAN
import machine
import time
import os
import pycom
import keys
pycom.pybytes_on_boot(False)
pycom.heartbeat(False)
uart = UART(0, baudrate=115200)
os.dupterm(uart)
# config wifi hardware
wlan = WLAN(mode=WLAN.STA)
wlan.antenna(WLAN.INT_ANT)
# Assign your Wi-Fi credentials
wlan.connect(keys.ssid, auth=(WLAN.WPA2, keys.ssid_pass), timeout=5000)
# Connecting to WiFi
while not wlan.isconnected ():
print("Connecting to WiFi...")
time.sleep(1)
#machine.idle()
print("Connected to Wifi \n")
time.sleep(0.5)
machine.main('main.py')
```
### Main
The code is quite long and includes multiple different functions divided over several files. Below, we'll go through the main functionality, but please have a look on [the github page](https://github.com/Berntzone/home_alarm.git) to see complete code.
The main file handles some initialization of the PIR sensor and syncs the system clock to an ntp server. It also initially calls the ubidots server what mode the alarm should be on start up. It then enters an infinite loop that sleeps and checks ubidots every 60 seconds.
```python=1
# Imported libraries
import urequests as requests
from machine import Pin
import machine
import time
# My own libraries to structure the code
import communicate_ubidots as ubi
import time_handler as tim3
import keys
import sound
import pir
# Config
INIT_DELAY = 60 # Delay to allow initialization of PIR Sensor. 60s according to docs.
SLEEP_DELAY = 60 # Time between every status update to Ubidots.
# Checks desired mode of device
def check_mode(): # 0: Alarm turned off.
mode = ubi.alarm_mode() # 1: Only sound. Mode for connecting smart lights to in the future.
ubi.post("status", mode) # 2: Silent Alarm mode. Only ubidots.
print("[Status updated to Ubidots]") # 3: Alarm fully armed. Both sound and ubidots.
# Ubidots is notified of device mode.
## -- MAIN CODE -- ##
# Syncing system clock to the internet
tim3.sync_time()
# Startup
state = machine.disable_irq() # Makes sure device can't be interrupted by PIR.
print("Initializing PIR sensor... (" + str(INIT_DELAY) + " seconds)")
time.sleep(INIT_DELAY)
print("Starting up. \n")
machine.enable_irq(state) # Allow interruption again.
while True:
check_mode() # Checks mode on ubidots and updates device status.
time.sleep(SLEEP_DELAY) # Sleeps for SLEEP_DELAY seconds or until interrupted by PIR.
```
The next part of the "main" code is the **pir.py**. This function handles most of the PIR interaction, most notably the interrupt when the sensor detects motion. The main loop is then interrupted and the device takes action depending on the mode it is in. Look at [this guide](https://techtutorialsx.com/2017/10/08/esp32-micropython-external-interrupts/) to better understand interrupts.
```python=1
import machine
import time
from machine import Pin
import communicate_ubidots as ubi
import time_handler as tim3
import sound
# Config of the PIR Sensor
LOCKOUT_TIME = 10 # Lockout time after the sensor has been triggered to avoid multiple triggers of one event.
# At least 2.2 seconds so we don't check ubidots too often.
# Function that runs when PIR is triggered (interruption)
def call_back(arg):
mode = ubi.alarm_mode()
if mode==1:
sound.play() # Mode for connecting smart lights to in the future.
elif mode==2:
post_trigger_to_ubi() # Silent Alarm mode
time.sleep(0.5)
elif mode==3:
post_trigger_to_ubi() # Alarm fully armed
sound.play_mario()
else:
pass # Alarm turned off (mode==0)
state = machine.disable_irq()
time.sleep(LOCKOUT_TIME)
machine.enable_irq(state)
# Interrupt config
P4 = machine.Pin('P4', Pin.IN)
irq_P4 = P4.callback(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=call_back)
# Post a trigger event to Ubidots
def post_trigger_to_ubi():
trigger_time = time.time()
print( tim3.present(time.localtime()) + " [Motion Detected]" )
ubi.post("alarm_trigger", 0)
time.sleep(1)
ubi.post("alarm_trigger", trigger_time)
time.sleep(1)
ubi.post("alarm_trigger", 0)
```
The part of "main" that handles communication with ubidots is **communication_ubidots** (surprise!), which I often import as just "ubi". This code builds the JSON objects, publishes and subscribes to the ubidots server. It also has a function for checking and detecting when the mode changes on the server.
```python=1
import urequests as requests
import keys
import sound
last_mode = None
# Builds the JSON object to send the request
def build_json(variable, value):
try:
# data array creation
data = {variable: {"value": value}}
return data
except:
return None
# Sends the request. Please reference the REST API reference https://ubidots.com/docs/api/
def post(topic, value):
try:
data = build_json(topic, value)
if data is not None:
r = requests.post(url=(keys.url + keys.pub), headers=keys.headers, json=data) # include data as JSON object
json_obj = r.json()
r.close()
return json_obj
else:
print("ERROR: JSON Empty. Nothing to post.")
pass
except:
print("ERROR: Can't send data to Ubidots.")
pass
# Function for listening for commands from the Ubidots server. In my case only integers.
def listen(topic):
r = requests.get(url=(keys.url + topic), headers=keys.headers)
value = int(r.json())
r.close()
return value
# Checks control variable on Ubidots and returns True or False
def alarm_mode():
global last_mode
mode = listen(keys.sub)
if mode==last_mode:
pass
else:
print("Mode: [" + str(mode) + "]")
sound.mode_change(mode)
last_mode = mode
return mode
```
Other than that, have a look in the different libraries on the [github page.](https://github.com/Berntzone/home_alarm)
## Transmitting the data / connectivity

### Wireless protocols
There are basically two-three different appropriate protocols that we have access to with the LoPy4 (harsh generalization, but somewhat true at least). The two I've looked at are the following:
* **LoRaWAN via TTN**
A great choice as we are not sending a lot of data, especially if you can make sure you have access to TTN at the location of your device. As I am not currently at the location I want to deploy my device, I have a hard time testing the reliability of TTN there. I will most definitely experiment with this in the future though.
* **WiFi via MQTT protocol**
As I'm at least sure that I have access to WiFi where I want to put my device, I decided to go for WiFi connectivity. Draws more power, but allows more bandwidth if we want to add more functions in the future. As the device is stationary and in range of a WiFi access point, distance is not a problem.
In the future, both LoRa and WiFi can be used for redundancy if desired, but is not something I focused on for this basic project.
### Transport protocols
In terms of transport protocol I decided to go for **MQTT** since I wanted to learn how it worked and it's generally a great protocol for IoT devices. Through MQTT, my pycom device connects to Ubidots platform through their broker.
From Ubidots, I can see the status of the alarm and also turn it on or off from anywhere in the world. I have also set up an action where a **webhook** is created in the event of the alarm being triggered. This is connected to [pipedream](https://www.pipedream.com), which sends a message to a discord server and notifies me on my phone.
I could've gone directly with webhooks (**HTTP**) and skipped **MQTT**, but as stated above I wanted to learn that protocol for future IoT projects that demand more in terms of power efficiency and bandwidth allocation etc. Since we're on WiFi and connected to a power outlet none of are really a problem with this project, but could be a good idea for redundancy.
### Packaging & sending data
The data is transmitted as **JSON** objects as this is a very usual way of packaging the type of data we have.
#### Signal 1: Transmit alarm status
We are sending very small objects every minute to confirm that the alarm is still running. This signal also functions as a way to tell Ubidots whether or not the alarm is turned on. The limit for STEM users is approximately once every 22 seconds, so this is ok.
#### Signal 2: Transmit trigger
The device also transmits to another **topic** in the event of the alarm being triggered. Because of how actions in Ubidots function, the device sends three packages to the broker to allow our action in ubidots to activate:
```
1st signal: 0
2nd signal: Time of alarm trigger
3rd signal: 0
```
Maybe not the most elegant solution, but it works...
#### Signal 3: Subscribe to control signal
Last but not least, the device also subscribes to the latest value of a control signal every minute. This subscription is also done every time the alarm is triggered. Since we have access to wall power, this isn't really an issue and we are well under the 50'000 dots/day subscription [limit of Ubidots](https://help.ubidots.com/en/articles/639806-what-is-the-difference-between-ubidots-and-ubidots-stem).
If I were to use LoRa and rely more heavily on battery power, the data communication would need to be trimmed a bit. Easiest way of doing this in our case is to make the regular posting and subscription only happen every 10 minutes and deep sleep in between. Since the alarm trigger is based on an interrupt, the alarm function wouldn't be affected. Only the lag of the ubidots dashboard.
## Presenting the data

### Dashboard and database
The data is presented in Ubidots on a dashboard like the one above. Here we can see the status/mode) of the alarm as well as controlling the mode with the slider to the right. We also see spikes on the graph when the alarm has been triggered.
As I mentioned, data is stored every minute and Ubidots STEM keeps my data in their database for 30 days, which is more than enough for me. It's a free cloud solution for students, which is what I was looking for when choosing database and platform. As long as I can see a couple of days, I'm happy and if I would like to go even further back, I can always check the history on Discord, where I get the notifications to my phone.
### Control
Via the Ubidots dashboard the alarm system can be controlled via the slider, which in turn controls the 'control'-variable that the device subscribes to.
#### The device has four modes:
* **[0] Disabled**
The device doesn't do anything special when PIR is triggered.
* **[1] Beep only**
A sound is played to notify you that the PIR is triggered. Used mostly for debugging and to offer a mode where smart lights etc can be controlled via if that is implemented in the future.
* **[2] Silent alarm**
Device publishes trigger signal to Ubidots.
* **[3] Fully armed alarm**
Device plays super mario and publishes trigger signal to ubidots.
### Action triggers
My system has two automated triggers of the data:
* **When alarm is triggered**
When the alarm_trigger signal is posted to ubidots, this action activates and sends a webhook to a service called **pipedream**, which is an easy way to integrate different APIs into your project. Pipedream then sends a message to my Discord server, which pops up as a push notification in my phone.
* **When status has been silent for 10 minutes**
When the status signal has been silent (hasn't been updated) for 10 minutes, this trigger sends a webhook through Pipedream and delivers a message notifying me of the irregularity.

*Picture of Pipedream.*
## Finalizing the design
### 3D printed case
To finish the whole thing off, I 3D printed a case for everything to both protect the components and package the alarm in a more neat way. The lopy and the other components are just friction fitted into the case, so it's easy to disassemble if I want to try another project soon. The USB charging port is left open and the PIR sticks out of a hole in the front.
The STL files are available [here](https://github.com/Berntzone/home_alarm/tree/master/3D%20printed%20cover) if you want to try for yourself. Most if it works great, but in my case I had to narrow down the pegs on which the LoPy rest on a bit to make it fit. I also just snapped of the pegs for the PIR. They are not needed.
 
*Case and USB port.*
 
*Leaving the breadboard. This is how components fit inside the case.*
### You did it!
Plug your little friend into a wall outlet via the USB cable and the 5V PSU, and you now have a finished little home alarm!
Personally, I will polish and spray paint my case before sticking it up on my wall with some double sided tape, but nothing stops you from just going raw. It's a free world after all!

Congratulations, you did it!
### Next stops for me:
* Add an **LCD screen** and a **rotary encoder** to make a more secure system that requires the user to input a combination before the alarm goes off in order to disable it. Design and 3D-print a neat old-school safe style case for the Lopy to finish it off.
* Connect it to **Google Home** via their API to turn on the lights when you enter the room on 'Home mode' and function as an alarm on 'Away mode'.
* Add **LoRaWAN** functionality and **Li-Po battery backup** to have multiple ways of communication and power delivery. This makes it harder to tamper with and lowers power consumption. Redundancy is king.
See you around!
Maybe I'll update this tutorial when I've upgraded the system...