[solved] Lilypad Erratic Temperature Sensor Output


hello, new arduino looking forward learning , using practical applications.  currently, using lilypad simple board mcp9700 temperature sensor, both of have been disconnected protosnap board.  my goal measure ambient temperature , read off of com port.  however, getting erratic readings on screen.

the board connected computer via usb, sensor connected board in understand correct way: hot hot, ground ground, , data pin a2 (my own choice).

the code using found online:

code: [select]
//tmp36 pin variables
int sensorpin = a2;

#define bandgapref 14   // special indicator want measure bandgap

/*
* setup() - function runs once when turn arduino on
* initialize serial connection computer
*/
void setup()
{
 serial.begin(9600);  //start serial connection computer
                      //to view result open serial monitor
 delay(500);
 
}

void loop()                     // run on , on again
{
 
 // voltage reading secret internal 1.05v reference
 int refreading = analogread(bandgapref);  
 serial.println(refreading);
 
 // calculate our power supply voltage known 1.05 volt reading
 float supplyvoltage = (1.05 * 1024) / refreading;
 serial.print(supplyvoltage); serial.println("v power supply");
 
 //getting voltage reading temperature sensor
 int reading = analogread(sensorpin);  

 // converting reading voltage
 float voltage = reading * supplyvoltage / 1024;

 // print out voltage
 serial.print(voltage); serial.println(" volts");

 // print out temperature
 float temperaturec = (voltage - 0.5) * 100 ;   //converting 10 mv per degree wit 500 mv offset
                                              //to degrees ((volatge - 500mv) times 100)
 serial.print(temperaturec); serial.println(" degress c");

 // convert fahrenheight
 float temperaturef = (temperaturec * 9 / 5) + 32;
 serial.print(temperaturef); serial.println(" degress f");

 delay(2000);                                     //waiting second
}


however, output unrealistic:

quote
403
2.67v power supply
0.15 volts
-34.63 degress c
-30.33 degress f
159
6.76v power supply
0.40 volts
-9.72 degress c
14.51 degress f
150
7.17v power supply
0.72 volts
22.10 degress c
71.78 degress f
137
7.85v power supply
0.82 volts
32.01 degress c
89.61 degress f
136
7.91v power supply
0.66 volts
15.62 degress c
60.12 degress f


troubleshooting, code modified output analog read of sensor pin a2.  the read out erratic, increasing , decreasing regardless of when heat applied sensor.  the temperature sensor replaced included light sensor.  there, analog readout increase increasing light , vice-versa.  this leads me believe problem may lie hardware (the temperature sensor).  on other hand, know sketch meant different temperature sensor, not see why not work in case.  any insight appreciated.

i don't know have bandgap code it's wrong.
one of first lines of analogread() is

code: [select]
if (pin >= 14) pin -= 14; // allow channel or pin numbers


so you're reading value of a0. wanted set analog mux internal voltage source:

code: [select]
admux = _bv(refs0) | _bv(mux3) | _bv(mux2) | _bv(mux1);

but doesn't work analogread().

please describe want achieve , why you're not reading value a2.


Arduino Forum > Using Arduino > Sensors > [solved] Lilypad Erratic Temperature Sensor Output


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62