Compilation errors

Hi, I made this project and while compiling the code it jumped out these errors:
Could somebody help me? Please :blush:



`temperature.cpp:2:10: error: #include expects "FILENAME" or <FILENAME>
 #include "application.h"
          ^

temperature.cpp:5:10: error: #include expects "FILENAME" or <FILENAME>
 #line 1 
          ^

temperature.cpp:8:10: error: #include expects "FILENAME" or <FILENAME>
  
          ^

temperature.cpp:10:1: error: stray '\342' in program
 #include “OneWire/OneWire.h”
 ^

temperature.cpp:10:1: error: stray '\200' in program
temperature.cpp:10:1: error: stray '\234' in program
temperature.cpp:10:1: error: stray '\342' in program
temperature.cpp:10:1: error: stray '\200' in program
temperature.cpp:10:1: error: stray '\234' in program
temperature.cpp:35:5: error: stray '\342' in program
 void printAddress(DeviceAddress deviceAddress)
     ^

temperature.cpp:35:5: error: stray '\200' in program
temperature.cpp:35:5: error: stray '\234' in program
temperature.cpp:35:5: error: stray '\342' in program
temperature.cpp:35:5: error: stray '\200' in program
temperature.cpp:35:5: error: stray '\235' in program
temperature.cpp:45:3: error: stray '\342' in program
 // function to print the temperature for a device
   ^

temperature.cpp:45:3: error: stray '\200' in program
temperature.cpp:45:3: error: stray '\234' in program
temperature.cpp:45:3: error: stray '\342' in program
temperature.cpp:45:3: error: stray '\200' in program
temperature.cpp:45:3: error: stray '\234' in program
temperature.cpp:47:3: error: stray '\342' in program
 void printTemperature(DeviceAddress deviceAddress)
   ^

temperature.cpp:47:3: error: stray '\200' in program
temperature.cpp:47:3: error: stray '\235' in program
temperature.cpp:47:3: error: stray '\342' in program
temperature.cpp:47:3: error: stray '\200' in program
temperature.cpp:47:3: error: stray '\234' in program
temperature.cpp:55:3: error: stray '\342' in program
  
   ^

temperature.cpp:55:3: error: stray '\200' in program
temperature.cpp:55:3: error: stray '\234' in program
temperature.cpp:55:3: error: stray '\342' in program
temperature.cpp:55:3: error: stray '\200' in program
temperature.cpp:55:3: error: stray '\234' in program
temperature.cpp:64:3: error: stray '\342' in program
  
   ^

temperature.cpp:64:3: error: stray '\200' in program
temperature.cpp:64:3: error: stray '\234' in program
temperature.cpp:64:3: error: stray '\342' in program
temperature.cpp:64:3: error: stray '\200' in program
temperature.cpp:64:3: error: stray '\234' in program
temperature.cpp:66:3: error: stray '\342' in program
 void printData(DeviceAddress deviceAddress);
   ^

temperature.cpp:66:3: error: stray '\200' in program
temperature.cpp:66:3: error: stray '\235' in program
temperature.cpp:66:3: error: stray '\342' in program
temperature.cpp:66:3: error: stray '\200' in program
temperature.cpp:66:3: error: stray '\234' in program
temperature.cpp:75:3: error: stray '\342' in program
  
   ^

temperature.cpp:75:3: error: stray '\200' in program
temperature.cpp:75:3: error: stray '\234' in program
temperature.cpp:75:3: error: stray '\342' in program
temperature.cpp:75:3: error: stray '\200' in program
temperature.cpp:75:3: error: stray '\235' in program
temperature.cpp:76:3: error: stray '\342' in program
 void setup(void)
   ^

temperature.cpp:76:3: error: stray '\200' in program
temperature.cpp:76:3: error: stray '\234' in program
temperature.cpp:76:3: error: stray '\342' in program
temperature.cpp:76:3: error: stray '\200' in program
temperature.cpp:76:3: error: stray '\235' in program
temperature.cpp:83:3: error: stray '\342' in program
  
   ^

temperature.cpp:83:3: error: stray '\200' in program
temperature.cpp:83:3: error: stray '\234' in program
temperature.cpp:83:3: error: stray '\342' in program
temperature.cpp:83:3: error: stray '\200' in program
temperature.cpp:83:3: error: stray '\246' in program
temperature.cpp:83:3: error: stray '\342' in program
temperature.cpp:83:3: error: stray '\200' in program
temperature.cpp:83:3: error: stray '\235' in program
temperature.cpp:84:3: error: stray '\342' in program
   // Start up the library
   ^

temperature.cpp:84:3: error: stray '\200' in program
temperature.cpp:84:3: error: stray '\234' in program
temperature.cpp:84:3: error: stray '\342' in program
temperature.cpp:84:3: error: stray '\200' in program
temperature.cpp:84:3: error: stray '\234' in program
temperature.cpp:86:3: error: stray '\342' in program
  
   ^

temperature.cpp:86:3: error: stray '\200' in program
temperature.cpp:86:3: error: stray '\235' in program
temperature.cpp:86:3: error: stray '\342' in program
temperature.cpp:86:3: error: stray '\200' in program
temperature.cpp:86:3: error: stray '\235' in program
temperature.cpp:89:3: error: stray '\342' in program
   Serial.print(“Found “);
   ^

temperature.cpp:89:3: error: stray '\200' in program
temperature.cpp:89:3: error: stray '\234' in program
temperature.cpp:89:3: error: stray '\342' in program
temperature.cpp:89:3: error: stray '\200' in program
temperature.cpp:89:3: error: stray '\234' in program
temperature.cpp:90:3: error: stray '\342' in program
   Serial.print(sensors.getDeviceCount(), DEC);
   ^

temperature.cpp:90:3: error: stray '\200' in program
temperature.cpp:90:3: error: stray '\234' in program
temperature.cpp:90:3: error: stray '\342' in program
temperature.cpp:90:3: error: stray '\200' in program
temperature.cpp:90:3: error: stray '\235' in program
temperature.cpp:91:3: error: stray '\342' in program
   Serial.println(” devices.”);
   ^

temperature.cpp:91:3: error: stray '\200' in program
temperature.cpp:91:3: error: stray '\234' in program
temperature.cpp:91:3: error: stray '\342' in program
temperature.cpp:91:3: error: stray '\200' in program
temperature.cpp:91:3: error: stray '\235' in program
temperature.cpp:106:3: error: stray '\342' in program
   // you would do this to initially discover addresses on the bus and then 
   ^

temperature.cpp:106:3: error: stray '\200' in program
temperature.cpp:106:3: error: stray '\234' in program
temperature.cpp:106:3: error: stray '\342' in program
temperature.cpp:106:3: error: stray '\200' in program
temperature.cpp:106:3: error: stray '\235' in program
temperature.cpp:107:3: error: stray '\342' in program
   // use those addresses and manually assign them (see above) once you know 
   ^

temperature.cpp:107:3: error: stray '\200' in program
temperature.cpp:107:3: error: stray '\234' in program
temperature.cpp:107:3: error: stray '\342' in program
temperature.cpp:107:3: error: stray '\200' in program
temperature.cpp:107:3: error: stray '\235' in program
temperature.cpp:124:3: error: stray '\342' in program
   //if (!oneWire.search(insideThermometer)) Serial.println(“Unable to find address for insideThermometer”);
   ^

temperature.cpp:124:3: error: stray '\200' in program
temperature.cpp:124:3: error: stray '\234' in program
temperature.cpp:124:3: error: stray '\342' in program
temperature.cpp:124:3: error: stray '\200' in program
temperature.cpp:124:3: error: stray '\234' in program
temperature.cpp:129:3: error: stray '\342' in program
   Serial.print(“Device 0 Address: “);
   ^

temperature.cpp:129:3: error: stray '\200' in program
temperature.cpp:129:3: error: stray '\234' in program
temperature.cpp:129:3: error: stray '\342' in program
temperature.cpp:129:3: error: stray '\200' in program
temperature.cpp:129:3: error: stray '\234' in program
temperature.cpp:137:3: error: stray '\342' in program
  
   ^

temperature.cpp:137:3: error: stray '\200' in program
temperature.cpp:137:3: error: stray '\234' in program
temperature.cpp:137:3: error: stray '\342' in program
temperature.cpp:137:3: error: stray '\200' in program
temperature.cpp:137:3: error: stray '\234' in program
temperature.cpp:141:3: error: stray '\342' in program
  
   ^

temperature.cpp:141:3: error: stray '\200' in program
temperature.cpp:141:3: error: stray '\234' in program
temperature.cpp:141:3: error: stray '\342' in program
temperature.cpp:141:3: error: stray '\200' in program
temperature.cpp:141:3: error: stray '\234' in program
temperature.cpp:150:3: error: stray '\342' in program
  
   ^

temperature.cpp:150:3: error: stray '\200' in program
temperature.cpp:150:3: error: stray '\234' in program
temperature.cpp:150:3: error: stray '\342' in program
temperature.cpp:150:3: error: stray '\200' in program
temperature.cpp:150:3: error: stray '\246' in program
temperature.cpp:150:3: error: stray '\342' in program
temperature.cpp:150:3: error: stray '\200' in program
temperature.cpp:150:3: error: stray '\235' in program
temperature.cpp:152:3: error: stray '\342' in program
 { 
   ^

temperature.cpp:152:3: error: stray '\200' in program
temperature.cpp:152:3: error: stray '\234' in program
temperature.cpp:152:3: error: stray '\342' in program
temperature.cpp:152:3: error: stray '\200' in program
temperature.cpp:152:3: error: stray '\235' in program
temperature.cpp:10:1: error: 'ThingSpeakLibrary' does not name a type
 #include “OneWire/OneWire.h”
 ^

temperature.cpp:18:1: error: 'OneWire' does not name a type
 #define TEMPERATURE_PRECISION 9
 ^

temperature.cpp:23:1: error: 'DallasTemperature' does not name a type
 OneWire oneWire(ONE_WIRE_BUS);
 ^

temperature.cpp:26:1: error: 'DeviceAddress' does not name a type
  
 ^

temperature.cpp:29:19: error: variable or field 'printAddress' declared void
  
                   ^

temperature.cpp:29:19: error: 'DeviceAddress' was not declared in this scope
temperature.cpp:30:19: error: variable or field 'printAddress' declared void
 // arrays to hold device addresses
                   ^

temperature.cpp:30:19: error: 'DeviceAddress' was not declared in this scope
make[1]: *** [../build/target/user/platform-6temperature.o] Error 1
make: *** [user] Error 2
Error: Could not compile. Please review your code.`

