Domoticz Contact Monitor (B4R)

Experiments & prototyping with the Arduino.
rwblinn
Site Admin
Posts: 210
Joined: 07 Oct 2017, 12:16

Domoticz Contact Monitor (B4R)

Postby rwblinn » 20 Dec 2017, 12:23

Objectives
Create a Domoticz Contact Monitor which indicates via LED and a Buzzer when a contact is opened.
The solution is flexible for additional contacts to monitor.

Solution
An ESP8266 connects to a local network and subscribes using MQTT to Domoticz topic "domoticz/out".
If a contact device is recognized, via its idx, then an alarm is turned on: LED RED and the Buzzer for 10 seconds.

Parts Needed
  • 1x ESP8266 - used an old WeMOS D1 (retired) as prototype
  • 1x LED RED + 220 Ohm Resistor - the alarm LED
  • 1x LED BLUE + 220 Ohm Resistor - the status LED
  • 1x Piezo Buzzer
  • 1x Battery 9v - for the ESP8266
Wiring

Code: Select all

LED Blue Status Control = ESP
+ = D3 GPIO5 Pin 5 (green)
GND = GND (black)

LED Red Alarm = ESP - for the frontdoor contact
+ = D4 GPIO4 Pin 4 (red)
GND = GND (black)

Buzzer = ESP
+ = D5 GPIO14 Pin 14 (brown)
GND = GND (black)


Circuit
Image

Prototype
Image

Download
Download B4R source code.

Software
ToDo
  • Experiment is completed.
Version
20171220

MQTT
The MQTT protocol is used to communicate between Domoticz and the ESP.
The B4R program running on the ESP subscribes to the Domoticz topic "domoticz/out".
From the payload, the idx is checked and if a contact device is found then the alarm is turned on (LED and Buzzer).
Example of Domoticz Message, which is parsed to obtain the idx of the contact device:

Code: Select all

{   
"Battery" : 255,   
"RSSI" : 6,   
"description" : "",   
"dtype" : "Lighting 4",   
"id" : "5C0703",   
"idx" : 58,   
"name" : "FrontDoor",   
"nvalue" : 1,   
"stype" : "PT2262",   
"svalue1" : "512",   
"switchType" : "Contact",   
"unit" : 0
'}

Note
The B4R code defines a sub to parse the JSON string. This sub is flexible and can be applied to to other solutions requiring MQTT parsing.

Return to “Arduino”

Who is online

Users browsing this forum: No registered users and 2 guests