Has anyone been able to use one of these joysticks with Esphome?
That is ridiculously cheap isn’t it?
The docs says it acts as two analog readings (for x and y) and a switch (for press). You’d need two ADC pins, so a ESP32 should work best.
You’ll also need to adjust the voltage from 5v down to 1.1v with voltage divider resistors.
Has anyone got a simple example for home assistant esphome 32 board
Ie moving a dot on screen in graph box or anything for me to get a simple starter project
Not very complicated
Moving in a box google map even for location with stick example anything easy to do with
Homeassistant and esphome thanks brian
The following works for me using this joystick: Arduino Compatible X and Y Axis Joystick Module | Jaycar Electronics New Zealand
I am powering this off the ESP32 3.3v, so no other voltage changes are needed, as each axis becomes 0-3.3v.
sensor:
- platform: adc
id: joystick_x
name: "Joystick X axis"
pin: GPIO33
internal: True
attenuation: auto
update_interval: 500ms
- platform: adc
id: joystick_y
name: "Joystick Y axis"
pin: GPIO35
internal: True
attenuation: 11db
update_interval: 500ms
binary_sensor:
# https://home-assistant-guide.com/guide/how-to-use-a-physical-switch-or-button-in-esphome-with-gpio-binary-sensor/
- platform: gpio
id: joystick_click
pin:
number: GPIO32
mode: INPUT_PULLUP
inverted: True
name: "Joystick click"
internal: True
display:
...
if (id(joystick_x).has_state()) {
it.printf(127, 70, id(roboto_10), colour_green, TextAlign::BASELINE_RIGHT , "JSX %.1f °", id(joystick_x).state);
}
else {
it.print(127, 70, id(roboto_10), colour_red, TextAlign::TOP_RIGHT ,"NJSX");
}
if (id(joystick_y).has_state()) {
it.printf(127, 80, id(roboto_10), colour_green, TextAlign::BASELINE_RIGHT , "JSY %.1f °", id(joystick_y).state);
}
else {
it.print(127, 80, id(roboto_10), colour_red, TextAlign::TOP_RIGHT ,"NJSY");
}