After trying almost everthing: reducing components, changing Arduino, proper external powering (min. 7V), reading the forums I need to post my problem.
Problem:
I try to read the temperature with an LM35 and get accelerometer x,y,z data with an ADXL335. As long the variable "pressed" is equal false (see sketch code), i get accurate room temperatures values. When i change the pressed variable to true (reading accelerometer data too), the values from the LM35 alter every loop (the ADXL335 rest on a flat surface). The output looks like this:
Code: Select all
logging lm35 and adxl335
tmp, x, y, z
21.7, 230, 340, 312
17.6, 230, 340, 312
20.0, 230, 340, 312
18.6, 230, 340, 311
22.0, 230, 340, 312
...
Setup:
- Arduino Duemilanove (powering from computer via usb)
- ADXL335 Accelerometer on a 0.5m cable, powered via Arduino 3.3V, attached to analog input 0-2
- LM35 attached to analog input 3
- the button, led, libelium microsd shield ist with this sketch not working, i used it to start logging (indicating with led) on the microsd card
Code: Select all
boolean pressed = false;
void setup() {
Serial.begin(9600);
Serial.println('logging lm35 and adxl335');
Serial.println('tmp, x, y, z');
}
void loop() {
// lm35
float volt = analogRead(3) * 3.3 / 1024;
float tmp = (volt - 0.5) * 100;
Serial.print(tmp);
// adxl335
if(pressed) {
Serial.print(',');
Serial.print(analogRead(0)); // x
Serial.print(',');
Serial.print(analogRead(1)); // y
Serial.print(',');
Serial.print(analogRead(1)); // z
}
Serial.println();
delay(500);
}