so i trying to 2 things… as a Temperature sensor…
1… id like to have mini D1 with the temperature sensor, and a 2nd one with a screen that reads that mini D1… i have been able to connect the 2 together using the ap: wifi option so that part works… but thats as far as i have gotten…
2… is i working on the orginal setup i have a OLED screen it displays the temperature… but i been trying to incorporate a Button… right now i dont have one… but i wanted to use a gpio in its high or low state at boot jsut to simulate a button is pressed
i want to use those touch pads or a mometary switch… i dont have either at this moment will in a day or so but i wanted to get the code working
and id like to do a timer say after 10min it shuts screen off…
here is my messy code i been trying google with the esp home to try to find what would work
at this moment i dont have a mini d1 i using a 12e board at the moment
you will see about a deck… i was jst copying code from someone else to try to work it in my code
esphome:
name: car-temp
platform: ESP8266
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "cdcbe64916c6e40cc4b331f94096eb68"
wifi:
# ssid: "test"
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Car-Temp Fallback Hotspot"
password: "zXXAgyYrjW9h"
captive_portal:
sensor:
- platform: dht
model: am2302
pin: GPIO4
temperature:
name: "Car Outside Temperature"
id: outside_temperature
# filters:
# offset: 2
humidity:
name: "Car Outside Humidity"
update_interval: 6s
switch:
- platform: gpio # or any other platform
pin: D2
name: Touch_Switch
# ...
on_turn_on:
- logger.log: "Switch Turned On!"
- lambda: id(oled).turn_off();
on_turn_off:
- logger.log: "Switch Turned Off!"
- lambda: id(oled).turn_on();
# deck lights off
- platform: gpio
pin: GPIO1
id: decklightsoff
- platform: template
name: "Deck Lights OFF"
lambda: 'return false;'
turn_on_action:
- switch.turn_on: decklightsoff
- delay: 10ms
- switch.turn_off: decklightsoff
- lambda: id(oled).turn_off();
binary_sensor:
- platform: gpio
name: "Button"
internal: true
pin:
number: D6
mode: INPUT_PULLUP
on_press:
- lambda: id(oled).turn_off();
# - delay: 5s
# - lambda: id(oled).turn_on();
on_state:
then:
- lambda: id(oled).turn_off();
# Example configuration entry
i2c:
sda: D3
scl: D4
font:
- file: "fonts/nasalization.ttf"
id: font1
size: 23
- file: "fonts/refsan.ttf"
id: font2
size: 35
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
id: oled
reset_pin: D0
address: 0x3C
lambda: |-
it.printf(0, 0, id(font1), "Outside");
it.printf(0, 22, id(font2), TextAlign::TOP_LEFT , "%.1f°c", id(outside_temperature).state);
# it.printf(0, 8, id(font1), id(office_temperature).state);
# // Print inside temperature (from homeassistant sensor)
# if (id(office_temperature).state == id(office_temperature).state) {
# it.printf(0, 8, id(font1), TextAlign::TOP_RIGHT , "%.1f°C", id(office_temperature).state);
# } else {
# it.print(0, 8, id(font1), TextAlign::TOP_RIGHT , "waiting");
# }
#// Within lambda, get the switch state and conditionally do something
# if (id(my_switch).state) {
# // Switch is ON, do something here
# } else {
# // Switch is OFF, do something else here
# };