Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! #
- # Take what you need from this example. do not try and run the whole thing. #
- # This code has a lot of examples you can use to learn and understand esphome yaml. #
- # running this whole example wont work. This is for people who are new #
- # !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! #
- esphome:
- name: device-01
- friendly_name: device_01
- comment: Living room ESP32 controller
- area: Living Room
- on_boot:
- then:
- - script.execute: blink_led
- esp32:
- board: esp32dev
- framework:
- type: esp-idf
- # Enable logging
- logger:
- # Enable Home Assistant API
- api:
- encryption:
- key: "yourKey"
- ota:
- password: "yourPassword"
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Device-01 Fallback Hotspot"
- password: "yourPassword"
- manual_ip:
- # Set this to the IP of the ESP
- static_ip: 15.10.0.5
- # Set this to the IP address of the router. Often ends with .1
- gateway: 15.10.0.1
- # The subnet of the network. 255.255.255.0 works for most home networks.
- subnet: 255.255.255.0
- captive_portal:
- ##==== Turn Onboard LED ON / Off ====##
- # Define the output for the onboard LED
- output:
- - platform: gpio
- pin: GPIO2
- id: onboard_led
- # Define a switch to control the onboard LED
- switch:
- - platform: output
- name: "Onboard LED"
- output: onboard_led
- ##==== End ====##
- ##==== Read Raw Remote IR Data ====#
- remote_receiver:
- pin:
- number: GPIO23
- inverted: True
- dump: all
- # Optional status LED
- status_led:
- pin: GPIO2
- ##==== End ====#
- #custom font for your display - there are web url .ttf's you can use
- font:
- - file: "Monocraft.ttf"
- id: my_font
- size: 20
- # Example configuration entry
- i2c:
- sda: 21 #GPIO 21
- scl: 22 #GPIO 22
- switch:
- - platform: template
- name: "LED Toggle"
- id: toggle_led
- optimistic: true
- - platform: template
- name: "Display Message Switch"
- id: display_switch
- optimistic: true
- #restore_mode: RESTORE_DEFAULT_ON #start in the on position
- light:
- - platform: monochromatic
- id: my_light
- name: "My Light"
- output: my_light_out
- output:
- #light out
- - platform: slow_pwm
- id: my_light_out
- period: 100ms
- #this simple example lets you turn the led on and off through HA
- - platform: gpio
- pin: GPIO2
- id: onboard_led
- display:
- - platform: ssd1306_i2c
- model: "SH1106 128x64"
- reset_pin: 0
- address: 0x3C
- lambda: |-
- if (id(display_switch).state) {
- it.printf(0, 0, id(my_font), TextAlign::LEFT, "LED is ON");
- } else {
- it.printf(0, 0, id(my_font), TextAlign::LEFT, "LED is OFF");
- }
- it.print(0,0, id(my_font), "Test 123");
- it.print(0,17, id(my_font), "more text");
- char buffer[10]; // Buffer to hold the converted string
- sprintf(buffer, "%.2f", 1.745); // Format the floating-point number with 2 decimal places
- it.print(0, 34, id(my_font), buffer);
- it.printf(0, 0, id(my_font), "light: %.2f", id(my_light).current_values.get_brightness());//or remote_values
- #More lighing information here:
- #https://esphome.io/components/light/index.html#
- #The Effects are activated in home assistant by clicking on the light bulb and turning effects on
- #light - Internal Led
- light:
- - platform: binary
- name: "ESP32 Onboard LED"
- output: onboard_led
- effects:
- - strobe:
- name: strobe
- colors:
- - state: true
- brightness: 100%
- duration: 500ms
- - state: False
- brightness: 0%
- duration: 500ms
- # Define a script to blink the LED
- script:
- # Blink the onboard LED
- id: blink_led
- then:
- - while:
- condition:
- lambda: 'return true;'
- then:
- - output.turn_on: onboard_led
- - delay: 500ms # Adjust the delay time as needed
- - output.turn_off: onboard_led
- - delay: 500ms # Adjust the delay time as needed
- switch:
- - platform: template
- name: "LED Toggle"
- id: toggle_led
- optimistic: true
- #restore_mode: RESTORE_DEFAULT_ON #start in the on position
- on_turn_on:
- then:
- - script.execute: toggle_led_script
- # Define a script to toggle the LED based on the switch state
- script:
- # Toggle the onboard LED based on the state of the switch
- id: toggle_led_script
- then:
- - while:
- condition:
- switch.is_on: toggle_led
- then:
- - output.turn_on: onboard_led
- - delay: 500ms
- - output.turn_off: onboard_led
- - delay: 500ms
- #VERY IMPORTANT!!!!!!!
- #if you get a big error message like this look for the option to run "CLEAN BUILD FILES"
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o:(.literal._ZNSt17_Function_handlerIFvRN7esphome7display7DisplayEEZ5setupvEUlS3_E_E9_M_invokeERKSt9_Any_dataS3_+0x8): undefined reference to `esphome::display::Display::print(int, int, esphome::display::BaseFont*, char const*)'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o:(.literal._Z5setupv+0x84): undefined reference to `vtable for esphome::i2c::IDFI2CBus'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o:(.literal._Z5setupv+0x88): undefined reference to `vtable for esphome::i2c::IDFI2CBus'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o:(.literal._Z5setupv+0xac): undefined reference to `vtable for esphome::ssd1306_i2c::I2CSSD1306'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o:(.literal._Z5setupv+0x114): undefined reference to `esphome::font::Font::Font(esphome::font::GlyphData const*, int, int, int, unsigned char)'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o:(.literal._Z5setupv+0x11c): undefined reference to `esphome::display::Display::set_writer(std::function<void (esphome::display::Display&)>&&)'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o: in function `std::_Function_handler<void (esphome::display::Display&), setup()::{lambda(esphome::display::Display&)#1}>::_M_invoke(std::_Any_data const&, esphome::display::Display&)':
- /config/device-01.yaml:58: undefined reference to `esphome::display::Display::print(int, int, esphome::display::BaseFont*, char const*)'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/device-01/src/main.o: in function `setup()':
- /config/.esphome/build/device-01/src/main.cpp:162: undefined reference to `esphome::font::Font::Font(esphome::font::GlyphData const*, int, int, int, unsigned char)'
- /config/.esphome/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /config/.esphome/build/device-01/src/main.cpp:836: undefined reference to `esphome::display::Display::set_writer(std::function<void (esphome::display::Display&)>&&)'
- collect2: error: ld returned 1 exit status
- *** [.pioenvs/device-01/firmware.elf] Error 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement