Used components:
Power supply
AC-DC 5V 700mA 3.5W Isolated Switching Power Supply
Ultrasonic sensor JSN-SR04T
JSN-SR04T
WemosD1 mini
[ESP8266 ESP 12 ESP 12F CH340G CH340 V2 Usb Wemos D1 Mini Wifi Development Board D1 Mini Nodemcu Lua Iot Board 3.3V Voldaan Pins|Integrated Circuits| - AliExpress](https://WemosD1 mini)
I have a question if I need bigger power supply. And if yes, I would like to know why.
If I connect the Wemos together with the sensor and a normal micro USB 2A phone charger, I receive correct measurements (for what you can expect from the sensor)
When I connect the 700mA power supply using a USB micro connector to the Wemos, I get wrong measurements. Measurements are to low (need to measure 2m)
So I think I need a bigger power supply, but a Wemos should have enough with 700mA and the ultrasonic sensor only used 30mA max according the info I can find.
I can’t use the phone charger because everything needs to be put in a small box.
My yaml config
substitutions:
devicename: Regenput
deviceid: regenput
globals:
# Distance between senso and water
- id: totaldistance
type: float
restore_value: no
initial_value: "189"
#Distance between sensor en max water level
- id: unuseddistance
type: float
restore_value: no
initial_value: "12"
esphome:
name: ${deviceid}
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid_secret
password: !secret wifi_password_secret
manual_ip:
static_ip: !secret wifi_regenput_ip_secret
gateway: !secret wifi_gateway_secret
subnet: !secret wifi_subnet_secret
dns1: !secret wifi_dns1_secret
#captive_portal:
# Enable logging
logger:
#web_server:
# port: 80
# Enable Home Assistant API
api:
password: !secret api_password_secret
ota:
password: !secret ota_password_secret
time:
- platform: homeassistant
id: homeassistant_time
# Sensors with general information.
sensor:
# WiFi Signal sensor.
- platform: wifi_signal
name: ${devicename} WiFi Signal
id: ${deviceid}_wifi_signal
update_interval: 60s
# Uptime sensor.
- platform: uptime
name: ${devicename} Uptime
id: ${deviceid}_uptime
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: ${deviceid}_uptime_human
state: !lambda |-
int seconds = round(id(${deviceid}_uptime).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
# https://community.home-assistant.io/t/water-tank-level-and-water-volume-with-esphome/192666
- platform: ultrasonic
id: ${deviceid}_value
trigger_pin: D1
echo_pin: D2
name: "${devicename} value"
timeout: 4.0m
accuracy_decimals: 2
update_interval: 60s
pulse_time: 20us
internal: true
filters:
- lambda: |-
float MAX_DIFFERENCE = 0.03; // adjust this!
static float last_value = NAN;
if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
return last_value = x;
else
return {};
# - median:
# window_size: 11
# send_every: 5
# send_first_at: 4
- filter_out: nan
- platform: template
name: "${devicename} afstand"
unit_of_measurement: "m"
accuracy_decimals: 2
lambda: return (id(totaldistance)/100)-id(${deviceid}_value).state;
update_interval: 15min
icon: mdi:arrow-expand-vertical
- platform: template
name: "${devicename} niveau"
unit_of_measurement: "%"
accuracy_decimals: 0
lambda: return ((((id(${deviceid}_value).state*100)-id(unuseddistance))-(id(totaldistance)-id(unuseddistance)))/(id(totaldistance)-id(unuseddistance)))*-100;
update_interval: 15min
icon: mdi:water-percent
- platform: template
name: "${devicename} volume"
unit_of_measurement: "l"
accuracy_decimals: 0
lambda: return ((((id(${deviceid}_value).state*100)-id(unuseddistance))-(id(totaldistance)-id(unuseddistance)))/(id(totaldistance)-id(unuseddistance)))*-15000;
update_interval: 15min
icon: mdi:cup-water
switch:
- platform: restart
name: ${devicename} Restart
binary_sensor:
- platform: status
name: ${devicename} Status
text_sensor:
- platform: template
name: ${devicename} Uptime Human Readable
id: ${deviceid}_uptime_human
icon: mdi:clock-start