# Ultrasonic sensor object detection

**URL:** <https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007>\
**Category:** General\
**Created:** [1 April 2020 06:08 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007 "2020-04-01T06:08:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![iankillz](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@iankillz](https://discourse.nodered.org/u/iankillz)\
**Post date:** [1 April 2020 06:08 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/1 "2020-04-01T06:08:16Z")

</div>

Hello im new in using raspberry pi and node-red and i am doing a smart parking project using ultrasonic sensors. How can I use node-red with an ultrasonic sensor to detect the car if the spot is taken or not and get results and publish it in a website?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 April 2020 06:37 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/2 "2020-04-01T06:37:23Z")

</div>

Welcome to the forum.  
Which bit don't you know how to do?

---

<div class="post-metadata">

**Author:** ![iankillz](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@iankillz](https://discourse.nodered.org/u/iankillz)\
**Post date:** [1 April 2020 08:24 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/4 "2020-04-01T08:24:05Z")

</div>

Using node-red to get sensor readings then publish it to a website

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 April 2020 08:44 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/5 "2020-04-01T08:44:30Z")

</div>

I don't know exactly what you mean by 'publish it to a website' but I suggest getting the sensor reading working first.  
What sensor are you using and how is it connected to the pi?

---

<div class="post-metadata">

**Author:** ![iankillz](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@iankillz](https://discourse.nodered.org/u/iankillz)\
**Post date:** [1 April 2020 09:20 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/6 "2020-04-01T09:20:04Z")

</div>

Im using Hc-sr04 sensors and its connected using gpio pins, is that right? Sorry

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [1 April 2020 09:47 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/7 "2020-04-01T09:47:34Z")

</div>

If you search the forum for that sensor I think there may have been some posts about them.

---

<div class="post-metadata">

**Author:** ![iankillz](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@iankillz](https://discourse.nodered.org/u/iankillz)\
**Post date:** [1 April 2020 09:50 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/8 "2020-04-01T09:50:11Z")

</div>

I've tried but no luck, I already have the python code working. I'm trying to use node red to send sensor reading to a webpage because the website im trying to make will supposed to tell if a sensor/spot is occupied or vaccant.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [1 April 2020 10:58 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/9 "2020-04-01T10:58:27Z")

</div>

try the node-red-contrib-pisrf node

> [@HC-SR04 Ultrasonic Sensor - rpi-srf - status not available](https://discourse.nodered.org/t/hc-sr04-ultrasonic-sensor-rpi-srf-status-not-available/21955/6):
>
> The node works for me (trig connected to pin10 - echo to pin 8, gnd to pin6 , vcc to pin 1) There are a a few things to check Have you got a newer 3.3V compatible version? If using an old 5V version - you need to use some resistors to reduce the echo signal voltage

---

<div class="post-metadata">

**Author:** ![iankillz](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@iankillz](https://discourse.nodered.org/u/iankillz)\
**Post date:** [3 April 2020 04:21 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/10 "2020-04-03T04:21:02Z")

</div>

its working, now how do I display an if else message if the car distance is lets say 5cm then it will send an "occupied" message then if its \>5 then it will send "available" message.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 April 2020 06:35 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/11 "2020-04-03T06:35:40Z")

</div>

If you add a switch node - you can check the values coming from the pisrf node and send them to one output if its 5cm or less and another output otherwise.

You can then use change nodes, on each output, to change the message from a number to occupied or available

---

<div class="post-metadata">

**Author:** ![iankillz](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@iankillz](https://discourse.nodered.org/u/iankillz)\
**Post date:** [3 April 2020 06:55 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/12 "2020-04-03T06:55:12Z")

</div>

Thanks cymplecy this helped a lot

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 April 2020 06:55 UTC](https://discourse.nodered.org/t/ultrasonic-sensor-object-detection/24007/13 "2020-04-17T06:55:16Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
