HI,
I'm running a basic sketch where I'm reading the temp for an TMP036. With my UNO I can set delay(15000) and it returns the proper value loop after loop.
When I uplaod the sketch to my DUE and adapt it to a 3.3v read on my analogue pin, the board reads the first loop correctly and then after 15000 milli secs the second and follwing loops read an analogue pin voltage much lower than it should.
Here's the sketch with no delay;
int sensorPin = 2;
float sensorValue,temperature,voltage;
void setup() {
Serial.begin(115200);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print("Sensor Raw value: ");
Serial.print(sensorValue);
voltage = (sensorValue * 3.3) / 1024.0;
Serial.print(" Voltage at 3.3v: ");
Serial.print(voltage);
temperature = (voltage - 0.5) * 100;
Serial.print(" Temperature Arduino monitor: ");
Serial.println(temperature);
}
Monitor reading with no delay
Sensor Raw value: 235.00 Voltage at 3.3v: 0.76 Temperature Arduino monitor: 25.73
Sensor Raw value: 234.00 Voltage at 3.3v: 0.75 Temperature Arduino monitor: 25.41
Sensor Raw value: 234.00 Voltage at 3.3v: 0.75 Temperature Arduino monitor: 25.41
Sensor Raw value: 234.00 Voltage at 3.3v: 0.75 Temperature Arduino monitor: 25.41
Sensor Raw value: 234.00 Voltage at 3.3v: 0.75 Temperature Arduino monitor: 25.41
Sensor Raw value: 235.00 Voltage at 3.3v: 0.76 Temperature Arduino monitor: 25.73
Sensor Raw value: 234.00 Voltage at 3.3v: 0.75 Temperature Arduino monitor: 25.41
Sensor Raw value: 235.00 Voltage at 3.3v: 0.76 Temperature Arduino monitor: 25.73
Sensor Raw value: 235.00 Voltage at 3.3v: 0.76 Temperature Arduino monitor: 25.73
And now the sketch and monitor reading with a Delay(15000);
[code]
int sensorPin = 2;
float sensorValue,temperature,voltage;
void setup() {
Serial.begin(115200);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print("Sensor Raw value: ");
Serial.print(sensorValue);
voltage = (sensorValue * 3.3) / 1024.0;
Serial.print(" Voltage at 3.3v: ");
Serial.print(voltage);
temperature = (voltage - 0.5) * 100;
Serial.print(" Temperature Arduino monitor: ");
Serial.println(temperature);
delay(15000);
}
Monitor
Sensor Raw value: 232.00 Voltage at 3.3v: 0.75 Temperature Arduino monitor: 24.77
Sensor Raw value: 71.00 Voltage at 3.3v: 0.23 Temperature Arduino monitor: -27.12
Sensor Raw value: 71.00 Voltage at 3.3v: 0.23 Temperature Arduino monitor: -27.12
Sensor Raw value: 71.00 Voltage at 3.3v: 0.23 Temperature Arduino monitor: -27.12
Any idea why the due is loosing voltage during the delay?
[/code]