Home        Store        Docs        Blog

Ping Sonar Altimeter and Echosounder

I want to connect arduino and sonar directly.

I connected
red : 5V
black :GND
green :~10
white :~9
as per the github manual.

However, it is displayed on the serial screen as follows.

Ping device failed to initialize!
Are the Ping rx/tx wired correctly?
Ping rx is the green wire, and should be connected to Arduino pin 10 (Arduino tx)
Ping tx is the white wire, and should be connected to Arduino pin 9 (Arduino rx)

I do not know why tx and rx are not recognized.
Please teach me.

The source used is ping 1d-simple.ino.

Hi,

Did you flash the firmware for 9600 baud rate ?
As the documentation points:

The examples use the SoftwareSerial library to communicate with the Ping device, which allows flexibility for the rx/tx pin assignments on the Arduino. The examples use pins 10 and 9. The SoftwareSerial library can only communicate with the Ping device at 9600 baud . If you are using a board with more than one HardwareSerial port, like the Arduino MEGA, you may use the second serial port to communicate with a Ping device at 115200 baud.

I think I have set the baud rate to 9600.

/////////////////////////////////////////////////////////
#include "ping1d.h"

#include "SoftwareSerial.h"

// This serial port is used to communicate with the Ping device
// If you are using and Arduino UNO or Nano, this must be software serial, and you must use
// 9600 baud communication
// Here, we use pin 9 as arduino rx (Ping tx, white), 10 as arduino tx (Ping rx, green)
static const uint8_t arduinoRxPin = 9;
static const uint8_t arduinoTxPin = 10;
SoftwareSerial pingSerial = SoftwareSerial(arduinoRxPin, arduinoTxPin);
static Ping1D ping { pingSerial };


void setup()
{
    pingSerial.begin(9600);
    Serial.begin(115200);
    pinMode(ledPin, OUTPUT);
    Serial.println("Blue Robotics ping1d-simple.ino");
    while (!ping.initialize()) {
        Serial.println("\nPing device failed to initialize!");
        Serial.println("Are the Ping rx/tx wired correctly?");
        Serial.print("Ping rx is the green wire, and should be connected to Arduino pin ");
        Serial.print(arduinoTxPin);
        Serial.println(" (Arduino tx)");
        Serial.print("Ping tx is the white wire, and should be connected to Arduino pin ");
        Serial.print(arduinoRxPin);
        Serial.println(" (Arduino rx)");
        delay(2000);
    }
}


void loop()
{
    if (ping.update()) {
        Serial.print("Distance: ");
        Serial.print(ping.distance());
        Serial.print("\tConfidence: ");
        Serial.println(ping.confidence());
    } else {
        Serial.println("No update received!");
    }

    // Toggle the LED to show that the program is running
    digitalWrite(ledPin, !digitalRead(ledPin));
}
/////////////////////////////////////////////////////////

Hi,

Sorry for not being explicit about my previous answer, you should flash Ping with a 9600 baud rate version. Ping comes with a 115200 baud rate from factory and it’s necessary to flash a 9600 baud rate firmware to allow it to communicate with your Arduino via SoftwareSerial interface. If you are working with an Arduino that provides more than one hardware serial interface, you can use Ping with the factory firmware of 115200 baud rate.

Thank you for your reply.
I understand to set the baud rate to 9600.
do I need to use “BLUART USB to Serial and RS485 Adapter”?

Hi,

BLUART is not necessary if you are aiming to use it with your Arduino.
If you want to connect Ping with your computer, check the product learn tab. If you are running Ping-Viewer and want to flash the 9600 baud rate firmware to use Ping with your Arduino, check the Firmware Update documentation page.

Thank you for your reply.

I tried to update the Automatic Update using the page you posted, but the Latest version did not come out.

Therefore, I downloaded “Ping_V3.26_9600b.hex” of “https://github.com/bluerobotics/ping-firmware/tree/master/ping1d” and tried Manual Update.

However, I got the following error.

///////////////////////////////////////////////////////////

Error:

stm32flash 0.5

http://stm32flash.sourceforge.net/

Using Parser:Intel HEX

Interface serial_w32:57600 8E1

Failed to init sevice.

///////////////////////////////////////////////////////////

Please give me some advice.

Hi,

What kind of serial adapter are you using ?
Are you able to connect with Ping using Ping-Viewer ? Was it working before the flash procedure ?

I don’t use a serial adapter.
I connect with sensor to arduino.

maybe,I cann’t connect with Ping using Ping-Viewer.
I can see this screen.

I can’t success “EMIT PING”.

Hi,

Please, connect Ping directly in a FTDI or any serial/USB adapter. Ping-Viewer will automatically connect and stream the data, after the connection is done and the communication between Ping-Viewer and Ping is accomplished, the available firmwares will be available for you in the flash menu.
You can brick Ping if you are going to use an Arduino to do the firmware update, I highly advice to use a BLUEART or any other serial/USB adapter.

You can also follow our quick start guide.

Thank you for your reply.

I don’t have any serial/USB adapter but I have arduinoMEGA.
If I change Arduino UNO for Arduino MEGA,can I connect ping directly without serial/USB adapter.

Hi,

Yes, it’s possible to use an Arduino uno or Arduino Mega but it’s not recommended if you aiming to use with Ping-Viewer as a serial/USB adapter. Be advice that flashing a new firmware while doing so it can brick your sensor and recovery methods will be necessary.

The easier an safer way is to use a simple and normal serial/USB adapter if you are aiming to update Ping firmware.

If you are aiming to integrate Arduino and Ping, you should use Arduino Mega and a second hardware serial port, doing so will not require to change the Ping baud rate from 115200 to 9600, and you can use our Arduino examples.

As described in my previous comment and documentation.

I want to catch data of distance.
So I think I don’t need use Ping-Viewer.

I wrote “ping1d-simple.ino” using arduino MEGA.
But like ArduinoUNO,I got an error.
"Ping device failed to initialize!
Are the Ping rx / tx wired correctly?
Ping rx is the green wire and should be connected to Arduino pin 10 (Arduino tx)
Ping tx is the white wire, and should be connected to Arduino pin 9 (Arduino rx) "

Please give me your advice.

Hi,

We are going to provide an example for Arduino Mega or a generic one for Arduino boards that contains multiple hardware serial interfaces.

Thank you for your reply.

I got the serial / USB adapter, so I connected it with the ping viewer, but it is the same as before.
I used an adapter named ”FTD1232”.

Hi,

Did you swapped the RX/TX pins ? Probably they are in the wrong position.
Did you check if windows can recognize your serial/USB adapter ?
image
If you plug and unplug your adapter, you’ll see a COM port appearing the disappearing in Device Manager.

To make sure that Ping is working and the original firmware is still there, you can open the sensor via the transducer ring:
image

The internal LED should be blinking.

Thank you for your reply.

Reconnecting the RX and TX pins did not change.
The device manager recognizes COM.

I open the sensor,but LED light don’t blink.

So, I took the steps of

https://docs.bluerobotics.com/ping-viewer/firmware-update/

to update.

However, I was unable to perform automatic update, I selected “Ping_V3.26_115kb.hex” and tried manual update, but I got an error as before.

By the way, when connected to ArduinoMEGA, the LED blinks. RT and TX did not recognize as before…

Hi,

It appears that in your previous flash attempts using an Arduino as a USB/Serial adapter bricked the sensor. Please follow the Device Recovery instructions with a real USB/Serial adapter (BLUART, FTDI, CH341) and not an Arduino board.