PlatformIO Community

Can't install SmoothThermistor library without weird errors in compile

Hello, I am making a project with an Esp32. I have code and other libraries already installed and compiling fine. I am wanting to install SmoothThermistor to read values from an assortment of thermistors attached to by board. I had already used this library in ArduinoIDE and it worked fine.

So, I go into the Library Manager and install it. It says it was installed fine without issue. When I compile the project though, it gives me some pretty strange errors regarding the SmoothThermistor library.

Here are the errors given for SmoothThermistor:

Compiling .pio/build/nodemcu-32s/libb97/SmoothThermistor/SmoothThermistor.cpp.o
.pio/libdeps/nodemcu-32s/SmoothThermistor/src/SmoothThermistor.cpp:53:2: error: invalid preprocessing directive #IF
 #IF !defined(ESP32) || !defined(ESP8266)
  ^
.pio/libdeps/nodemcu-32s/SmoothThermistor/src/SmoothThermistor.cpp:55:2: error: invalid preprocessing directive #ENDIF
 #ENDIF
  ^
Compiling .pio/build/nodemcu-32s/libb3d/BLE/BLE2902.cpp.o
.pio/libdeps/nodemcu-32s/SmoothThermistor/src/SmoothThermistor.cpp: In member function 'void SmoothThermistor::useAREF(bool)':
.pio/libdeps/nodemcu-32s/SmoothThermistor/src/SmoothThermistor.cpp:54:44: error: 'analogReference' was not declared in this scope
     analogReference(aref? EXTERNAL: DEFAULT);
                                            ^
*** [.pio/build/nodemcu-32s/libb97/SmoothThermistor/SmoothThermistor.cpp.o] Error 1
==================================================== [FAILED] Took 14.45 seconds =======================================

I am using the latest version of arduino-esp32, 2.0.0-rc1. I did backtrack it tot he stable version and compiled and it came up with the same errors, so it can’t be the issue. In any even, here is my platform.ini code:

[env:nodemcu-32s]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
board = nodemcu-32s
framework = arduino
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#2.0.0-rc1
upload_port = /dev/cu.SLAB_USBtoUART
upload_speed = 921600
monitor_speed = 115200
lib_deps =
gilmaimon/ArduinoWebsockets@^0.5.2
bblanchon/ArduinoJson@^6.18.3
protohaus/ESPRandom@^1.4.1
board_build.partitions = partitions_large.csv
build_type = debug
monitor_filters = log2file, default, esp32_exception_decoder

I’m asking here if anyone else has had issues with this library as it works fine on ArduinoIDE, so I’m figuring there may be a platformio specific issue. If you haven’t used it, maybe you could try installing it and compiling to see if get the same issue.

Thanks for any help.

Looks like the issue was fixed in Change if statement to lowercase · giannivh/SmoothThermistor@6cb001a · GitHub nearly a year ago. The compiler doesn’t like the uppercase #IF.

However, the author of the library has made a really weird thing: A commit rolls back the version of the library from 1.3.1 to 1.3.0.

Meaning now 1.3.0 is actually more updated than… 1.3.1…

Please use the following expression in the lib_deps of the platformio.ini

lib_deps =
   giannivh/SmoothThermistor @ 1.3.0
   gilmaimon/ArduinoWebsockets@^0.5.2
   bblanchon/ArduinoJson@^6.18.3
   protohaus/ESPRandom@^1.4.1

also make sure the lines are indented properly by at least two spaces, I don’t see those spaces in your post above.

1 Like

@ivankravets could you remove the actual older “1.3.1” library from https://platformio.org/lib/show/498/SmoothThermistor/installation (but keep the actually updated 1.3.0 version)?

Thanks, @maxgerhardt, removed!

Thank you all. It’s now compiling. I had thought about the capitalized IF, but when I did a search on it, it said that those types of statements are supposed to be case insensitive. Obviously, my lack of knowledge on C++ compilers is showing there.