How are you building? Web IDE, Particle Dev, or particle-cli?

Do you have all of your libraries added properly to your project?

I´m compiling with Web IDE.
Can you explain me which libraries do I need how do I install them?

it looks to me that you have included unicode quotes, which C++ compiler does not support.

try replacing all of the unicode quotes with standard quotes in the editor… then once you get all of those errors out, you can focus on any rel problems in your code.

2 Likes

If you building from the Web IDE you do not need “application.h”.

Unicode quotes are the most annoying thing in the world. :wink:

Thank you I will try that. :blush:

Just one last errror message:

temperature.cpp:4:35: fatal error: thingspeak/thingspeak.h: No such file or directory
void loop(void);
^

compilation terminated.
make[1]: *** […/build/target/user/platform-6temperature.o] Error 1
make: *** [user] Error 2

Have a look:
https://docs.particle.io/guide/getting-started/build/photon/#using-libraries

I included all libraries and errors still remain.

    #include "OneWire/OneWire.h"
    #include "spark-dallas-temperature/spark-dallas-temperature.h"
    #include "application.h"
    #include "thingspeak/thingspeak.h"
    #include "OneWire/OneWire.h"

Error:

temperature.cpp:7:35: fatal error: thingspeak/thingspeak.h: No such file or directory
 
                                   ^

