Hello, my name is Jamie and i'm having trouble with the TF03 180m UART lidar module. i have seen other topics on this sensor, but i haven't seen this. I'm getting a compiling error from the example sketch. I started there before i incorporating it into my project. I don't have the sensor wired up because i can't even compile the code. If i did, it would be wired up this way:
Here's the example Code directly from the library ( which is installed by the way)
/*
* @File : DFRobot_TFmini_test.ino
* @Brief : This example use TFmini to measure distance
* With initialization completed, we can get distance value and signal strength
* @Copyright [DFRobot](http://www.dfrobot.com), 2016
* GNU Lesser General Public License
*
* @version V1.0
* @date 2018-1-10
*/
#include <DFRobot_TFmini.h>
SoftwareSerial mySerial(8, 7); // RX, TX
DFRobot_TFmini TFmini;
uint16_t distance,strength;
void setup(){
Serial.begin(115200);
TFmini.begin(mySerial);
}
void loop(){
if(TFmini.measure()){ //Measure Distance and get signal strength
distance = TFmini.getDistance(); //Get distance data
strength = TFmini.getStrength(); //Get signal strength data
Serial.print("Distance = ");
Serial.print(distance);
Serial.println("mm");
Serial.print("Strength = ");
Serial.println(strength);
delay(500);
}
delay(500);
}
The error i get when compiling is:
c:\Users\rober\Documents\Arduino\libraries\DFRobot_TFmini-master\DFRobot_TFmini.cpp:5:16: error: invalid conversion from 'arduino::Stream*' to 'SoftwareSerial*' [-fpermissive]
TFSerial = &s_;
^~~
exit status 1
Compilation error: exit status 1
From what i understand, that means it's trying to assign a Stream* (a base class pointer) to a SoftwareSerial* pointer. I've seen a couple of fixes which i've tried, for instance addjusting the CPP file to not call TFSerial->begin(115200); because Stream doesn't define begin().
I'm not very good with Stream* pointers. Can someone help please.
Put the cursor between the exit status 1 and the three "backticks" (```)
Hit <enter>
Click "Save Edit"
I do not receive a compile error. Libraries generally have no reason to be edited. The error you are seeing is due to an input parameter from the sketch to the library (TFmini). Is TFmini working? Verify your libraries are current.
Thank you so much for the help. I've made sure my IDE is updated as well as my UNO R4. There are a couple of libraries for this sensor. I've tried 2. They both came from gitHub. Can you give me a reference or a link to the most updated. Neither of the two i tried worked. I used the TTL boot loader and the sensor is working. I believe that i just don't have the right library. Thank you in advanced for your help
Perhaps you need to "fall back" to a previous version of the library by using your IDE Library manager, then remove the current library, then pick an earlier version in the dropdown to install in the IDE. Compare compile errors.
Will do. Thank you very much. You said that you compiled it with no problem. I'll unload and reload libraries, but do you happen to know which library you have?
It is very odd. I've started knocking down library files. Some from github and some from the library manager. Deleting the old ones and updating. Some of the others have different examples. But for whatever reason the sketch i put on this post gives me that pointer error. Very weird. As i've searched online, they say the right library is the TF Mini, but theres a TF Mini Plus that is supposed to be updated. This sketch still doesn't go.
Really weird. I already tried that one, but i reloaded it just as you said. (did that the 1st time). So, second try no go. same pointer error. You think it's because i'm on windows 10?
It worked for me on Windows (11) and Linux (appimage on Mint 21). Maybe someone out there has a Window 10 system? Perhaps @ptillisch can gather some of your system information and point you in the right direction.
c:\Users\rober\Documents\Arduino\libraries\DFRobot_TFmini-master\DFRobot_TFmini.cpp: In member function 'void DFRobot_TFmini::begin(arduino::Stream&)':
c:\Users\rober\Documents\Arduino\libraries\DFRobot_TFmini-master\DFRobot_TFmini.cpp:5:16: error: invalid conversion from 'arduino::Stream*' to 'SoftwareSerial*' [-fpermissive]
TFSerial = &s_;
^~~
exit status 1
Compilation error: exit status 1
Its the same code. This is really weird. I've never had a problem like this with a library. I feel it's probably something weird and stupid. I appreciate all the effort. thank you
Check the board manager for most recent version for Uno (Arduino AVR Boards... my version on Linux is 1.8.6), re-compile. Last on the list for me is re-install the IDE. (sry)
Well, i loaded on my mac. fresh install. downloaded the library. The example in the library compiled, but no data. gonna hit up the TLL again. did updates on everything. The code i posted still doesn't compile. Sorry for all the trouble. still don't know what's going on, but i'm going to use the example in that library. a little frustrated at this point. not at you of course. Thank you for all the trouble shooting