Hi. I have ordered the new KNOT Embedded LTE router to connect my garage to get notified to my home lab if somebody would try to pry open the door using magnetic Normally Open sensor or if a movement would be detected using a PIR sensor. There were some thefts during the holidays and I got sick of it, but it’s really hard to get some “low power” solution with internet connectivity.
Now the idea is to have also a camera from which I’d start RTSP poll in case of an event to store it at home. In continuous streaming that’d be roughly 500GB/month which is quite expensive for a mobile plan. So the idea is as follows:
KNOT is connected using WireGuard to my home lab
If PIR sensor detects motion OR door gets open, it triggers a GPIO high signal to which I react within KNOT
The event triggers a MQTT message to my home lab mqtt server from where I consume it with my own scripts + sends an SMS
Those scripts trigger RTSP download and set off a Apple Homekit alarm + some automation to wake me up in case of night…
I’m quite okish from the MQTT part to do it myself, though I’m quite new to GPIO and need help with that.
From what I see in the docs, KNOT operates on 2.45VMax for digital logic with 0-~1.4 LOW and ~1.4→2.45 HIGH, but most of the optocouplers I’d use would go with 3.3V. so maybe I should go with a relay or do a resistor bridge or I don’t know how. I need guidance on this, I’ve never did anything with GPIO, but I sense it should be the stuff I need to achieve my goal.
Any ideas/diagrams that could help pls? I don’t want to fry the GPIO on the KNOT.
Actually more recent boards (and I assume you will get one of those) have a pull-up resistor on the board, and the voltage should be:
With PCB pull-up resistor:
to receive a logical "0" on the pin, the voltage should be between 0-1.34 V;
to receive a logical "1" on the pin, the voltage should be between 1.35-2.5 V.
Newer routerboards will have a pull-up resistor on the PCB (on the board) - 10k ohm. Older boards (the first released batch) may need an external pull-up resistor.
Thank you. Now if I would like to test stuff out, could a rechargable AA battery (~1.3V) be used to send a signal directly to the digital pin ? Or is that a no-go ?
I would say a no-go, i.e. you are adding an additional layer of uncertainty to something that is already not fully documented.
Personally I don't buy (with all due respect) the Mikrotik's specs as being accurate.
It would be a very poorly designed logic if actually a 1.3399 volts is a 0 and 1.3501 volts are a 1 (or an extremely accurate mechanism, hardly usable with normal external components), usual logic has a (rather "wide") "no status" gap between what is considered a 0 and what is considered a 1, for both 5 V and 3.3 V TTL this is between 0.8 and 2.0 v, and most also have a lower limit of 0.4 and an upper limit of 2.4 v exactly to avoid the possibility that a minimal fluctuation in the voltage can accidentally trigger (or fail to trigger) something.
You could also try with a (bidirectional) logic level shifter, while most will be only 5v<->3.3V, some models allow conversion also with different voltages (getting it from the +/- power supplies on either side of the shifter), but really cannot say if they could work in this case, example:
In any case a 1.30 v battery should not be able to "trigger" a 1, if actually the needed voltage is 1.35 v.
Well, I’ve tried to stay away from Mikrotik my whole life exactly for this reason, though circumstances forced me to pull the trigger as their Knot embedded pretty much seems to do the trick for what I need to achieve.
Honestly, both basic PIR sensors and Door Magnets do binary triggering, so there’s not that much of a noise I believe. Not sure if a cheap PIR can do “voltage by sensitivity” output to be read. Hence … it pretty much should be enough even with the lack of docs, while relying on the community.
I do not really care about accidental triggers. That can be solved eventually by computed event logic within the mqtt consumer.
For the conversion I considered an optocoupler - something like https://techfun.sk/produkt/optoclen-s-izolaciou-3-3v-5v-12v-24v-napatovy-menic/ - in the 12v→12v and further lowering the output using resistor bridges from 12v down to 2.4v for the GPIO to understand and powering everything with a 12v adapter (including the door sensor). Not sure if the level shifter is needed in my scenario (might add even a higher complexity and error rate. Last thing I consider using just a Relay for simple “open/close” state.
Well over the weekend I tinkered with all the other stuff and the system works, boots, connects the camera, I can stream over rtsp from the remote garage. I even managed to get eSIM provisioned and deployed on it. Last stuff I need is the gpio part for PIR and mag sensor…
Open a ticket with support.
There are reports on the forum showing pin5 in /iot/gpio/digital/print, so maybe there is some other setting to be changed or your unit is defective.