Distance Sensors HC-SR04, JSN-SR04T and more

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Distance Sensors HC-SR04, JSN-SR04T and more

#1 Post by LisaM » 12 Aug 2017, 15:24

I'm going to revamp PO13 to include a whole new set of distance sensors using this library: https://bitbucket.org/teckel12/arduino- ... /wiki/Home
This should make maintaining the plugin a lot easier, since most functions are now part of the library.
I have an HC-SR04 and a JSN-SR04T, the others i cannot test...
Alternative to revamping P013 is to build a new plugin, but that wouldn't make much sense.

rol-rider
Normal user
Posts: 43
Joined: 02 Oct 2016, 12:36

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#2 Post by rol-rider » 13 Aug 2017, 10:01

Great !
I ordered this sensor.(JSN-SR04T)
thank you for your work.
sorry for my English ! i use google translat.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#3 Post by Shardan » 13 Aug 2017, 11:59

That's good, thanks for the info.

I'll put revamping the HC-SR04 Wiki on hold until the new plugin is merged.


Regards
Shardan
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#4 Post by LisaM » 13 Aug 2017, 23:26

Please let me know if anyone is using the STATE mode, state mode means that the distance is below the threshold set in the form earlier. When state mode is reached, distance below threshold, then a sensor switch event is send.

If nobody is using it, i can as well take it out...

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#5 Post by Domosapiens » 13 Aug 2017, 23:44

Lisa,
it is my intention to use State mode with the HC-SR04.
To check if my garage doors are fully opened.
So please don't remove this functionality.
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#6 Post by Shardan » 14 Aug 2017, 12:45

I'm using state mode with a HC_SR04
just for light switching in the basement.
It's far mor precise as PIR's
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#7 Post by LisaM » 14 Aug 2017, 12:56

Ok, i'll leave it in there. State is actually a 10-times per second check if the distance value has fallen below the threshold set in the form. Strangely enough the measured values in a 10-times per second loop are not broadcasted to the HA server, probably to not overload the HA server with messages.

I'm also going to add a metric(cm) vs imperial(inch) switch for our UK/US friends over here. ;)

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#8 Post by LisaM » 14 Aug 2017, 13:34

Shardan wrote: 14 Aug 2017, 12:45 I'm using state mode with a HC_SR04
just for light switching in the basement.
It's far mor precise as PIR's
Did you try the new microwave radar (RCWL-0516) yet?

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#9 Post by papperone » 14 Aug 2017, 13:42

LisaM wrote: 14 Aug 2017, 13:34
Shardan wrote: 14 Aug 2017, 12:45 I'm using state mode with a HC_SR04
just for light switching in the basement.
It's far mor precise as PIR's
Did you try the new microwave radar (RCWL-0516) yet?
I tested and well, they looks great in the beginning but... they are too powerful and do activate even when the movements are behind brick walls, glass, and concrete (like pavement between 2 floors).
They can be great for probably some application but as I wanted to use to switch light as well, it was switching even when someone was walking the upper floor, or in the next room when the room with the sensor was even with closed door!
Unless we build some sort of "screen" to stop microwaves go 360° form the sensor IMHO they are not ok as a light switch actuator (unless you want exactly this, turn on the light if the sensor capture a movement no matter where it is in all directions!)
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#10 Post by Shardan » 14 Aug 2017, 15:31

I have 5 or 10 RCWL0516 microwave sensors in the shelf.
Nice for some purposes but for lights in the basemet it is cruel.
It switches lights on if a dog in the floor above moves around the sensor and such.

It is possible to reduce sensivity, i know - but if i put sensivity down to a level where the sensor
isn't triggered from floor above or other side of the wall, it does not work for lighting at all.

Besides that, microwave sensors are not allowed in all countries and even if allowed they might be
forbidden in specific areas like airports and radar stations.

The HC-SR04 runs with a focused direction so i can go along the basement shelves and the light is
wandering in parallel... better then any microwave or PIR.
Another thing i want to use HC-SR04 with threshold for in the future is a "small area presence".
If i'm at home at all is detected my bluetooth, FHEM has a nice function for it and the raspberry 3 has bluetooth.
But i want to detect if i'm sitting at my desktop (printer is on, and desktop lights at night) or not.
A SR-04 hidden under the desktop does this job, i've tested it.
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#11 Post by LisaM » 14 Aug 2017, 16:58

