HC-SR04

Any bugs you encounter with Flowcode should be discussed here.
ELECTRONICA67
Posts: 83
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 20 times
Been thanked: 6 times

HC-SR04

Post by ELECTRONICA67 »

Hi, I was testing the hc-sr04 sonic sensor using the example published on wiki, by compiling the program in the Pic and testing the correct operation of the distance detected by the sensor, it gives a fixed reading of distance=504 cm and it does not change.
Can you check it please :?:

Thanks
Enrique
Attachments
HC-SR04_Distance_Sensor_Demo.fcfx
(11.04 KiB) Downloaded 49 times

medelec35
Matrix Staff
Posts: 1452
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: HC-SR04

Post by medelec35 »

Hello Enrique.
I have just tested with an HC-SR04 and it does show distance changes for me.
Could you have a connection issue?
Are you using the BL0011 Eblocks2?
Can you describe what hardware you are using?
Martin

ELECTRONICA67
Posts: 83
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 20 times
Been thanked: 6 times

Re: HC-SR04

Post by ELECTRONICA67 »

Hello Martin,

I am using the AJ-SR04M model (waterproof), in fact I have this sensor working with a program that you developed in Flowcode 5.

Thanks
Enrique

medelec35
Matrix Staff
Posts: 1452
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: HC-SR04

Post by medelec35 »

They should be compatible so I'm surprised it's not working
Do you have the link to the post with the Flowcode v5 help, or the v5 project file?
Also, do you have a voltage analyser, A dual scope, or a Matrix Eblock2 upstream board with ghost, e.g. BL0011?
Martin

ELECTRONICA67
Posts: 83
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 20 times
Been thanked: 6 times

Re: HC-SR04

Post by ELECTRONICA67 »

Hello Martin,

I'm going to buy another sensor, maybe it's damaged and I'll do the test again.

Thanks
Enrique

medelec35
Matrix Staff
Posts: 1452
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: HC-SR04

Post by medelec35 »

Now you have ordered one we could test that when it arrives, so you will know for the future.
Assuming you have any of the above of course.

This might be the topic you were referring to.
Martin

ELECTRONICA67
Posts: 83
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 20 times
Been thanked: 6 times

Re: HC-SR04

Post by ELECTRONICA67 »

Ok thank you, When it arrives I will do the test and let you know the result.

jgu1
Posts: 615
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 507 times
Been thanked: 132 times

Re: HC-SR04

Post by jgu1 »

Hi Both!

I think the sensor Enriko use is this model: https://www.aliexpress.com/item/1005005 ... ainProduct

@martin. I remember from a previus test that the Trig duration for the HCR04 is 10uS, for the waterproof model it work with duration on 20uS

I have played with both model and if I change the trig duration to 20uS for the waterproof model, and it work, the att, testprogram I think it is yours tesprogram Martin, For loong time ago, when I played with it, I change the device to an Arduino Mega, change the trigtiming to 20uS. Futhermore in this waterproof device is more setting for communication.
Here is a very good explanation here by Droonebot: https://dronebotworkshop.com/waterproof-ultrasonic/
Maybe an idea to update the component for HC-SR04 and inplement more features in the component for more different kind of type in your component so it (as always from you) would be more flexibel :D

****By the way Martin, have you seen this: viewtopic.php?f=3&t=2091&start=10 at the end ;) *****

Hope it´s ok I interfered :D

Br jorgen
Attachments
Distance Sensor Mega - Temp Compensation_v8_God.fcfx
(24.71 KiB) Downloaded 48 times

medelec35
Matrix Staff
Posts: 1452
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: HC-SR04

Post by medelec35 »

Thank you, Jorgen.
jgu1 wrote:
Thu Sep 14, 2023 7:06 pm
Hope it´s ok I interfered
It's totally OK as what you have stated is useful information and thank you for the links.
We like it when other forum members have their say on a topic.
With your information, I can modify the HC-SR04 component to work with both types, assuming the waterproof version is not faulty.
Martin

jgu1
Posts: 615
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 507 times
Been thanked: 132 times

Re: HC-SR04

Post by jgu1 »

Glad if I can help. :D Look forward to see if you can modify the component with some option in Properties, let me know if I can do something, tests or so.

****By the way Martin, have you seen this: viewtopic.php?f=3&t=2091&start=10 at the end ;) *****

Br Jorgen

Post Reply