Hello,
I am trying to use an DUE to read from the TFmini (Benewake) sensor. I am using the accompanying library and sample code provided by the sensor where I changed the Software Serial to be Serial1.
However, the code seems to hang when calling the tfmini.getDistance() function and a reading is never received. Has anyone else encountered this problem? I've posted my code below. Any advice would be much appreciated. I have hooked the lines to 18/19 directly as the DUE is a 3.3v controller.
//#include <SoftwareSerial.h>
#include "TFMini.h"
// Setup software serial port
//SoftwareSerial mySerial(10, 11); // Uno RX (TFMINI TX), Uno TX (TFMINI RX)
#define mySerial Serial1
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);
Serial.println(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);
}