laptophead
Well-known member
I got this lidar, TF Mini Plus and found a library for it.
https://github.com/budryerson/TFMini-Plus
I have been using Serial.printf for a long time and it required no library, but this sketch must have it.
I am not able to print anything from the serial port other than my code "NOW" that I added for testing....
I am on Com 4
Please help,
Thanks
https://github.com/budryerson/TFMini-Plus
I have been using Serial.printf for a long time and it required no library, but this sketch must have it.
I am not able to print anything from the serial port other than my code "NOW" that I added for testing....
I am on Com 4
Please help,
Code:
#include <TFMPlus.h> // Include TFMini Plus Library v1.4.1
TFMPlus tfmP; // Create a TFMini Plus object
#include "printf.h"
void setup()
{
Serial.begin( 115200); // Intialize terminal serial port
Serial.println ("NOW");
delay(20); // Give port time to initalize
printf_begin(); // Initialize printf.
printf("\r\nTFMPlus Library Example - 18JUN2020\r\n"); // say 'hello'
Serial4.begin( 115200); // Initialize TFMPLus device serial port.
delay(20); // Give port time to initalize
tfmP.begin( &Serial4); // Initialize device library object and...
// pass device serial port to the object.
// Send some example commands to the TFMini-Plus
// - - Perform a system reset - - - - - - - - - - -
printf( "System reset: ");
if( tfmP.sendCommand( SYSTEM_RESET, 0))
{
printf( "passed.\r\n");
}
else tfmP.printReply();
delay(500); // added to allow the System Rest enough time to complete
// - - Display the firmware version - - - - - - - - -
printf( "Firmware version: ");
if( tfmP.sendCommand( OBTAIN_FIRMWARE_VERSION, 0))
{
printf( "%1u.", tfmP.version[ 0]); // print three single numbers
printf( "%1u.", tfmP.version[ 1]); // each separated by a dot
printf( "%1u\r\n", tfmP.version[ 2]);
}
else tfmP.printReply();
// - - Set the data frame-rate to 20Hz - - - - - - - -
printf( "Data-Frame rate: ");
if( tfmP.sendCommand( SET_FRAME_RATE, FRAME_20))
{
printf( "%2uHz.\r\n", FRAME_20);
}
else tfmP.printReply();
// - - - - - - - - - - - - - - - - - - - - - - - -
delay(500); // And wait for half a second.
}
// Initialize variables
int16_t tfDist = 0; // Distance to object in centimeters
int16_t tfFlux = 0; // Strength or quality of return signal
int16_t tfTemp = 0; // Internal temperature of Lidar sensor chip
// Use the 'getData' function to pass back device data.
void loop()
{
delay(50); // Loop delay to match the 20Hz data frame rate
if( tfmP.getData( tfDist, tfFlux, tfTemp)) // Get data from the device.
{
printf( "Dist:%04icm ", tfDist); // display distance,
printf( "Flux:%05i ", tfFlux); // display signal strength/quality,
printf( "Temp:%2i°C", tfTemp); // display temperature,
printf( "\r\n"); // end-of-line.
}
else // If the command fails...
{
tfmP.printFrame(); // display the error and HEX dataa
}
}
Thanks