External Sensors on Thingy:52

Posted on
  • Hi All,

    i was hoping to be able to use Espruino to query some external sensors on Thingy:52

    The basic idea is to connect an external analogue sensor, say soil moisture, to Thingy and let Thingy broadcast the sensor readings.

    Very much like a combination of what is done with the Pico here to connect an external light sensor: https://www.espruino.com/Pico+Light+Sens­or and the Thingy here to let it broadcast sensor values: https://www.espruino.com/Pixl.js+Wireles­s+Weather+Station

    The Espruino-Thingy page at https://www.espruino.com/Thingy52#on-boa­rd-peripherals
    seems to suggest this is possible (Section "On BOard Peripherals") via
    // External IO outputs

    However, I can find no further documentation/ tutorials on how to actually read the sensor values.

    Any pointers to further information would be very much appreciated!



  • Good question!

    So in terms of IO you have:

    • IOEXT0/1/2/3 from the IO expander - good for digital IO, but not very fast as they go through the expander
    • MOS1/2/3/4 - which control 4 MOSFETs for high power stuff
    • D2/D3/D4 - analog capable IO from the MCU

    On the rear of the thingy D2/D3/D4 are labelled as P0.02/etc.

    So basically all you need is to use D2 3 or 4 exactly like you would on the Pico (analogRead(D2)) and you're sorted.

  • Thanks for the swift reply, Gordon!
    Very cool, I didn't realise you could do this without using anything Thingy-specific!
    Just flashed one of my Thingies with Espruino. Exciting!

  • ...fortunately... or unfortunately... it all depends... first for you, latter 'not-for'-for @Gordon... but it speaks for what @Gordon does: powerful solutions easy to apply!

    So fare I stayed with having Espruino only on Espruino boards and could abstain from putting Espruino onto something else but Espruino board... but with my most recent tinkering - Espruino on the mini 10 x 10 [mm] ESP-09 - if feel like a traitor... :/

    The fact that I was unable to update my aged ESP-09 with new AT version from espressif... but it was a breeze to get Espruino onto it and it worked right of the bat (after properly connecting CP_PD), speaks even more for the quality and ease of use what comes out of @Gordon's 'Schmiede'.

  • Hi!
    I just get espruino on my Thingy:52, followed tutorial. It works very well!
    I want to attach an OLED 128x32 driver SSD1306 I2C to display some info.

    I was unable to connect on the rear SCL/SDA.
    Is there an example for Thingy:52 to connect on I2C bus an external sensor (BME280) and an OLED SSD1306?

  • Thr 2019.06.27

    Hi @zeromem, congratulations on your successful flash attempt, and welcome to the exciting IoT world using Espruino!

    'Is there an example for . . . sensor (BME280) and an OLED SSD1306?'

    Were you aware of the search box at page top right of the site?


    I just typed in I2C

    and found example code and tutorials for all the sensors requested:




  • Hi Robin,
    Thank you for fast reply, I read all that before, my question was about specific hardware pins on specific rear port from my board.
    I already use display, BME280 and DS18B20 connected on micro:bit using weather:bit from sparkfun with makecode.
    Thank you,

  • On my rear port (P7) I have:
    P0.14 SDA_EXT External and low power accelerometer I2C data line
    P0.15 SCL_EXT External and low power accelerometer I2C clock line.

    Please help my with I2C setup.
    Thank you,

  • The setup tutorial example is in the link, third from the end in post #6

  • @zeromem I know SDA/SCL are labelled on the back, but as you noted they're shared with the accelerometer which could cause you issues (eg. the accelerometer is off by default so it may then inadvertently 'clamp' the I2C signals and stop them working).

    As I understand it, pins P0.02/3/4 (corresponding to D2/3/4) are completely unused, so I would strongly suggest you use those.

    To avoid any confusion try using the software I2C as well, and hopefully it'll work:

    var i2c = new I2C();
    var g = require("SSD1306").connect(i2c, function(){
     g.drawString("Hello World!",2,2);
  • Thank you all.
    It works.
    This is my Nordic Thingy:52 with espruino_2v04.1_thingy52.hex,
    MLX90614 and oled SSD1306 128x32 displaying from both internal and external sensors.

    1 Attachment

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

External Sensors on Thingy:52

Posted by Avatar for Bernd @Bernd