Code Monkey home page Code Monkey logo

tfmini-plus's People

Contributors

budryerson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tfmini-plus's Issues

Licence ?

Hey !
Thanks for you library !
Do you plan of adding a specific licence (tell me if I missed the file) ?

Junk lines when reading distance?

Dear Bud,

I uploaded your example code to an Arduino UNO using software serial. Everything works, I omitted some lines, because I don't need them.

The issue is, that when I'm reading distance, I get random CHECKSUM lines, which looks like these:

Data: 59 59 ec 00 02 14 28 09 e4 Status: CHECKSUM
237
237
Data: 59 59 ed 00 71 15 28 08 56 Status: CHECKSUM
237
237
237
236
237
Data: 59 59 ed 00 0d 17 28 09 f3 Status: CHECKSUM
Data: 59 59 ed 00 27 16 28 09 0c Status: CHECKSUM
237
237
237
Data: 59 59 ec 00 3c 16 28 09 22 Status: CHECKSUM
Data: 59 59 ec 00 45 16 28 09 2b Status: CHECKSUM
Data: 59 59 ec 00 45 16 28 09 2b Status: CHECKSUM

What can I do to get clean distance readout? I need to pass raw distance data for the application that I'm using.

Not working on ESP8266 chip

I tried to run the code on a Wemos D1 Mini board.

First, the compiler threw an error, which I fixed like this:

Line 30 in print.h:
fdevopen( &serial_putc, 0 );

Needs to be changed to:
Serial.setDebugOutput(true);

This seems to be the proper way to redirect stdout on ESP8266 chips - a conditional based on the chip type might be useful in the code in the future.

But even after uploading the revised code to the board, I can't get it to communicate with the TFMini Plus (which works well on an Arduino Uno).

Did somebody have any luck with this?

TFMini-Plus Neuf

Hello,

I just got a brand new TFMini, I installed your library, but I got this result. I may not have tried everything, but ..

Cordialement

Bertrand

Bonjour,

Je viens de recevoir un TFMini tout neuf, j'ai installé votre bibliothèque, mais j'ai ce résultat. Je n'ai peut être pas tout essayé mais..

TFMPlus Library Example - 19MAY2021
System reset: Status: TIMEOUT
00 00 00 00 00 00 00 00
Firmware version: Status: TIMEOUT
00 00 00 00 00 00 00 00
Data-Frame rate: Status: TIMEOUT
00 00 00 00 00 00 00 00
Status: HEADER
Data: 00 00 00 00 00 00 00 00 00
Status: HEADER
Data: 00 00 00 00 00 00 00 00 00
Status: HEADER
Data: 00 00 00 00 00 00 00 00 00

Cordialement
Bertrand

compile error

exit status 1
'Serial2' was not declared in this scope

Get firmware version failed.

Hi.

I am using a mega 2560, and am having some issues getting this up and running. I have tried connecting the tx and rx to pin 0 and 1, and I have also tried port 12 and 13. From what i can tell the mega 2560 does not communicate with the tfmini plus. Any idea what i am doing wrong?

My serial looks like this:

TFMPlus Library Example - 07JUN2019
Get firmware version failed. Attempt: 1 Data: Status: SERIAL

Get firmware version failed. Attempt: 2 Data: Status: SERIAL

Get firmware version failed. Attempt: 3 Data: Status: SERIAL

Lidar frame rate command failed. Data: Status: SERIAL
Loop:00 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
Loop:00 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
Loop:00 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
Loop:00 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
Loop:00 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL

Loop:01 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
Loop:01 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
Loop:01 Data: 00 00 00 00 00 00 00 00 00 Status: SERIAL
...

I am a bit new to this so any help would be much appreciated :)

Stuck on checksum [SOLVED]

I am stuck in a checksum. Before that, I tried using the code for Arduino from the official Benewake and success to read the distance. Also i tried to read via GUI, and managed to read. But when i tried to use this library, its stuck on checksum. Any idea? Thanks

image

Max Distance

First, thanks for your work on this library!

