An Open-Source platform to create digital devices and interactive objects that sense and control physical devices. | Arduino Tutorials | |
Arduino Projects |
Introduction
Back in October (2018) I put forward an idea for making access to communal spaces smarter as my entry to the Arduino “MAKE A SMARTER WORLD COMPETITION”.
This blog documents my progress so far, of designing a smarter Access Control system based on two Arduino MKR WAN 1300 boards and a MKR Relay Proto Shield.
The first MKR 1300 board acts as the remote access control unit and will be designed to handle a number of interfaces:
- An I2C based LCD with RGB backlighting to display text messages to the user
- A Keypad to enter a one-off random generated entry code
- A LUX sensor to determine if a light needs turning on
- A pushbutton to trigger a system wakeup (from deep sleep) and trigger the call via LoRa
- A BLE module to enable communication between a person's smartphone and the remote Access Control unit
The second MKR 1300 board acts as the central control unit and a gateway to the Internet to allow for communal control. The central control unit will be designed to handle these interfaces
- A WIFI module to provide Internet communication via a local router
- A pushbutton to accept a remote call and to clear any local alerts
- A speaker to play audio chimes via an I2S-based amplifier
My design approach was to split the project into two phases. Phase 1, which is the focus of this blog, is to develop and test a standalone system using just LoRa between the access panel and the central control panel. Phase 2 will then take the phase 1 design and expand the functionality by adding in the Internet gateway to allow for communal based access-control. It will also include some BLE functionality to allow for the possibility of configuration control and another user interface.
Phase 1 Design: Standalone Option
The initial standalone design is based on a standard Door Entry Access Panel design with some variances to it.
So, if we look at a standard door entry access panel it would typically include the following:
- A keypad to enter a door entry code. Most access control systems would have a defined number of entry codes, which can be changed periodically;
- A button to call someone if they do not have an access code; and
- A speaker and microphone to speak to a person through an intercom system.
- Some access panels would also include an LCD to display messages
- More advanced systems would also include a video camera in order to see the person.
The door unlocking mechanism is typically handled by a door control unit which reads the data from the access panel and responds according to defined logic governed by the control unit’s firmware.
The Intercom audio would typically be a wired system but it can also be wireless using cellular (GSM/3G), for example, as the means to communicate with someone. Cellular provides the advantage of removing geographical barriers but this adds to the cost and is also power hungry. And finally, another option that you quite often see is the use of RFID access cards which are then read by an RFID reader attached to or embedded within the access control panel.
So, in my case I wanted to start with having a push button that any stranger could press. This would then trigger a notification on the other end, which would require a response. Now as the communication between the remote door entry access panel and the central control unit will be handled using LoRa, the level of data transfer will be very much constrained. As such, we would not be able to handle audio communication between remote and central units, for example. Thus, the 2-way audio comms part of a typical standalone design has to be excluded (for now). Instead an LCD is included to provide local text messages.
A keypad is still included in my standalone design, but its use case is different. As you know, with most access panels you would get assigned a pin code. In many cases this would be unique to you, but this access code would not change each time you enter. In my case the keypad is used for a once only pin code which is randomly generated. This ensures that a user has to enter the code given before access is granted.
System Architecture
The standalone system is built around three Arduino-based microcontrollers. One is deployed as the central unit and two are used in the remote unit.
As mentioned previously, the central controller uses an Arduino MKR WAN 1300 board. The antenna I am using with my central controller is an EAd Quintus 3G pentaband antenna, as it happens to be something I had available. This antenna is primarily targeted for cellular connectivity but still works at the 868MHz (EU) LoRa frequency band, although looking at the spec sheet it is not optimised at that frequency. Still, it is not bad and perfectly acceptable for prototype testing (in my opinion). Then to handle the audio chime, I am using an Adafruit MAX98357A I2S 3W Class D Amplifier breakout together with the handy Adafruit I2S Zero library, which provided me with some great examples to work from. The SAMD21 also allows for Direct Memory Access (DMA) which can also assist with I2S audio. There is also a DMA library from Adafruit which has a very basic audio example but I haven't managed to get that far as yet to create an enhanced audio file an upload into DMA. For my speaker I am using a Tectonic transducer type, only because it is something I had in a drawer, and it works great inside a cardboard box (which I covered with a picture of Liverpool's superb victory against Manchester Utd.).
{gallery} Central Controller |
---|
Then for the user interface (HMI) at the remote Access Control Panel, I am using an Adafruit Feather 32u4 Bluefruit LE board, only because it was one I already had available that matched all my requirements. An enhancement to this choice would be either an Adafruit Feather M0 Bluefruit LE board or the Arduino MKR WiFi 1010 board as it uses the higher performance SAMD21 Cortex-M0+ chipset. As my standalone phase 1 option does not use BLE for now, I will have to test to see if the 32u4 is capable of handling this part too as it may not have enough memory and/or processing speed. The for the gate controller itself I am using the other Arduino MKR WAN 1300 board together with the relay proto shield.
{gallery} Remote Controller |
---|
The components I am using for the gate/door controller include:
- an injection moulded white enclosure from Adafruit, which is merged together with a bit of Sugru putty.
- an I2C LCD with RGB backlight from SeeedStudio
- a blue LED Tactile Button from Sparkfun, which is attached to the enclosure with more Sugru.
- a 3x4 matrix keypad from Multicomp, which is also attached and sealed to the enclosure with yet more Sugru.
- a 4-channel bidirectional logic level converter from Adafruit for the LCD (requires 5V)
- a passive piezo buzzer (requires pwm to drive) from Adafruit
- a TSL2561 Digital Luminosity/Lux/Light Sensor breakout from Adafruit
For the LoRa antenna I am using another GSM antenna from EAD-LTD as it was something I had.
For the power rail I am using a 5V power bank. I have also set it up that I can power down the Arduino MKR 1300 board when not required using a transistor. This then allows me to put the 32u4 Feather into deep-sleep mode which is woken up periodically to briefly flash the LED on the Sparkfun Tactile button or is placed into active mode when the button is pressed.
The real beauty of using Arduino based controllers is that there are open source libraries available for almost everything and most libraries can be used with different Arduino boards. The libraries used in this project include:
- wire.h for I2C bus (used for LCD and for TSL2561 sensor)
- SPI.h for SPI bus (used for LoRa module)
- rgb_lcd.h for LCD messaging
- Keypad.h for handling key presses on keypad
- SoftwareSerial.h for Serial bus between Feather 32u4 and MKR 1300
- LoRa.h for MKR 1300 LoRa functionality
- LowPower.h to put the Feather 32u4 into deepsleep
- Adafruit_ZeroI2S.h to play audio using the MKR 1300 board
The only interface snag I had was getting the Multicomp keypad to work correctly as this pin configuration differs from what is commonly used - one has to use a multimeter to figure out the matrix configuration. The rest worked straight out the box and only required customisation for the project itself.
Top-Level Business Logic
No doubt there are many other ways to handle the logic for a standalone system, and as it not the purpose of the project to get this optimised I have left it as is. The process flow logic I came up with is therefore as follows (watch video for demonstration):
Video Demo
Upcoming - Phase 2
So far, I am rather pleased with the outcome. I will attempt some real world testing too but as my antennas may not be optimum for LoRa I may not get great coverage. We will see.
Then for my next steps I will now develop the community aspect of the project. This will introduce the concept of a LoRa gateway, which acts as the interface between the Internet and the LoRa wireless network. In my case this gateway will be a very simple single channel private gateway as I plan to connect a WIFI module to the MKR 1300 board. However, with the MKR 1300 board I could also link into a public LoRaWAN network and use a public gateway to communicate to a cloud server. So plenty of options to play with.