I'm pretty sure I've got this figured out... looks like Analogue 0 is in use by my LCD shield and so I'll need to move the analog 0 pin on either the weathershield or the LCD to an open analogue port since there is hardware in play. Once the pins are physically changed then it looks like I'll be making a bit of change to the libraries for the weathershield and or lcd.
Hardware:
Arduino Due
Weathershield (Futura Meteo_Shield) Weather Shield for Arduino- Shield for Arduino to measure and display on the
16x2 LCD identical to http://www.dhgate.com/lcd-keypad-shield-for-arduino-duemilanove/p-ff808081371757e4013718baa5627e8c.html
#include <rtc_clock.h>
#include <WeatherShield1.h>
#include <LiquidCrystal.h>
#include <String.h>
#define RXBUFFERLENGTH 4
WeatherShield1 weatherShield;
/* Class for sensors reading */
class WeatherData {
private:
float fTemperature;
unsigned short shTemperature;
float fPressure;
unsigned short shPressure;
float fHumidity;
unsigned short shHumidity;
public:
WeatherData() { bReady = false; } // constructor
// get methods
float getAvgTemperature() { return fTemperature; }
float getInstTemperature() { return ((float)shTemperature/16); }
float getAvgPressure() { return fPressure; }
float getInstPressure() {
float value ;
value = (((float)shPressure/1024)+0.095)/0.009;
return value;
}
float getAvgHumidity() { return fHumidity; }
float getInstHumidity() {
float value;
value = (((float)shHumidity/1024)-0.1515)/0.00636; // without compensation
// compensation relative humidity with read temperature
value = value/(1.0546-0.00216*getInstTemperature());
return value;
}
// set methods
void setAvgTemperature(float Temperature) { fTemperature=Temperature; }
void setInstTemperature(unsigned short Temperature) { shTemperature=Temperature; }
void setAvgPressure(float Pressure) { fPressure=Pressure; }
void setInstPressure(unsigned short Pressure) { shPressure=Pressure; }
void setAvgHumidity(float Humidity) { fHumidity=Humidity; }
void setInstHumidity(unsigned short Humidity) { shHumidity=Humidity; }
public:
boolean bReady;
};
#define RXBUFFERLENGTH 4
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// --- from here ----
// You can use next lines instead of the previous one if you need to specify a
// shield address different from the default factory programmed one
// (because you already changed issuing the proper command) or if you
// connected the shield in a custom way.
//#define IODATA_PIN 2
//#define CLOCK_PIN 7
//#define MY_WEATHERSHIELD_ADDRESS 10
//WeatherShield1 weatherShield(CLOCK_PIN, IODATA_PIN, MY_WEATHERSHIELD_ADDRESS);
// ---- till here ----
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
// put your setup code here, to run once:
lcd.print("helloworld");
delay(3000);
lcd.clear();
/* Initialize the serial port */
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
/* This is the buffer for the answers */
unsigned char ucBuffer[RXBUFFERLENGTH];
/* Check for the weather shield connection */
if (weatherShield.sendCommand(CMD_ECHO_PAR, 100, ucBuffer)) {
lcd.println("Connection With Shield Performed OK");
delay(1000);
lcd.clear();
}
/* Start reading temperature */
float fTemperature = 0.0f;
unsigned short shTemperature = 0;
if (weatherShield.sendCommand(CMD_GETTEMP_C_AVG, 0, ucBuffer))
fTemperature = weatherShield.decodeFloatValue(ucBuffer);
if (weatherShield.sendCommand(CMD_GETTEMP_C_RAW, PAR_GET_LAST_SAMPLE, ucBuffer))
shTemperature = weatherShield.decodeShortValue(ucBuffer);
/* Read pressure values */
float fPressure = 0;
unsigned short shPressure = 0;
if (weatherShield.sendCommand(CMD_GETPRESS_AVG, 0, ucBuffer))
fPressure = weatherShield.decodeFloatValue(ucBuffer);
if (weatherShield.sendCommand(CMD_GETPRESS_RAW, PAR_GET_LAST_SAMPLE, ucBuffer))
shPressure = weatherShield.decodeShortValue(ucBuffer);
/* Read humidity values */
float fHumidity = 0;
unsigned short shHumidity = 0;
if (weatherShield.sendCommand(CMD_GETHUM_AVG, 0, ucBuffer))
fHumidity = weatherShield.decodeFloatValue(ucBuffer);
if (weatherShield.sendCommand(CMD_GETHUM_RAW, PAR_GET_LAST_SAMPLE, ucBuffer))
shHumidity = weatherShield.decodeShortValue(ucBuffer);
/* Send all data through the lcd line */
lcd.setCursor(0,0);
lcd.print("Temperature: ");
lcd.print(fTemperature);
lcd.setCursor(0,1);
lcd.print(" Celsius");
// lcd.print(shTemperature);
// lcd.println(")");
delay(2500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print ("Pressure: ");
lcd.setCursor(0,1);
lcd.print(fPressure);
lcd.print(" kPa");
//lcd.print(shPressure);
// lcd.println(")");
delay(2500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Humidity: ");
lcd.setCursor(0,1);
lcd.print(fHumidity);
lcd.print(" %");
//lcd.print(shHumidity);
// lcd.println(")");
delay(2500);
lcd.clear();
/* Wait some time before running again */
delay(5000);
lcd.clear();
lcd.print("Oooh yeah");
delay(2000);
lcd.clear();
}
the code above is more or less sample code and I'm not a cpp programmer but I have some experience in the matter. Be gentle.