Distance Sensors HC-SR04, JSN-SR04T and more
Moderators: grovkillen, Stuntteam, TD-er
Distance Sensors HC-SR04, JSN-SR04T and more
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.
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Great !
I ordered this sensor.(JSN-SR04T)
thank you for your work.
I ordered this sensor.(JSN-SR04T)
thank you for your work.
sorry for my English ! i use google translat.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
I'll put revamping the HC-SR04 Wiki on hold until the new plugin is merged.
Regards
Shardan
Regards
Shardan
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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...
If nobody is using it, i can as well take it out...
-
- Normal user
- Posts: 307
- Joined: 06 Nov 2016, 13:45
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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.
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
I'm using state mode with a HC_SR04
just for light switching in the basement.
It's far mor precise as PIR's
just for light switching in the basement.
It's far mor precise as PIR's
Regards
Shardan
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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.
I'm also going to add a metric(cm) vs imperial(inch) switch for our UK/US friends over here.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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.
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
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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...
I'm done rewriting it, test phase is next...
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Definitely. These sensors are omnidirectional.papperone wrote: ↑14 Aug 2017, 17:29Please 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°)
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
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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 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
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Microwaves are electromagnetic waves of some cm wavelengt. A metal tube very near the sensor influences the antenna tuning.LisaM wrote: ↑15 Aug 2017, 13:39How 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 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
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
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Hi LisaMLisaM 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...
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
Re: Distance Sensors HC-SR04, JSN-SR04T and more
No problem, i'll add another pulldown (normal, median).
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Thanks
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Volunteers wanted...
Tested with HC-SR04 and JSN-SR04T...
Tested with HC-SR04 and JSN-SR04T...
Re: Distance Sensors HC-SR04, JSN-SR04T and more
I'll test as soon as i have some spare time.... might take a while.
Regards
Shardan
Regards
Shardan
Regards
Shardan
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Hello Lisa,
I've unpacked the plugin to my source folder and compiling with platformio failed.
Is there a library missing in the .zip-file?
Regards
Shardan
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.
Regards
Shardan
Regards
Shardan
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
The newping lib can be found here: https://bitbucket.org/teckel12/arduino- ... /wiki/Home
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
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
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Great, thx for testing!
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...
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
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
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
That is true, the specs for the JSN-SR04T clearly indicate that the JSN-SR04T is not useable for distances less then 20cm: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
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℃
Re: Distance Sensors HC-SR04, JSN-SR04T and more
OK !
its good
and even with vcc 3.3V
its good
and even with vcc 3.3V
sorry for my English ! i use google translat.
-
- New user
- Posts: 3
- Joined: 12 Dec 2017, 03:30
Re: Distance Sensors HC-SR04, JSN-SR04T and more
So the waterproof JSN-SR04T version is not measuring closer than 20cm correctly?
HC-SR04 with some selfmade waterproofing it will be then
HC-SR04 with some selfmade waterproofing it will be then
-
- Normal user
- Posts: 307
- Joined: 06 Nov 2016, 13:45
Re: Distance Sensors HC-SR04, JSN-SR04T and more
It seems that this PLUGIN_13 from LisaM
never was integrated in the Mega branch. The version in the Mega branch has a header like this
viewtopic.php?f=5&t=3432&hilit=HC+SR04+ ... =10#p18413//#######################################################################################################
//#################################### Plugin 013: Ultrasonic Sensors ###################################
//################ models: HC-SR04, SRF05, SRF06, DYP-ME007, JSN-SR04T & Parallax PING ##################
//#######################################################################################################
never was integrated in the Mega branch. The version in the Mega branch has a header like this
For what reason, it was not integrated?//#######################################################################################################
//#################################### Plugin 013: HC-SR04 ##############################################
//#######################################################################################################
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
That's an interesting question.
I've been testing that plugin for a while, it worked nicely for me.
I've been testing that plugin for a while, it worked nicely for me.
Regards
Shardan
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Could you please add an issue here: https://github.com/letscontrolit/ESPEasy/issues ?
It keeps merging/fixing things a lot easier.
It keeps merging/fixing things a lot easier.
-
- Normal user
- Posts: 307
- Joined: 06 Nov 2016, 13:45
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Sherdan and TD-er ... thanks for your acknowledge.
Opened issue: https://github.com/letscontrolit/ESPEasy/issues/782
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Please share firmware (bin) 4096kB and / or 1024 with support JSN-SR04T.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
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
Regards
Shardan
Shardan
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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.
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
Hi
Read it this morning, was nearly to jump ship for that measurement, you make my day, will test tonight
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
- 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
Great job JoJoS!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.
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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
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
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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.
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.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
thanks. I know the R27.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.
I don't have this resistor on my PCB
still searching
thank you anyway
T.
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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?
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?
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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 withoutTD-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?
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
}
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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?
Have you tried using a PNP transistor to increase the output level?
Re: Distance Sensors HC-SR04, JSN-SR04T and more
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?
Maybe the logic level is too low for that sensor to act on it?
Who is online
Users browsing this forum: Google [Bot] and 1 guest