compilation terminated.
make[1]: *** [../build/target/user/platform-6temperature.o] Error 1
make: *** [user] Error 2

Did you include them using the library system, or did you just copy&paste those lines?

Also, though it shouldn’t hurt to include a library twice (provided measures are in place against that in said libraries), you really shouldn’t do that.

I made it new.

    // This #include statement was automatically added by the Particle IDE.
#include "ThingSpeak/ThingSpeak.h"

// This #include statement was automatically added by the Particle IDE.
#include "OneWire/OneWire.h"

// This #include statement was automatically added by the Particle IDE.
#include "spark-dallas-temperature/spark-dallas-temperature.h"

Now correctly included to the programme.

Errors:

temp.cpp:10:1: error: 'ThingSpeakLibrary' does not name a type
 #include "OneWire/OneWire.h"
 ^

temp.cpp: In function 'void setup()':
temp.cpp:76:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:357): Spark is now Particle. [-Wdeprecated-declarations]
 void setup(void)
   ^
temp.cpp: In function 'void loop()':
temp.cpp:165:17: error: 'thingspeak' was not declared in this scope
   tempF = tempC * 9.0 / 5.0 + 32.0;
                 ^

temp.cpp:165:8: warning: unused variable 'valSet' [-Wunused-variable]
   tempF = tempC * 9.0 / 5.0 + 32.0;
        ^
