# Can Arduino get raw sampling data array of 1D sonar?

**URL:** <https://discuss.bluerobotics.com/t/can-arduino-get-raw-sampling-data-array-of-1d-sonar/10207>\
**Category:** Ping Sonar Devices\
**Created:** [July 18, 2021, 3:19pm UTC](https://discuss.bluerobotics.com/t/can-arduino-get-raw-sampling-data-array-of-1d-sonar/10207 "2021-07-18T15:19:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ken555](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@ken555](https://discuss.bluerobotics.com/u/ken555)\
**Post date:** [July 18, 2021, 3:19pm UTC](https://discuss.bluerobotics.com/t/can-arduino-get-raw-sampling-data-array-of-1d-sonar/10207/1 "2021-07-18T15:19:59Z")

</div>

Hello there. I’m using 1D Ping Sonar Altimeter and Echosounder.  
Ping viewer and Arduino sample program (ping1d-simple.ino) provided by Blue Robotics official successfully worked and I can get distance and confidence by Arduino.

Now I want to get whole sampling data received by sonar. I think distance and confidence are the data obtained by processing raw echo intensity data array such as “time 0: intensity 0.1, time 1: intensity 0.15, …, time M: intensity 1.0(when wave came), …, time N: intensity 0.0 (end of sampling)” received by sonar in predetermined sampling rate.

So, my question is can I get raw received data array of sonar by Arduino?  
I understand “if(!request(Ping1DNamespace::Some\_function))” function in Arduino sample code which is called when user want to treat Some\_function data. If there is the way, which function I should specify for getting raw echo intensity data (I thought “Continuous\_start” may be related because of the name, but I could not understand what continuous\_start truly means and use it)?

Any advice here is greatly appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [July 19, 2021, 1:40am UTC](https://discuss.bluerobotics.com/t/can-arduino-get-raw-sampling-data-array-of-1d-sonar/10207/2 "2021-07-19T01:40:41Z")

</div>

Hi @ken555, welcome to the forum 🙂

The full intensity data from a profile is provided in the [‘`profile`’ message](https://docs.bluerobotics.com/ping-protocol/pingmessage-ping1d/#1300-profile). There’s an example of requesting and receiving that in the [`ping1d-advanced.ino`](https://github.com/bluerobotics/ping-arduino/blob/master/examples/ping1d-advanced/ping1d-advanced.ino#L87-L98) example, but it’s commented out by default because it may not work fully/correctly using software serial (I’m unsure if that still applies, but it should definitely at least work for hardware serial).

The [`continuous start`](https://docs.bluerobotics.com/ping-protocol/pingmessage-ping1d/#1400-continuous_start) message is used to start a continuous stream of profile messages from the sensor, that can then be actively read in and processed by the program. I had a look around and it doesn’t seem like there’s a convenient way to receive the results using `ping-arduino`, because the [`request`](https://github.com/bluerobotics/ping-arduino/blob/master/src/ping1d.cpp#L271-L279) method sends a message and waits for a single response, and the [`read`](https://github.com/bluerobotics/ping-arduino/blob/master/src/ping1d.h#L387-L397) and [`waitMessage`](https://github.com/bluerobotics/ping-arduino/blob/master/src/ping1d.h#L409-L418) methods (which could be used to receive subsequent profiles in the stream) are both declared as `private`.

More generally, I’m not sure how well an Arduino would be able to handle a continuous stream of profiles - it may be better for it to request them as required anyway. If you’re using an Arduino (e.g. Mega) with hardware serial and 115200 baud and finding that repeated requests are too slow for your use-case you could potentially move the `waitMessage` declaration to `public` and then use the continuous streaming functionality, but definitely try just repeated requests first 🙂

---

<div class="post-metadata">

**Author:** ![ken555](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@ken555](https://discuss.bluerobotics.com/u/ken555)\
**Post date:** [July 19, 2021, 2:38pm UTC](https://discuss.bluerobotics.com/t/can-arduino-get-raw-sampling-data-array-of-1d-sonar/10207/3 "2021-07-19T14:38:49Z")

</div>

Dear @EliotBR  
Thank you for your quick and detailed advice!  
The difference between HardwareSerial and SoftwareSerial is very interesting. Actually, I tried to get profile message, but it failed despite Arduino seemed to get some serial data. It might related to the loss of SoftwareSerial and private class.  
I haven’t tried the improved version yet, but I’ll try it in the next few days.  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [July 20, 2021, 7:28am UTC](https://discuss.bluerobotics.com/t/can-arduino-get-raw-sampling-data-array-of-1d-sonar/10207/4 "2021-07-20T07:28:29Z")

</div>

I spoke with our software team this morning re baud rates and software vs hardware serial - there’s something of an update on that here:

> [@"Ping device failed to initialise" using ping-arduino](https://discuss.bluerobotics.com/t/ping-device-failed-to-initialise-using-ping-arduino/9352/6):
>
> @Josh1977 I’ve spoken with our software team and apparently the reasoning for using 9600 baud is that Arduino Software Serial can have issues going much faster than that, especially when there’s much other code running. We’re planning to update our Arduino examples to work correctly with our latest Ping\_V3.28\_auto.hex firmware (enabling both 9600 and 115200 baud without needing to change firmware), and change our documentation to say that 115200 baud is possible, but not recommended unless on H…

If you’re using features that require 115200 baud or long messages then it’s still recommended to use hardware serial. Software serial _may_ work at that speed, but is apparently known to be somewhat unreliable above 9600 baud, and in particular has issues with long messages (like profile data) or if there’s much other code running in the same program.

> [@ken555](#):
>
> Actually, I tried to get profile message, but it failed despite Arduino seemed to get some serial data. It might related to the loss of SoftwareSerial and private class.

Just the normal `request(Ping1DNamespace::Profile)` approach shouldn’t have any issues with `private` declaration, because `request` is declared `public`. There may be issues with Software serial though, as mentioned in my comment above, and in the code 🙂