I've ordered some and are considering using it at ground floor directed downwards. That should eliminate the triggers from the next room.
I'm done rewriting it, test phase is next...

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#12 Post by papperone » 14 Aug 2017, 17:29

LisaM wrote: 14 Aug 2017, 16:58 I've ordered some and are considering using it at ground floor directed downwards. That should eliminate the triggers from the next room.
I'm done rewriting it, test phase is next...
Please let me know as per my test the micrwave irradiates from the modules in all directions no matter how I position it :(
I know there are similar modules with different chipset and some kind of shielding on one side of the board in order to "cut" waves to goin that direction (so they cover only 180°)
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#13 Post by Shardan » 14 Aug 2017, 19:49

papperone wrote: 14 Aug 2017, 17:29
LisaM wrote: 14 Aug 2017, 16:58 I've ordered some and are considering using it at ground floor directed downwards. That should eliminate the triggers from the next room.
I'm done rewriting it, test phase is next...
Please let me know as per my test the micrwave irradiates from the modules in all directions no matter how I position it :(
I know there are similar modules with different chipset and some kind of shielding on one side of the board in order to "cut" waves to goin that direction (so they cover only 180°)
Definitely. These sensors are omnidirectional.
I can make it work if i go to a wall made from ferroconcrete.
Anyways it should be possible to shield the antenna if you cover two or three sides
of a case with aluminium foil for example. But don't put the foil too near to the module,
keep some centimeters distance. Maybe use a plastic case, mount the module at the mid of the lid and cover bottom and sides for shielding...
I didn't test that yet.

Regards
Shardan
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#14 Post by LisaM » 15 Aug 2017, 13:39

Shardan wrote: 14 Aug 2017, 19:49 Definitely. These sensors are omnidirectional.
I can make it work if i go to a wall made from ferroconcrete.
Anyways it should be possible to shield the antenna if you cover two or three sides
of a case with aluminium foil for example. But don't put the foil too near to the module,
keep some centimeters distance. Maybe use a plastic case, mount the module at the mid of the lid and cover bottom and sides for shielding...
I didn't test that yet.

Regards
Shardan
How about using the same kind of shielding/focus as on a HC-SR04? Some kind of a thin metal tube glued over the sensor...

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#15 Post by Shardan » 15 Aug 2017, 15:41

LisaM wrote: 15 Aug 2017, 13:39
Shardan wrote: 14 Aug 2017, 19:49 Definitely. These sensors are omnidirectional.
I can make it work if i go to a wall made from ferroconcrete.
Anyways it should be possible to shield the antenna if you cover two or three sides
of a case with aluminium foil for example. But don't put the foil too near to the module,
keep some centimeters distance. Maybe use a plastic case, mount the module at the mid of the lid and cover bottom and sides for shielding...
I didn't test that yet.

Regards
Shardan
How about using the same kind of shielding/focus as on a HC-SR04? Some kind of a thin metal tube glued over the sensor...
Microwaves are electromagnetic waves of some cm wavelengt. A metal tube very near the sensor influences the antenna tuning.
So it is better to keep some cm distance to the microwave antenna - it wil still misstune it a bit but not too much i hope.
Another way might be to tune the shielding into resonance with the antenna so it works like a radar dish or a Yagi antenna.
Might work or not, i won't predict any result.

But that won't make the microwave sensor usable for my purposes as i need a distance + threshhold.....
Regards
Shardan

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#16 Post by toffel969 » 15 Aug 2017, 21:58

LisaM wrote: 13 Aug 2017, 23:26 Please let me know if anyone is using the STATE mode, state mode means that the distance is below the threshold set in the form earlier. When state mode is reached, distance below threshold, then a sensor switch event is send.

If nobody is using it, i can as well take it out...
Hi LisaM

Would it be possible to include median function of the New ping lib?(optional with parameter on device page). It can be done using a dummy device and rules, however it can b very handy when using t distance sensor a water level sensor.
Regards seb
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#17 Post by LisaM » 16 Aug 2017, 00:20

toffel969 wrote: 15 Aug 2017, 21:58 Would it be possible to include median function of the New ping lib?(optional with parameter on device page). It can be done using a dummy device and rules, however it can b very handy when using t distance sensor a water level sensor.
Regards seb
No problem, i'll add another pulldown (normal, median).

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#18 Post by Shardan » 16 Aug 2017, 15:53

Looking forward to it.....
Regards
Shardan

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#19 Post by toffel969 » 16 Aug 2017, 19:29

Thanks :)
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#20 Post by LisaM » 18 Aug 2017, 17:12

Volunteers wanted... ;)

