I Have 2 DHT22’s Working with this Code.
esphome:
name: 3dp-1
friendly_name: 3dP-1
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "="
reboot_timeout: 30min
ota:
- platform: esphome
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "3Dp-1 Fallback Hotspot"
password: ""
web_server:
version: 3
captive_portal:
## To Add Reboot Button to Web Interface
button:
- platform: restart
name: "3dP-1~~Reboot"
## -----------------------------------------------
sensor:
- platform: dht
## model: AM2302
model: DHT22
pin: GPIO18
#mode:
# input: true
# pullup: true
temperature:
name: "3dP1-T1"
humidity:
name: "3dP1-H1"
accuracy_decimals: 1
update_interval: 10s
- platform: dht
## model: AM2302
model: DHT22
pin: GPIO19
#mode:
# input: true
# pullup: true
temperature:
name: "3dP1-T2"
humidity:
name: "3dP1-H2"
accuracy_decimals: 1
update_interval: 10s
## Sensor Block for Standard Configuration.
## Uptime, Wifi Info etc
##
text_sensor:
- platform: wifi_info
ip_address:
name: "3dP-1~Address"
bssid:
name: 3dP-1~AP Mac Address
filters:
substitute:
- "84:D8:1B:DD:4E:F4 -> Front_Office"
- "00:5F:67:A0:71:F0 -> Centre_Office"
- "C0:06:C3:35:A7:FE -> Lounge_Room"
- "00:31:92:1B:38:22 -> Bbq_Area"
- "50:C7:BF:D3:38:5A -> Back_Room"
- "B0:4E:26:E4:41:FE -> Outdoor"
- "50:C7:BF:D3:3C:61 -> Shed"
mac_address:
name: "3dP-1~Wifi Mac Address"
When I incorporate it with My Other Code it Gives a Comms Error, say to Check the Pull-up.
Have Tried a few different Pins and Wonder if the SPI Bus being Implemented is causing the Issue.
The Other Code includes a Display & Pulse-Meter.
esphome:
name: testesp-1
friendly_name: TestEsp-1
esp32:
board: esp32dev
# variant: esp32
framework:
type: esp-idf
# type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "="
ota:
- platform: esphome
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Testesp-1 Fallback Hotspot"
password: ""
web_server:
version: 3
captive_portal:
## To Add Reboot Button to Web Interface
button:
- platform: restart
name: "TestEsp-1~~Reboot"
## -----------------------------------------------
spi:
clk_pin: 18
mosi_pin: 23 # Was 23 Works on 19
#miso_pin: 23 # Was 19. Not Being Used.
color:
- id: red_1
hex: ff5132
- id: red_2
hex: f53333
- id: blue_1
hex: 74d4fc
- id: blue_2
hex: 547cff
- id: yel_1
hex: ffcd17
- id: gry_1
hex: c8c8c8
font:
# gfonts://family[@weight]
- file: "gfonts://Roboto"
# - file: "arial.ttf"
id: robo_30
size: 30
display:
- platform: ili9xxx
model: ILI9341
cs_pin: 14
dc_pin: 27
reset_pin: 33
rotation: 270
invert_colors: false
color_palette: 8BIT
color_order: bgr
id: tft_display
lambda: |-
it.fill(Color::BLACK);
// Get the hostname (derived from the 'name' in esphome: section)
// You can also get it from the API if needed, but for display purposes,
// the 'name' is often sufficient.
std::string hostname = App.get_friendly_name() + ".local";
// Print the hostname on the display
it.print(0, 0, id(robo_30), hostname.c_str());
// Plain Text Example
//it.print(0, 0, id(robo_30), id(red_1), TextAlign::TOP_LEFT, "Hello World!");
it.printf(0, 30, id(robo_30), id(blue_1), TextAlign::TOP_LEFT , "%.1f", id(testesp1_uptime_s).state);
it.printf(0, 60, id(robo_30), id(blue_2), TextAlign::TOP_LEFT , "Ip: %s", id(testesp1_address).state.c_str());
it.printf(0, 90, id(robo_30), id(yel_1),TextAlign::TOP_LEFT , "Ap: %s", id(testesp1_ap).state.c_str());
it.printf(0, 120, id(robo_30), id(blue_1), TextAlign::TOP_LEFT , "Up: %s", id(testesp1_uptime_f).state.c_str());
it.printf(0, 150, id(robo_30), id(gry_1),TextAlign::TOP_LEFT , "RPM: %.0f", id(fan1_rpm).state);
sensor:
- platform: dht
## model: AM2302
model: DHT22
pin: GPIO16
#mode:
# input: true
# pullup: true
temperature:
name: "3dP1-T1"
humidity:
name: "3dP1-H1"
accuracy_decimals: 1
update_interval: 10s
- platform: pulse_meter
pin: 34 # Was 23
unit_of_measurement: 'RPM'
name: 'Fan 1 RPM'
id: 'fan1_rpm'
accuracy_decimals: 0
# internal_filter_mode: PULSE #Default is EDGE # No Improvement
# internal_filter: 2ms
timeout: 1s # Reset to 0 after 1 second without a pulse
filters:
# - throttle_average: 3s # Works Now Whwn Above Multiply.
- sliding_window_moving_average: # Needs to be Before Multiply.
window_size: 100
send_every: 10
- multiply: .5 # (2 pulses per Rev)
- lambda: 'return 5 * round(x / 5);' # Just to Round to Nearest Value when ther is Flicker.
# - median: #Seems to Default Timeout Back to 5 Minutes
# window_size: 5
# send_every: 5
# send_first_at: 1
- timeout: # Fixes Value Not Returning to Zero with Averaging Avtive.
timeout: 1s
value: !lambda return 0;
## Sensor Block for Standard Configuration.
## Uptime, Wifi Info etc
##
- platform: uptime
name: "TestEsp-1_Uptime_s"
id: testesp1_uptime_s
update_interval: 5s
filters:
- round_to_multiple_of: 5
text_sensor:
- platform: template
name: "TestEsp-1_Uptime_f"
id: testesp1_uptime_f
lambda: |-
uint32_t dur = id(testesp1_uptime_s).state;
int dys = 0;
int hrs = 0;
int mnts = 0;
if (dur > 86399) {
dys = trunc(dur / 86400);
dur = dur - (dys * 86400);
}
if (dur > 3599) {
hrs = trunc(dur / 3600);
dur = dur - (hrs * 3600);
}
if (dur > 59) {
mnts = trunc(dur / 60);
dur = dur - (mnts * 60);
}
char buffer[17];
sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
return {buffer};
icon: mdi:clock-start
update_interval: 5s
- platform: wifi_info
ip_address:
name: "TestEsp-1~Address"
id: testesp1_address
bssid:
name: TestEsp-1~AP Mac Address
id: testesp1_ap
filters:
substitute:
- "84:D8:1B:DD:4E:F4 -> Front_Office"
- "00:5F:67:A0:71:F0 -> Centre_Office"
- "C0:06:C3:35:A7:FE -> Lounge_Room"
- "00:31:92:1B:38:22 -> Bbq_Area"
- "50:C7:BF:D3:38:5A -> Back_Room"
- "B0:4E:26:E4:41:FE -> Outdoor"
- "50:C7:BF:D3:3C:61 -> Shed"
mac_address:
name: "TestEsp-1~Wifi Mac Address"
The DHT22’s do have an On-Board Pullup.
