Let me try to understand what’s working and what’s not. You have the laser rangefinder (LRF) connected to an Uno. The
LRF talks to the Uno via a TTL serial link (115k baud). The Uno talks to a Mega via a TTL serial link (9600 baud) ? The distance is sent via these serial links ? As an ASCII encoded data block, 8 times/sec. You can “print” the distance at the ?Uno and/or Mega? and it contains a correct value that will always, has always been 32m or less ?
The problem arises only when trying to write the data to the SD card ? Or when trying to get the distance from the Uno to the Mega, even w/o any SD card activity ongoing ? Or is the distance coming across the AUX serial link, directly from the LRF ?