alfwro13
(Andre W.)
July 28, 2023, 8:03am
1
Hi,
I’m trying to crack my esp32 s3 box lite buttons: https://fr.aliexpress.com/item/1005004441701974.html . The device has 3 buttons connected to ADC pin 1 so I can read them using this config:
sensor:
- platform: adc
id: button_adc
pin: 1
update_interval: .2s
attenuation: auto
button 1 when pressed reads 2.4360V
button 2 when pressed reads between 2.006 and 1.990V
button 3 when pressed reads 0.8262V
when released the reading is 3.1554V
Is there a way to use that info and make working buttons?
Thanks
alfwro13
(Andre W.)
July 28, 2023, 6:14pm
2
I have cracked it - that code seems to do the trick:
sensor:
- platform: adc
id: button_adc
pin: 1
update_interval: 200ms
attenuation: auto
binary_sensor:
- platform: template
name: "Button 1"
id: button_1
lambda: |-
if (id(button_adc).state > 2.2 && id(button_adc).state < 3.005){
return true;
} else {
return false;
}
- platform: template
name: "Button 2"
id: button_2
lambda: |-
if (id(button_adc).state > 1.8 && id(button_adc).state < 2.1) {
return true;
} else {
return false;
}
- platform: template
name: "Button 3"
id: button_3
lambda: |-
if (id(button_adc).state > 0.8 && id(button_adc).state < 1.8){
return true;
} else {
return false;
}
2 Likes
Thanks for this!
I made the version below to handle simultaneous button presses. The voltage ranges are a bit narrow, so hopefully the values don’t vary between devices or power supplies.
sensor:
- platform: adc
id: button_adc
pin: 1
update_interval: 200ms
attenuation: auto
binary_sensor:
- platform: template
name: "Button 1"
id: button_1
lambda: |-
if ( (id(button_adc).state > 2.2 && id(button_adc).state < 2.76) ||
(id(button_adc).state > 1.22 && id(button_adc).state < 1.81) ||
(id(button_adc).state > 0.73 && id(button_adc).state < 0.79) ||
id(button_adc).state < 0.68 ) {
return true;
} else {
return false;
}
- platform: template
name: "Button 2"
id: button_2
lambda: |-
if ( (id(button_adc).state > 1.22 && id(button_adc).state < 2.20) ||
id(button_adc).state < 0.73 ) {
return true;
} else {
return false;
}
- platform: template
name: "Button 3"
id: button_3
lambda: |-
if ( id(button_adc).state < 1.22) {
return true;
} else {
return false;
}
tozim
(Tobias)
September 16, 2023, 2:16pm
4
How did you disable the reset function of the button on the lower left?
alfwro13
(Andre W.)
September 30, 2023, 2:58pm
5
I don’t think you can - that’s hardwired to the reset button on the board
alfwro13
(Andre W.)
October 13, 2023, 11:27am
6
did you manage to get the microphone working on your esp32 s3 box lite?