temp.cpp:166:8: warning: unused variable 'valSet1' [-Wunused-variable]
   int WT = sensors.getTempC(insideThermometer);
        ^
temp.cpp:167:8: warning: unused variable 'valsSent' [-Wunused-variable]
  F1temp = (WT * 9.0)/ 5.0 + 32.0; 
        ^
temp.cpp:168:8: warning: unused variable 'valsSent1' [-Wunused-variable]
  int OT = sensors.getTempC(outsideThermometer);
        ^
temp.cpp:168:42: error: expected '}' at end of input
  int OT = sensors.getTempC(outsideThermometer);
                                          ^

make[1]: *** [../build/target/user/platform-6temp.o] Error 1
make: *** [user] Error 2
Error: Could not compile. Please review your code.

My Code:

// This #include statement was automatically added by the Particle IDE.
#include "ThingSpeak/ThingSpeak.h"

// This #include statement was automatically added by the Particle IDE.
#include "OneWire/OneWire.h"

// This #include statement was automatically added by the Particle IDE.
#include "spark-dallas-temperature/spark-dallas-temperature.h"

ThingSpeakLibrary::ThingSpeak thingspeak ("MY.KEY");
// Data wire is plugged into port 2 on the Particle Photon
#define ONE_WIRE_BUS D2
#define TEMPERATURE_PRECISION 9
int F1temp ;
int F2temp ;
 
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
double tempF = 0.0;
double tempC = 0.0;
 
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);
 
// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;
 
// function to print a device address
void printAddress(DeviceAddress deviceAddress);
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}
 
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress);
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}
 
// function to print a device’s resolution
void printResolution(DeviceAddress deviceAddress);
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}
 
// main function to print information about a device
void printData(DeviceAddress deviceAddress);
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}
 
void setup(void)
{ 
  sensors.begin();// start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");
  Spark.variable("tempf", &tempF, DOUBLE);
 
 
  // Start up the library
  sensors.begin();
 
  // locate devices on the bus
  Serial.print("Locating devices…");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");
 
  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
 
  // assign address manually.  the addresses below will need to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };
 
  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don’t change).
  // 
  // method 1: by index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); 
 
  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them.  It might be a good idea to 
  // check the CRC to make sure you didn’t get garbage.  The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");
 
  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
 
  Serial.println();
 
  Serial.print("Device 1 Address: ");
  printAddress(outsideThermometer);
  Serial.println();
 
  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);
 
  Serial.print("Device 0 Resolution: ");
  //Serial.print(sensors.getResolution(insideThermometer), DEC); 
  Serial.println();
 
  Serial.print("Device 1 Resolution: ");
  //Serial.print(sensors.getResolution(outsideThermometer), DEC); 
  Serial.println();
}
 
void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures…");
  sensors.requestTemperatures();
  Serial.println("DONE");
  delay(300000);
 
 
  // print the device information
  printData(insideThermometer);
  printData(outsideThermometer);sensors.requestTemperatures();
  tempC = sensors.getTempCByIndex(0);
  tempF = tempC * 9.0 / 5.0 + 32.0;
  int WT = sensors.getTempC(insideThermometer);
 F1temp = (WT * 9.0)/ 5.0 + 32.0; 
 int OT = sensors.getTempC(outsideThermometer);
 F2temp = (OT * 9.0)/ 5.0 + 32.0; 
  bool valSet = thingspeak.recordValue(1, String(F1temp, DEC));
  bool valSet1 = thingspeak.recordValue(8, String(F2temp, DEC));
  bool valsSent= thingspeak.sendValues();
  bool valsSent1= thingspeak.sendValues();

Your IDE should look like this:

Also, make sure to select this library:

(edit: beat you to it this time @BulldogLowell :sunglasses:)

1 Like

be careful… it seems that there are two libraries with the same name… :disappointed:

EDIT: Jordy beat me to the punch!

2 Likes

OMG, Another error :flushed:

// This #include statement was automatically added by the Particle IDE.
#include "thingspeak/thingspeak.h"

// This #include statement was automatically added by the Particle IDE.
#include "OneWire/OneWire.h"

// This #include statement was automatically added by the Particle IDE.
#include "spark-dallas-temperature/spark-dallas-temperature.h"

ThingSpeakLibrary::ThingSpeak thingspeak ("MY.KEY");
// Data wire is plugged into port 2 on the Particle Photon
#define ONE_WIRE_BUS D2
#define TEMPERATURE_PRECISION 9
int F1temp ;
int F2temp ;
 
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
double tempF = 0.0;
double tempC = 0.0;
 
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);
 
// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;
 
// function to print a device address
void printAddress(DeviceAddress deviceAddress);
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}
 
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress);
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}
 
// function to print a device’s resolution
void printResolution(DeviceAddress deviceAddress);
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}
 
// main function to print information about a device
void printData(DeviceAddress deviceAddress);
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}
 
void setup(void)
{ 
  sensors.begin();// start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");
  Spark.variable("tempf", &tempF, DOUBLE);
 
 
  // Start up the library
  sensors.begin();
 
  // locate devices on the bus
  Serial.print("Locating devices…");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");
 
  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
 
  // assign address manually.  the addresses below will need to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };
 
  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don’t change).
  // 
  // method 1: by index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); 
 
  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them.  It might be a good idea to 
  // check the CRC to make sure you didn’t get garbage.  The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");
 
  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
 
  Serial.println();
 
  Serial.print("Device 1 Address: ");
  printAddress(outsideThermometer);
  Serial.println();
 
  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);
 
  Serial.print("Device 0 Resolution: ");
  //Serial.print(sensors.getResolution(insideThermometer), DEC); 
  Serial.println();
 
  Serial.print("Device 1 Resolution: ");
  //Serial.print(sensors.getResolution(outsideThermometer), DEC); 
  Serial.println();
}
 
void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures…");

Errors:

teplota.cpp: In function 'void setup()':
teplota.cpp:76:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:357): Spark is now Particle. [-Wdeprecated-declarations]
 void setup(void)
   ^
teplota.cpp: In function 'void loop()':
teplota.cpp:165:8: warning: unused variable 'valSet' [-Wunused-variable]
   tempF = tempC * 9.0 / 5.0 + 32.0;
        ^
teplota.cpp:166:8: warning: unused variable 'valSet1' [-Wunused-variable]
   int WT = sensors.getTempC(insideThermometer);
        ^
teplota.cpp:167:8: warning: unused variable 'valsSent' [-Wunused-variable]
  F1temp = (WT * 9.0)/ 5.0 + 32.0; 
        ^
teplota.cpp:168:8: warning: unused variable 'valsSent1' [-Wunused-variable]
  int OT = sensors.getTempC(outsideThermometer);
        ^
teplota.cpp:168:42: error: expected '}' at end of input
  int OT = sensors.getTempC(outsideThermometer);
                                          ^

make[1]: *** [../build/target/user/platform-6teplota.o] Error 1
make: *** [user] Error 2

It seems you’re not posting your full code since it’s cut off halfway down the loop, missing the closing bracket (as stated in the error…) and any logic in-between.

2 Likes

