Any suggestions to connect trig and echo of ultrasonic to microcontroller via dc

I have ultrasonic sensor has 4 pins as + & - & trig & echo then is there a way to inject echo to dc lines then need to read pulse width, so want to use just two wires to connect ultrasonic sensor to microcontroller the length of dc lines 30 meters

Not a "Programming Question", but short answer is "no".
If you only have 2 x 30m wires, you have to put the micro and sensor together at the far end of the wires. Then you may send commands and replies over radio (wifi, bluetooth, 433Mhz RF etc) to another micro.

the distance between sensor and microcontroller as 30 meters between first floor & eighth floor then can not use wireless communication because of many ceilings then the signal will be down

Not a "Programming Question"

Admin could you please move question to appropriate category :)?

Moved to Project Guidance

I am using HC-12 modules to transmit commands / replies to sensor equipped micros (ATTiny85) in my garden. The ATtiny's are sleeping most of the time (current is only 5 uA) and I wake them up with a HC-12 signal (use SoftwareSerial library). My house has a metal facade, no problem. If I set it to 100 mW (maybe not legal) it can cover much longer distances.
I would use two micros, one HC-12 pair and no cables. Just put the antennas near a window and set the output power to whatever is needed (and legal).

wireless is not good idea because of many ceilings then I am thinking of use another microcontroller with sensor side but how to connect to dc bus lines to send data to another side of main board?

You obviously have a 2 wire DC connection between the devices so why not use cable with more cores to provide sensor connections ?

it is very difficult to pass more cores to sensor connections

Not sure if my suggestions below will work, but I find it interesting to think "what if..." etc. If it eventually ends up as a success, it is very rewarding to have made what´s "impossible".

A master board with usb connection (for convenience), connected via 30 meter twin wire to a Attiny85 slave with the ultrasonic sensor. If the slave is allowed to sleep between samples, it needs just 5 uA (and 2.5 mA awake @ 1 Mhz). The sensor needs 2 mA (passive) to 15 mA (active).

A super capacitor plus 1 - 2 smaller caps should be able to buffer enough juice to the far end components, depending of how frequent readings will occur. An Attiny running the SoftwareSerial library wakes up from sleep without missing anything in the first incoming byte (that is how I wake up and control a few nodes in my current project - but they are all powered separately).

So you could send commands from the master and recieve replies from the slave. The code in both ends would have to skip all input when it´s own Tx is active.

I am not saying this will work, but it may be worth investigating.

could you please have a look of this video but no any schematic & code for communication


You can easily add audio to power wires and let the other end interpret how you decide to encode information. Perhaps frequency shift keying. This can ONLY work half-duplex.


is there any schematic & code to start testing?

Google for: "AFSK Arduino". That is Audio Frequency Shift Keying.

You can edit your posts using the "pencil" icon. No need to delete them. :roll_eyes:

What exactly are you trying to do?
What is the application?

Is it a doorbell type project.
You would be better to put the controller and ultrasonic at the ground floor, and push a tone on the power leads back to the upper floor, with another controller to detect the tone and activate your alarm/LED or what ever.

A tone will not be as time sensitive as your ultrasonic control pulses.

In fact using different tones you could transmit different situations.

Just a thought.. Tom... :smiley: :+1: :coffee: :australia:

application is to measure water at the tank using ultrasonic sensor via dc lines, sensor is located at last floor of building & main board is at first floor

Why must you use the DC lines, what voltage are they?

Does my suggestion make sense?

Tom... :smiley: :+1: :coffee: :australia:

I have just two cores so impossible to use additional cores, voltage can be 5V or 12V

nothing impossible do it after long research with just two wires result is exactly as using 4 wires
Admin could you please close post :slight_smile:
thanks guys for your suggestions