I’d like to make use of the actual touch sensor value rather than configure it as binary on or off.
The config only supports “binary_sensor:” for - platform: esp32_touch, trying as simply “sensor:” it will not compile.
That in itself doesn’t matter too much but I don’t know how to access the reading as displayed in the logs.
For example the logs show
[16:21:45][D][esp32_touch:122]: Touch Pad 'GPIO27' (T7): 1458
and it is the end of this string, the value “1458” that I’d like to display.
At the moment my display shows 0.00000
This is my code, any help appreciated on how to format the last line to display the proper value:
I’d like to use the capacitive values for a non-contact fluid level sensor. The values are present in the log file yet I can’t find a way to give them an id and make use of them in esphome, its just assumed you only want a binary result.
I just figure this out a couple days ago but I don’t know if I needed to go to the development version or not (at the time I thought I did). I found it in the discussion regarding adaptive threshold.
binary_sensor:
# ESP32_Touch Sensors
- platform: esp32_touch
name: "espTouch Bed Top Left"
id: esptouch_bed_top_left
pin: GPIO2
threshold: 56
filters:
- delayed_on_off: 5s
sensor:
#Readings calculated from espTouch sensors
- platform: template
name: "Bed Top Left Readings"
id: "bed_top_left_readings"
update_interval: 10s
accuracy_decimals: 0
lambda: |-
return ((uint32_t) id(esptouch_bed_top_left)->get_value());
I’ll happily do a full write-up although at the moment its some way off working. Having been helped to solve the above I now find I’m stuck again with the display data.
What I’d like to do is use the sensor and display different text based upon the reading,
eg if the sensor reading is below 1000 I’d like to display LOW, if >1000 and <2000 display MEDIUM and if >3000 display HIGH for example.
These aren’t the exact figures but I can tweak with that once I have a system. I don’t want to use the HA template builder as I want this data to be displayed on the ESP and for it to be able to function stand-alone.
I’ve been down several dead ends looking at how to change variables but keep getting stuck. My last example attempt is below (just for LOW and HIGH) but I can’t seem to find the right format for it to compile:
Thanks for the suggestion. I’ve added a text sensor as follows:
text_sensor:
- platform: template
name: "Litres"
id: "Litres"
lambda: |-
if ((id(touchValue).state >= 5) and (id(touchValue).state < 400)) {
return {"LOW"};
}
if ((id(touchValue).state >= 400) and (id(touchValue).state < 1500)) {
return {"MEDIUM"};
}
if ((id(touchValue).state >= 1500) and (id(touchValue).state < 1800)) {
return {"HIGH"};
}
if ((id(touchValue).state >= 1800)) {
return {"VERY HIGH"};
} else {
return {"OUT OF RANGE"};
}
update_interval: 5s
And that works in that I can see the correct message in the log file. But where it falls over at the moment is in trying to get that to display, there’s clearly some error in the least line but it eludes me at the moment.
src/main.cpp:412:60: warning: format '%s' expects argument of type 'char*', but argument 6 has type 'std::__cxx11::string* {aka std::__cxx11::basic_string<char>*}' [-Wformat=]
it.printf(2, 55, frut, "volume is: %s" ,Litres->state);
and displays just a solid block rather than the expected LOW, HIGH etc