I'm replacing a TFMini with a TFMini plus. The TFMini would return a value of 65535 if the object was out of range, but the TFMini plus seems to return a value of 0, which is not super helpful in determining whether I'm dealing with an error in reading or just out of range. Is there a good way to differentiate?

thanks!

Problem using the ESP32 and suggested solution!

To make it work on my ESP32 Devkit I had to add 2 lines in the "TFMPI2C.h" headers file:

#define PIN_WIRE_SDA 21
#define PIN_WIRE_SCL 22

Those are the I2C pins of the ESP32-WROOM-32 that I use in my devkit.

I think perhaps the ideal would be to clarify something or leave it ready to complete in the library.
Greetings from Chile!

PIN_WIRE_SDA' was not declared in this scope

PIN_WIRE_SDA' was not declared in this scope
recoverI2CBus( PIN_WIRE_SDA, PIN_WIRE_SCL);

'PIN_WIRE_SCL' was not declared in this scope
recoverI2CBus( PIN_WIRE_SDA, PIN_WIRE_SCL);
^~~~~~~~~~~~

Setting precision to mm

Hello!

I have been trying to change the precision of the device's reads but have been unsuccessful.

The TFMPlus.h file includes a line (137) with the definition for STANDARD_FORMAT_MM assigned to a certain hexadecimal value. This is next to other commands like SET_FRAME_RATE (with its corresponding hexadecimal value) that are used with the sendCommand() function in the TFMPlus.cpp, but said function works for the following commands:
SET_FRAME_RATE
SET_BAUD_RATE
OBTAIN_FIRMWARE_VERSION
SYSTEM_RESET
RESTORE_FACTORY_SETTINGS
SAVE_SETTINGS
and the change of format is not implemented here.

I would like to be able to fix this but I don't have enough knowledge and the warning of causing the device to be unresponsive prevents me from changing some things.

As far as I understand it should follow the commented steps in the function:

bool TFMPlus::sendCommand( uint32_t cmnd, uint32_t param)
{
   // Step 1 - Build the command data to send to the device

 if( cmnd == STANDARD_FORMAT_MM)     // If the command is Standard Format MM...
    {    
              memcpy( &cmndData[ 3], &param, X);     // add the X byte Standard Format parameter. 
// 3 is the array position for the example I copied (SET_FRAME_RATE)
// but maybe in this case is different. I don't know X either.
    }
 
     // Step 2 - Send the command data array to the device

     // Step 3 - Get command reply data back from the device.

    // Step 4 - Perform a checksum test.

    // Step 5 - Interpret different command responses.

    // Step 6 - Set READY status and go home

}

I assume steps 2, 4 and 6 should stay the same, but don't know if this command generates a reply or not (steps 3 and 5).
At the moment there is not much more I can do.

Anyway, thank you for the library!

TFmini plus timeout?

I'm getting the messages:

TFMPlus Library Example - 18JUN2020
System reset: Status: TIMEOUT
00 00 00 00 00 00 00 00
Firmware version: Status: TIMEOUT
00 00 00 00 00 00 00 00
Data-Frame rate: Status: TIMEOUT
00 00 00 00 00 00 00 00
Status: HEADER
Data: 00 00 00 00 00 00 00 00 00

And then it continues printing the last two lines.

I'm using the example code.

Initial Run

Hello @budryerson ,

I just hooked a TF Mini Plus to a MKRWAN 1300. Pin 14 TX Pin 13 RX.
I am kind of a noob but how do I get the printf to work? Will including ArdiunoSTL.h work?
Also I get this error... 'bbTfmp' was not declared in this scope.

Any help would be greatly appreciated.

Thanks!

How to use TFmini plus distance reading as a threshold?

Hi! I'm working on an obstacle avoidance system using TFmini plus. I want to know how do you obtain the getDistance value as an integer in order to turn on and off an LED depending upon the distance. My code doesn't seem to work.

image

got message - Status: HEADER Data: 20 09 68 FF 20 09 68 FF 20

