Connecting Arduino with ESP-01S

I was trying to set it up, I created this

binary_sensor:
  - platform: gpio
    id: "potenciometr_pin_1"
    pin:
      number: 05
      mode:
        input: true
        pullup: true
    name: "potenciomet pin 1"
    device_class: update

  - platform: gpio
    id: "potenciometr_pin_2"
    pin:
      number: 04
      mode:
        input: true
        pullup: true
    name: "potenciomet pin 2"
    device_class: update


and it kind of works but at every signal it it goes both ON and OFF, this id part of log

[D][binary_sensor:036]: 'potenciomet pin 1': Sending state ON
[D][binary_sensor:036]: 'potenciomet pin 1': Sending state OFF
[D][binary_sensor:036]: 'potenciomet pin 1': Sending state ON
[D][binary_sensor:036]: 'potenciomet pin 1': Sending state OFF

Sorry for this for sure dumb questions but this is my first project using D1 mini so I dont really know what I am doing

You probably want to use the adc component instead of the binary_sensor which only knows on and off :wink:

But I only need on/off I need to send the information that the ā€œbuttonā€ was pressed and I need it for 9 buttons so using analog pin does not make sense

thatā€™s how a button works. when you press it, itā€™s ON and when you release it, itā€™s OFF. Does it need to stay on or off with a single push?

yeah, sorry I just realized and was going to write it so thats that, I am going to use 2 D1 and that should do the trick, thank you all guys for your help both projects I wanted to do are working and I really would not manage it without you, especially Justin and Stephen so thanks guys very much

Thereā€™s really no reason you should need to use 2 d1 mini boards for a single project. Is the second one just for more GPIO pins?

Yes, I need 9 in total

there are 10 usable gpio pins on the d1 miniā€¦

thereā€™s really 11 but a couple have certain requirements on boot and either need to be high or low BUT you can still use them.

and I can use them all as buttons? orange-assistant said I would need to use port expander

so I could ude D0 to D8 and it would not cause any problems?

yes. for example look at RX-GPIO3 - High at boot. It just needs to be high at boot so you cant attach a button to that pin and use a pull down resistor as that will pull it LOW and it wont be able to boot. As long as your not interfering with the logic level it needs to be in at boot then you can use it. A lot of people will say you canā€™t or dont use them because itā€™s just easier to say that and avoid issues when they get used incorrectly.

These are pins you wouldnā€™t want to use if normal GPIO pins are available, they shouldnā€™t be your fist choice but, you can use them.

Ok so if I only connect buttons and not any pullup or pulldown resistors I should be ok, so I can connect button that has one pin to GND and other to D0 but I can not press it when its booting but after it starts I can use it with no problems

yes. the one issue you may run into though is when its booting, the state of that pin(button) does change and that may effect whatever that button is supposed to trigger in your program but, you can usually account for this by ignoring it or some other way. It very well may not cause an issue either since itā€™s only happening during boot and it may not register as a valid button press in your program. Just try it, if you need help iā€™m here for a few more hours.

for example here. This morning i was messing around with 2 stepper motors and a d1 mini. Iā€™m making a pan/tilt mount for a camera so i can move it through HA. I try not to use those GPIO pins but i needed to use 1 because i have 4 control pins for each stepper and i had to use one. Iā€™m using RX-GPIO3. As long as iā€™m not pulling it low at boot, which doesnā€™t happen with me using a stepper then itā€™s fine.

stepper:
  - platform: uln2003
    id: my_stepper1
    pin_a: D4
    pin_b: D2
    pin_c: D1
    pin_d: GPIO3
    max_speed: 250 steps/s

    # Optional:
    acceleration: inf
    deceleration: inf  

  - platform: uln2003
    id: my_stepper2
    pin_a: D7
    pin_b: D6
    pin_c: D5
    pin_d: D0
    max_speed: 250 steps/s

    # Optional:
    acceleration: inf
    deceleration: inf    
         
