🤖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

    Scheduled Pinned Locked Moved UIFlow
    3 Posts 3 Posters 7.4k Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post