Menu

Tree [r483] /
 History

HTTPS access


File Date Author Commit
 components 2023-02-05 dannybackx [r481] Attempt to merge rcswitch and wtdecoder, so it'...
 libraries 2022-12-24 dannybackx [r479] Not referenced anywhere
 main 2023-02-05 dannybackx [r483] Update copyright date
 mobile 2020-04-10 dannybackx [r300] Add directory
 pcb 2018-08-19 dannybackx [r49] Add v1 of the PCB
 CMakeLists.txt 2021-10-03 dannybackx [r399] Replace legacy build configuration
 LICENSE 2018-08-19 dannybackx [r47] Add license file, remove pubsubclient
 Readme.md 2022-12-29 dannybackx [r480] A version of rcswitch without Arduino dependenc...
 config.json.sample 2020-10-24 dannybackx [r348] Add sample json configuration file (to be uploa...
 partitions-mine.csv 2021-10-03 dannybackx [r400] Add partitions file, required for large code pa...

Read Me

House alarm system based on ESP32

Copyright (c) 2017, 2018, 2019, 2020, 2021, 2022 by Danny Backx

This alarm system is designed to work with a bunch of similar controllers.
You can choose which hardware and capabilities go in each individual controller, and configure them accordingly.

The software needs a small amount of configuration to talk to the hardware.
With no configuration, the software will format a LittleFS partition, start an FTP server,
and you can use that to upload a file into /fs/config.json .

A sample content :

{ "name" : "prototype",
"haveOled" : true, "oledLedPin" : 5, "oledCSPin" : 17, "oledDCPin" : 16,
"run_ftp" : true, "ftp_user" : "me", "ftp_pass" : "myself",
"radioPin" : 22,
"sensors" :
{ "name" : "Hall motion", "id" : 0x00CD4FAA, "zone" : "secure" },
{ "name" : "Kitchen smoke", "id" : 0x004F55E8, "zone" : "always" },
{ "name" : "Upstairs smoke", "id" : 0x007DF9E8, "zone" : "always" }

}

It's obviously possible to turn off FTP to make the system less hackable, the flip side is that
recovery is harder.

This software should be built with ESP-IDF, the build environment recommended by Espressif.
Note : currently works on esp-idf-v4.4 .

Components required (you need to put these in components/) :
- arduino (https://github.com/espressif/arduino-esp32.git)
- littlefs (a simple filesystem superior to the well known spiffs, https://github.com/ARMmbed/littlefs.git)
- esp_littlefs (esp-idf integration for littlefs https://github.com/joltwallet/esp_littlefs.git)
- arduinojson

Three components should be included, but are optional :
- acmeclient (https://esp32-acme-client.sourceforge.io), to have mutually authenticated communication
- firebase (https://esp32-firebase.sourceforge.io) to push messages to your phone,
this works via FCM (Firebase Cloud Messaging), a freely available service.
- rcswitch (my version has no Arduino dependencies, and is included here) interprets
signals from a 433MHz radio receiver

Acmeclient and Firebase are mine, the other is borrowed, see copyrights in source files.

Arduino libraries (these are already copied in libraries/) :
- TFT_eSPI (Bodmer's stuff with small changes)
- rfid (optional)
- QR code generation with the C version of https://www.nayuki.io/page/qr-code-generator-library (optional)

Libraries for temperature sensors should be copied into libraries/ :
- Adafruit (Sensor, BusIO, AHTX0, BME280, MCP9808)
See https://github.com/adafruit/Adafruit_AHTX0 and similar for the source.

In the "make menuconfig -> Arduino", only the Arduino libraries ESP32, Wire and SPI are needed. Hence advice
to select "Include only specific Arduino libraries".

Hardware platform :
- ESP32 (esp8266 not supported any more)
- Some sensors with wireless RF communication
* https://www.aliexpress.com/item/Kerui-433MHz-Wireless-Intelligent-PIR-Sensor-Motion-Detector-For-GSM-PSTN-Security-Alarm-System-Auto-Dial/32566190623.html?spm=a2g0
s.9042311.0.0.04PnSB
* https://www.aliexpress.com/item/433MHz-Portable-Alarm-Sensors-Wireless-Fire-Smoke-Detector/32593947430.html?spm=a2g0s.9042311.0.0.04PnSB
- Keypads with touch displays
* https://www.aliexpress.com/item/1pcs-J34-F85-240x320-2-8-SPI-TFT-LCD-Touch-Panel-Serial-Port-Module-with-PCB/32795636902.html?spm=a2g0s.9042311.0.0.04PnSB
- RF receivers
* https://www.aliexpress.com/item/1set-2pcs-RF-wireless-receiver-module-transmitter-module-board-Ordinary-super-regeneration-433MHZ-DC5V-ASK-OOK/32606396563.html?spm
=a2g0s.9042311.0.0.04PnSB
- RFID card readers
* https://www.aliexpress.com/item/2pcs-lot-MFRC-522-RC522-RFID-Kits-S50-13-56-Mhz-With-Tags-SPI-Write-Read/32620671237.html?spm=a2g0s.9042311.0.0.tm7J7e
* https://www.aliexpress.com/item/PN532-NFC-RFID-Module-V3-Kits-Reader-Writer/32452824672.html?spm=a2g0s.9042311.0.0.XugjzW

I have a PCB design that can be used to build a controller module with minimal wiring.
See my project on easyeda.com, or the copy in pcb .
The v1 has one known bug : the radio data line should go to esp32 pin 27 instead of pin 22.

Note : you may need to set some parameters in "make menuconfig" to make this work
- CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=4304 (was 2304)
to prevent eventTask from running out of stack space
- CONFIG_FREERTOS_USE_TRACE_FACILITY=y if you want to be able to list the ESP32 tasks,
or their memory/stack usage
(menuconfig->Component config->FreeRTOS->Enable FreeRTOS trace facility)
- For mutual authentication to work (in WebServer.cpp and JsonServer.cpp) we need a patch
on esp-idf which was integrated in esp-idf-v4.4 .

February 2022 note : I've asked for another addition so we also get a user_cb call
when a connection is broken. This would allow for cleanup.
Sample fix supplied, see https://github.com/espressif/esp-idf/issues/8288 .

You'll need to apply that fix for the newer code to work.

Security

Please note that this source code allows setting up your system securely, but it's easy
to screw that up by e.g. whitelisting the IP address of a forwarding server.
Especially the "whitelist" configuration entry, and also the client_certificates configuration
entry, can be used to cause such security holes.

Special function

I built a power switch based on an esp8266. That board is rather limited so I didn't feel like
trying to integrate a fully authenticated and secured web server in it. It does have a simple
web server, only locally accessible.

A proxy can be enabled in the alarm controller to forward https sessions to the power switch,
thus shifting the security and encryption to an esp32.
This is not compiled by default, see menuconfig.