button:
  platform: template
  name: step2
  on_press:
    then:
    - stepper.set_target:
        id: my_stepper1
        target: 250         

    - stepper.set_target:
        id: my_stepper2
        target: 250            

ok, I think I get it, well I am going to try to connect it all and I will be back with update

Ok I connected everything and it works, kind ofā€¦ most of the times when I turn the ā€œpotentiometerā€ one way it pushes both way like for example I turn what should activate potentiometer 1 pin 1 and it does but with that also activates pin 2, could there be problem in my code? also sending example from log, I pressed the button and then rotated once to one side and it did this

[D][binary_sensor:036]: 'potenciometr 2 push': Sending state OFF
[D][binary_sensor:036]: 'potenciometr 2 push': Sending state ON
[D][binary_sensor:036]: 'potenciometr 2 pin 2': Sending state OFF
[D][binary_sensor:036]: 'potenciometr 2 pin 2': Sending state ON
[D][binary_sensor:036]: 'potenciometr 2 pin 1': Sending state OFF
[D][binary_sensor:036]: 'potenciometr 2 pin 1': Sending state ON
binary_sensor:
  - platform: gpio
    id: "potenciometr_1_pin_1"
    pin:
      number: 05
      mode:
        input: true
        pullup: true
    name: "potenciomet 1 pin 1"
    device_class: update

  - platform: gpio
    id: "potenciometr_1_pin_2"
    pin:
      number: 04
      mode:
        input: true
        pullup: true
    name: "potenciometr 1 pin 2"
    device_class: update

  - platform: gpio
    id: "potenciometr_1_push"
    pin:
      number: 00
      mode:
        input: true
        pullup: true
    name: "potenciometr 1 push"
    device_class: update

  - platform: gpio
    id: "potenciometr_2_pin_1"
    pin:
      number: 03
      mode:
        input: true
    name: "potenciometr 2 pin 1"
    device_class: update

  - platform: gpio
    id: "potenciometr_2_pin_2"
    pin:
      number: 14
      mode:
        input: true
        pullup: true
    name: "potenciometr 2 pin 2"
    device_class: update

  - platform: gpio
    id: "potenciometr_2_push"
    pin:
      number: 02
      mode:
        input: true
        pullup: true
    name: "potenciometr 2 push"
    device_class: update

  - platform: gpio
    id: "potenciometr_3_pin_1"
    pin:
      number: 12
      mode:
        input: true
        pullup: true
    name: "potenciometr 3 pin 1"
    device_class: update

  - platform: gpio
    id: "potenciometr_3_pin_2"
    pin:
      number: 13
      mode:
        input: true
        pullup: true
    name: "potenciometr 3 pin 2"
    device_class: update

  - platform: gpio
    id: "potenciometr_3_push"
    pin:
      number: 15
      mode:
        input: true
    name: "potenciometr 3 push"
    device_class: update


ok so after some more testing it seems that its hardware problem with the ā€œpotentiometersā€

https://www.aliexpress.com/item/10000000931574.html

is this the one that shouldnā€™t be there?
[D][binary_sensor:036]: ā€˜potenciometr 2 pin 1ā€™: Sending state OFF
[D][binary_sensor:036]: ā€˜potenciometr 2 pin 1ā€™: Sending state ON

exactly, the problem was that I was using encoder but set it up as buttons so when I set it up as encoder its now working great

ya, using it as a binary sensor isnā€™t really ideal, although i guess you could do something with it like that. I was going to say the reason you got that unexpected state change was because you left it floating while the other pins are pulled High.

- platform: gpio
    id: "potenciometr_1_push"
    pin:
      number: 00
      mode:
        input: true
        pullup: true
    name: "potenciometr 1 push"
    device_class: update

  - platform: gpio
    id: "potenciometr_2_pin_1"
    pin:
      number: 03
      mode:
        input: true
    name: "potenciometr 2 pin 1"
    device_class: update