No announcement yet.

Mail notification via Zigbee Sensor and LoRa Transport

  • Filter
  • Time
  • Show
Clear All
new posts

    Mail notification via Zigbee Sensor and LoRa Transport

    The problem-space being solved is awareness of US Mail delivery for a mailbox that is located 600 ft from house in a heavily wooded area. Several years ago a mail delivery notification unit available at Radio Shack was installed with a battery operated RF sensor on the mailbox lid and the receiver unit located about 100 ft away at the nearest power source. The audio of the receiver was interfaced to a UPB IO module so when the mail alarm sounded a UPB message was delivered to HS for notification.
    While protected from the elements the “inside rated” receiver died last year and replacement no longer available. The replacement solution is a combination of Zigbee, LoRa and MQTT technologies. Zigbee was selected for the mail delivery sensor based upon its efficient battery management. LoRa was selected for RF that spans the 600 ft non-line-of-sight distance. MQTT was used as a matter of convience.
    The sensor that was selected was a Xiaomi Aqara Vibration Sensor that is mounted on the door of the mailbox. The sensor is small and does not interfere with the mailbox operation.
    Click image for larger version

Name:	Capture1.PNG
Views:	34
Size:	23.3 KB
ID:	1409673
    The sensor worked well in bench testing with Y axis motion sensed. To receive the notification a CC2531 such as shown below was used. It was flashed with the same firmware as used for Zigbee2MQTT.
    Click image for larger version

Name:	Capture2.PNG
Views:	32
Size:	118.1 KB
ID:	1409674

    In field testing it appears the metal of the mailbox interfered with the operation of the vibration sensor. The sensor would work fine in free air, but not when mounted to the metal surface.

    The second choice was a Zigbee window/door sensor such as Aqara ZigBee Version Window Door Sensor. In this case the larger component was mounted at the same location as the vibration sensor on the mailbox lid. The smaller magnet was not use, but a smaller form factor magnet was installed at the top of the mailbox to provide the “pull” of the reed relay in the part mounted on the door. Since the mailbox was metallic the magnet could be mounted without any adhesive at the top inside behind the stop tab.

    Click image for larger version

Name:	Capture9.PNG
Views:	28
Size:	327.7 KB
ID:	1409681

    As a first choice for microcontroller to interface with Zigbee, ESP82666 running the Zigbee build of Tasmota was used. This project is early in the development cycle and out-of-the-box success was not achieved. My actual intent is to use ESP32 that has a LoRa interface integrated into its module and port the Zigbee code from ESP8266 to the ESP32 using the port developed for the BLE tracking project. Without success with ESP8266 I elected to put this approach on hold until the Tasmota-Zigbee matures.

    The backup is the proven Zigbee2MQTT development that uses a processor similar to a Raspberry Pi. In this case I utilized a Hardkernel Odroid C1 with DietPi OS (Debian Lite) installed. This previous effort was described in Section 15.

    Since the EPS32/Lora was on hold the LoRa interface became a pair of Ebyte EB32 LoRa transponders such as shown below. In my case the receiver was rated at 100 mw (which does not matter) and the transmitter at 1W. Both use 433 MHz. The approved frequency for LoRa in USA is 915 MHz so the 433 MHz China-approved frequency may not be legal in US. Since it is point to point and 433 MHz was a common sensor frequency, I felt comfortable using it. 433 MHz should actually be better through trees than 915 MHz.

    Click image for larger version

Name:	Capture4.PNG
Views:	27
Size:	28.9 KB
ID:	1409675

    The EB32 uses a RS232 or RS485 to interface the controller. I elected the RS232 using a USB/Serial adapter on the Odroid C1. This was a China-supplied adapter. I normally use a FTDI-clone chip, but tried an old Prolific chipset one. It was recognized, but had issues with going offline. I added software management in the C1 software to deal with it.

    On the HS side I used two different models of FTDI-based USB/Serial. Given it worked with Prolific and multiple FTDI I do not think the EB32 is very sensitive to the serial interface quality. In the end I used a Lantronix EPS1 (IP/Serial) adapter on the HS side so I could relocate the receiving EB32 to a higher location that had better reception. mcsMQTT was updated to receive Serial from either IP/Serial or COM sources.

    The Odroid C1 and EB32 were mounted in a repurposed Costco Chocolate Raisin container shown below. An angle grinder was used to slice slots in the lower side for ventilation. These are not visible in figure as they are located at the bottom so that they would not be affected by rain. A drill was used to penetrate the bottom for antenna and power cable penetration. A scrap wood bock was used to provide a physical barrio between EB32 and C1. A screw was use in the center of the lid to mount to a tree near the power source. It was snug but still allowed the lid to spin to engage the remainder of the container.

    Click image for larger version

Name:	Capture5.PNG
Views:	31
Size:	281.8 KB
ID:	1409677

    Click image for larger version

Name:	Capture10.PNG
Views:	30
Size:	323.7 KB
ID:	1409682

    Within the Odroid C1 are three packages. Zigbee2MQTT interfaces the CC2531 and delivers the changes of the mailbox sensor via MQTT. Mosquitto was installed as the MQTT broker. This was not the original choice, but became the most convenient as Mosquitto was an easy install option via DietPi. A .NET application was developed (LORA.exe) to subscribe to MQTT topics delivered by Zigbee2MQTT and convert the message to Serial for communication via LoRa.

    There were various issues on the initial installation so diagnostics were added to LORA.exe to help understand the issues that existed. A heartbeat was added to confirm the integrity of the LoRa link. Two-way communication via LoRa was not introduced as this added another potential failure mode and I did not feel there was sufficient benefit. I also had only 100 mw at the HS side of the LoRa communication so a lack of connection could easily be attributed to a weak transmit signal.

    LoRa.exe communicates using JSON payload. Screenshot below provides a snapshot that encompasses a period of time that includes multiple open/close of the mailbox lid and the heartbeat that is used to confirm the mailbox monitoring is occurring.

    The serial communication is encoded with “T” to be the topic which is always “Mail”. The payload is “P” with keys of “hb” for periodic heartbeat and “door” and “link” for the open/close position of the mailbox lid and the zigbee link quality between the sensor and the CC2531. A link of over 100 is reported when the two units are next to each other. In this case the two had a separate of about 50 ft.

    After this screenshot the battery status was also added. Typical of zigbee devices I expect long life of the battery. It is replaceable coin-like cell.

    LoRa is a low bandwidth technology. LORA.exe assured the bandwidth was not exceeded by shorthand notation of the message payload and limiting messages to a rate of one per two seconds. A standard LoRa Ebyte message can be no more than 56 characters.

    Click image for larger version

Name:	Capture6.PNG
Views:	33
Size:	44.8 KB
ID:	1409678

    With HS an event is setup to illuminate the Mail LED on the notification sign when mcsMQTT provides the status indication that the Mail door is at 0 (open) state. This LED remains illuminated until the IR remote is used to change the LED color from red to blue on the sign. The notification sign is described in Section 17.10 of the mcsMQTT manual.

    The HS setup of the device for mail status and reporting to illuminate the Notification frame is shown below. The status values are the LED RGB hex values that control the Notification frame. Blue indicates normal. Red indicates mailbox opened. Yellow indicates that the heartbeat has been lost.

    Click image for larger version

Name:	Capture7.PNG
Views:	27
Size:	13.1 KB
ID:	1409679

    Click image for larger version

Name:	Capture8.PNG
Views:	26
Size:	142.2 KB
ID:	1409680
    Attached Files