Click here to Skip to main content
15,899,937 members

Comments by Doctor Wizard (Top 1 by date)

Doctor Wizard 11-May-16 9:18am View    
<pre lang="C#">Problem is NOT with HTUD21D.h, as my HTUD21D_testbed and DS18B20_testbed projects both compile and run just fine. Further testing seems to confirm it is a problem with the conditional compile. Note the following:
1) I finished the DS18B20 section. The following will not compile:
<pre lang="c++">#define SENSOR_NONE 0
#define SENSOR_BMP180 1 // Set to 1 BMP180 Barometric Pressure sensor is installed -- OR
#define SENSOR_HTU21D 2 // set to 2 if HTU21D Temp & Humidity sensor is installed -- OR
#define SENSOR_DS18B20 3 // Set to 3 if DS18B20 Temp sensor is installed on the TinyRTC
#define SENSOR_TYPE SENSOR_DS18B20

#if SENSOR_TYPE == SENSOR_BMP180
#include <BMP180.h>
BMP180 weather;
#endif
#if SENSOR_TYPE == SENSOR_HTU21D

#include <HTU21D.h>
HTU21D weather;
#endif
#if SENSOR_TYPE == SENSOR_DS18B20
#define ONE_WIRE_BUS 15 // Data Pin that DS18B20 is connected to
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature weather(&oneWire);
#endif
</pre>
But this will:
<pre lang="c++">#define SENSOR_NONE 0
#define SENSOR_BMP180 1 // Set to 1 BMP180 Barometric Pressure sensor is installed -- OR
#define SENSOR_HTU21D 2 // set to 2 if HTU21D Temp & Humidity sensor is installed -- OR
#define SENSOR_DS18B20 3 // Set to 3 if DS18B20 Temp sensor is installed on the TinyRTC
#define SENSOR_TYPE SENSOR_DS18B20

/*
#if SENSOR_TYPE == SENSOR_BMP180
#include <BMP180.h>
BMP180 weather;
#endif
#if SENSOR_TYPE == SENSOR_HTU21D

#include <HTU21D.h>
HTU21D weather;
#endif
#if SENSOR_TYPE == SENSOR_DS18B20
*/
#define ONE_WIRE_BUS 15 // Data Pin that DS18B20 is connected to
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature weather(&oneWire);
//#endif</pre>
Likewise, if I move the DS18B20 block to the top, it will compile
<pre lang="c++">#define SENSOR_NONE 0
#define SENSOR_BMP180 1 // Set to 1 BMP180 Barometric Pressure sensor is installed -- OR
#define SENSOR_HTU21D 2 // set to 2 if HTU21D Temp & Humidity sensor is installed -- OR
#define SENSOR_DS18B20 3 // Set to 3 if DS18B20 Temp sensor is installed on the TinyRTC
#define SENSOR_TYPE SENSOR_DS18B20

#if SENSOR_TYPE == SENSOR_DS18B20
#define ONE_WIRE_BUS 15 // Data Pin that DS18B20 is connected to
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature weather(&oneWire);
#endif
#if SENSOR_TYPE == SENSOR_BMP180
#include <BMP180.h>
BMP180 weather;
#endif
#if SENSOR_TYPE == SENSOR_HTU21D

#include <HTU21D.h>
HTU21D weather;
#endif</pre>
Same tricks apply to the HTU21D block. Commenting out the BMP180 block above it and the DS18B20 block below it gets it to compile. Moving the DS18B20 block to the top gets it to compile. But with it in the middle (or at the bottom) it will not compile.
Won't Compile:
<pre lang="c++">#define SENSOR_NONE 0
#define SENSOR_BMP180 1 // Set to 1 BMP180 Barometric Pressure sensor is installed -- OR
#define SENSOR_HTU21D 2 // set to 2 if HTU21D Temp & Humidity sensor is installed -- OR
#define SENSOR_DS18B20 3 // Set to 3 if DS18B20 Temp sensor is installed on the TinyRTC
#define SENSOR_TYPE SENSOR_HTU21D

#if SENSOR_TYPE == SENSOR_BMP180
#include <BMP180.h>
BMP180 weather;
#endif
#if SENSOR_TYPE == SENSOR_HTU21D
#include <HTU21D.h>
HTU21D weather;
#endif
#if SENSOR_TYPE == SENSOR_DS18B20
#define ONE_WIRE_BUS 15 // Data Pin that DS18B20 is connected to
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature weather(&oneWire);
#endif</pre>
Will Compile:
<pre lang="c++">#define SENSOR_NONE 0
#define SENSOR_BMP180 1 // Set to 1 BMP180 Barometric Pr