Hello 
I bought a TFmini Plus and am testing.Thanks for your library.
I'm testing the code with ESP32 Cam.
I' got some printf  related errors.And changed them as Serial.print.
I think I got message from  the TFmini Plus.But I can not understand the messages.
I think it is error.Following is the message and the code that I used.
Could you give me an advice?

Status: HEADER
Data: 20 09 68 FF 20 09 68 FF 20
Status: HEADER
Data: FF 26 09 64 FF 20 09 65 FF
Status: HEADER
Data: 09 6D FF 16 20 20 09 74 FF
Status: HEADER
Data: FF 20 09 7C FF 20 09 71 FF
Status: HEADER
Data: FF 20 09 70 FF 20 09 6D FF
Status: HEADER
Data: FF 20 09 7D FF 20 09 75 FF
Status: HEADER
Data: FF 20 09 71 FF 20 09 74 FF
Status: HEADER
Data: FF 22 09 6C FF 20 09 7D FF

---------------code---------------------------------------------------------/* File Name: TFMP_example.ino
 * Developer: Bud Ryerson
 * Inception: 29JAN2019
 * Last work: 10SEP2021

 * Description: Arduino sketch to test the Benewake TFMini Plus
 * time-of-flight Lidar ranging sensor using the TFMPlus Library.

 * Default settings for the TFMini Plus are a 115200 serial baud rate
 * and a 100Hz measurement frame rate. The device will begin returning
 * measurement data right away:
 *   Distance in centimeters,
 *   Signal strength in arbitrary units,
 *   and an encoded number for Temperature in degrees centigrade.

 * Use the 'sendCommand()' to send commands and return a status code.
 * Commands are selected from the library's list of defined commands.
 * Parameters can be entered directly (115200, 250, etc) but for
 * safety, they should be chosen from the library's defined lists.
 */

#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
//#include "printEX.h"   // Modified to support Intel based Arduino
// 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( 13, 15);  
                                   
void setup()
{
    Serial.begin( 115200);   // Intialize terminal serial port
    delay(20);               // Give port time to initalize
//    printf_begin();          // Initialize printf.
    Serial.print("\r\nTFMPlus Library Example - 10SEP2021\r\n");  // say 'hello'

    mySerial.begin( 115200);  // Initialize TFMPLus device serial port.
    delay(20);               // Give port time to initalize
    tfmP.begin( &mySerial);   // 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.print( "passed.\r\n");
    }
    else tfmP.printReply();
 
    delay(500);  // added to allow the System Rest enough time to complete

  // - - Display the firmware version - - - - - - - - -
//    Serial.print( "Firmware version: ");
//    if( tfmP.sendCommand( GET_FIRMWARE_VERSION, 0))
//    {
//        Serial.print( tfmP.version[ 0]); // print three single numbers
//        Serial.print( tfmP.version[ 1]); // each separated by a dot
//        Serial.print( tfmP.version[ 2]);
//    }
//    else tfmP.printReply();
    // - - Set the data frame-rate to 20Hz - - - - - - - -
//    Serial.print( "Data-Frame rate: ");
//    if( tfmP.sendCommand( SET_FRAME_RATE, FRAME_20))
//    {
//        Serial.println( String(FRAME_20));
//    }
//    else 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.
    // - - - - - - - - - - - - - - - - - - - - - - - -
    printf( "Set I2C Mode: ");
    if( tfmP.sendCommand( SET_I2C_MODE, 0))
    {
        printf( "mode set.\r\n");
    }
    else tfmP.printReply();
    printf( "Save settings: ");
    if( tfmP.sendCommand( SAVE_SETTINGS, 0))
    {
        printf( "saved.\r\n");
    }
    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.
    {
      Serial.print( "Louis_Dist: cm ");   // display distance,
      Serial.print( tfDist);   // display distance,
//      Serial.print( "Flux: ");   // display signal strength/quality,
//      Serial.print( tfFlux);   // display signal strength/quality,
//      Serial.print( "Temp:"  );   // display temperature,
//      Serial.print( tfTemp);   // display temperature,
      Serial.print( "\r\n");                   // end-of-line.
    }
    else                  // If the command fails...
    {
      tfmP.printFrame();  // display the error and HEX dataa
    }
}

