TFMini Plus does not respond

New TFMini Plus connected to a Mega2560. red and black to VCC and Gnd. The two serial wires to Serial2 on the Mega. I also tried it in Serial1 and other combos. Noting works. It does not respond in setup() as needed.

I am out of ides as to why a seemingly good (new out of the box) TFMini Plus should not respond to this code.

Any help is much appreciated!

Here is the error from my code:

16:45:58.991 -> TFMPlus Library Example - 10SEP2021
16:45:58.991 -> Soft reset: 
16:46:00.020 ->        *********** failed soft reset ****************
16:46:00.020 -> Status: TIMEOUT
16:46:00.020 ->  00 00 00 00 00 00 00 00
16:46:00.535 -> Firmware version: 
16:46:01.518 -> *************  Failed version data  **********************
16:46:01.565 -> Status: TIMEOUT
16:46:01.565 ->  00 00 00 00 00 00 00 00
16:46:01.565 -> Data-Frame rate: 
16:46:02.547 -> ****************  Failed set frame rate  ***********************
16:46:02.547 -> Status: TIMEOUT
16:46:02.547 ->  00 00 00 00 00 00 00 00

Here is my source code:



#include <TFMPlus.h>  // Include TFMini Plus Library v1.5.0
TFMPlus tfmP;         // Create a TFMini Plus object

//#include "printf.h"   // Modified to support Intel based Arduino
//                      // devices such as the Galileo. Download from:
//                      // https://github.com/spaniakos/AES/blob/master/printf.h

// The Software Serial library is an alternative for devices that
// have only one hardware serial port. Delete the comment slashes
// on lines 37 and 38 to invoke the library, and be sure to choose
// the correct RX and TX pins: pins 10 and 11 in this example. Then
// in the 'setup' section, change the name of the hardware 'Serial2'
// port to match the name of your software serial port, such as:
// 'mySerial.begin(115200); etc.

//#include <SoftwareSerial.h>       
//SoftwareSerial mySerial( 10, 11);   
                                    
void setup()
   {
   Serial.begin( 115200);   // Intialize terminal serial port
   delay(20);               // Give port time to initalize
   //printf_begin();          // Initialize printf.
   Serial.println(   F(   "TFMPlus Library Example - 10SEP2021"   )  );  

   Serial2.begin( 115200);  // Initialize TFMPLus device serial port.
   delay(20);               // Give port time to initalize
   tfmP.begin( &Serial2);   // Initialize device library object and...
                             // pass device serial port to the object.

   // Send some example commands to the TFMini-Plus
   // - - Perform a system reset - - - - - - - - - - -
   Serial.println( "Soft reset: ");
   if( tfmP.sendCommand( SOFT_RESET, 0))
       {
       Serial.println( "passed");
       }
   else 
       {
       Serial.println( F("       *********** failed soft reset ****************" ) ) ;  
       tfmP.printReply();
       }
   delay(500);  // added to allow the System Rest enough time to complete
 
   
   
   // - - Display the firmware version - - - - - - - - -
   Serial.println( "Firmware version: ");
   if( tfmP.sendCommand( GET_FIRMWARE_VERSION, 0))
      {
      Serial.print(  F( "Version   " ) ) ;
      Serial.print(  tfmP.version[ 0]); // print three single numbers
      Serial.print(  F( "." ) ) ;
      Serial.print(  tfmP.version[ 1]); // each separated by a dot
      Serial.print(  F( "." ) ) ;
      Serial.println(  tfmP.version[ 2]);
      
      }
   else
      { 
      Serial.println( F(  "*************  Failed version data  **********************" ) ) ; 
      tfmP.printReply();
      }
   // - - Set the data frame-rate to 20Hz - - - - - - - -
   Serial.println( "Data-Frame rate: ");
   if( tfmP.sendCommand( SET_FRAME_RATE, FRAME_20))
      {
      Serial.print(  F( "Frame rate:  " ) ) ;
      Serial.println(  FRAME_20);
      }
   else 
      {
      Serial.println(  F(  "****************  Failed set frame rate  ***********************" ) ) ; 
      tfmP.printReply();
      }
    













    /********************  
    // The next two commands may be used to switch the device 
    // into I2C mode.  This sketch will no longer receive UART
    // (serial) data.  The 'TFMPI2C_example' sketch in the 
    // TFMPI2C Library can be used to switch the device back
    // to UART mode.
    // Don't forget to switch the cables, too.
    // - - - - - - - - - - - - - - - - - - - - - - - -
    Serial.println( "Set I2C Mode: ");
    if( tfmP.sendCommand( SET_I2C_MODE, 0))
    {
        Serial.println( "mode set.\r\n");
    }
    else tfmP.printReply();
    Serial.println( "Save settings: ");
    if( tfmP.sendCommand( SAVE_SETTINGS, 0))
    {
        Serial.println( "saved.\r\n");
    }
    else tfmP.printReply();
    // - - - - - - - - - - - - - - - - - - - - - - - -    
    ************/

   delay(50000);            // And wait for a long time
   }


















// 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.
    {
      Serial.print(  F( "   distance   " ) ) ;
      Serial.println(  tfDist);   // display distance,
      Serial.print(  F( "   flux   " ) ) ;
      Serial.println(  tfFlux);   // display signal strength/quality,
      Serial.print(  F( "   temp     " ) ) ;
      Serial.println( tfTemp );   // display temperature,
      //Serial.println( "\r\n");                   // end-of-line.
    }
    else                  // If the command fails...
    {
      tfmP.printFrame();  // display the error and HEX dataa
    }
}







Did you take the plastic coating off the front of the TFMiniP? I burnt my first TFMiniP up cause I did not take the plastic covering off. The thing just does not work with the covering in place.

Yes I did take the plastic film off.

In Setup it never gets past the initialization. Not even the first step

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.