This is the first in a series of guides for building your own Sensor nodes. The firmwares for these will be just put into the one free download ZIP here: https://buymeacoffee.com/ripplebiz/e/355171
To kick things off, I'm starting with a simple but fun example of a Trip Sensor. This can be very useful if you have a large property and want to get intruder alerts. Also, with this particular setup, you can 'set-and-forget' and don't need to worry about battery levels, solar or whatever.
Shopping List:
Small 3.7V lithium battery
A limit switch, eg. https://s.click.aliexpress.com/e/_oFJ4mtV
Flash the firmware
Flash the 'Full-Image-XiaoS3-TripSensor.bin' firmware to offset 0. The firmwares with 'Full-Image-...' prefix will be merged, ie. have boot loader and partition tables included, so are for first-time flashing.
If you need more help on flashing, refer to This Post.
Wiring
All you need to do is solder (+) and (-) wires from your lithium battery, with the limit switch breaking (usually) the red wire. Also, the D2 GPIO needs to be pulled LOW, so just a wire from GND to D2. Refer to this diagram:
You need to wire the limit switch, so that OPEN is on/connected, and when pressed is off. ie. the limit switch being released completes the circuit. Also, once activated you want the circuit to stay on, so I 3D printed a sliding pull-tab and switch housing, with the tab attached to a string, and when tripped this pulls the tab out and the switch remains released (ie. On). You just slide the tab back into the housing to reset/turn the sensor OFF.
You could attach the string to a gate (or a door), for instance, and have that be the tripping/triggering.
Pairing with a T-Deck
This is the easiest, but you can also configure and monitor using the Ripple Commander app.
IMPORTANT: make sure the LoRa antenna is connected to the LoRa board!
NOTE: if you have used this Xiao before, in some other Ripple role, you'll need to erase the config first. After powering on quickly hold down the button on the top of the Xiao/LoRa combo for about 6 seconds then release.
Initially the Xiao will have no configuration, so on powering up it will be periodically sending a pairing request. The firmware bin filename should indicate what pairing code is required. On the T-Deck, go into Setup > Pair Device. Enter the pairing code, then press enter. After a short delay you should the screen below. Enter a unique ID and name for this device:
After pressing ENTER, there should be a few beeps, then a SUCCESS screen. Power off the Xiao, then on the T-Deck navigate back to the home screen. You should see a new item in the list with the name you assigned.
Test the Sensor
Activate the limit switch, ie. power it on, then after a few seconds you should get an alert. If the T-Deck screen is off, you should get a full-screen preview like normal text messages. Or, if you are in the home screen you should see an unread message counter like so:
If you navigate into the trip sensor you go to this details screen:
(The 'LOW' just refers to the sensor state, ie. the D2 pin is in the LOW state. For other sensors this can be, for instance, a temperature like "28.4C")
Power off the Xiao (ie. reset the limit switch), then select the 'Reset Alert' menu (tap on top-right) to clear the alert state. Now it's good to go once again, ie. in intruder detection mode again.
Under The Hood
When the trip sensor powers up, it first tries to sync its clock with the T-Deck (or whichever admin device configured it). Once it gets a reply, it then makes potentially multiple attempts to send the "ALERT" message, and keeps trying until acknowledged. The alert message will also have the timestamp back dated to when the trip alarm was triggered. So, you should see a fairly accurate 'x secs/mins ago' in the details screen, even if your T-Deck was OFF or out of range when the trip alarm was triggered.
Conclusion
OK, that's about it. This is a very handy setup to aid in your own security, and all you need is to have your T-Deck on you and you'll have the jump on the bad guys!