Become a leader in the IoT community!

Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.

Step 1 of 5

CREATE YOUR PROFILE *Required

OR
Step 2 of 5

WHAT BRINGS YOU TO DEVHEADS? *Choose 1 or more

Connect & collaborate 🤝with other tech professionals
Learn & Grow 📚
Contribute Experience & Expertise 🔧
Step 3 of 5

WHAT'S YOUR INTEREST OR EXPERTISE? *Choose 1 or more

Hardware Design 💡
Embedded Software 💻
Edge Networking
Step 4 of 5

Personalize your profile

Step 5 of 5

Read & agree to our COMMUNITY RULES

  1. We want this server to be a welcoming space! Treat everyone with respect. Absolutely no harassment, witch hunting, sexism, racism, or hate speech will be tolerated.
  2. If you see something against the rules or something that makes you feel unsafe, let staff know by messaging @admin in the "support-tickets" tab in the Live DevChat menu.
  3. No age-restricted, obscene or NSFW content. This includes text, images, or links featuring nudity, sex, hard violence, or other graphically disturbing content.
  4. No spam. This includes DMing fellow members.
  5. You must be over the age of 18 years old to participate in our community.
  6. You agree to our Terms of Service (https://www.devheads.io/terms-of-service/) and Privacy Policy (https://www.devheads.io/privacy-policy)
By clicking "Finish", you have read and agreed to the our Terms of Service and Privacy Policy.

Using ESP32 for 3-pin Sensor Square Wave Input

Hey everyone, I have a 3-pin sensor that operates at 5V to 12V (12V for optimal performance) and outputs a square wave signal. Previously, I used an Arduino since its digital pins can handle 5V input, allowing me to count pulses by detecting the falling edge. Now, I want to use an ESP32 instead. How should I proceed with inputting the data properly?

  1. undefined2001#0000

    voltage divider can do the job but tha’s not a good option

  2. accur4te#0000

    ok got it

  3. undefined2001#0000

    if you want long term effectiveness then go with logic level shifter

  4. accur4te#0000

    is going with a voltage divide a good choice ?

  5. undefined2001#0000

    in that case you can go with the voltage divider approach

  6. accur4te#0000

    ohhh okay i was confused with different approaches thanks for solving the confusion

  7. undefined2001#0000

    well you can use a logic level shifter

  8. accur4te#0000

    frequency of my signal is below 100hz . if this makes a difference while choosing with which option to go with

  9. undefined2001#0000

    for example since the frequency is really low you can go with the voltage divider and LL shifter

  10. undefined2001#0000

    options varies on your requirements

  11. undefined2001#0000

    but LL shifter will be an overkill approach but more reliable

  12. accur4te#0000

    but its difficult to find a ll shifter for 12v to 3.3 , i have searched multiple sites in india , but its not available for that requirement , i will go for voltage divider for now

  13. undefined.elf#0000

    if you have to shift that much voltage then use Optocoupler instead

  14. accur4te#0000

    hey i tired the voltage divider method but the problem is that my sensor is outputting 0v to 11v and averaging around 6-7v . so if i design a voltage divider for 6,7v it can damage the esp cause of sudden spikes of 10-11v . but if i design a voltage divider for 12v , the input that esp receiving is 0.50v max during most of the time which is being not detected by the esp32 . the signal is a square wave . How should i tackle this issue?

  15. undefined2001#0000

    since your sensor doesn’t give constant output using voltage divider is not gonna be the best option as it varies but resistance is constant

  16. undefined2001#0000

    I would rather suggest you to use Optocoupler or MOSFET

  17. accur4te#0000

    but if the average value voltage is 6-7v (which will input around 1.62 to 1.97v) will esp able to detect the pulses of that voltage it seems less , but i might be wrong

  18. afuevu_#0000

    The challenge I see here is the resistor value you are using, use a voltage divider such that at 12v input the ESP should be seeing 3.2v

  19. afuevu_#0000

    Hmmm…your source voltage is 12v, so I expect your square wave to go from between 0v and 12v, just for clarity sake, were is the average voltage coming from?

CONTRIBUTE TO THIS THREAD

Browse other questions tagged 

Leaderboard

RANKED BY XP

All time
  • 1.
    Avatar
    @Nayel115
    1620 XP
  • 2.
    Avatar
    @UcGee
    650 XP
  • 3.
    Avatar
    @melta101
    600 XP
  • 4.
    Avatar
    @chitour
    600 XP
  • 5.
    Avatar
    @lifegochi
    250 XP
  • 6.
    Avatar
    @Youuce
    180 XP