Problem with #include <OneWire.h>, <DallasTemperature.h>

Hello! I have a problem that I have been trying to solve for half a day and have searched everything - it does not find the OneWire, DallasTemperature libraries. I have the code in Visual Studio Code, I installed the libraries in the Arduino IDE, and they are displayed there. I inserted the path to the libraries into the c_cpp_properties.json file:

{
    "configurations": [
      {
        "name": "vscode_avr_c_properties",
        "includePath": [
          "${workspaceFolder}/**",
          "/usr/lib/avr/include",
          "/home/ubuntu/Arduino/libraries/**"
        ],
        "defines": [
          "__AVR_ATmega328P__"
        ],
        "cStandard": "c11",
        "intelliSenseMode": "gcc-x64",
        "compilerPath": "avr-gcc"
      }
    ],
    "version": 4
  }

I copied the path from the properties:
VirtualBoxVM_pCyox6v9Rl
A screenshot of the error itself:


I'll also leave the code itself (I don't know if it works, since I can't even test it):

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
  
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  sensors.requestTemperatures(); // Send the command to get temperature readings
  
  // print the first sensor temperature in Celsius
  lcd.setCursor(0, 0);
  lcd.print("Temp 1: ");
  lcd.print(sensors.getTempCByIndex(0));
  
  // print the second sensor temperature in Celsius
  lcd.setCursor(0, 1);
  lcd.print("Temp 2: ");
  lcd.print(sensors.getTempCByIndex(1));
  
  delay(2000); // Wait for 2 seconds before updating the temperature readings
}
If you need any more information, please write to me. I really hope for your help, I think there are people here who know or have encountered something like this. Thank you!

Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.

I have never heard of such a file but, if you really have installed the new library in the same folder as all the other libraries, it should work. Just in case you haven't already done it, you need to restart the IDE when you install a new library.

Can Visual Studio use libraries installed in the Arduino IDE? I don't know.

Does the code compile if you use the Arduino IDE to compile it?

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