I have enountered a problem which may indicate a hardware/firmware problem with the Ardunio or Electronic Brick. I don't know how to get this post to the people who should evaluate it.
Situation: A simple sketch to read the input from the Electronic Brick temperature sensor, convert it to Degrees C and output to serial monitor and/or LCD board. Listings of sketches for serial monitor only and serial monitor + LCD follow.
==============================================================
Serial Monitor Only
// Project Seven - temperature
//
int a;
int del=1000; // duration between temperature readings
float temperature;
int B=3975;
float resistance;
void setup()
{
Serial.begin(9600);
}
void loop()
{
a=analogRead(1);
resistance=(float)(1023-a)*10000/a;
temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
delay(del);
Serial.print(a);
Serial.print(" ");
Serial.println(temperature);
}
=======================================================================
Serial Monitor Plus LCD
// From http://www.seeedstudio.com/wiki/Project_Seven_-_Temperature
//
// Project Seven - temperature
//
//
// temperature is in Deg C
int a;
int del=1000; // duration between temperature readings
float temperature;
int B=3975;
float resistance;
float degF ;
#include <LiquidCrystal.h>
#include<LiquidCrystal.h>
// Liquid/crystal display with:
// rs on pin 10
// rw on pin 11
// enable on pin 12
// d4, d5, d6, d7 on pins 13, 14, 15, 16
LiquidCrystal lcd(10,11,12,13,14,15,16);
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
}
// Project Seven - temperature
//
void loop()
{
a=analogRead(1);
resistance=(float)(1023-a)*10000/a;
temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
degF = (9/5)*temperature + 32 ;
delay(del);
Serial.print(a);
Serial.print(" ");
Serial.println(temperature);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(temperature);
lcd.setCursor(6,0);
lcd.print("C");
lcd.setCursor(9,0);
lcd.print(degF);
lcd.setCursor(15,0);
lcd.print("F");
lcd.setCursor(0,1);
lcd.print(a);
lcd.setCursor(5,1);
lcd.print("a");
}
With trhe serial monitor only, the value of "a" (temp sensor input) is about 500 and Deg C is about 24. With output to the LCD, the value of "A" is about 122 with Deg C about -14.0. When I comment-out all coding related to the LCD in the second sketch, the value of "a" is much closer to the 500 value in the serial monitor only sketch. With all LCD related lines commented-out, the two sketches are virtually identical.
Will someone look at this and confirm/deny a hardware/firmware problem? Also, can someone try it with a Grove shield and temp sensor?
Thanks for your help. This is a real head scratcher!