Help with altimeter build

Was hoping to see whether anyone may be able to help me with the following. I used the BR Ping/Bar30 sensors in combination with an Arduino Uno + LCD + Datalogging Shield to build a simple altimeter for our camera scooter. The idea was that it can help us keep consistent altitude while conducting diver-based underwater surveys, while at the same time logging altitude/depth every second.

I managed to get it all working except for the SD card logging: for some reason the Arduino freezes up when I try to use both the Ping and SD card reader. If I comment out the init_sdcard() function - everything works fine (except of course logging to SD card). Similarly, SD card logging works fine when I comment out the init_sonar() function. I can’t figure out what’s causing the conflict - as far as I know there are no overlapping/conflicting pins (I cut a trace on the datashield to reassign chipselect to pin 8).

Just wanted to post a link to the code here - to see if anyone spots something obvious that I missed? First arduino project for me - so any help would be greatly appreciated! Otherwise altimeter itself worked great - see short video snippet of it in action here.

It sounds like there is a conflict in the mcu resources required by the software serial library and the sd card library. If you google arduino spi + software serial, you will find a lot of similar experiences: SPI and SoftwareSerial Not Working Together - Programming Questions - Arduino Forum. Sadly, this can be difficult to resolve.

One quick thing to try: It looks like you are not using the hardware serial port on your arduino, that’s connected to the arduino RX and TX pins. Move the ping to those pins, and try removing the softwareserial lines.

Instead use static Ping1D ping { Serial };

and Serial.begin(9600)

Finally got around to trying this - and it worked. Thank you!

1 Like