HI, I am a beginner with the whole LIDAR sensing technology and software serial on Arduino. Essentially I hooked up one tf mini to my Arduino using a logic level converter, and it worked splendidly. I then attempted to add a second sensor. But when I tried to get a reading from either of the sensors only one showed up in the serial monitor. Through testing I relized whatever LIDAR sensor serial begin went last gave readings. I am using an Arduino Uno, 5v 3.3v bidirectional logic level converter. This is the original code with one LIDAR:
#include <SoftwareSerial.h>
#include "TFMini.h"
// Setup software serial port 
SoftwareSerial mySerial(10, 11);      // Uno RX (TFMINI TX), Uno TX (TFMINI RX)
TFMini tfmini;
void setup() {
  // Step 1: Initialize hardware serial port (serial debug port)
  Serial.begin(115200);
  // wait for serial port to connect. Needed for native USB port only
  while (!Serial);
     
  Serial.println ("Initializing...");
  // Step 2: Initialize the data rate for the SoftwareSerial port
  mySerial.begin(TFMINI_BAUDRATE);
  // Step 3: Initialize the TF Mini sensor
  tfmini.begin(&mySerial);    
}
void loop() {
  // Take one TF Mini distance measurement
  uint16_t dist = tfmini.getDistance();
  uint16_t strength = tfmini.getRecentSignalStrength();
  // Display the measurement
  Serial.print(dist);
  Serial.print(" cm      sigstr: ");
  Serial.println(strength);
  // Wait some short time before taking the next measurement
  delay(25);  
}
I then tried to modify for 2 LIDAR. This is my Code:
#include <SoftwareSerial.h>
#include "TFMini.h"
// Setup software serial port 
SoftwareSerial mySerial(10, 11);      // Uno RX (TFMINI TX), Uno TX (TFMINI RX)
SoftwareSerial mySerial2(12, 13);
TFMini tfmini;
TFMini tfmini2;
void setup() {
  // Step 1: Initialize hardware serial port (serial debug port)
  Serial.begin(115200);
  // wait for serial port to connect. Needed for native USB port only
  while (!Serial);
     
  Serial.println ("Initializing...");
  // Step 2: Initialize the data rate for the SoftwareSerial port
  mySerial2.begin(TFMINI_BAUDRATE);
  mySerial.begin(TFMINI_BAUDRATE);
  // Step 3: Initialize the TF Mini sensor
  tfmini2.begin(&mySerial);
  tfmini.begin(&mySerial); 
     
}
void loop() {
  // Take one TF Mini distance measurement
  uint16_t dist = tfmini.getDistance();
  uint16_t strength = tfmini.getRecentSignalStrength();
  // Display the measurement
  Serial.print(dist);
  Serial.print(" cm      sigstr: ");
  Serial.println(strength);
  // Wait some short time before taking the next measurement
  delay(5000);  
  uint16_t dist2 = tfmini2.getDistance();
  uint16_t strength2 = tfmini2.getRecentSignalStrength();
  // Display the measurement
  Serial.print(dist2);
  Serial.print(" cm      sigstr: ");
  Serial.println(strength2);
  delay(5000);
}
Can anyone help with this problem.
Thanks!
								
							
