-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
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:
- 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.
- 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.
- 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.
- 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:
- The Hub needs to process the received messages to determine which message (opened or closed) was received.
- 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.
- 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.
- With either option, the Hub issues a response message to the sensor.
Metadata
Metadata
Assignees
Labels
No labels