Rpi pico w onboard temperature sensor and onboard led

Just started playing with an RPi Pico W and making an ESPHome device with it. Does anyone have guidance/links/whatever for how to use one or both of the onboard temperature sensor and LED? I’ve tried both General Googling and also searches on this site…

Thanks in advance for any help you are able to give. :slight_smile:

It is not possible to control the LED on a Pico W from a gpio.


1 Like

@nickrout indeed; IIRC, the onboard LED is connected to the Wifi controller; not sure about the temperature sensor. I don’t think it’s on a GPIO pin though. I’ve had the LED working in both uPython and C++. The Temperature sensor only in uPython. TBH the onboard LED is probably really only cosmetic; useful in test/example scenarios only. The onboard temperature sensor is another matter, though. It’d be really nice for it to be usable from ESPhome. I suspect it needs support in ESPhome; to have a platform module written for it, if that’s not been done already. For my own part, if I don’t find something after a bit more poking about around here and elswhere, I may have a go at writing a custom sensor. If I do, and if I get it working, I’ll post the code here…

@nickrout OK, so part one: I took the easy option first; I had a go at the internal LED. 2 source files to follow; one C++ .h file and one yaml file…


  device_name: picowtest
  friendly_name: "Raspberry Pi Pico W Test"
  device_description: "Raspberry Pi Pico W based test device."

<<: !include .INC_Common_RP2040.yaml

  name: ${device_name}
  - picow_intLED.h

  board: rpipicow
    # Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged
    platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git

  - platform: gpio
    id: yellow_led
    pin: GPIO15
    # inverted: True

  - platform: custom
    type: binary
    lambda: |-
      auto picowLED = new picow_intLED();
      return {picowLED};

      id: picowLED

 - platform: binary
   name: "${device_name} - Yellow LED"
   id: yellow_led_light
   output: yellow_led
   # internal: true
 - platform: binary
   name: "${device_name} - Internal LED"
   id: intLED
   output: picowLED

// C++ Code (picow_intLED.h)

#include "esphome.h"
using namespace esphome;

// Custom binary output, for exposing binary states
class picow_intLED : public Component, public BinaryOutput {


  void setup() override {
    // This will be called by App.setup()


  void write_state(bool state) override {

    digitalWrite(LED_BUILTIN, state);

On to part 2: the Pico W temperature Sensor. If I can make it work; I’ll post that code here also.

This works and is dead simple

thanks @ballakers that worked.