# Deep sleep balenafin

**URL:** <https://forums.balena.io/t/deep-sleep-balenafin/350702>\
**Category:** Project help\
**Tags:** raspberrypi3\
**Created:** [December 28, 2021, 8:46am UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702 "2021-12-28T08:46:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luca1](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@luca1](https://forums.balena.io/u/luca1)\
**Post date:** [December 28, 2021, 8:46am UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/1 "2021-12-28T08:46:37Z")

</div>

Hi,  
I’m looking for a best way to move my balenafin with cm3 in sleep mode.  
Any suggestions?

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [December 28, 2021, 9:03am UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/2 "2021-12-28T09:03:40Z")

</div>

Hi

We have a coprocessor on the balenaFin which you can use to put the Fin to sleep. Some of my colleagues have created a block to help with such things. For example see [fin/02-usage.md at master · balenablocks/fin · GitHub](https://github.com/balenablocks/fin/blob/master/docs/02-usage.md#rest-api)

In the above example you will see a REST endpoint that you can use to put the Fin to sleep.

May I ask what application you are working on? Are you thinking of running the Fin off a battery?

---

<div class="post-metadata">

**Author:** ![luca1](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@luca1](https://forums.balena.io/u/luca1)\
**Post date:** [January 3, 2022, 2:51pm UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/4 "2022-01-03T14:51:30Z")

</div>

I’m running a balenafin 1.1.1 with a cm3 module with 8gb with raspbian 0.1.0 installed, when trying to build the docker image i run out of disk space

---

<div class="post-metadata">

**Author:** ![phil-d-wilson](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/phil-d-wilson/32/3730_2.png) [@phil-d-wilson](https://forums.balena.io/u/phil-d-wilson)\
**Post date:** [January 5, 2022, 8:28am UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/5 "2022-01-05T08:28:49Z")

</div>

Hi,

You can add the pre-built block to your docker-compose file with this reference: `balenablocks/fin:latest` - you then won’t need to build the image.

If you’re not using docker on the device then you’ll need to use the flasher to ensure you have a known version of firmata flashed to the co-processor:

> <https://github.com/balenablocks/fin/blob/master/src/utils/flasher/index.js>

then you can use firmata to sleep the device:

> <https://github.com/balenablocks/fin/blob/9d98ec93fbb84975f3eff0fdd8e026daa111aac0/src/utils/firmata/index.js#L67>

---

<div class="post-metadata">

**Author:** ![luca1](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@luca1](https://forums.balena.io/u/luca1)\
**Post date:** [January 5, 2022, 6:13pm UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/7 "2022-01-05T18:13:06Z")

</div>

Hi, thanks for your help.  
I just create a simple docker-compose.yml with this content  
version: “2.0”  
volumes:  
fin:  
services:  
fin:  
restart: always  
image: balenablocks/fin:latest  
network\_mode: host  
privileged: true  
volumes:  
- “fin:/data/firmware”  
labels:  
io.balena.features.supervisor-api: “1”  
io.balena.features.balena-api: “1”  
environment:  
- “DEBUG=firmata,flasher,downloader,supervisor,eeprom,main”  
- “AUTOFLASH=1”  
- “AUTOCONFIG=1”  
expose:  
- “1337”

If I try to get device sleep I will not get response  
curl -X POST [http://localhost:1337/sleep](http://localhost:1337/sleep) -H ‘Content-Type: application/json’ -d ‘{“sleepTime” : 4, “sleepDelay” : 1}’

If I run  
curl -X GET [http://localhost:1337/version](http://localhost:1337/version)  
{“fin”:11,“firmata”:{“firmataName”:"",“firmataVersion”:"",“implementationVersion”:""},“block”:“3.6.0”}

curl -X GET [http://localhost:1337/firmware](http://localhost:1337/firmware)  
{“firmataName”:"",“firmataVersion”:"",“implementationVersion”:""}

Any suggestions?

---

<div class="post-metadata">

**Author:** ![phil-d-wilson](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/phil-d-wilson/32/3730_2.png) [@phil-d-wilson](https://forums.balena.io/u/phil-d-wilson)\
**Post date:** [January 6, 2022, 10:16am UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/8 "2022-01-06T10:16:49Z")

</div>

Hi again,

Are you still running on rasbian, and is this device being used with balenaCloud?

It looks, to me, from the output of the firmware endpoint like the co-processor has not been successfully flashed with a version of firmata, and so will not be able to sleep the board.  
Looking at the code, there is balenaCloud-specific functionality that may stop the flashing process from succeeding if it fails:

> <https://github.com/balenablocks/fin/blob/9d98ec93fbb84975f3eff0fdd8e026daa111aac0/src/index.js#L203>

Furthermore, the block assumes it can contact the supervisor that runs on all balenaOS devices, in order to reboot the device once the flashing process has finished.

I don’t currently have a balena Fin available that I can run Raspbian on to test - and this block does not seem to be supported on non-balenaOS devices.

I think your options are:

- move the device to balenaOS if possible
- use the block source code to make your own scripts to flash and sleep the device
- raise an issue in the block GH, and ask the maintainer if they intend on supporting non-balenaOS applications.

Phil

---

<div class="post-metadata">

**Author:** ![luca1](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@luca1](https://forums.balena.io/u/luca1)\
**Post date:** [January 6, 2022, 10:44am UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/11 "2022-01-06T10:44:34Z")

</div>

Hi Philip,  
Yes the device running on raspbian, but it’s not connected to balenaCloud. Maybe this block not working on raspbian

---

<div class="post-metadata">

**Author:** ![ntzovanis](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ntzovanis/32/1150_2.png) [@ntzovanis](https://forums.balena.io/u/ntzovanis)\
**Post date:** [March 9, 2022, 1:28pm UTC](https://forums.balena.io/t/deep-sleep-balenafin/350702/12 "2022-03-09T13:28:44Z")

</div>

Hi @luca1 ,

As Phil mentioned, this block was intended to be used with balenaOS, so it is likely that it doesn’t work on Raspbian.

I’ve created a [GitHub](https://github.com/balenablocks/fin/issues/59) issue on the repo for the maintainers to take a look.  
In the meantime, you can try the OS-independent solution that consists of:

- Installing firmata on the co-processor by following the instructions in this repo: [GitHub - balena-io-hardware/balena-fin-coprocessor-firmata: firmata firmware for the BGM111 co-processor on the balenaFin](https://github.com/balena-io-hardware/balena-fin-coprocessor-firmata)
- Running the [Sysex command](https://github.com/balena-io-hardware/balena-fin-coprocessor-firmata#power-down-0x01) directly to put the fin in sleep mode.

Cheers,  
Nico.
