Wake up when motion is detected

Hi there,
I recently worked on a bird watcher project using Fin. To take the project further, I like to put a PIR sensor to Fin and wake up the module when any motion is detected, to reduce power consumption. I have Fin 1.1.1 and I looked at Finabler and supervisor APIs. At present my project has 3 services ( camera, face & tweet) … I am planning to add another service ( motion ) which will be connected to PIR sensor. When no motion is detected for certain time, it will shutdown other 3 services using supervisor api. When any motion is detected, it will start up those 3 services. But one issue with this approach is “motion” service is always running. Is there any better way to achieve the same outcome? My ultimate goal is to power the bird watcher using solar panel and need to run it on lowest possible power.

Thanks,
Mithun

Hi Mithun,

I think the best way to achieve this would be to sleep the device and wake it when the PIR signals to the coprocessor GPIO. However the Finabler block hasn’t had that implemented yet - I’ve raised an issue to track it though: Support waking device on coprocessor GPIO signal · Issue #22 · balenablocks/finabler (github.com)

Phil

Thanks Phil ! I will keep an eye on this. Can I achieve the same without using Finabler block for time being? I mean using supervisor APIs … I guess I need to learn more about coprocessor and GPIO signal. Is there any good online resource to learn?

This is doable, but we don’t have an example for this at the moment.

I have pinged the maintainer for this about an ETA

In the meantime, if you are feeling brave enough you could give this a shot yourself - we always contributions to our projects from the community :slight_smile:

We have the balena-fin-firmata project, which has a nifty application on the coprocessor to do things like read an analog pin, or write some other pin, etc. More about it here

The right way to do this would be to add this functionality to the coprocessor application that’s part of this repo, so that you can use flashing, and communication interfaces that are already built for you.

Thanks Anuj ! Will take a look.

I deployed finabler block and I was able to sleep the compute module using REST API sleep. This was an east get. I can call same API from the container running PIR sensor to sleep the module. Also in the pin map , it says

16 - PF5 - PW_ON_3V3 - balenaFin Power Rail (used for sleep mode)

Does it mean that, if I send high to pin 16, module will wake up? If so, then I can connect PIR sensor to this pin and module should wake up when motion is detected … on the flip side, it may sleep when no motion … am I going in entirely opposite direction?

Hi Mithun, I am the maintainer for the coprocessor firmata repo; pin 16 is not exposed externally on the coprocessor GPIO header of the balenaFin and is internal to the PCB so you can’t easily connect your PIR sensor to it. Regardless, setting this pin high/low is not a recommended method as it is software controlled by the coprocessor and could result in accidentally driving too much current into the input pin. The best solution here is to add a handler for the sleep function from firmata to accept a pin value that can break the sleep event on an external HIGH/LOW pin digital read and wake the fin back up again. We have had a number of requests to add this feature and its very much on our todo list. You’re more than welcome to attempt to add this feature or write your own coprocessor firmware to handle it, until this feature gets merged into the coprocessor firmata repo (I’m hoping to get around to it within a week).

2 Likes

Hi. Were you able to implement Alex’s suggestions, or are you waiting for an official release? This is the issue btw: Coprocessor based watchdog timer · Issue #18 · balena-io/balena-fin-coprocessor-firmata · GitHub

I have not tried as ETA was quick. Is it going to take a while?

Hey - I don’t know timescales, but I would say that Alex is a busy chappy and it’s likely to be more than the week he suggested. :slight_smile: If you feel you could attempt the PR, we would all appreciate your efforts! :smiley:

I for one would love to do something similar in the future for a fin-based burglar alarm!

Let us know if you try.
Phil

I would give it a shot. Running with a time constraint as well :frowning: