Light Sensor for micro:bit

Posted on
  • Hi all
    Just discovered Espruino for Micro:bit and it was a revelation!
    I'm trying to build a small project that makes use of the internal "light sensor" (the one that makes use of the led display) but I see it isn't yet supported, right?
    I imagine it would need to be implemented from scratch since I don't see the library used eg by MicroPython to access micro:bit hardware.
    Any plan for the future?
    Otherwise I'll start studying the library in my spare time to understand how it works to try to implement it directly in Espruino

    Thanks in advance!
    Paolo

  • Hi - glad you're enjoying it!

    Is this the micro:bit 2, or the 1?

    It's not supported yet, but as far as I can see all the micro:bit does is read the voltage from one of the LEDs on the display (it's something we do for Puck.js too) so actually doing it shouldn't be too hard - the code we have is at https://github.com/espruino/Espruino/blo­b/cfbc4040d/libs/puckjs/jswrap_puck.c#L1­298-L1311

    I'm having real difficulty finding out which pins they use for sensing, but if you knew which pin was used, even though we don't expose all the analogs, you could still use the NRF52LL library to manually kick off an ADC reading: https://www.espruino.com/NRF52LL#make-on­e-reading-from-the-adc-

  • Hi

    Thanks a lot for the feedback !

    It's a micro:bit 2

    I'll read your docs and try to figure it out... there's also some code for micro:bit more (a scratch extension that features the light intensity reading), I'll try to figure out how to add it to espruino

    Thanks !!!

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

Light Sensor for micro:bit

Posted by Avatar for user156703 @user156703

Actions