i am a beginner with coding
and this is my first try with homeassistant
i wrote a small code for a watersensor in arduino IDE:
#define POWER_PIN 2 // ESP32 pin GPIO2 connected to sensor's VCC pin
#define SIGNAL_PIN 1 // ESP32 pin GPIO1 (ADC0) connected to sensor's signal pin
int value = 0; // variable to store the sensor value
void setup() {
Serial.begin(9600);
pinMode(POWER_PIN, OUTPUT); // configure pin as an OUTPUT
digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
}
void loop() {
digitalWrite(POWER_PIN, HIGH); // turn the sensor ON
delay(10); // wait 10 milliseconds
value = analogRead(SIGNAL_PIN); // read the analog value from sensor
digitalWrite(POWER_PIN, LOW); // turn the sensor OFF
Serial.print("The water sensor value: ");
Serial.println(value);
delay(1000);
}
and it worked as intended
when the sensos comes in contact with water it gives a readout
then withoud changing the wireing i mage a yaml file:
esphome:
name: esphome-web-830490
friendly_name: Watersensor
esp32:
board: heltec_wifi_kit_32_V3
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "XXX"
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-830490"
password: "sn3pbzDwbTyP"
captive_portal:
# Add the water sensor configuration
sensor:
- platform: adc
pin: GPIO1 # Change this to match the GPIO pin you're using for the signal pin of the water sensor (e.g., GPIO1)
name: "Water Sensor"
update_interval: 1s # Adjust the update interval as needed
filters:
- lambda: |-
if (x < 10) {
return 0.0; // Adjust this threshold to match your sensor's readings
} else {
return x;
}
unit_of_measurement: "units" # Change to the appropriate unit
icon: "mdi:water"
attenuation: 0db # Add this line to set the ADC attenuation to 0db
id: water_sensor # Add an ID to the sensor for later reference
output:
- platform: gpio
pin: GPIO2 # Set this to the GPIO pin you used for Vcc (e.g., GPIO2)
id: water_sensor_vcc
but i get an errormessage in the line
board: heltec_wifi_kit_32_V3
This board is unknown, please set the variant manually.
i used the ID from:
https://docs.platformio.org/en/latest/boards/espressif32/heltec_wifi_kit_32_V3.html
so i dont know what i am doing wrong