lancaster-university / microbit-dal

http://lancaster-university.github.io/microbit-docs
Other
259 stars 131 forks source link

Feature request: Put device into deep sleep in Javascript Blocks Editor (powered by MakeCode) #309

Open rharbird opened 7 years ago

rharbird commented 7 years ago

Hello,

We would like to be able to put the Micro:bit into a deep sleep and periodically wake it to do something. This ticket is about being able to put the device into a deep sleep using the Javascript Blocks Editor.

Use case: We teach 'A' level students and undergraduates using the Micro:bit. We ask them to code the Micro:bit for IoT projects in which they must gather data over time and it is important to be able to conserve energy on the device. These students are not Computing 'majors' but do need to learn the importance of coding and engineering through working on real world projects. In a recent project students had to create a system for water and presence monitoring in the toilets to ascertain the effectiveness of water saving measures.

Regards,

Rae

DavidWhaleMEF commented 6 years ago

@jaustin @finneyj I'm about to need such a service myself too, to build some sensors that last a long time on one set of batteries.

I recall some discussions with Jonny where he hinted that if display and radio were turned off and you do a long pause, the device would indeed be in a low power sleep, however could we confirm a few points

1) Would we need to display.off() to prevent the display multiplexer and light sensor code from regularly running?

2) Would we need to turn the radio off, and how would we do this in MakeCode - particularly, would we need to de-register the lambda handler that is currently registered as the receive handler, in order to get it to turn off the radio circuitry?

3) would a sleep() with a large value be enough to put the device into deep sleep for a fixed period?

4) Does the event queue still run when in such a deep sleep, and therefore could we use a pin change event to wake up the device from it's current sleep() (e.g. I plan to fit an external low power RTC chip like a MCP79410 to generate an interrupt on hourly intervals).

5) Is the accelerometer service always polling when any gestures are registered (and is it not polling when no gestures are registered)?

Thanks.