Tested with HC-SR04 and JSN-SR04T...
_P013_HCSR04.zip
(1.97 KiB) Downloaded 630 times

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#21 Post by Shardan » 18 Aug 2017, 18:39

I'll test as soon as i have some spare time.... might take a while.

Regards
Shardan
Regards
Shardan

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#22 Post by toffel969 » 18 Aug 2017, 20:13

Shardan wrote: 18 Aug 2017, 18:39 I'll test as soon as i have some spare time.... might take a while.

Regards
Shardan
Same here... unfortunately
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#23 Post by Shardan » 24 Aug 2017, 20:22

Hello Lisa,

I've unpacked the plugin to my source folder and compiling with platformio failed.

Code: Select all

Compiling .pioenvs\normal_4096\FrameworkArduino\Updater.o
D:/ESP_MEGA_Clone/ESPEasy-mega_20170818 - HCSR04/src/_P013_HCSR04.ino:12:21: fatal error: NewPing.h: No such file or di
rectory
#include <NewPing.h>
^
compilation terminated.
Is there a library missing in the .zip-file?

Regards
Shardan
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#24 Post by LisaM » 24 Aug 2017, 20:42


Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#25 Post by Shardan » 24 Aug 2017, 22:00

Quick breadboard setup, tested with the last Github version.
Distance - works
Threshhold - works
Free mem - 21624 constant.

Looks good so far. Can't test the JSN-SR04T, i don't have one yet.

Regards
Shardan
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#26 Post by LisaM » 24 Aug 2017, 23:17

Shardan wrote: 24 Aug 2017, 22:00 Quick breadboard setup, tested with the last Github version.
Distance - works
Threshhold - works
Free mem - 21624 constant.

Looks good so far. Can't test the JSN-SR04T, i don't have one yet.

Regards
Shardan
Great, thx for testing! :D
i have a JSN-SR04T running for week now, hopefully this can be confirmed by somebody else also. After confirmation, it's time to upload it into P013...

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#27 Post by Shardan » 25 Aug 2017, 10:28

Anytime :)

I'll let the breadboard run for a while and look if memory changes or such,
maybe combine it with a BME280 or such to see if anything interferes.

Regards
Shardan
Regards
Shardan

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#28 Post by LisaM » 25 Aug 2017, 13:14

Shardan wrote: 25 Aug 2017, 10:28 Anytime :)

I'll let the breadboard run for a while and look if memory changes or such,
maybe combine it with a BME280 or such to see if anything interferes.

Regards
Shardan
sonic.JPG
sonic.JPG (158.63 KiB) Viewed 42682 times
sonic mem.JPG
sonic mem.JPG (59.22 KiB) Viewed 42681 times
:D

rol-rider
Normal user
Posts: 43
Joined: 02 Oct 2016, 12:36

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#29 Post by rol-rider » 05 Sep 2017, 01:32

Hello,
I tested both sensors.
the hc-SR04 ------- distance = 180cm - ok ---- distance <to 20cm --- ok
the JSN-SR04T --- distance = 180cm - ok --- distance <to 20cm --- NOK

the JSN-SR04T looks less good for distances <20cm

excuse me for English .... google translate
sorry for my English ! i use google translat.

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#30 Post by LisaM » 05 Sep 2017, 09:23

rol-rider wrote: 05 Sep 2017, 01:32 Hello,
I tested both sensors.
the hc-SR04 ------- distance = 180cm - ok ---- distance <to 20cm --- ok
the JSN-SR04T --- distance = 180cm - ok --- distance <to 20cm --- NOK

the JSN-SR04T looks less good for distances <20cm

excuse me for English .... google translate
That is true, the specs for the JSN-SR04T clearly indicate that the JSN-SR04T is not useable for distances less then 20cm:
Electrical parameters: JSN-SR04T

Working voltage: DC 3.0-5.5V
Working current: <8mA
Acoustic emission frequency: 40khz
Farthest distance: 600cm
Nearest distance: 20cm
Distance accuracy: ±1cm
Module size: 42mm*29mm*12mm
Resolution: about 1mm
Angle: 75 degrees
Working temperature: -20℃—+70℃

rol-rider
Normal user
Posts: 43
Joined: 02 Oct 2016, 12:36

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#31 Post by rol-rider » 05 Sep 2017, 19:37

OK !
its good
and even with vcc 3.3V
sorry for my English ! i use google translat.

sammyke007
New user
Posts: 3
Joined: 12 Dec 2017, 03:30

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#32 Post by sammyke007 » 12 Dec 2017, 03:50

So the waterproof JSN-SR04T version is not measuring closer than 20cm correctly?
HC-SR04 with some selfmade waterproofing it will be then :D

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#33 Post by Domosapiens » 28 Jan 2018, 13:48

It seems that this PLUGIN_13 from LisaM
//#######################################################################################################
//#################################### Plugin 013: Ultrasonic Sensors ###################################
//################ models: HC-SR04, SRF05, SRF06, DYP-ME007, JSN-SR04T & Parallax PING ##################
//#######################################################################################################
viewtopic.php?f=5&t=3432&hilit=HC+SR04+ ... =10#p18413
never was integrated in the Mega branch. The version in the Mega branch has a header like this
//#######################################################################################################
//#################################### Plugin 013: HC-SR04 ##############################################
//#######################################################################################################
For what reason, it was not integrated?
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#34 Post by Shardan » 28 Jan 2018, 14:10

That's an interesting question.

I've been testing that plugin for a while, it worked nicely for me.
Regards
Shardan

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#35 Post by TD-er » 28 Jan 2018, 20:10

Could you please add an issue here: https://github.com/letscontrolit/ESPEasy/issues ?
It keeps merging/fixing things a lot easier.

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#36 Post by Domosapiens » 28 Jan 2018, 23:04

Sherdan and TD-er ... thanks for your acknowledge.
Opened issue: https://github.com/letscontrolit/ESPEasy/issues/782
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

bogas
Normal user
Posts: 20
Joined: 20 Jan 2018, 11:22

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#37 Post by bogas » 01 Feb 2018, 22:33

Shardan wrote: 28 Jan 2018, 14:10 That's an interesting question.

I've been testing that plugin for a while, it worked nicely for me.
Hi.
Which last version supports these sensors? Added to "mega"?

bogas
Normal user
Posts: 20
Joined: 20 Jan 2018, 11:22

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#38 Post by bogas » 02 Feb 2018, 12:30

Please share firmware (bin) 4096kB and / or 1024 with support JSN-SR04T.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#39 Post by Shardan » 02 Feb 2018, 17:45

So, now i'm at home and can check:
I've compiled the plugin with ESP-Mega with Sources from Aug. 18. 2017.

I've a compiled version for 4096KB on my HDD, it is attached.
Please remember that this is not an officially supported version.

Regards
Shardan
firmware4096-hcsr04.zip
(361.68 KiB) Downloaded 453 times
Regards
Shardan

JojoS
New user
Posts: 3
Joined: 08 Sep 2018, 13:48

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#40 Post by JojoS » 04 Oct 2018, 15:18

Hi,
there is an update for the US plugin. I have fixed some errors, now multiple sensors are possible. The plugin supports the median filter from the NewPing class, output as cm or inch (although this was possible with a formula expression already). I have changed also the calculation from integer to float so that you will see fractions of cm or inches.
For better troubleshooting, some more detailed errors will be shown in the log.

HomeJCL
Normal user
Posts: 89
Joined: 03 Feb 2018, 10:42

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#41 Post by HomeJCL » 04 Oct 2018, 16:16

Hi

Read it this morning, was nearly to jump ship for that measurement, you make my day, will test tonight 👍
Belgium and land of ESP ... counting :D

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#42 Post by grovkillen » 04 Oct 2018, 17:04