Sorry it was already there. I made a mistake and didn´t copy the wole code. Here it is:

    // This #include statement was automatically added by the Particle IDE.
    #include "thingspeak/thingspeak.h"
    
    // This #include statement was automatically added by the Particle IDE.
    #include "OneWire/OneWire.h"
    
    // This #include statement was automatically added by the Particle IDE.
    #include "spark-dallas-temperature/spark-dallas-temperature.h"
    
    ThingSpeakLibrary::ThingSpeak thingspeak ("MY.KEY");
    // Data wire is plugged into port 2 on the Particle Photon
    #define ONE_WIRE_BUS D2
    #define TEMPERATURE_PRECISION 9
    int F1temp ;
    int F2temp ;
     
    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    OneWire oneWire(ONE_WIRE_BUS);
    double tempF = 0.0;
    double tempC = 0.0;
     
    // Pass our oneWire reference to Dallas Temperature. 
    DallasTemperature sensors(&oneWire);
     
    // arrays to hold device addresses
    DeviceAddress insideThermometer, outsideThermometer;
     
    // function to print a device address
    void printAddress(DeviceAddress deviceAddress);
    void printAddress(DeviceAddress deviceAddress)
    {
      for (uint8_t i = 0; i < 8; i++)
      {
        // zero pad the address if necessary
        if (deviceAddress[i] < 16) Serial.print("0");
        Serial.print(deviceAddress[i], HEX);
      }
    }
     
    // function to print the temperature for a device
    void printTemperature(DeviceAddress deviceAddress);
    void printTemperature(DeviceAddress deviceAddress)
    {
      float tempC = sensors.getTempC(deviceAddress);
      Serial.print("Temp C: ");
      Serial.print(tempC);
      Serial.print(" Temp F: ");
      Serial.print(DallasTemperature::toFahrenheit(tempC));
    }
     
    // function to print a device’s resolution
    void printResolution(DeviceAddress deviceAddress);
    void printResolution(DeviceAddress deviceAddress)
    {
      Serial.print("Resolution: ");
      Serial.print(sensors.getResolution(deviceAddress));
      Serial.println();    
    }
     
    // main function to print information about a device
    void printData(DeviceAddress deviceAddress);
    void printData(DeviceAddress deviceAddress)
    {
      Serial.print("Device Address: ");
      printAddress(deviceAddress);
      Serial.print(" ");
      printTemperature(deviceAddress);
      Serial.println();
    }
     
    void setup(void)
    { 
      sensors.begin();// start serial port
      Serial.begin(9600);
      Serial.println("Dallas Temperature IC Control Library Demo");
      Spark.variable("tempf", &tempF, DOUBLE);
     
     
      // Start up the library
      sensors.begin();
     
      // locate devices on the bus
      Serial.print("Locating devices…");
      Serial.print("Found ");
      Serial.print(sensors.getDeviceCount(), DEC);
      Serial.println(" devices.");
     
      // report parasite power requirements
      Serial.print("Parasite power is: "); 
      if (sensors.isParasitePowerMode()) Serial.println("ON");
      else Serial.println("OFF");
     
      // assign address manually.  the addresses below will need to be changed
      // to valid device addresses on your bus.  device address can be retrieved
      // by using either oneWire.search(deviceAddress) or individually via
      // sensors.getAddress(deviceAddress, index)
      //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
      //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };
     
      // search for devices on the bus and assign based on an index.  ideally,
      // you would do this to initially discover addresses on the bus and then 
      // use those addresses and manually assign them (see above) once you know 
      // the devices on your bus (and assuming they don’t change).
      // 
      // method 1: by index
      if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
      if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); 
     
      // method 2: search()
      // search() looks for the next device. Returns 1 if a new address has been
      // returned. A zero might mean that the bus is shorted, there are no devices, 
      // or you have already retrieved all of them.  It might be a good idea to 
      // check the CRC to make sure you didn’t get garbage.  The order is 
      // deterministic. You will always get the same devices in the same order
      //
      // Must be called before search()
      //oneWire.reset_search();
      // assigns the first address found to insideThermometer
      //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
      // assigns the seconds address found to outsideThermometer
      //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");
     
      // show the addresses we found on the bus
      Serial.print("Device 0 Address: ");
      printAddress(insideThermometer);
     
      Serial.println();
     
      Serial.print("Device 1 Address: ");
      printAddress(outsideThermometer);
      Serial.println();
     
      // set the resolution to 9 bit
      sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
      sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);
     
      Serial.print("Device 0 Resolution: ");
      //Serial.print(sensors.getResolution(insideThermometer), DEC); 
      Serial.println();
     
      Serial.print("Device 1 Resolution: ");
      //Serial.print(sensors.getResolution(outsideThermometer), DEC); 
      Serial.println();
    }
     
    void loop(void)
    { 
      // call sensors.requestTemperatures() to issue a global temperature 
      // request to all devices on the bus
      Serial.print("Requesting temperatures…");
      sensors.requestTemperatures();
      Serial.println("DONE");
      delay(300000);
     
     
      // print the device information
      printData(insideThermometer);
      printData(outsideThermometer);sensors.requestTemperatures();
      tempC = sensors.getTempCByIndex(0);
      tempF = tempC * 9.0 / 5.0 + 32.0;
      int WT = sensors.getTempC(insideThermometer);
     F1temp = (WT * 9.0)/ 5.0 + 32.0; 
     int OT = sensors.getTempC(outsideThermometer);
     F2temp = (OT * 9.0)/ 5.0 + 32.0; 
      bool valSet = thingspeak.recordValue(1, String(F1temp, DEC));
      bool valSet1 = thingspeak.recordValue(8, String(F2temp, DEC));
      bool valsSent= thingspeak.sendValues();
      bool valsSent1= thingspeak.sendValues();

That, too, is missing a closing bracket for the loop (as stated in the error, and my post above). All code you’ve posted thus far has been lacking that bracket.

1 Like

I think that this error must be probably even in the source from which is this code. Correct?
What exactly is missing? Could you please make a suggestion of the code.

The Source: http://www.foxandhammer.com/2015/11/24/temperature-logger-using-particle-photon-and-thingspeak/