|
Post by papa on Oct 27, 2022 19:09:09 GMT
ESP32 DHT Node on HiLetgo OLED ESP32, Expected Results When the upload finishes, open the Arduino IDE Serial Monitor (SM). At the SM's lower right, make sure the SM's baud matches that in the sketch line #define SERIAL_BAUD 115200. It may help to press the ESP32 board's reset button. Then the SM will display boot info from the board.
The SM should show typical Node output (my notes in [ ] ) : Node 36 Version ESP32_nodes_nxxx MQCON 25 DHT 15 pwr 13 Fahr [Node ID #, code version, MQTT indicator is on pin 25, DHT data on pin 15 powered by pin 13 Fahrenheit Connecting to XXX [connecting to WiFi station named in sketch] .... [several dots may show while WiFi is connecting] WiFi connected IP address: 192.168.10.140 [Your IP will differ.]
Connect to MQTT broker...connected topic home/esp_gw/nb/node36/dev99 value:NODE 35 WAKEUP: ESP_36 [wakeup reported via MQTT broker
topic home/esp_gw/nb/node36/dev02 value:-66 [Radio Signal strength device 2, closer to zero the better] topic home/esp_gw/nb/node36/dev10 value:192.168.10.140 [IP device 10] topic home/esp_gw/nb/node36/dev48 value: 73.40 [73.4 degrees Fahrenheit] topic home/esp_gw/nb/node36/dev49 value: 34.00 [34% humidity] OR topic home/esp_gw/nb/node36/dev48 value: 23.00 [23 degrees Celsius]
Next, Configure OpenHAB for a ESP32 DHT Node
|
|
|
Post by papa on Oct 27, 2022 18:59:15 GMT
ESP32 DHT Node Software, Initial & Node Customization Use this thread for the latest software & initial customization. Software Customization for DHT Node:
At IDE/tools/Manage Libraries, search for DHT & install Adafruit version
At Arduino IDE/tools/Manage Libraries, search for Adafruit Unified Sensor & install the library with that exact name near list's end
In the software sketch, deactivate #define lines from previous nodes (have // at line's start). Change the nodeId if you have another node with that ID.
// [By comment / uncomment], ACTIVATE ONLY ONE of these two for your Temperature Scale: // #define FAHR // Fahrenheit << remove // to activate this line // #define CELS // Celsius
In the software sketch, find & activate these #define lines (delete // at the start) if needed, change pin assignments: // #define DHTPIN 15 // DHT data pin, uses internal pullup // #define DHTpower 13 // pin to power DHT sensor
// type of DHT sensor. Activate ONLY ONE of these two lines: // #define DHTTYPE DHT11 // #define DHTTYPE DHT22
Upload the customized software to the ESP32 board. Next, Expected results
|
|
|
Post by papa on Oct 27, 2022 18:49:44 GMT
ESP32 Node + DHT (Temp-Humidity) Sensor
Needed besides the ESP32 board:
A DHT Sensor: an individual DHT11 or DHT22 or either on a breakout board. The DHT22 sensor has a better resolution & a wider temperature & humidity measurement range. The DHT11 has a smaller range & is less accurate. It’s also cheaper. The DHT11 is probably adequate for most uses. That's what I use so far. An individual sensor has 4 pins & a breakout board has only 3.
Planning: Make your ESP32 pin choices & your connection choices based on your ESP32 board & the following.
Ways to connect ESP32 pins to the sensor's 3 male pins: 1) Solder at least 1.5 inches of color coded insulated wire to the 3 used DHT pins, bare the wire ends & plug into female headers on ESP32 board. OR 2) from the shortest male to female dupont cable, remove the plastic end of the female side. Put some heat shrink tubing on the cable. Crimp a dupont female end onto a DHT pin. Move the heat shrink tubing over the crimped female end/DHT pin. Shrink the tubing with heat. Method 1 creates a more compact node. Method 2 allows more distance between ESP32 pins used. I used method 1 & as shown below, I chose 3 pins near each other on my HiLetgo OLED ESP32 board. For me, powering the sensor with ESP32 pin 13 worked better than with a 3.3v pin
<< Click on pic for larger view.
Use the following as hints to connecting: DHT pin
| Function
| ESP32 pins, General Guide
| ESP32-papa | 1
| Power pin
| 3.3v or GPIO pin as output on high | 13 | 2
| Data
| GPIO pin | 15
| 3
| not used |
|
| 4 | GND | GND | GND
|
The provided software sketch uses ESP32 pin 15 for sensor data & pin 13 to power the sensor . You can change those, but avoid ESP32 pins 6-11 Next, Software & Initial Customization
|
|
|
Post by papa on Oct 24, 2022 19:48:21 GMT
Links for ESP32 Nodes with a Specific Sensor or Output Go to this thread for examples of basic nodes with one sensor & one output & related openHAB configuration.
See this thread on an ESP32 Node (SWITCH) for Door, Gate, Window, Mailbox...
|
|
|
Post by papa on Oct 23, 2022 21:55:42 GMT
Upgrade for ESP32 PIR Node (Interrupt) The last PIR software is moderately responsive in detecting motion. However, putting PIR code on an interrupt might be more responsive, especially if we create a node with more functions. At this post, download updated code with the option to put a PIR on an interrupt. To use the new option, follow customization shown above (incl possible OLED display). Then find & activate (delete // at the start) the new line #define PIRirq
Results on the Serial Monitor (& optional OLED display) should be similar to before, but may be somewhat more responsive. To see how the new code works, search the sketch for "ifdef PIRirq"
If you deactivate (add // to the start) #define PIRirq, the code will work as before & you can compare.
|
|
|
Post by papa on Oct 23, 2022 19:55:00 GMT
Display a Node's PIR Data on HABPanelGo to the browser address localhost:8080. At the upper right are two small icons, a pencil & a "page." Hovering the mouse pointer over the pencil shows "Edit Home Page." Over the "page," shows "Other apps." Click on the "Other apps" icon & then click on HABPanel. The browser address becomes " http://localhost:8080/habpanel/" The first time you use HABPanel, click the gear icon at the upper right. At the middle left, click on "Add new dashboard." For the new dashboard, enter a Name, perhaps "Main" & click OK. (I assume Node36 & a dashboard named "Main." Yours may differ.) Hover the mouse pointer over "Main" at the upper left. Click on the small pencil icon (edit dashboard) that appears. At the upper right, click on the [Add Widget] button. In Add Widget, choose Dummy (useful for text). In the new widget window at the upper right, click the 3 stacked dots. Choose Edit. Enter a Name, perhaps Door36pir. In the openHAB Item field, choose the desired Item to link. You can click the drop down icon & scroll down to the Item named Node36PIR. OR you can enter Node36PIR in the search box. Either way, click on the Node36PIR Item listed. Scroll to the bottom of the Edit Widget Window & click [ Save]. Click the [Run] button to see "Door36pir" in the Main dashboard. If the node is programmed & powered & something enters the PIR field of vision, "MOTION" should be displayed on the widget. If nothing is in the PIR field of vision, "NO MOTION" should be displayed. Next, Upgrade for ESP32 PIR Node
|
|
|
Post by papa on Oct 23, 2022 19:38:41 GMT
Create Item to Link to Node36's Channel 41, My Preference: Text Config File
Remember: Use only one method to create & edit an Item (Dashboard OR .items file) NOT BOTH. This method both creates the Item AND links it to the Node36 Thing's Channel 41. [Your node & Thing may differ.]
In openHAB's items folder (Linux /etc/openhab/items), have an .items file to hold the Item. Mine is called ESP32.items, but the name before the .items tag is up to you. The channel 41 Item takes the form: [ Your Item's Name & Label could differ.] String Name "Label [%s]" { channel=" Node36channelUID" } Go to localhost:8080/settings/things/ Click on the listed Node36 Thing Click on the [ channels] tab After the Node36_RSSI channel is a small stacked pages icon. Click on that icon to copy the channel UID Into the Item, paste that channel UID in place of Node36channelUID color-coded above. For example, my channel's UID is mqtt:topic:c08f02ca8d:3f938be488:Node36Channel41
So my Item (your channel UID for the Item will be different) is String Node36PIR "Door36pir [%s]" { channel="mqtt:topic:c08f02ca8d:3f938be488:Node36Channel41" } For display purposes only, go to localhost:8080/settings/items/nDoor Look at the field just below the top brightly-colored rectangle. If our Node is programmed & powered, that field should display the Node36's PIR state, e.g. MOTION or NO MOTION.
Next: Display Node36's PIR Data on HABPanel
|
|
|
Post by papa on Oct 23, 2022 19:26:36 GMT
Create Node36 Channel for a Node's Device 41 (PIR) [Your node ID & device may differ.]I'm adding a channel to a previously created Thing Node36. To create a different Thing, see here. See this post. We're making a channel for the MQTT topic home/esp_gw/nb/node36/dev41Logged in to your openHAB configuration, go to localhost:8080/settings/things/In the listed Things, click Node36. Then click the [channels tab] near the top. Near the bottom, click Add Channel. In the Add Channel Window, fill the fields with configs: Channel identifier Node36Channel41 ^^ arbitrary ? as long as we match it in a linked Item later (see below) Label Node36_PIR ^^ arbitrary ?, make it useful for yourself, but not too long Channel type Text Value ^^ choose type compatible with the device/channel data type MQTT State Topic home/esp_gw/nb/node36/dev41MQTT Command Topic [leave blank] Click "Show Advanced" & at Transform values/Incoming value transformations, enter MAP:pir.map [<< This will use the transform file we created earlier.] Outgoing Value Format, enter %s
Click [Create] to save your configs Next: Create Item to Link to Node36's Channel 41
|
|
|
Post by papa on Oct 23, 2022 19:21:49 GMT
Configure OpenHAB for a ESP32 PIR Node
Prepare to Transform the Node's Message
From Serial Monitor results above, we see that channel 41 (PIR) sends the MQTT message of ON or OFF. We'll use an openHAB feature to transform ON to MOTION & OFF to NO MOTION.
First in openHAB's transform folder (Linux /etc/openhab/transform), create a pir.map file with the contents:
ON=MOTION OFF=NO MOTION
Next, Create OpenHAB Channel for PIR
|
|
|
Post by papa on Oct 23, 2022 19:12:58 GMT
Add OLED Display to the ESP32 PIR NodeIf, as in this thread, you use an OLED display & add the OLED sketch customization, PIR state reports will show at the bottom of one of the OLED screens.
Next, Configure OpenHAB for a ESP32 PIR Node
|
|
|
Post by papa on Oct 23, 2022 18:55:18 GMT
ESP32 PIR Node on HiLetgo OLED ESP32, Expected Results When the upload finishes, open the Arduino IDE Serial Monitor (SM). At the SM's lower right, make sure the SM's baud matches that in the sketch line #define SERIAL_BAUD 115200. It may help to press the ESP32 board's reset button. Then the SM will display boot info from the board. A little after the node boots & connects to WiFi/MQTT, move your hand in front of the PIR sensor. Then remove your hand. Note the SM reports of PIR states.
The SM should show typical Node output (my notes in [ ] ) : Node 36 Version ESP32_nodes_nxxx MQCON 12 PIR 26 [Node ID #, code version, MQTT indicator is on pin 12, PIR on pin 26] Connecting to XXX [connecting to WiFi station named in sketch] .... [several dots may show while WiFi is connecting] WiFi connected IP address: 192.168.10.140 [Your IP will differ.]
Connect to MQTT broker...connected topic home/esp_gw/nb/node36/dev99 value:NODE 35 WAKEUP: ESP_36 [wakeup reported via MQTT broker]
topic home/esp_gw/nb/node36/dev02 value:-29 [Radio Signal strength device 2, closer to zero the better] topic home/esp_gw/nb/node36/dev10 value:192.168.10.140 [IP device 10] topic home/esp_gw/nb/node36/dev41 value:OFF [PIR state starts as OFF] PIR reads motion [motion detected ... topic home/esp_gw/nb/node36/dev41 value:ON [device 41 state confirms detection] PIR reads no motion [PIR detects nothing ... topic home/esp_gw/nb/node36/dev41 value:OFF [so device 41 reverts to OFF]
Next, Add OLED Display to the ESP32 PIR Node
|
|
|
Post by papa on Oct 22, 2022 17:46:52 GMT
ESP32 PIR Node Software, Initial & Node Customization Use this thread for the latest software & initial customization. Software Customization for PIR Node: In the software sketch, deactivate #define lines from previous nodes (have // at line's start). Change the nodeId if you have another node with that ID. In the software sketch, find & activate these #define lines (delete // at the start):
// #define PIR // activates code for PIR presence / motion sensor // #define PIR_PIN 26 // ESP32 pin for PIR data pin, avoid 6-11 [^^ change if you don't use pin 26] If you want to use an OLED display with the PIR ... in the software sketch, find & activate these #define lines (delete // at the start): // #define ENABLE_SSD1306 // #define I2C_ SDA 5 // #define I2C_ SCL 4 If you connect SDA & SDL to different pins, change the 2nd & 3rd lines accordingly. Upload the customized software to the ESP32 board. Next, Expected results
|
|
|
Post by papa on Oct 22, 2022 17:36:31 GMT
ESP32 Node + PIR Motion Sensor Needed besides the ESP32 board: Sensor such as Mini PIR motion sensor (AM312) or PIR motion sensor (HC-SR501) Ways to connect ESP32 pins to the sensor's 3 male pins. I have female headers on my ESP32 board so I use (color-coded) male to female dupont cables. Connect as follows: ESP32 | AM312 Sensor
| HC-SR501 | 3.3 v
| power pin
| not used
| 5 v
| not used
| 5v pin
| 26 ??
| Data | Data
| GND | GND | GND |
The provided software sketch uses ESP32 pin 26 for sensor data. You can change that, but avoid ESP32 pins 6-11 Next, Software & Initial Customization
|
|
|
Post by papa on Oct 20, 2022 20:25:33 GMT
ESP32 & OLED, Other PossibilitiesOther customization you might do for now: Put your own text into msg02 & msg05-msg08. Pay attention to the length of those variables. Options to be documented later:
- openHAB can command different messages for the OLED display.
- PIR presence status can be shown on the OLED display.
|
|
|
Post by papa on Oct 20, 2022 20:22:05 GMT
ESP32 OLED Node, Expected resultsFor topics, the IDE Serial Monitor will show only RSSI & the board's IP address.
Note, like many computer things, OLED display coordinates start counting up from zero.
When the node boots up, the first OLED screen will show: msg01 = "OLED 0.0"; // OLED screen 1, line 0 msg02 = "OLED 0.1"; // line 1, IP address for a while, then blank Then the next screen will show: msg05 = "OLED 1.0"; // line 0 msg06 = "OLED 1.1"; // Screen 2, line 1 msg07 = "OLED 1.2" ; // Screen 2, line 2 msg08 = "OLED 1.3" ; // line 3 Then the OLED display alternates between the first & second screens. To see how the OLED programming works, search for ifdef ENABLE_SSD1306 Next, ESP32 & OLED, Other Possibilities
|
|
|
Post by papa on Oct 20, 2022 20:18:18 GMT
ESP32 OLED Node CustomizationIn the software sketch, deactivate #define lines from previous nodes (have // at line's start). Change the nodeId if you have another node with that ID. In the software sketch, find & activate these #define lines (delete // at the start): // #define ENABLE_SSD1306 // #define I2C_ SDA 5 // #define I2C_ SCL 4 If you connect SDA & SDL to different pins, change the 2nd & 3rd lines accordingly. Upload the customized software to the ESP32 board. Next, Expected results
|
|
|
Post by papa on Oct 20, 2022 20:11:34 GMT
ESP32 OLED Node Software & Initial Customization Use this thread for the latest software & initial customization. Also the Arduino IDE needs to load an OLED software library.... In Arduino IDE, open Tools/Manage Libraries... Search for & install "ESP8266 and ESP32 Oled Driver for SSD1306 display" Next, ESP32 OLED Node Customization
|
|
|
Post by papa on Oct 20, 2022 20:04:48 GMT
ESP32 Node with OLED Display, IntroductionA 0.96 inch SSD1306 OLED display is a nice ESP32 board accessory. The I2C method is used to communicate with the OLED via an SDA pin & a SCL pin. The easiest way may be to get an ESP32 board with hard-wired OLED, like HiLetgo OLED ESP32. On this board, SDA is pin 5 & SCL is pin 4. This is the board I have. Or get an separate OLED with I2C communication protocol to connect to your ESP32 Board. Such an OLED has four pins to connect: Vin (ESP32 3.3v), GND (ESP32 GND), SDA, & SCL. If pins 4 & 5 are usable on your board, connect OLED SDA to ESP32 pin 5 & SCL to pin 4. See here for other possible pins. Disclosure: I have a hard-wired OLED, not a separate OLED board.
Next, Software & Initial Customization
|
|
|
Post by papa on Oct 19, 2022 19:55:40 GMT
Other Uses for SWITCH1 (& Other) StatesVia rules, openHAB can be configured to act based on states reported from nodes. In openHAB's rules folder (Linux /etc/openhab/items), you could have a .rules text file, for example ESP32.rules. (See here.) The start of some textual rules: "ruleOne"
when Item nDoor received update then [ action ] end "ruleTwo"
when Item nDoor changed from CLOSED to OPEN then [ action ] end
----------------------------------------------- Or you could go to http://localhost:8080/settings/rules/ & use the dashboard to create rules. (See here.) ==============================
If WiFi will connect reliably to it, a ESP32 node might monitor a mailbox. Via SWITCH1 (or ...2 or ...3), a tilt switch could signal change in a mailbox door &/or flag.
|
|
|
Post by papa on Oct 19, 2022 19:03:34 GMT
Display a Node's SWITCH1 Data on HABPanelGo to the browser address localhost:8080. At the upper right are two small icons, a pencil & a "page." Hovering the mouse pointer over the pencil shows "Edit Home Page." Over the "page," shows "Other apps." Click on the "Other apps" icon & then click on HABPanel. The browser address becomes " http://localhost:8080/habpanel/" The first time you use HABPanel, click the gear icon at the upper right. At the middle left, click on "Add new dashboard." For the new dashboard, enter a Name, perhaps "Main" & click OK.
(I assume Node36 & a dashboard named "Main." Yours may differ.)
Hover the mouse pointer over "Main" at the upper left. Click on the small pencil icon (edit dashboard) that appears. At the upper right, click on the [Add Widget] button. In Add Widget, choose Dummy (useful for text).
In the new widget window at the upper right, click the 3 stacked dots. Choose Edit. Enter a Name, perhaps nDoor36. In the openHAB Item field, choose the desired Item. You can click the drop down icon & scroll down to the Item named nDoor. OR you can enter nDoor in the search box. Either way, click on the nDoor Item listed. Scroll to the bottom of the Edit Widget Window & click [ Save]. Click the [ Run] button to see "nDoor36" in the Main dashboard. If the node is programmed & powered & a jumper connects ESP32 pin 13 & GND pin, "CLOSED" should be displayed on the widget. If the jumper does not connect the pins, "OPEN" should be displayed. Other Uses of SWITCH1 States
|
|
|
Post by papa on Oct 19, 2022 15:52:02 GMT
Create Item to Link to Node36's Channel 43, My Preference: Text Config File
Remember: Use only one method to create & edit an Item (Dashboard OR .items file) NOT BOTH. This method both creates the Item AND links it to the Node36 Thing's Channel 43. [Your node & Thing may differ.]
In openHAB's items folder (Linux /etc/openhab/items), have an .items file to hold the Item. Mine is called ESP32.items, but the name before the .items tag is up to you. The channel 43 Item takes the form: [ Your Item's Name & Label could differ.] String Name "Label [%s]" { channel=" Node36channelUID" } Go to localhost:8080/settings/things/ Click on the listed Node36 Thing Click on the [ channels] tab After the Node36_RSSI channel is a small stacked pages icon. Click on that icon to copy the channel UID Into the Item, paste that channel UID in place of Node36channelUID color-coded above. For example, my channel's UID is mqtt:topic:c08f02ca8d:3f938be488:Node36Channel43
So my Item (your channel UID for the Item will be different) is String nDoor "northDoor36 [%s]" { channel="mqtt:topic:c08f02ca8d:3f938be488:Node36Channel43" }
For display purposes only, go to localhost:8080/settings/items/nDoor Look at the field just below the top brightly-colored rectangle. If our Node is programmed & powered, that field should display the Node36's SWITCH1 state, e.g. OPEN or CLOSED.
Next: Display Node36's SWITCH1 Data on HABPanel
|
|
|
Post by papa on Oct 19, 2022 15:36:07 GMT
Create Node36 Channel for a Node's Device 43 (SWITCH1) [Your node ID & device may differ.]I'm adding a channel to a previously created Thing Node36. To create a different Thing, see here. See this post. We're making a channel for the MQTT topic home/esp_gw/nb/node36/dev43Logged in to your openHAB configuration, go to localhost:8080/settings/things/In the listed Things, click Node36. Then click the [channels tab] near the top. Near the bottom, click Add Channel. In the Add Channel Window, fill the fields with configs: Channel identifier Node36Channel43 ^^ arbitrary ? as long as we match it in a linked Item later (see below) Label Node36_Door ^^ arbitrary ?, make it useful for yourself, but not too long Channel type Text Value ^^ choose type compatible with the device/channel data type MQTT State Topic home/esp_gw/nb/node36/dev43MQTT Command Topic [leave blank] Click "Show Advanced" & at Transform values/Incoming value transformations, enter MAP:door.map [<< This will use the transform file we created earlier.] Outgoing Value Format, enter %s
Click [Create] to save your configs Next: Create Item to Link to Node36's Channel 43
|
|
|
Post by papa on Oct 19, 2022 15:12:48 GMT
Configure OpenHAB for Node SWITCHes Prepare to Transform Node's SWITCH1 Message
(For SWITCH2 or SWITCH3, adapt the following posts.)
From Serial Monitor results above, we see that channel 43 (SWITCH1) sends the MQTT message of ON or OFF. We'll use an openHAB feature to transform ON to CLOSED & OFF to OPEN.
First in openHAB's transform folder (Linux /etc/openhab/transform), create a door.map file with the contents:
ON=CLOSED OFF=OPEN
Next, Create OpenHAB Channel for SWITCH1
|
|
|
Post by papa on Oct 18, 2022 20:10:37 GMT
Serial Monitor Results for ESP32 Node with SwitchThis is only the results that relates directly to a switch.
If SWITCH1pin is activated on node 36: [Your node ID may differ]
topic home/esp_gw/nb/node36/dev43 value:ON [switch closed, ?? dupont cable connected on both ends] topic home/esp_gw/nb/node36/dev43 value:OFF [switch open, perhaps when dupont cable pulled from ESP32 GND If SWITCH2pin is activated on node 36: topic home/esp_gw/nb/node36/dev44 value:ON [switch closed] topic home/esp_gw/nb/node36/dev44 value:OFF [switch open, perhaps when dupont cable pulled from ESP32 GND If SWITCH3pin is activated on node 36: topic home/esp_gw/nb/node36/dev45 value:ON [switch closed] topic home/esp_gw/nb/node36/dev45 value:OFF [switch open, perhaps when dupont cable pulled from ESP32 GND
Next, Configure OpenHAB for Node SWITCHes
|
|
|
Post by papa on Oct 18, 2022 19:51:32 GMT
ESP32 Node Software for SwitchesSee this thread & this thread for the latest program code, initial customization, examples of node customization, & related openHAB configuration.
Node Specific Customization:
Remember that each WiFi node must have a unique nodeId.
Deactivate node #defines left over from a previous node.
Find the 3 lines: // #define SWITCH1pin 13 // ... // #define SWITCH2pin 14 // ... // #define SWITCH3pin 15 // ...
Edit those lines to match how you wired your node. For every switch you use, activate its #define (delete // at the start). If you change the pin a node switch uses from 13, 14, or 15, change the #define accordingly. For example, if you wire a switch to pin 13, change // #define SWITCH1pin 13 to #define SWITCH1pin 13 [no //]
To test the node, wire a male to male dupont cable from the switch's pin (13 for example) to an ESP32 GND
Upload to a USB connected node.
Next, Serial Monitor Results for ESP32 Node with Switch
|
|
|
Post by papa on Oct 18, 2022 18:35:07 GMT
ESP32 Node with More Than One Switch
An ESP32 Node can monitor more than one switch. See the following example of monitoring both a reed switch (for a garage door) AND a dead bolt switch for a people door.
In this case, ESP32 pins 13 & 14 are used.
<< Click on pic for larger view
Next, ESP32 Node Software for Switches
|
|
|
Post by papa on Oct 18, 2022 18:27:51 GMT
ESP32 Node for Dead Bolt LockThis method senses when a garage's vehicle door is TOTALLY closed or (even partly) open & when a people door's deadbolt is closed or open. For installing the switch sensors, besides the schematic above, see the following diagram & picture: << Click on pic for larger view
<< Click on pic for larger view ^^ Looking into the dead bolt receiving hole Sensing the status of the people entrance door: My people door dead bolt is metal. With steel wool, I polished the end for best conductivity. Across the bottom of the dead bolt receiving hole, I installed two bared ends of 24 gauge insulated wire so the bottom of the hole was divided into horizontal (unequal) thirds. Using a 16 finishing nail as a drill bit, I drilled two holes that went about level from the drywall right next to the door frame to the inside edge of the end of the dead bolt hole. Level & opposite to the first two holes, I made two more tiny holes to hold tightly the end of the bared wires. The insulated part of each wire goes through from the dead bolt hole to the side of the door frame & to its ESP32 connection. The bared part of each wire (with separation between wires) goes across the (padded?) bottom of the dead bolt hole & is anchored in its tight hole. As I did, you may have to put folded cardboard (or other insulating material) under both bared wires so a fully extended dead bolt touches them. Thread the longer insulated parts of the wires through the side of the dead bolt hole toward the ESP32. There one bared end goes to ESP32 GND & the other bared end to ESP32 pin 13. As necessary, conceal the wires next to or beneath door trim pieces. When the people door is NOT dead bolted, an software pull-up holds pin 13 HIGH. When the dead bolt fully extends & touches the two bare wires, it functionally closes a switch, connecting 13 to GND & making it LOW. The node sends this data to OpenHAB via MQTT.
Next, ESP32 Node with More Than One Switch
|
|
|
Post by papa on Oct 18, 2022 15:56:27 GMT
ESP32 Node with Reed Switch for Window, Gate or Garage Door:
This method senses when a window or gate is TOTALLY closed or (even partly) open. For installing the switch sensors, besides the schematic above, see the following diagram & picture: << Forum members, click on pic for larger view For wiring, I suggest you use insulated 24 gauge wire which can be hidden under trim, etc.
Sensing the status of the window or gate: A strong magnet is mounted on the edge of the window or gate. A magnet could be attached (magnetically, glue) to the steel cable pin at the bottom corner of a garage door.
Opposite the magnet at the closed position, mount a (normally open) reed switch to be near, but not touching the magnet. A magnet near the reed switch closes the switch, connecting ESP32 pin 14 to GND, making the pin LOW which will help signal OpenHAB that the window or gate is totally closed. When the magnet & reed switch are away from each other, a software pull-up holds ESP32 14 HIGH, indicating the window or gate is at least partly open. With customization, the software code allows one to use one to three of the ESP32 pins 13-15. Other available ESP32 pins could be used. A node can monitor more than one switch.
Next, ESP32 Node for Deadbolt Lock
|
|
|
Post by papa on Oct 17, 2022 21:45:11 GMT
ESP32 Node for Door, Gate, Window, Mailbox... Switch Sensor NodeVarious switches can be effective sensors for the states of things like doors (garage & people), windows, gates, mailboxes, etc. Such sensors include reed switches, tilt switches, & even dupont cable jumpers between an ESP32 I/O pin & a GND pin. See this thread & this thread for the latest program code, initial customization, examples of node customization, & related openHAB configuration. A switch sensor node might have one, two, or three switches to monitor one or more doors &/or windows &/or mailbox features. The program code uses ESP32 pins 13, 14, & 15. One could change the code to use other pins as long as those pins are available ( see here). The code applies a pullup resistor to the pins (avoids a physical resistor) to give the pins a reliable state of one/HIGH. Then the code detects when the switch closes & changes the pins' state to zero/LOW. Via MQTT, a switch node can send a switch's state to openHAB. OpenHAB can display the state (e.g. HABPanel) & take action based on the state (e.g. rules). See the following wiring diagram for one to three switches. << Forum members, click on pic for larger view. Next, Installing a Switch Sensor for a Door's Deadbolt
|
|
|
Post by papa on Oct 15, 2022 20:23:11 GMT
Create Item to Link to Node36's Channel 16In an .items file, create an item entry based on the following. However, replace my channel UID with your channel UID determining it like you did in this post above. Refresh the openHAB dashboard & the channel should link to the just created Item.
To display on HABPanel, use a Switch widget. The HABPanel switch tile should report the state of the ACTOR pin (clicks of the push button changes the state). Also clicking the HABPanel tile should toggle the state of the ACTOR pin & LED on the ESP32 node.
Nodes can have other devices/channels/functions which can be linked to openHAB via configurations similar to those just above in this thread.
Next: ...
|
|