Arduino and the SparkFun TMP102 sensor

I am brand-new to Arduino. I have it connected to my Raspberry Pi 3B+. I have a SparkFun TMP102 temperature sensor properly connected to the Arduino and have downloaded the appropriate sketch from the SparkFun web site. When I try to compile the sketch, however, I get an error that it can't find 'Wire.h'.

The downloaded file, 'SparkFun_TMP102_Arduino_Library-master', contains a folder named 'examples', and this folder contains a folder named 'SparkFun_TMP102_Breakout_Example'. This folder originally contained two files: 'SparkFun_TMP102_Breakout_Example.ino' and 'SparkFunTMP102.h'. Because the error said it couldn't find 'Wire.h' I found 'Wire.h' in the Arduino software, and copied it into this folder.

However, I still get the same error message. I don't know if the sketches maybe have become outdated, or if I just don't know how to run sketches properly.

Thanks for any help!

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a message here USING CODE TAGS (</> button on the forum toolbar). If the text exceeds the forum's 9000 character limit, save it to a text file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

I couldn't find the required button in the forum toolbar, so I saved the errors to a .doc file and attached it.

SparkFunTMP102_errors.doc (14.5 KB)

If your browser doesn't show the posting toolbar, then you can manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]

I don't have any program installed that can read a .doc file. When you do need to attach files, please use .txt format.

I found the </> button, actually, but I can't figure out how to paste the txt file where the cursor is. I'm just attaching it as I did before. Thanks for your patience!

SparkFunTMP102_errors.txt (2.32 KB)

You don't paste the file in the code tags, you copy the text and then paste the text into the code tags.

Please provide a link to where you downloaded SparkFun_TMP102_Arduino_Library-master from. Please use the chain links icon on the toolbar to make the link clickable.

I actually had to use three links to download that: SparkFun Digital Temperature Sensor Breakout - TMP102 - SEN-13314 - SparkFun Electronics
and on that site I clicked on 'Documents' and then on 'Arduino Library'. I'm sorry for the inefficiency my inexperience causes.

First we need to get back to the original example as it's provided by Sparkfun. That will work fine with no modifications needed. You should not be getting an error about Wire.h when compiling for the Uno. Putting that file in the sketch folder is not a solution to that error. If you get the error about Wire.h after going back to the original example, then we'll investigate and resolve that issue.

Please delete the folder /home/pi/Arduino/libraries/SparkFun_TMP102_Breakout_Example.

Also, this is incorrect:

emeyeraway:
The downloaded file, 'SparkFun_TMP102_Arduino_Library-master', contains a folder named 'examples', and this folder contains a folder named 'SparkFun_TMP102_Breakout_Example'. This folder originally contained two files: 'SparkFun_TMP102_Breakout_Example.ino' and 'SparkFunTMP102.h'

The folder SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example does not contain a file named SparkFunTMP102.h. Based on what you did with Wire.h, I suspect that what happened is you got an error about SparkFunTMP102.h and chucked it into the sketch folder in an attempt to fix it. That's not how you fix that error.

In general, when you get a "No such file or directory" error, it almost always means you need to install the library that contains that file. The thing you downloaded from SparkFun is a library. You need to install the library in order to use the example that comes with it.

Here's how to install the library:

Now that the library is installed, you can open the example at File > Examples > SparkFun TMP102 Breakout > SparkFun_TMP102_Breakout_Example. Now do a Sketch > Verify/Compile. If you get an error, please follow these instructions:

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a message here USING CODE TAGS (</> button on the forum toolbar). If the text exceeds the forum's 9000 character limit, save it to a text file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

I believe I followed your instructions, but still got an error.

When I downloaded from github, there was no 'archive' present in the path. However, I did find 'SparkFun_TMP102_Arduino_Library-master.zip', and tried to install it according to your instructions. However, the series of steps you suggest skips 'SparkFunTMP102Breakout' and goes directly to 'SparkFun_TMP102_Breakout_Example'. I open this, but then 'Sketch>Verify/Compile' produces the following errors:

Arduino: 1.8.8 (Linux), Board: "Arduino/Genuino Uno"

/tmp/cchnIwq8.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_SparkFun_TMP102_Breakout_Example.ino.cpp.o.1997':
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:36: undefined reference to `TMP102::TMP102(unsigned char)'
/tmp/cchnIwq8.ltrans0.ltrans.o: In function `setup':
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:46: undefined reference to `TMP102::begin()'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:53: undefined reference to `TMP102::setFault(unsigned char)'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:56: undefined reference to `TMP102::setAlertPolarity(bool)'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:59: undefined reference to `TMP102::setAlertMode(bool)'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:63: undefined reference to `TMP102::setConversionRate(unsigned char)'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:67: undefined reference to `TMP102::setExtendedMode(bool)'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:70: undefined reference to `TMP102::setHighTempF(float)'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:74: undefined reference to `TMP102::setLowTempF(float)'
/tmp/cchnIwq8.ltrans0.ltrans.o: In function `loop':
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:85: undefined reference to `TMP102::wakeup()'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:88: undefined reference to `TMP102::readTempF()'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:93: undefined reference to `TMP102::alert()'
/home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example/SparkFun_TMP102_Breakout_Example.ino:97: undefined reference to `TMP102::sleep()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please do this:

  • File > Preferences > Show verbose output during: > compilation (check) > OK
  • Sketch > Verify/Compile
  • After the compilation fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the forum toolbar).

If the length of the output exceeds the forum's 9000 character limit, save it in a txt file and post it here as an attachment. If you click the "Reply" button you'll see the "Attachments and other options" link.

The error file did exceed the limit; I hope I succeeded in attaching it.

tmp102_errors_2.txt (28.8 KB)

Does /home/pi/Arduino/libraries/SparkFun_TMP102_Arduino_Library-master/examples/SparkFun_TMP102_Breakout_Example contain a file named SparkFunTMP102.h?

No. It contains only one file: SparkFun_TMP102_Breakout_Example.ino

Problem solved! I put arduino-1.8.8 in the trash and downloaded it anew, as you suggested, and now all is well. Thanks for your willingness to help me out.