Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:12 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Help how to hookup HC-SR04

Author Message
Rickard5

Guru

Joined: 31/03/2022
Location: United States
Posts: 463
Posted: 05:58pm 17 Apr 2022
Copy link to clipboard 
Print this post

Hello everybody I'm trying to figure out how to hookup the HC-SR04 o the Picomite and the only info I found was from the manual :

  Quote  Using a HC-SR04 ultrasonic sensor and the DISTANCE() function you can measure the distance to a target.
Any PicoMite I/O Pin
On the PicoMite you use the DISTANCE function as follows:
    d = DISTANCE(trig, echo)
The value returned is the distance in centimetres to the target.
Where trig is the I/O pin connected to the "trig" input of the sensor and echo is the pin connected the "echo" output of the sensor. You can also use 3-pin devices and in that case only one pin number is specified. The maximum voltage on the PicoMite’s I/O pins is 3.3V so a resistor divider will be required to interface the PicoMite to the echo pin of the sensor (which operates on 5V).


my question is, so how do I build this Resistor Divider? and what pins do I use ?
I may be Vulgar, but , while I'm poor, I'm Industrious, Honest,  and trustworthy! I Know my Place
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 08:34pm 17 Apr 2022
Copy link to clipboard 
Print this post

This is from my Android app "Electrodoc" (nice).

Play with combinations that suit what you have in stock or whatever power dissipation you want to shoot for.




Craig
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 09:00pm 17 Apr 2022
Copy link to clipboard 
Print this post

I doubt if the Pico input will load that with 165R!

Try 3.3K on top and 6.8K on the bottom to give 3.366V off-load. The Pico input is pretty high resistance but that is safe and will drop a little further.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Rickard5

Guru

Joined: 31/03/2022
Location: United States
Posts: 463
Posted: 09:57pm 17 Apr 2022
Copy link to clipboard 
Print this post

so VCC goes Strait to 5v pin
GND goes strait to GND pin
ECHO goes straight to an input
and Trig goes through visitor ladder ?
Thanks Guys
I feel Dumb but I don't know
I may be Vulgar, but , while I'm poor, I'm Industrious, Honest,  and trustworthy! I Know my Place
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:20pm 17 Apr 2022
Copy link to clipboard 
Print this post

  Rickard5 said  so VCC goes Strait to 5v pin
GND goes strait to GND pin
ECHO goes straight to an input
and Trig goes through visitor ladder ?
Thanks Guys
I feel Dumb but I don't know


TRIGGER goes straight to an output
and ECHO goes through resistor ladder to input
VK7JH
MMedit
 
Rickard5

Guru

Joined: 31/03/2022
Location: United States
Posts: 463
Posted: 11:12pm 17 Apr 2022
Copy link to clipboard 
Print this post

OK Cool Thanks Jim now I just have to go though the unenviable task of sorting though the mega box of Resistors looking for 3.3 K and 6.8k resistors :)2 then I'm off to try it :)
I may be Vulgar, but , while I'm poor, I'm Industrious, Honest,  and trustworthy! I Know my Place
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 12:12am 18 Apr 2022
Copy link to clipboard 
Print this post

Getting the exact resistors isn't very important. Just make the bottom one twice the value (or a little less to be safe) of the top one.
Other examples:-
5.1k, 10k
12k, 22k
2.7k, 5.1k

The required voltage ratio is

3.3 / 5 = 2/3

So you can use any three of the same value in series to get an exact division of 2/3.
 
KD5ZXG
Regular Member

Joined: 21/01/2022
Location: United States
Posts: 53
Posted: 02:37am 18 Apr 2022
Copy link to clipboard 
Print this post

Cut 5V simply in half works fine too.
Anything over 2V is probably logic true.
You can hit anywhere from there to 3.3V.
Edited 2022-04-18 12:39 by KD5ZXG
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 06:33am 18 Apr 2022
Copy link to clipboard 
Print this post

Using 50% is borderline and there's no real need to do it. It increases problems due to noise on the signal and supply lines. e.g. you have a Pico input that happens to need 2.1v (within spec). If you use 50% then you have to guarantee an output of 4.2V. If your "5V" rail is at 4.7V then that may not be possible.

Also, don't use too high a value if using a potential divider for level shifting into MOS logic. Inputs have a high impedance and capacitance so high resistor values will slow the logic down. That can lead to all sorts of interesting bugs to find. :) You generally have plenty of current to spare so use it. Why use a 10uA divider when you can use a 1mA one?
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025