Hi, I’m looking for some help with the Electronic Brick Kit Temperature sensor.
The Docs do not give any clue as to how to connect the module or provide an example sketch.
I have only just received the kit and was going through the examples to make sure everything worked - Everything does, except I can’t test the Temp. Sensor.
Sorry to be a pain - But just a pointer in the right direction would be appreciated.
const int tempPin = A0; // Analog input pin that the potentiometer is attached to
int Temp = 0; // value output of analog
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
Temp= analogRead(tempPin) * 45 / 1024;
// print the results to the serial monitor:
Serial.print("temperature = " );
Serial.println(Temp);
// wait 100 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(100);
}[/code]
OK SQX, many thanks - That works … Sort of…
I’m getting a temperature reading, but it’s nothing like accurate - I wasn’t expecting 3 decimal places and would have been happy with +/- 1 or 2 degrees C. But i’ve placed the sensor (carefully) in ice and I get a reading of 11 degrees - just a bit high!
However, at room temperature, it seems to be OK (ish). Looks to me like there is a bit of non-linearity going on here. I also don’t understand the 45/1024 bit of the code - I assume that is some “fiddle factor”.
This has been a good learning experience, but I think I’ll be looking towards the LM35, as there seems to be better reports on this device.
I'm getting a temperature reading, but it's nothing like accurate - I wasn't expecting 3 decimal places and would have been happy with +/- 1 or 2 degrees C. But i've placed the sensor (carefully) in ice and I get a reading of 11 degrees - just a bit high!
However, at room temperature, it seems to be OK (ish). Looks to me like there is a bit of non-linearity going on here. I also don't understand the 45/1024 bit of the code - I assume that is some "fiddle factor"