Skip to content

ENH: Report and track door/gate state #61

@BobGlicksman

Description

@BobGlicksman

Modify the sensor code to detect if the door/gate was opened or closed and send an appropriate message. Keep track of the current door/gate state (where?) and change it if a message is received indicating the opposite. Here are some details:

SENSOR CODE:

  1. change the MODE parameter in attachInterrupt() in loop() from FALLING to CHANGE. Note: it needs to be tested to verify that this works to wake up the microcontroller on both falling and rising edges.
  2. Immediately when the microcontroller wakes up and before waking up the LoRa module, wait a few milliseconds (to debounce the sensor contact) and then read the interrupt pin (pin 2) to determine the current state of the contact sensor.
  3. Proceed as normal to power up the LoRa module and send a message; but now there are two messages -- one says that the door/gate is closed and the other says that it is opened.
  4. Waiting for a response from the hub and retrying sending the message if no response is received is a good idea in this application.

HUB/CLOUD:

  1. The Hub needs to process the received messages to determine which message (opened or closed) was received.
  2. OPTION 1: The Hub keeps track of the current state of each door/gate. The Hub compares the last stored state of the door/gate with the message type and if they are opposite, the Hub changes the persistent door/gate state per the message.
  3. OPTION 2: The Hub reposts the received message to the Google App Script. The Google App Script reads the last stored state of the door/gate from the spreadsheet and compares with the message type. If they are opposite, the Google App Script changes the door/gate state in the spreadsheet.
  4. With either option, the Hub issues a response message to the sensor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions