Pico W and ESP32 Application

Hi everyone,

I’m currently working intensively on the Pico W and Home Assistant applications.
YAML is used to program the Picos. It takes some getting used to. Thanks to my diverse knowledge of other programming languages, I’ve been able to create small applications.

  1. Example
    Pico W with OLED (ssd1306) for temperature and humidity display
    as well as a 4-digit display for the current time.

  2. Example
    Waveshare PicoLCD-1.44 with 4 buttons.
    The demo program (?.py) has been adapted in Home Assistant.

Objective:
I want to use the 4 buttons to switch the respective ESP or Pico.

Example:
Button 1 → displays the temperature and humidity values ​​for room 1 on the display
Button 2 → displays the temperature and humidity values ​​for room 2 on the display

  1. yaml program here:
    esphome:
    name: pico-test
    friendly_name: Pico-Test
rp2040:
  board: rpipicow

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: 
  password: 

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: ""
    password: ""

# make
# ESPHome Builder 
# + add New Device
# skip
# 
# darunter bitte einfügen

# Example configuration entry    
time:
  - platform: homeassistant
    id: esptime
    timezone: Europe/Berlin

# Example configuration entry
#time:
#  - platform: homeassistant
#    id: homeassistant_time

color:
  - id: my_red
    red: 100%
    green: 3%
    blue: 5%
  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%
  - id: my_green
    red: 0%
    green: 100%
    blue: 0%
  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%
  - id: my_magenta
    red: 100%
    green: 0%
    blue: 100%
  - id: my_gray
    red: 50%
    green: 50%
    blue: 50%
  - id: my_white
    red:  100%
    green:  100%
    blue: 100%
  - id: color_tomato
    hex: FF6347
  - id: my_whiskey
    hex: d29062
  - id: my_dark_pink
    hex: cb416b
  - id: my_grape
    hex: 5d1451
  - id: my_lavender
    hex: d5c9dd
  - id: my_arctic_blue
    hex: 95d6dc
  - id: my_sapphire
    hex: 09577B
  - id: my_light_blue
    hex: add8e6


# Font /config/esphome
font:
  - file: "Roboto-Regular.ttf"
    id: roboto
    size: 20
  - file: "Roboto-Regular.ttf"
    id: roboto_20
    size: 12
  - file: "ARIAL.TTF"
    id: font20
    size: 20
  - file: "ARIAL.TTF"
    id: font10
    size: 10 
  - file: "ARIAL.TTF"
    id: font12
    size: 12  
  - file: "ARIAL.TTF"
    id: font9
    size: 9
  - file: 'ARIAL.TTF'
    id: font1
    size: 8   

binary_sensor:
  - platform: gpio
    pin:
      number: 15
      mode:
        input: True
        pullup: True
    name: "Taste 1"
    id: "Taste1"
    #device_class: opening
    filters:
      - delayed_on: 10ms
#
  - platform: gpio
    pin:
      number: 17
      mode:
        input: True
        pullup: True
    name: "Taste 2"
    id: "Taste2"
    filters:
      - delayed_off: 10ms
#
  - platform: gpio
    pin:
      number: 02
      mode:
        input: True
        pullup: True
    name: "Taste 3"
    id: "Taste3"
    filters:
      - delayed_on: 10ms
#
  - platform: gpio
    pin:
      number: 03
      mode:
        input: True
        pullup: True
    name: "Taste 4"
    id: "Taste4"
    filters:
      - delayed_off: 10ms

sensor:
  - platform: homeassistant
    id: inside_temperature
    entity_id: sensor.pico_temperature_upper
    internal: True

  - platform: homeassistant
    id: inside_humidity
    entity_id: sensor.pico_humidity_upper
    internal: True

spi:
    clk_pin:  GPIO10
    mosi_pin: GPIO11
    miso_pin: GPIO16

display:
  - platform: ili9xxx
    model: "ST7735"
    cs_pin: GPIO09
    dc_pin: GPIO08
    reset_pin: GPIO12
    dimensions:
      height: 130
      width:  130
    color_order: bgr
    invert_colors: False
    show_test_card: False
    #eight_bit_color: True
    update_interval: 2s
    rotation: 90
    lambda: |-
      auto black = Color(0, 0, 0);
      auto red = Color(255, 0, 0);
      auto green = Color(0, 255, 0);
      auto blue = Color(0, 0, 255);
      auto blue1 = Color(255,0, 255);
      auto gblue = Color(0, 70, 255);
      auto white = Color(255, 255, 255);
      auto yellow = Color(255, 255, 0);
      auto orange = Color(255, 127, 0);
      //
      it.print( 10, 5, id(font10), white, "PicoLCD-1.44");
      it.print( 10, 107, id(font9), id(my_magenta), "Bitte Taste (min.3s)");
      //
      it.filled_rectangle(15,40,75,12,id(my_yellow));
      it.filled_rectangle(15,40,75,12,id(my_yellow));binary_sensor:
      it.print(17, 40 , id(font10), black, "1in44-LCD");
      //
      it.filled_rectangle(15,60,75,12,green);
      it.rectangle(15,60,75,12,green);
      it.print(17, 60 , id(font10), gblue, "128x128Px");
      //
      it.filled_rectangle(15,80,75,12,blue);
      it.rectangle(15,80,75,12,blue);
      it.print(17, 80 , id(font10), white, "ST7735S");
      //it.print(12, 30, id(font9), "           ");
      //
      // Key abfragen
      if (id(Taste1).state) {
        it.filled_rectangle(100,100,20,20,black);
        it.rectangle(100,100,20,20,gblue);
        //it.print(12, 30, id(font9), "state: off");
      } else {
        it.filled_rectangle(100,100,20,20,gblue);
        //it.print(14, 30, id(font9), "state: ON");
      }
      if (id(Taste2).state) {
        it.filled_rectangle(100,70,20,20,black);
        it.rectangle(100,70,20,20,gblue);
        //it.print(14, 30, id(font9), "state: ON");
      } else {
        it.filled_rectangle(100,70,20,20,gblue);
        //it.print(14, 30, id(font9), "state: OFF");
      }
      if (id(Taste3).state) {
        it.filled_rectangle(100,40,20,20,black);
        it.rectangle(100,40,20,20,gblue);
        //it.print(14, 30, id(font9), "state: ON");
      } else {
        it.filled_rectangle(100,40,20,20,gblue);
        //it.print(14, 30, id(font9), "state: OFF");
      }
      if (id(Taste4).state) {
        it.filled_rectangle(100,10,20,20,black);
        it.rectangle(100,10,20,20,gblue);
        //it.print(14, 30, id(font9), "state: ON");
      } else {
        it.filled_rectangle(100,10,20,20,gblue);
        //it.print(14, 30, id(font9), "state: OFF");
      }
      // Rahmen OK
      // Spalte, Zeile Laenge horizontal, Laenger vertikel
      it.rectangle(2, 1, 126, 126,gblue);  // OK

Here are two photos

Text created with Google Translate

  • List item

The program is used in this application.