I’ve bought HTCC-AB01 board to make a sensor for my letterbox. I’ve also bought a battery and two reed sensors. This is my rig: https://ibb.co/dmGfGZr
I’m not a programmer at all, but somehow I’ve managed to develop the code in Arduino IDE through several “stages”:
- First, I’ve successfully connected it to TTN
- Than I’ve managed to read state of two reed sensors and pass it to TTN
- Then I’ve added battery and read battery voltage and calculated battery state
- I’ve added also a payload formater at TTN app, so I see all data I wanted to see:
- contact sensor #1 state (boolean)
- contact sensor #2 state (boolean)
- battery voltage (V)
- battery level (%)
- I also see that the board is put to sleep mode between transmit cycles.
I’m struggling with the last state - waking it up on contact sensor state.
I’ve used the interrupt example but I’m lost here:
a) First I wanted to transmit both edges - rising and falling. But that does not work reliably. Sensor open state (1) is usually transmited, but sensor close state (0) is not. Is that becuse of LoraWAN transmission limitations?
b) So later I’ve decided to transmit only rising edge (sensor opening) but I’m event failing on this. The board is woken up on both state changes and I don’t know why.
Anyway it doesn’t work reliably.
Here’s my code:
Any tips / ideas / optimalisations - very welcome!