Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Thomas Weeks
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Thomas Weeks

    @Thomas Weeks

    6
    Reputation
    10
    Posts
    7
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Thomas Weeks Follow

    Best posts made by Thomas Weeks

    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      For those interested..

      I found another engineer who reverse engineered the JSN-SR04T v2. Not identical, but close. Here's the v2 schematic:
      JSN-SR04T_Schematic.jpg

      Here's the full theory of operation article he wrote (in Vietnamese, google xlate URL) on how to remove the STM 8 bit microcontroller and do your own echo-pulse based on the waveshape of the detection LED driver.

      Here's an interesting tidbit of implementation info that's good to know before you try to use this sensor in a project:

      "Defect:

      • JSN-SR04T has a very large opening angle (> = 75 degrees), so it is NOT suitable for measuring distances in tight spaces. Should only be used in open spaces such as outdoors or large-size tanks - no obstructions .

      • If measured in a confined space, the error is very large due to the reflected wave being impacted and the object or the tank - tank wall."

      Good to know!... I have seen some of this error in the form of echo width "jitter" both in the bad/unreliable data, as well as with the raw signal combing back on the o-scope:
      JSN_jitter.png

      I'll need to experiment with this in confined spaces.. but the JSN units also seems to have problems with "soft targets" (like people in clothes). You can test this yourself by testing with a plywood sheet (the size of a person) vs a clothed person. If anyone finds a way to get more reliable soft target detection, please share here.

      These JSN-SR04 modules seem to have multiple operating modes.

      On the v2 module, the empty R27 pad controls the echo mode of operation. Here's a best guess regarding the four "operating modes" that I think the author is documenting (attempted to better translate from Vietnamese):

      1. Trigger/Echo ECHO-Pulse Mode (default): (R27 open)
      You send a 10uS pulse on Trigger pin, then 8 x 40KHz pulses are sent out of sensor, if bounce signal returns within 60mS, the duration of the time to return is sent as pulse-width based on the formula:
      Distance = (high time * speed of sound (340M / s)) / 2

      2. Continuous Distance-Data TX Mode: (R27=47k)
      In this working mode, every 100ms will automatically output the measured sensor distance value, in millimeters. Once the module is powered on, it operates in mode 2 immediately, and data will be sent every 100 ms via echo (TX) pins. The data sent includes: 0xFF + H_DATA + L_DATA + SUM. Breakdown:

      • 0xFF: Byte signaling to start sending data.
      • H_Data: 8 bits above of the distance.
      • L_Data: 8 bits below the distance.
      • SUM: Byte checks whether the passed data is correct or not.
      • SUM = 0xFF + H_DATA + L_DATA (H+L = 16bits which represents distances in millimeters.) (assume 9600, n, 8, 1 data on echo pin)

      For example, the sensor sends FF 07 A1 A7 Sum = A7 = (0x07 + 0xA1 + 0xFF) & 0x00FF. 0x07 is the upper 8 bits of the distance. 0xA1 is the lower 8 bits of the distance. The distance value is 0x07A1, converted to 1953mm in decimal

      3 . Standby Distance-Data TX Mode: (R27=120k)
      Same as mode2, but module starts in a disabled, standby mode, waiting for a 0x55 command (on trigger pin, as 9600, n, 8, 1), after which module runs same as mode-2 (continuous distance data TX mode)

      Well that's all useful info!
      Hmm.. No R27 pad on my v3 sensor.. but I wonder what these four jumper pads do 🙂
      GZ_JSN-SR04Tv3_jumpers.png

      If anyone else gets time to play with these new v3 jumpers.. or figure out how to resolve the "jitter issues", please do share here.

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: Advisory: put IOT devices on a separate LAN/vLAN for better security

      FBI recommendation or not.. Never trust closed source, non-human (IoT/embedded) systems on your human network. Take most any Chinese IP webcam or similar device and set it up on a sniffer (wireshark or tcpdump) and you'll see many of these devices "calling home" to China (C&C?) and even exfiltrating your WiFi passwords. Not cool.

      I've been running a near-edge IoT DMZ for years now. All Bluray players, VoIP terminals, and even network printers (if you set up a reverse established related rule) should be pushed outside your human network.

      T.Weeks

      posted in General Discussion
      Thomas Weeks
      Thomas Weeks
    • JSN-SR04T (distance sensor) Reliability Issue Fix?

      Refreshing the older thread Trouble with the JSN SR04T..

      I now have the ver 3 of this hardware and I must say.. the output is still flaky as hell. NewPing never worked for me.. and I had to adjust up some of the 4-10nS reading delays up to like 6-10nS.. which seems to at least WORK now.. but still, every few readings I'll still get a minimum distance pulse width from it (works out to around 22cm).. So I'll be reading a stationary wall at like 120cm away.. and it will "glitch" down to 22cm once every few minutes.

      I had to write my own getDistance() funciton that takes like 5 samples and throws away errors.. it's okay.. but even it gets fooled now and then with the sensor output reports minimum distance.

      I've even looked at the echo output on the o-scope and verified that the output will occasionally "jitter" between actual distance pulse width and some false minimum distance.. so I know this is not a software issue.

      I'm now trying localized 5v power bypass capacitors to see if that helps.. but am starting to lose hope in being able to rely on the JSN SR04T for use in a commercial solution.

      Does anyone have a schematic of this thing? I want to try playing with the variable inductor to to see if that can be used to better "tune" whatever it's doing. but am afraid of tweaking a knob I don't understand.

      Any help appreciated.

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: Advisory: put IOT devices on a separate LAN/vLAN for better security

      @NeverDie I wouldn't.. check out this dedicated/embedded hardware.. used in many pieces of high end network appliances:
      https://pcengines.ch/apu4d4.htm

      T.Weeks

      posted in General Discussion
      Thomas Weeks
      Thomas Weeks
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      For anyone interested in this.. I found that ultrasonic sensors, while accurate on solid surfaces.. detecting distance of "soft" objects like torsos with clothing in front of it can create "ghosting", or massive jitter (at best) at certain distances and angles. This can be seen in the o-scope image above. As soon as I put a piece of plywood on my chest, the signal is rock solid. So yes, tracking the depth of water (a solid, mostly smooth surface) works great.. detecting people walking and distances reliably is problematic. Some of it can be lessened via software filtering, but not all.

      For those looking for a soft-body distance measurements.. this IR LIDAR TOF sensor works VERY well.. is sub-CM accurate(!!) and is sunlight resistant, and quick as hell.
      alt text
      Link -
      https://www.aliexpress.com/item/1005001643925191.html

      plus.. it's TINY!

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks

    Latest posts made by Thomas Weeks

    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @rvendrame Again.. I'm not measuring water.. I'm measuring people in a climate controlled environment. No problems with condensation. But I can see how condensation would wreak havoc on an IR laser TOF sensor. Why did you have to move away from the JSN04T? It seems pretty solid candidate for your application.

      Tweeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      For anyone interested in this.. I found that ultrasonic sensors, while accurate on solid surfaces.. detecting distance of "soft" objects like torsos with clothing in front of it can create "ghosting", or massive jitter (at best) at certain distances and angles. This can be seen in the o-scope image above. As soon as I put a piece of plywood on my chest, the signal is rock solid. So yes, tracking the depth of water (a solid, mostly smooth surface) works great.. detecting people walking and distances reliably is problematic. Some of it can be lessened via software filtering, but not all.

      For those looking for a soft-body distance measurements.. this IR LIDAR TOF sensor works VERY well.. is sub-CM accurate(!!) and is sunlight resistant, and quick as hell.
      alt text
      Link -
      https://www.aliexpress.com/item/1005001643925191.html

      plus.. it's TINY!

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: Advisory: put IOT devices on a separate LAN/vLAN for better security

      @NeverDie I wouldn't.. check out this dedicated/embedded hardware.. used in many pieces of high end network appliances:
      https://pcengines.ch/apu4d4.htm

      T.Weeks

      posted in General Discussion
      Thomas Weeks
      Thomas Weeks
    • RE: Advisory: put IOT devices on a separate LAN/vLAN for better security

      FBI recommendation or not.. Never trust closed source, non-human (IoT/embedded) systems on your human network. Take most any Chinese IP webcam or similar device and set it up on a sniffer (wireshark or tcpdump) and you'll see many of these devices "calling home" to China (C&C?) and even exfiltrating your WiFi passwords. Not cool.

      I've been running a near-edge IoT DMZ for years now. All Bluray players, VoIP terminals, and even network printers (if you set up a reverse established related rule) should be pushed outside your human network.

      T.Weeks

      posted in General Discussion
      Thomas Weeks
      Thomas Weeks
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @Yveaux I might like to eventually check out a ToF sensor.. but I'm already at a commercialization stage using this JSN sensor, and it looks like I can mostly compensate for the echo jittering.

      If anyone has any experience with any other newer, narrow-angle sensors they would recommend (ToF, LiDar), etc), please share. So far I've also tried PIR (motion) sensors (which don't work if my subject stops moving), RFID, and a couple others.

      Some of my requirements are, it must be:

      • "Splash & Spray" water resistant (mounted in bathrooms)
      • Multi-sensor interference proof (4-5 sensors next to each other can't interfere)
      • Light & IR proof (sun light, heat sources, etc)
      • EMF (florescent RF noise) proof
      • Can't be any type of "camera" (used to capture photos)

      Thoughts?
      Maybe I should start a separate thread ^^^ on this ^^^.

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @mrdisco @zboblamont

      Thanks for the comments guys.. My application is very different than water level sensing though. I'm using it as a "people-distance" sensor (detecting distance to people's torsos) and our 3D printed case has a hand adjustable angle mount that works well for us:
      JSN-sensor-mount.png

      The PROBLEM (for me) is that while the JSN sensor works well against flat, hard, smooth surfaces like plywood or a liquid surface (did all my testing of this on the bench), they seem to be much less reliable with soft surfaces like a clothed torso, a coat on a hangar, a pillow, etc. This soft-surface error appears in the output as distance pulse "jitter" as seen here in the signal pulse width output jumping around:
      JSN-SR04T Jitter When Distancing "soft" Objects

      Thus far I'm solving this specific issue in software with a rapid detection loop that throws away known "bad values" (as previously discussed) with a watch-dog loop-break that limit its detection polling duration.

      I hope that's clear enough.

      It sounds like the JSN is a perfect sensor for detecting walls (from a car bumper) or other hard/fault car surfaces (<20ft proximity.. maybe along with radar).. and I know most people following these threads seem to be using it for liquid-level measurements (which is really cool).. but one is pushing the JSN's usability with soft target objects.

      If anyone comes up with a better, more elegant solution for making this sensor more universal in its target detection.. even if done at the sensor hardware or STM micocontroller reflashing side of things.

      Cheers..

      TWeeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      For those interested..

      I found another engineer who reverse engineered the JSN-SR04T v2. Not identical, but close. Here's the v2 schematic:
      JSN-SR04T_Schematic.jpg

      Here's the full theory of operation article he wrote (in Vietnamese, google xlate URL) on how to remove the STM 8 bit microcontroller and do your own echo-pulse based on the waveshape of the detection LED driver.

      Here's an interesting tidbit of implementation info that's good to know before you try to use this sensor in a project:

      "Defect:

      • JSN-SR04T has a very large opening angle (> = 75 degrees), so it is NOT suitable for measuring distances in tight spaces. Should only be used in open spaces such as outdoors or large-size tanks - no obstructions .

      • If measured in a confined space, the error is very large due to the reflected wave being impacted and the object or the tank - tank wall."

      Good to know!... I have seen some of this error in the form of echo width "jitter" both in the bad/unreliable data, as well as with the raw signal combing back on the o-scope:
      JSN_jitter.png

      I'll need to experiment with this in confined spaces.. but the JSN units also seems to have problems with "soft targets" (like people in clothes). You can test this yourself by testing with a plywood sheet (the size of a person) vs a clothed person. If anyone finds a way to get more reliable soft target detection, please share here.

      These JSN-SR04 modules seem to have multiple operating modes.

      On the v2 module, the empty R27 pad controls the echo mode of operation. Here's a best guess regarding the four "operating modes" that I think the author is documenting (attempted to better translate from Vietnamese):

      1. Trigger/Echo ECHO-Pulse Mode (default): (R27 open)
      You send a 10uS pulse on Trigger pin, then 8 x 40KHz pulses are sent out of sensor, if bounce signal returns within 60mS, the duration of the time to return is sent as pulse-width based on the formula:
      Distance = (high time * speed of sound (340M / s)) / 2

      2. Continuous Distance-Data TX Mode: (R27=47k)
      In this working mode, every 100ms will automatically output the measured sensor distance value, in millimeters. Once the module is powered on, it operates in mode 2 immediately, and data will be sent every 100 ms via echo (TX) pins. The data sent includes: 0xFF + H_DATA + L_DATA + SUM. Breakdown:

      • 0xFF: Byte signaling to start sending data.
      • H_Data: 8 bits above of the distance.
      • L_Data: 8 bits below the distance.
      • SUM: Byte checks whether the passed data is correct or not.
      • SUM = 0xFF + H_DATA + L_DATA (H+L = 16bits which represents distances in millimeters.) (assume 9600, n, 8, 1 data on echo pin)

      For example, the sensor sends FF 07 A1 A7 Sum = A7 = (0x07 + 0xA1 + 0xFF) & 0x00FF. 0x07 is the upper 8 bits of the distance. 0xA1 is the lower 8 bits of the distance. The distance value is 0x07A1, converted to 1953mm in decimal

      3 . Standby Distance-Data TX Mode: (R27=120k)
      Same as mode2, but module starts in a disabled, standby mode, waiting for a 0x55 command (on trigger pin, as 9600, n, 8, 1), after which module runs same as mode-2 (continuous distance data TX mode)

      Well that's all useful info!
      Hmm.. No R27 pad on my v3 sensor.. but I wonder what these four jumper pads do 🙂
      GZ_JSN-SR04Tv3_jumpers.png

      If anyone else gets time to play with these new v3 jumpers.. or figure out how to resolve the "jitter issues", please do share here.

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @bjacobse
      You asked:

      How does your function work with 5 samples and throws away errors?

      I toss readings that differ greatly from the norm.. OR any that are either near the MAX(600cm) or MIN (22cm). Those strategies (plus a read-loop that looks for "good readings" eliminates >99% of the bad readings.

      Why not take measures until you get 3 or 5 measures that are identical,
      and then use this as your measurement?

      BC many times, multiple errors (sometimes 10-20 or more) readings register the MAX or MIN values. I've watched the pulse width on an o-scope.. and it IS a hardware, reading reliability issue. In such cases of getting a string of bad readings, I just loop trough and keep taking readings until I get several reliable readings in a row.. and include a watch-dog variable that will break out of the read-again loop if X number of bad readings have been taken.

      I can post the code if people want.

      BTW.. Whomever posted that schematic futher back.. it's NOT a JSN-SR04T. The JSN has no MAX232 , has only ONE sensor element (not two), and the googled schematic is missing the STM STM8S003F3P6 8bit microcontroller and the variable inductor.
      JSN board

      So that previous schematic is a fake. Anyone have the REAL schematic?

      Tweeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • JSN-SR04T (distance sensor) Reliability Issue Fix?

      Refreshing the older thread Trouble with the JSN SR04T..

      I now have the ver 3 of this hardware and I must say.. the output is still flaky as hell. NewPing never worked for me.. and I had to adjust up some of the 4-10nS reading delays up to like 6-10nS.. which seems to at least WORK now.. but still, every few readings I'll still get a minimum distance pulse width from it (works out to around 22cm).. So I'll be reading a stationary wall at like 120cm away.. and it will "glitch" down to 22cm once every few minutes.

      I had to write my own getDistance() funciton that takes like 5 samples and throws away errors.. it's okay.. but even it gets fooled now and then with the sensor output reports minimum distance.

      I've even looked at the echo output on the o-scope and verified that the output will occasionally "jitter" between actual distance pulse width and some false minimum distance.. so I know this is not a software issue.

      I'm now trying localized 5v power bypass capacitors to see if that helps.. but am starting to lose hope in being able to rely on the JSN SR04T for use in a commercial solution.

      Does anyone have a schematic of this thing? I want to try playing with the variable inductor to to see if that can be used to better "tune" whatever it's doing. but am afraid of tweaking a knob I don't understand.

      Any help appreciated.

      T.Weeks

      posted in Troubleshooting
      Thomas Weeks
      Thomas Weeks
    • RE: Placing a water leak detector on cotton

      @celestial I've done several water detectors using these units:
      https://www.amazon.com/dp/B01FDGUHBM/

      The cotton is a good idea.. but might be a hard time drying out. I might switch to a synthetic... like stuffed animal stuffing that won't rot like cotton. Also.. to increase conductivity you can sprinkle in some table salt that greatly increases the sensor reliability.. especially if you're measuring things like AC condensate (which is non conductive alone).

      T.Weeks

      posted in General Discussion
      Thomas Weeks
      Thomas Weeks