Puck.js as light/temp sensor for orchard

Posted on
  • Looked at the puck.js specs, and love to use it as a temp/light sensor which samples data and sends out the data through a phone to SD or Internet after a while when the button is pressed.

    No beacon or looking for devices to spare battery, although when I attach it high in a tree, I need a ladder to press the button.

    Curious what sample rate would be possible before the memory is filled. And how to make a good trade-off for battery life and sampling rate.

    Some rules of thumb about the power needed for sensors, sleep modes etc would be nice.

    What things can be used to interrupt/wake up the device on which mode. Probably the button, probably a timer, maybe by BT signal or sensor trigger value? Only familiar with atmel/Arduino.

    The BT chip datasheet would answer a lot of questions, but some things would depend on hard wiring and firmware.

  • Using RAM you'd have maybe 30kB available, so if using 2 bytes for temp + light, it's 15000 samples, so if measuring once a minute it's 10 days worth.

    Having said that, you can use the on-chip flash too, but it'll drain the battery a bit more. There's 512kB flash, but Espruino + the bluetooth stack and bootloader will take a lot of that. I'd hope there would be 100kB free but I can't be sure about that. SD cards are also supported so you could wire one of those up - but realistically the power consumption will drain the battery quickly - there are also some flash, EEPROM or RAM chips that you could wire on.

    The chip is the nRF52832 - it's easy enough to google for the datasheet. It can wake up on a digital IO changing state, a timer, or a bluetooth event - so realistically you probably don't need to go up a tree for it :)

    In terms of power consumption, on average with normal Bluetooth advertising it uses 15uA. I'll need to do some proper measurements of the power consumption when running, but I think it's around 5mA. JS execution speed isn't that fast, so you could expect that it might take 2ms to wake up, read temperature and light and write it to memory - so you can work out battery life based on that.

    Realistically, as long as you're sampling every minute or more, you shouldn't suffer a big hit on battery life.

  • Thanks Gordon, for your rules of thumb about ram usage and power/timing. I rather lower the sample rate than adding physical memory for more logging space. 30 days data retention is good enough for me.

    The sleep modes I read in the datasheet (system on/off, ram retention yes/no) triggered a question. How time conscious is the puck.js if it is asleep most of the time?

    I want to beacon some light/temp stats, and some real date/time makes sense. The Nordic chip has a RTC, but have not figured out yet how to use the power save mode friendly TICK event, and how power consuming this RTC implementation will be.

    So every couple of minutes sample temp/light, beacon some stats, a quick listen (no ladder climbing push button activity ;-) if a known BT host is present for downloading logging data and free up the ram for another month of sampling.

    If a user adds some hardware, is it costly to make a resized puck housing (base/sleeve) for a single (outdoor proof) prototype? If a 3D printing service or nearby fablab is used, what materials should be used?

    Maybe a batch casted XL silicone sleeves could be made/sold where you cut off some silicone from the bottom yourself to seal your homebrew stacked puck.

  • The RTC on Espruino will 'just work' - as in normal JavaScript you can do new Date() and you'll get the current date. And just use setInterval to call your code however often you want, and setWatch to wake Puck.js up when the button is pressed.

    There's no 32kHz oscillator on Puck.js but the nRF52 does some fancy calibration stuff, so it manages better than 250ppm. That means that worst case over 1 year of operation it'll lose 2 hours... So if you checked it once a month and updated the time at that point, I guess that'd be good enough?

    In terms of cases, the case will be open source, and hopefully some people will contribute some different sized cases (I may do as well). I'm hoping that the solid base will be easy enough to 3D print yourself if you have access to a printer (or it'll be ~£10 to send it off and get it printed) - and the existing silicone sleeve would still seal over the top of a new, larger case without any trouble.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Puck.js as light/temp sensor for orchard

Posted by Avatar for Bas @Bas