requestTemperaturesByAddress errors

Hi all,

I'm new here, and to the arduino. But i'm already facing problem I can't seem to fix myself.

I've connected a few OneWire temp. sensors to the Arduino Uno. Using the Dallas Temperature Library I can red all sensors perfectly. But since I've got 5 of them, and they al have a specific function, I would like te set the addresses of each sensor manualy. This is because there function stays the same, but there order on the OneWire bus may change. I've tried it with the example code, but keep getting an error. This is what i've done:

I've got a main sketch (BrouwMaat) where all global variables are declared, and other sketches are called.Here I've declared an array for my sensors adresses:

DeviceAddress Waterketel, Wortin, Wortuit, Maischketel, Kookketel;

In an other sketch (Initialise) I tried to fill the array with the addresses of my sensors:

Waterketel = { 0x28, 0x54, 0xD9. 0xB1, 0x2, 0x0, 0x0 };

But I keep getting this error:

BrouwMaat.cpp:235:30: error: hexadecimal floating constants require an exponent BrouwMaat.cpp: In function 'void Initialise()': Initialise:34: error: expected primary-expression before '{' token Initialise:34: error: expected `;' before '{' token

I'm lost. Maybe someone has encountered this before?

Regards,

Ed.

I would like te set the addresses of each sensor manualy.

Can’t be done, addresses are hard coded, see datasheet. However you can place all addresses in a table and order this to your need.

The error message indicates a type conflict. Please share more code to see what’s wrong. Try to minimize the sketch that still produces the error before posting as it makes debugging far easier.

Rob

I know the addresses are hardcoded.

Here is the simplified code:

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

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

#define ONE_WIRE_BUS 8                  
#define TEMPERATURE_PRECISION 9            

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); 
DeviceAddress Waterketel, Wortin, Wortuit, Maischketel, Kookketel; ;
int numSensors;  
int i = 0;       
int temparray[5]; 

void setup()
{
  lcd.begin(20,4);
  
  sensors.begin();
  numSensors = sensors.getDeviceCount();
  
  Waterketel = { 0x28, 0x54, 0xD9. 0xB1, 0x2, 0x0, 0x0 };
  Wortin = { 0x28, 0xC7, 0xEE, 0xB1, 0x2, 0x0, 0x0 };
  Wortuit = { 0x28, 0xD1, 0x71, 0xC, 0x2, 0x0, 0x0 };
  Maischketel = { 0x28, 0x85, 0xA8, 0xB2, 0x2, 0x0, 0x0 };
  Kookketel = { 0x28, 0xE9, 0xDD, 0xB1, 0x2, 0x0, 0x0 };
  
   if(numSensors = 5)                    
 {
  lcd.clear();              
  lcd.setCursor(0,0);       
  lcd.print(numSensors);
  lcd.print( " sensoren gevonden.");
  lcd.setCursor(0,2); 
  lcd.print("Parasite power: "); 
  if (sensors.isParasitePowerMode()) lcd.print("AAN");
  else lcd.print("UIT");
 }
  else
 {
  lcd.print("<5 sensoren gevonden!!");      
 }
 delay(5000);                  
 lcd.clear();                    
  
}

void loop()
{
    numSensors = sensors.getDeviceCount();

  sensors.requestTemperatures();      
//   delay(100);      
  for(i=0; i<numSensors; i++)   
{
  temparray[i] = sensors.getTempCByIndex(i);       //Here i want to get temps by address
} 

   lcd.setCursor(0,0);             
   lcd.print("mk: ");
   lcd.print(temparray[0]);      

   lcd.setCursor(12,0);
   lcd.print("==> ");   
   lcd.print("12.3");      
    
   lcd.setCursor(0,1); 
   lcd.print("wi: ");              
   lcd.print(temparray[1]);
   
   lcd.setCursor(12,1);
   lcd.print("wu: ");                  
   lcd.print(temparray[2]);

   lcd.setCursor(0,2);             
   lcd.print("ww: "); 
   lcd.print(temparray[3]);      

   lcd.setCursor(12,2);      
   lcd.print("kk: "); 
   lcd.print(temparray[4]);                  

   lcd.setCursor(0,3);                   
   lcd.print("stp: "); 
   lcd.print("1/3");

}

In this code snippet I still do a “sensors.getTempCByIndex”.
I want to get te values based on the address, but I keep gettin an error so I didn’t finish this.

Regards,
Ed.

Changed the place of initialization of the addresses and changed a . in a , in the address of Waterketel. Please give it a try.

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

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

#define ONE_WIRE_BUS 8
#define TEMPERATURE_PRECISION 9

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Waterketel = { 0x28, 0x54, 0xD9, 0xB1, 0x2, 0x0, 0x0 };
DeviceAddress Wortin = { 0x28, 0xC7, 0xEE, 0xB1, 0x2, 0x0, 0x0 };
DeviceAddress Wortuit = { 0x28, 0xD1, 0x71, 0xC, 0x2, 0x0, 0x0 };
DeviceAddress  Maischketel = { 0x28, 0x85, 0xA8, 0xB2, 0x2, 0x0, 0x0 };
DeviceAddress  Kookketel = { 0x28, 0xE9, 0xDD, 0xB1, 0x2, 0x0, 0x0 };

int numSensors;  
int i = 0;      
int temparray[5];

void setup()
{
  lcd.begin(20,4);
  
  sensors.begin();
  numSensors = sensors.getDeviceCount();
  
   if(numSensors = 5)                    
 {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(numSensors);
  lcd.print( " sensoren gevonden.");
  lcd.setCursor(0,2);
  lcd.print("Parasite power: ");
  if (sensors.isParasitePowerMode()) lcd.print("AAN");
  else lcd.print("UIT");
 }
  else
 {
  lcd.print("<5 sensoren gevonden!!");
 }
 delay(5000);
 lcd.clear();                    
  
}

void loop()
{
    numSensors = sensors.getDeviceCount();

  sensors.requestTemperatures();
//   delay(100);
  for(i=0; i<numSensors; i++)  
{
  temparray[i] = sensors.getTempCByIndex(i);       //Here i want to get temps by address
}

   lcd.setCursor(0,0);
   lcd.print("mk: ");
   lcd.print(temparray[0]);

   lcd.setCursor(12,0);
   lcd.print("==> ");  
   lcd.print("12.3");
    
   lcd.setCursor(0,1);
   lcd.print("wi: ");  
   lcd.print(temparray[1]);
  
   lcd.setCursor(12,1);
   lcd.print("wu: ");
   lcd.print(temparray[2]);

   lcd.setCursor(0,2);
   lcd.print("ww: ");
   lcd.print(temparray[3]);

   lcd.setCursor(12,2);
   lcd.print("kk: ");
   lcd.print(temparray[4]);

   lcd.setCursor(0,3);
   lcd.print("stp: ");
   lcd.print("1/3");
}

Thanks! It compiles without any errors now.. I feel a bit stupid that I didn't see that there was a . in stead of a , in the address.

Now I can continue coding ;-)

Regards, Ed.