Security Panel Extender ESP-12F
by btidey in Circuits > Sensors
4385 Views, 16 Favorites, 0 Comments
Security Panel Extender ESP-12F
This is an extender for a basic Security Panel controlling a wired alarm system. In my case this was a 4 zone Pyronix Sterling compact but the same principles apply to many wired alarm systems.
The extender uses a small ESP-12F (ESP8266) wifi module which fits inside the panel and provides the following extra capabilities.
- Notification to a phone if the alarm goes off
- Monitoring of the basic Zones, alarm state and battery voltage via a web browser
- Monitoring recent events (all sensor changes) via a web browser
- Allowing up to a 100 extra wifi based sensors to be added. These can trigger the main alarm and can also be monitored.
Hardware
The hardware requires the following components
- ESP-12F wifi processing module
- 3.3V mini buck converter (e.g. MP2307)
- 5 Schottky diodes (e.g. BAT85)
- 2 MOSFET n-channel switches (e.g. AO3400)
The schematic shows the schottky diodes used to interface to the 'cold side of the sensor switches to the ESP-12F GPIO. The GPIO is pulled up and the schottky diodes allow the sensors to pull down the inputs to ground while protecting against the 12V logic of the panel. For the Pyronix case the hot side of the sensor is connected to +12V through a 4K7 resistor and the cold is connected through a 4K7 resistor to ground. When the sensor is the normal closed state then the hot/cold are shorted together and have a potential of about 6V. If the sensor opens then the hot side goes to 12V and the cold side goes to ground. The module monitors the cold side and will sense a 0 when the sensor is activated.
5 points are monitored; the 4 base zones and the bell alarm trigger which is +12V in its normal state and goes to ground when triggered.
It is a good idea to check the panel to make sure the interfacing is similar. The two zone sensor wires can be checked by monitoring the voltage to 0V when the sensor is inactive / active. Similarly the Alarm trigger signal voltage should be checked.
A MOSFET switch is used to provide a sensor expansion method by wiring in series with the hot side of one of the zone sensors. Normally the switch is turned on and so the zone operates as normal with its normal sensor . The ESP-12F module can turn the switch off and simulate this zone sensor being activated (triggering an alarm if the panel itself is active.
The buck converter provides a source of 3.3V to run the circuit and this is fed from the normal sensor +12V supply. The back up battery connection is also wired in so that the battery voltage can be monitored by the ESP-12F ADC. I originally used the battery connection for both but this is not good as the trickle into the battery can be quite small and the module power would subtract off this.
The ESP-12F needs a 2k2 resistor from GPIO15 to GND, and the EN connected to Vdd to operate normally.
I constructed it by attaching the buck converter to the ESP-12F and using a small fragment of prototype board to mount the MOSFET switch circuit. I use SMD components to keep it as small as possible but equivalent through hole components could be used.
Software
The security panel extender uses an Arduino sketch available on github
This needs to adjusted to suit local conditions and then compiled in a esp8266 Arduino environment.
The following libraries needed, they are standard or can be added.
- ESP8266WiFi
- ESP8266WebServer
- ESP8266mDNS
- ESP8266HTTPUpdateServer
- ArduinoJson
- WifiClientSecure
- IFTTTMaker
DNSServer
WiFiManager (optional use)
Items in the sketch to be changed include
- Local wifi access details (ssid, password) if not using WifiManager
- Authorisation code for web access AP_AUTHID. It is good to make this a decent length. It can contain alphanumeric characters.
- firmware OTA password update_password
- WifiManager password WM_PASSWORD
- Wifi can be manually set up by commenting out WM_NAME
- IFTTT maker key (see the notification step)
Optional changes include
- Changing input pin allocation
- Battery calibration. One can measure the battery voltage with a meter and adjust the ADC_CAL to get it accurate.
Once this is done then it should first be uploaded using conventional serial upload. Subsequent update may be done by compiling an export binary in Arduino environment and then accessing the OTA interface at ip/firmware.
Installation
The module can be made very small and in my case there was plenty of room by the side of the battery to slip it in.
To make it easier to add/remove I put a 10 way jumper connector between the module and the panel wiring and I put an extra 1 way connector in the +12V supply to the module so that it can be plugged in before any power is applied to the module. This can also be used to do a power up reset.
The 4 zone sensors just go into the same cold side of the zone sensors. The expander+ replaces the sensor wire on one of the zone hot connectors which is then connected to the expander- wire. I just tight twisted them together and used heat shrink to secure.
The alarm sensor goes in parallel with the existing bell alarm trigger. In my case this was labelled BA.
When powered up for the first time then the wifi connection can happen in two ways. If manually set up by compiling in the wifi details and commenting out WM_NAME then it will try to connect immediately. If using wifiManager then the first time it will not know how to connect so it will start a wifi access point called securityWebSetUp. Connect to this network on a phone or tablet and then browse to 192.168.4.1 This brings up a panel to select the real local network and enter access details. The module will reboot and use the selected network and continue to do so directly even if reset.. If network connectivity fails then it will bring up the Access point wifi entry again.
Notification and Web Access
The notification is done by using the IFTTT service and the IFTTT phone app.
When the alarm goes off the module tries to trigger an IFTTT event by making a secure web access to the Maker Web Hook channel. The action part of the event is to send a notification request to the IFTTT phone app which will activate a notification on the phone.
One needs to register with IFTTT and activate the Maker webhooks channel. One needs to install the IFTTT phone app from the app store and login with same credentials.
On the IFTTT side create a new applet with Maker Webhook as the IF with an event name 'security'. The action should be an IFTTT notification. Configure it with OccurredAt, EventName, Value1, Value2, Value3. These will show up in the notification.
To get internet access to the security panel extender you will need to forward the port in your network router. It is also good to use a dns provider (e.g. freedns) to give your external ip address a name and to make it easier to maintain if it changes.
A test facility is available by accessing ip:port The password must be entered. If the event is 'security' then the test facility will send a test notification with the 3 values. If the event is 'zoneSet' then this will simulate a message from expander device (value1) with a value (value2).
Status may be obtained by using ip:port/status?auth=password. This gives the basic zones, battery level and whether the expander has triggered. A full status including the states of all expander modules can be obtained by using ip:port/status?auth=password&expand=true
Recent events may be obtained by using ip:port/recent?auth=password
Adding Expand Modules
Expand modules are wifi based units that can make a web request. They could for example be simple esp8266 units with a sensor attached.
To signal they make a web request to the security panel
ip:port/request?auth=password&event=zoneSet&value1=expandDeviceId&value2=state
where expandDeviceId can be from 0-99 and state should be 0 (OK) or 1(not OK)
It is good to allocate expandDeviceIds form 0 upwards as the software keeps track of the highest Id in use and this minimises overheads by keeping the number of devices down.