Ultrasonic Data Communication

Hi, currently i want to try to build an ultrasonic data communication. I tried one sample project from this website, https://hackaday.com/2018/06/01/dead-simple-ultrasonic-data-communication/#comments but i cannot get data transmitted.

I used Arduino nano in this project.

On the transmitter side, i got PWM waveform with much noises but on the receiver side i got straight line waveforms throughout the circuit.

How do i reduce the noise in the transmitter? How to i make sure whether the data from transmitter is transit or not? Is it possible transmitter transmitted data, but receiver cannot receive it? Any solution? Thank you :slight_smile:

These coding is given in the website.

Transmitter Coding:

void setup() 
{
   Serial.begin(115200);
   pinMode(3,OUTPUT);
}

void loop() 
{
  send("Ultrasonic communication by Zola Lab\n");
  send("Hello World\n\n");   
}

void send(String msg)
{
  byte ch;
  unsigned int pos = 0;
  unsigned int sz = msg.length();
  while(pos<sz)
  {
     ch = msg.charAt(pos);
     Serial.print((char)ch);
     tone(3,40000);
     delay(10);
     noTone(3);
     for(int i=0;i<8;i++)
     {
        boolean b;
        b = bitRead(ch,7-i);
       // Serial.print (b);
        if(b) 
        {
           tone(3,40000);
           delay(2);
        }
        else
        {
           tone(3,40000);
           delay(4);
        }
        noTone(3);
        delay(11);
     }
     pos++;
  }
}

Receiver Coding :

int pos = 0;
unsigned char CH = 0;
unsigned int bits1 = 0;
boolean capture = false;

void setup() 
{
  Serial.begin(115200);
  pinMode(5,INPUT_PULLUP);
}

void loop() 
{
  if(digitalRead(5))
  {
     bits1 = 0;
     unsigned long deltaT = millis();
     while(millis()-deltaT <= 10) if(digitalRead(5)) bits1 ++;
     Serial.println(bits1); 
     if(capture)
     {
        boolean b = 0;
        if(bits1 > 290 && bits1 < 600) b = 0;
        if(bits1 > 20 && bits1 < 290) b = 1;
        if(b) bitSet(CH,7-pos); else bitClear(CH,7-pos);
        Serial.print(b);
        pos++;
        if(pos == 8)
        {
           Serial.print((char)CH);
           pos = 0;
           capture = false;
        }
     }
     if(bits1 > 600) 
     {
        capture = true;
        pos = 0;
     }
  }
}

The project looks quite interesting. Can you post the circuit diagram of the receiver part ?
How can you see "noise" on the transmitter part ? Are you using an oscilloscope ?

I connected one terminal of transmitter to 5V in arduino and another to d3 in arduino.
Yes. I am using oscilloscope to view the waveform.

The waveform picture is attached below as transmitter waveform.png

The receiver circuit is attached below as ultrasonic_receiver.png.

The main thing I notice is that the audio amplifier (LM386) is extremely bare and there are no power decoupling capacitors.

The LM386 has a gain in this circuit of only 20 which seems rather low. Not only that, these are designed to drive a load of 4 to 32 ohms impedance. The data sheet here has some sample circuits. http://www.ti.com/lit/ds/symlink/lm386.pdf

Do you see any output from the audio amplifier (pin 5) with the oscilloscope if you tap the transducer ?

Just for reference, the circuit diagram of the ultrasonic sensor module, from which the transducers come, is here: Emil's Projects & Reviews: Making a better HC-SR04 Echo Locator

Thanks for your response.
I now able to get PWM modulation waveform in lm386 output (pin 5) with gnd attached below by changing a new lm386.

Do you know how to reduce noise in transmitter? I cannot get a clean signal in receiver.

Am I reading your oscilloscope plots correctly? It looks like they're showing a capture of the signal at 40k (post #2) and 16k (post #4) samples per second. That's not going to provide an accurate representation of a nominal 40 kHz signal. You should probably have at least 10x 40 kHz as the minimal sample rate.