🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5stack connect HC-SR04 with I/O port (not grove connector) coding by UI Flow

    UIFlow
    3
    3
    6.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      doctan
      last edited by

      Hello i'm trying M5stack Basic Development conect ultrasonic sensor model HC-SR04 with GPIO2 (trig) & GPIO5 (echo) for read parameter shown on the screen.
      So coding on UI Flow but in platform don't have digital pwm read input function (in Arduino IDE is "pluseIn")
      Could there be any object or commands or functions that can be used instead, or how can the program read pulse input ?

      thank you so much.

      1 Reply Last reply Reply Quote 0
      • lukasmaximusL
        lukasmaximus
        last edited by

        @doctan I used an ultrasonic sensor with m5stack in arduino before but it is a simple one
        https://www.hackster.io/lukasmaximus89/grove-ultrasonic-sensor-with-m5stack-710d15 and made a guide, but it is arduino. For uiflow since m5stack did not create any ultrasonic unit you would have to create your own code in micropython to control it and then create custom blocks. I think I read that hc-sr04 has 5 pins, is it true? and is it using i2c protocol or just analogue out?

        1 Reply Last reply Reply Quote 0
        • S
          Serge
          last edited by

          This worked well for me with pin 21 (trigger) and pin 22 (echo)

          https://github.com/rsc1975/micropython-hcsr04

          1 Reply Last reply Reply Quote 0
          • First post
            Last post