JojoS wrote: 04 Oct 2018, 15:18 Hi,
there is an update for the US plugin. I have fixed some errors, now multiple sensors are possible. The plugin supports the median filter from the NewPing class, output as cm or inch (although this was possible with a formula expression already). I have changed also the calculation from integer to float so that you will see fractions of cm or inches.
For better troubleshooting, some more detailed errors will be shown in the log.
Great job JoJoS!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#43 Post by tparvais » 10 Apr 2020, 16:26

Hello

I've tested my JSN-SR04T (not version 02) , never used with last Mega build 20200328. It does not work. Measure = 0
I i use my HC-SR04, it works fine.

should it work for both with same plugin ?

Im' a bit los of what I shall do. I don't have a scope to idetnify the problem

Any idea ?

Thank you

Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#44 Post by TD-er » 10 Apr 2020, 19:21

This datasheet (https://www.makerguides.com/wp-content/ ... asheet.pdf ) does mention a resistor on R27 to switch between different modi.

Open = similar behavior to the well known other Ultrasonic sensors
47k = switch to serial mode continuously sending distance in mm
120k = serial mode starting in stand-by and you have to wake it.

tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#45 Post by tparvais » 10 Apr 2020, 19:32

TD-er wrote: 10 Apr 2020, 19:21 This datasheet (https://www.makerguides.com/wp-content/ ... asheet.pdf ) does mention a resistor on R27 to switch between different modi.

Open = similar behavior to the well known other Ultrasonic sensors
47k = switch to serial mode continuously sending distance in mm
120k = serial mode starting in stand-by and you have to wake it.
thanks. I know the R27.
I don't have this resistor on my PCB :-(
still searching

thank you anyway
T.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#46 Post by TD-er » 10 Apr 2020, 19:38

How is the board powered?
Can you measure the voltage you supply to the sensor?
Maybe switch to 5V for powering the sensor and then add a small voltage divider to make sure the output of the signal pin is not over 3v3?

Maybe the GPIO connected to the trigger pin should have its pull-up resistor enabled?

tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#47 Post by tparvais » 10 Apr 2020, 21:17

TD-er wrote: 10 Apr 2020, 19:38 How is the board powered?
Can you measure the voltage you supply to the sensor?
Maybe switch to 5V for powering the sensor and then add a small voltage divider to make sure the output of the signal pin is not over 3v3?

Maybe the GPIO connected to the trigger pin should have its pull-up resistor enabled?
Wemos D1 mini, powered by USB. JST module powered by 5V. Echo output is connected to PIN5 via a zener+Resistor to decrease level (works for hc-sr04). I tried also without

I tried this very simple code without success (always 0 cm)

Code: Select all

#define ECHOPIN 5// Pin to receive echo pulse
#define TRIGPIN 4// Pin to send trigger pulse
void setup(){
  Serial.begin(9600);
  pinMode(ECHOPIN, INPUT_PULLUP);
  pinMode(TRIGPIN, OUTPUT);
  
  digitalWrite(ECHOPIN, HIGH);
}
void loop(){
  digitalWrite(TRIGPIN, LOW); // Set the trigger pin to low for 2uS
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH); // Send a 10uS high to trigger ranging
  delayMicroseconds(15);
  digitalWrite(TRIGPIN, LOW); // Send pin low again
  int distance = pulseIn(ECHOPIN, HIGH,26000); // Read in times pulse
  distance= distance/58;
  Serial.print(distance);
  Serial.println("   cm");                  
  delay(50);// Wait 50mS before next ranging
}

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#48 Post by TD-er » 10 Apr 2020, 21:47

Maybe the trigger you try to send does not have the right voltage level?
Have you tried using a PNP transistor to increase the output level?

tparvais
Normal user
Posts: 99
Joined: 28 Oct 2015, 23:13

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#49 Post by tparvais » 11 Apr 2020, 12:23

TD-er wrote: 10 Apr 2020, 21:47 Maybe the trigger you try to send does not have the right voltage level?
Have you tried using a PNP transistor to increase the output level?
I'm now feeding with real 5V, not usb naymore. Power is ok on JSN module.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Distance Sensors HC-SR04, JSN-SR04T and more

#50 Post by TD-er » 11 Apr 2020, 15:33

I was talking about the trigger signal from the ESP to the ultra sonic sensor.
Maybe the logic level is too low for that sensor to act on it?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 25 guests