"Status: Checksum" Galore

Hi Bud,

I am currently using an Arduino Uno meaning that I am trying to use the Software Serial ports. Also, I am very new to Arduino so if you could dumb down the language that would be great!

When I'm running the sample program you created, I am getting plenty of Status: Checksum's instead of readings. Like this image. I'm not sure how to fix this so could you help me out?
image

I saw the post from about two weeks ago talking about using the hardware serial, but I don't know how to do that, so if you think that is the best solution could you please teach me how to use the hardware serial ports?

Here is the code that I am using
TFMP_example2.zip

Thanks in advance,
Weyland Kanada

Wrong results

Hello

Thank you for this library. I managed to make test program for Node MCU with Basic reading code and library. I can look distance results from serialmonitor and It gives mainly right results. However there are also few wrong results as you can see at picture. Where do you think those comes from and can I avoid somehow those wrong measurements?
Measurements

Recommendation?

Wanting to inquire how your code differs from senegalo library for the TFMini-Plus, and recommendation for one over the other? Just got my first of several units and excited to be able to find working code and get them tested. Thanks

https://github.com/senegalo/TFMiniPlus

Arduino freezed after new library updated

My projects are Arduino nano + TFM mini plus + TVout library
I used the hardware serial to communicate with TFM.
it works fine and stable without trouble, but after the new library updated.
I recompile with the same code,
Arduino nano run normally when TFM distance = 0 cm (cannot get distance since low signal strength)
but whenever TFM can detect the distance, Arduino nano will stop and hang.
and it also makes Arduino unusable (it like the code was changed or deleted somehow)
I have to compile and upload the code again to make it work.
(TFMplus connect to Arduino nano hardware serial, this is the same serial that connects to onboard USB to serial converter for uploading code.

some part of the code
Serial.begin(115200);
tfmP.begin(&Serial);

while (Serial.available()) Serial.read(); //flush serial
tfmP.getData( newdist, sigstr, tfTemp); // Get data from the device.

https://1drv.ms/u/s!Am7Lg3UW7uqijKwOY6OmUdqVWXjVcA

Wrong constant in TFMPlus.h

In TFMPlus.h, hex constants are defined for various frame rates. In every case but one, the hex constant matches the rate — for example, FRAME_25 maps to 0x0016.

One does not match:
#define FRAME_5 0x0003

Surely you meant 0x0005?

TF Mini Plus Raspberry Pi library

Any chance you have a library for Raspberry Pi for the TF Mini Plus? Getting checksum errors and not sure if there's a code problem or a sensor problem.

sendCommand() not working with Arduino MKR GSM 1400

Hello,

I am using the library with TFMini Plus and Arduino MKR GSM 1400 board.
I connected the sensor to TX and SX serial ports on my board. I can get the distance data without a problem as that is working as expected.

What I do have problem with is sending ANY command to the sensor itself. The execution just halts and nothing is returned by sendCommand() function. Here is an example code that does not work (I want to check firmware version, but ultimately want to change to I2C as I'll connect multiple sensors).

Here is the code example (I'm using Serial.print() as printf is not working)

#include <TFMPlus.h>
#include "printf.h"

TFMPlus tfmP;
void setup()
{

  Serial.begin(9600);
  while (!Serial);
  delay(20);

  Serial1.begin(115200);
  delay(20);               // Give port time to initalize
  tfmP.begin( &Serial1);
  
  delay(500);

  if (tfmP.sendCommand(OBTAIN_FIRMWARE_VERSION, 0))
  {
    Serial.println("Printing firmware version:");
  }
  else
  {
    Serial.println("Error printing version");
    tfmP.printReply();
  }
}


void loop()
{

}

When I run this, nothing is printed to the serial monitor, the execution apparently stops in tfmP.sendCommand(OBTAIN_FIRMWARE_VERSION, 0) part of the code.

Frame rate command failed

Hello,

I'm having an issue using your library / example sketch with a new TFMini Plus with firmware version 1.9.0, initially the frame rate command fails with the error data - Data: 5a 03 20 Status: CHECKSUM for example (the hex digits change every time, another example - Data: 5a 07 03 14 00 77 00) but always with a CHECKSUM status.

As the sketch continues to run, the library doesn't seem to get any data from the device, and instead reports the error - Loop:20 Data: 30 0d 0a 32 2e 30 30 0d 0a Status: SERIAL and loops forever with the Data values changing as I move objects in front of the sensor, but no distance measurements come through.

I'm going to dig deeper into my issues tomorrow, but I thought I may as well see if you could offer any appreciated insight.

Any working code in arduino uno?

Hello, i have used your code in arduino mega2560, it works, but when i used it on arduino uno, uncommenting the SoftwareSerial(10,11) //tfluna rx pin to 11, tfluna tx to pin 10, it never prints a thing. Any suggestions on that?

Failure rate

Hi budryerson,
I am using your library for 1 TFMini Plus with SoftwareSerial and an Arduino Uno. I was wondering why so many readings are bad. So I wrote a little code to show it. I give you some random lines of that output:

Test TFMini Plus (203) at 500Hz 500x -> Failure rate: ss 30.20
Test TFMini Plus (203) at 1000Hz 500x -> Failure rate: sf 29.00
Test TFMini Plus (203) at 20Hz 100x -> Failure rate: 29.00
Test TFMini Plus (203) at 100Hz 500x -> Failure rate: ss 32.20
Test TFMini Plus (203) at 200Hz 500x -> Failure rate: ss 33.80
Test TFMini Plus (203) at 500Hz 500x -> Failure rate: ss 37.20
Test TFMini Plus (203) at 1000Hz 500x -> Failure rate: s 30.20
Test TFMini Plus (203) at 20Hz 100x -> Failure rate: sf 32.00
Test TFMini Plus (203) at 100Hz 500x -> Failure rate: ss 33.00
Test TFMini Plus (203) at 200Hz 500x -> Failure rate: ss 24.80
Test TFMini Plus (203) at 500Hz 500x -> Failure rate: ss 14.80
Test TFMini Plus (203) at 1000Hz 500x -> Failure rate: s 20.80
Test TFMini Plus (203) at 20Hz 100x -> Failure rate: 24.00
Test TFMini Plus (203) at 100Hz 500x -> Failure rate: sssss 22.60
Test TFMini Plus (203) at 200Hz 500x -> Failure rate: ss 21.40
Test TFMini Plus (203) at 500Hz 500x -> Failure rate: sss 21.00
Test TFMini Plus (203) at 1000Hz 500x -> Failure rate: s 22.60
Test TFMini Plus (203) at 20Hz 100x -> Failure rate: 21.00

s=system reset failed once
f=set frame rate failed once
Failure rate= failed readings/total readings

The distance is just 2,2 m to a white wall. And it is indoors.
What do you think? Would that be normal for a TFMini Plus?

Thanks in advance!
Tom

PS: If it is of any help, I could give that test code to you.

Converting tfDist into meters

Hi Bud,

Using your example code, I would like to convert the tfDist value, which is outputted in centimeters, into meters. I have tried performing math using a double:

if ( tfmP.getData( tfDist, tfFlux, tfTemp)) // Get data from the device.
{
double tfMeter;
tfMeter = tfDist / 100.0;
printf( " Dist: %f", tfMeter); // Display the distance.
break; // Escape this sub-loop
}

However, it always outputs something like:

Loop:01 Dist: ?
Loop:02 Dist: ?
Loop:03 Dist: ?
Loop:04 Dist: ?
Loop:05 Dist: ?

Do you have any idea of how I could solve this issue? I am not sure, it may be because tfDist is a uint16_t integer type, but I am not sure how I would fix it regardless. Hope you can help, thank you.

printf.h: No such file or directory

Hello

I am relatively new to this. I have connected up a TFMini Plus to an Arduino UNO, added this library to /Arduino/libraries, then attempted to run TMFM_example.ino. On verify I got the following, so not sure what to do. Thanks!

TFMP_example:25:10: fatal error: printf.h: No such file or directory #include "printf.h" // Modified to support Intel based Arduino ^~~~~~~~~~ compilation terminated. exit status 1 printf.h: No such file or directory

Temperature

I'm using your library and it works great. I do receive temperature readings in 40-45 degree range. The TFMPlus returns Celsius degrees, so I think this is not correct. (My room temp is about 22ºF). So I reversed the algorithm for calculating temp:

original from library is:
temp = ( temp >> 3) - 256;

my reverse calculation:
float newtemp = ((temp+256) << 3)/100.;

(temp of 45 yields 2408 in reverse, so dividing by 100 gives 24.08... Just guessing... maybe it reports in 1/100ths?)

This gives reasonable temperatures for my physical space. Am I on the wrong track? Could benewake have updated the device to report temperature values in a different format than previous versions of the device?

I plan on using my device outside, so I would like to use the temperature data. (single digit accuracy is completely adequate)

Thanks.

Problemes upgrading to library 1.4.0

Hello again Bud,

I am compiling for the ESP32. Library 1.3.5 was working fine for me. However, I can not get 1.4.0 to compile?
This is how have I changed my sketch?

  1. Replaced
uint16_t tfDist     = 0;       // Distance measurement in centimeters (default)
uint16_t tfFlux     = 0;       // Luminous flux or intensity of return signal
uint16_t tfTemp     = 0;       // Temperature in degrees Centigrade (coded)
**with**
int16_t tfDist     = 0;       // Distance measurement in centimeters (default)
int16_t tfFlux     = 0;       // Luminous flux or intensity of return signal
int16_t tfTemp     = 0;       // Temperature in degrees Centigrade (coded)
  1. Replaced all instances of
tfmP.printStatus(true); 
**with**
tfmP.printFrame(true);
  1. Replaced the the 1.3.5 library with the 1.4.0 version using the Arduino IDE Library manager.

My errors:

Arduino: 1.8.12 (Linux), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

/******************* text truncated for brevity. Full log appended ********************/

Using library Wire at version 1.0.1 in folder: /home/mprowe/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/Wire 
Using library NHD_US2066 in folder: /home/mprowe/Arduino/libraries/NHD_US2066 (legacy)
Using library SPI at version 1.0 in folder: /home/mprowe/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SPI 
Using library TFMPlus at version 1.4.0 in folder: /home/mprowe/Arduino/libraries/TFMPlus 
Using library WiFi at version 1.0 in folder: /home/mprowe/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi 
exit status 1
no matching function for call to 'TFMPlus::printFrame(bool)

Error.log

Any suggestions will be appreciated.

Regards, Martin

weird return values

Hi Bud!

Love your library. I'm having what I hope is a small problem getting the TFMini-Plus to talk to a Madunio Lora Radio on SoftwareSerial on pins (D4,D5)

It's doing this:

TFMPlus Library Example - 18JUN2020
System reset: Status: TIMEOUT
F6 04 60 09 FF 00 00 00
Firmware version: Status: TIMEOUT
A3 00 FA 04 B0 41 F8 00
Data-Frame rate: Status: TIMEOUT
00 F5 04 60 09 BF 00 00
Status: HEADER
Data: FF 58 99 69 80 08 C0 42 DF
Status: HEADER
Data: 58 B9 A3 80 1F 08 4B C4 FF
Status: HEADER
Data: 58 99 A3 80 1F 08 53 C4 FF
Status: HEADER
Data: 58 99 A3 00 F4 04 60 09 EF
Status: HEADER
Data: 58 99 A3 00 F5 04 60 09 BF
Status: HEADER
Data: 58 99 A3 00 F6 04 60 09 FF
Status: HEADER
Data: 58 99 B3 00 F8 04 B8 41 F0
Status: HEADER

Signal saturation Data - Error

Hello,
i'm using this library in arduino

TFMPlus I2C Library 1.5.0
11:56:15.300 -> Firmware version: 2.0.3
11:56:15.814 -> Data-Frame rate: 20Hz.
11:56:17.965 -> Status: Signal saturation Data: 59 59 00 00 FF FF E8 08 A0

what can cause this problem? I checked the cables and all seems to be fine
Not sure what this error/status message means?!

caused by this code: (I2C Mode)
tfmP.status == TFMP_READY (FALSE)
--> tfmP.printFrame(); // Otherwise, display error and data frame

How to set reading time tfmini?

Hello Bud,
How do I set the tfmini reading time?
I want to read every 5 seconds. When using the delay function (5000), the reading results in lag and chaos.
I tried to set frame rate to 1Hz, then the tfmini read every 1 second. But, when I add delay function, it interrupts the sensor reading and makes the reading lag.
any suggestion?

Need some help with TF-Luna and Seeeduino XIAO

Hello.

Thank you for creating the library.

I am a relatively new Arduino programmer. I am attempting to use a Seeeduino XIAO, which is an ARM-based processor (ARM® Cortex®-M0+ 32bit 48MHz microcontroller(SAMD21G18)). It cIaims to be Arduino compatible. I have run many of the tutorial examples on it without issue. I hope to use this package because it is small, but also it speaks 3.3V TTL logic and so is compatible with the TF-Luna without a logic converter. I am not 100% certain that the Serial connections are independent of the USB connection to the computer. I also tried setting up a software serial interface but I don't think that works at 115200 baud? I got a different HEX output as I recall when I tried that.

https://wiki.seeedstudio.com/Seeeduino-XIAO/

Here is my schematic:

image

I think I understand that the TF-Luna is Serial by default, but I have also tried hooking up Pin 5 to 3.3V (3V3 on Seeeduino) with no change in the results.

The PrintF library says it is for Arduino and not ARM:

#if defined (ARDUINO) && !defined (__arm__) && !defined(__ARDUINO_X86__)

But it is not generating any error so maybe the Seeduino is compatible as it claims to be.

I experimented with using printf but it doesn't matter because the only line of the example code that seems to be executing is:

tfmP.printFrame(); // display the error and HEX dataa }

Because my output to Serial Monitor is:

18:21:50.515 -> Status: HEADER
18:21:50.515 -> Data: 00 00 00 00 00 00 00 00 00
18:21:51.565 -> Status: HEADER
18:21:51.565 -> Data: 00 00 00 00 00 00 00 00 00
18:21:52.609 -> Status: HEADER
18:21:52.609 -> Data: 00 00 00 00 00 00 00 00 00

Here is my code. It is identical to the example, except I am calling Serial1 instead of Serial2.

/* File Name: TFMP_example.ino
 * Developer: Bud Ryerson
 * Inception: 29JAN2019
 * Last work: 10SEP2021

 * Description: Arduino sketch to test the Benewake TFMini Plus
 * time-of-flight Lidar ranging sensor using the TFMPlus Library.

 * Default settings for the TFMini Plus are a 115200 serial baud rate
 * and a 100Hz measurement frame rate. The device will begin returning
 * measurement data right away:
 *   Distance in centimeters,
 *   Signal strength in arbitrary units,
 *   and an encoded number for Temperature in degrees centigrade.

 * Use the 'sendCommand()' to send commands and return a status code.
 * Commands are selected from the library's list of defined commands.
 * Parameters can be entered directly (115200, 250, etc) but for
 * safety, they should be chosen from the library's defined lists.
 */

#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.
    printf("\r\nTFMPlus Library Example - 10SEP2021\r\n");  // say 'hello'

    Serial1.begin( 115200);  // Initialize TFMPLus device serial port.
    delay(20);               // Give port time to initalize
    tfmP.begin( &Serial1);   // 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( "Soft reset: ");
    if( tfmP.sendCommand( SOFT_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( GET_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();
    // - - - - - - - - - - - - - - - - - - - - - - - -

/*  // - - - - - - - - - - - - - - - - - - - - - - - -  
    // 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.
    // - - - - - - - - - - - - - - - - - - - - - - - -
    printf( "Set I2C Mode: ");
    if( tfmP.sendCommand( SET_I2C_MODE, 0))
    {
        printf( "mode set.\r\n");
    }
    else tfmP.printReply();
    printf( "Save settings: ");
    if( tfmP.sendCommand( SAVE_SETTINGS, 0))
    {
        printf( "saved.\r\n");
    }
    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%s",  tfTemp, "C");   // display temperature,
      printf( "\r\n");                   // end-of-line.
    }
    else                  // If the command fails...
    {
      tfmP.printFrame();  // display the error and HEX dataa
    }
}

Any help would be greatly appreciated. Thanks in advance.

How to use multiple TFMini Plus and TF02 Pro sensors on AT Mega 2560?

Hey Bud,
I have been recently working on a project which requires multiple TFMini Plus sensors and TF2Pro sensors to be connected in a single AT Mega 2560 module. Can you tell me how can I achieve that and what should be the code for it because if I am trying it's not working. Only one value is getting transmitted and received not from the other sensor please help me on this.
Thank you!

Change to I2C returning Serial

I make a call in the beginning of the code to change to I2C but it always returns "Serial" but no error with the SetCommand. Do I need a parameter with the SET_I2C_MODE command?

Using Example code

void setup()
{
Serial.begin(115200); // Intialize terminal serial port
delay(20); // Give port time to initalize
printf_begin(); // Initialize printf.
printf("\r\nTFMPlus Library Example - 18JUN2020\r\n"); // say 'hello'

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


// - - - - - - - - - - - - - - - - - - - - - - - -
printf( "SET_Mode: ");//SET_I2C_MODE, SET_SERIAL_MODE
if( tfmP.sendCommand(SET_I2C_MODE , 0))
{
    tfmP.printReply();
}
else 
{
  printf( "Failed: ");
  tfmP.printReply();
}

//.....

Output

SET_Mode: Status: SERIAL
00 00 00 00 00 00 00 00

What is this library called in the Arduino examples

Sorry, this could be the dumbest thing I ever asked, but I see that you have an example sketch, yet it's not showing up under File->Examples in the IDE and I can't find your library after installing it. What is it called?

RPi Pico CRC check error (memcpy)

I tried to run the sample code on an RPi Pico, but I always got a 0 as output (Arduino IDE 2.0.3).
The problem is the memcpy function for shifting the arrays with overlapping memory. I changed it to memmove and it works now (Also I increased the buffer size for Serial1, to 128 bytes).

memcpy( frame, frame + 1, TFMP_FRAME_SIZE);

Another "Get Firmware Version" failed [SOLVED]

I am running your example on an ESP32 and the tfmP.getData( tfDist, tfFlux, tfTemp) is working (although I have doubts about the Temp, which I'll skip over for now).
However, I can't get any output from the firmwareVersion() function. Run as-is, the debug output is:

FMPlus Library Example - 07JUN2019
 Status: SERIAL
Get firmware version failed. Attempt: 1 Data:
 Status: SERIAL
Get firmware version failed. Attempt: 2 Data:
 Status: SERIAL
Get firmware version failed. Attempt: 3 Data:

...and re-running with tfmP.printStatus(true);, `gives:

FMPlus Library Example - 07JUN2019
 Status: SERIAL
Get firmware version failed. Attempt: 1 Data: 00 00 00 00 00 00 00 00 00
 Status: SERIAL
Get firmware version failed. Attempt: 2 Data: 00 00 00 00 00 00 00 00 00
 Status: SERIAL
Get firmware version failed. Attempt: 3 Data: 00 00 00 00 00 00 00 00 00

A quick look through TFMPlus.h, throws up an immediate question. That header has this:
#define OBTAIN_FIRMWARE_VERSION 0x00010407 // returns 3 byte firmware version
...but looking through the TFmini-Plus-T-01 A04_Product Manual.pdf which you have very helpfully included in the library, Table 11 says that the Obtain firmware version is 5A 04 01 5F
Should they be the same?
Regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.