Using a temperature sensor with the Arduino GBoard -
We are using a temperature sensor with A7 to A7 from the Arduino board pin, in fact any one of them pin The problem is that I can not get the stable and accurate value in the serial window in the Arduino software code below I am using:
int pin = 0; // analog pin int thromb = 0, tmf = 0; // temperature variable ant samples [8]; // variable to make a better precision int maxi = -100, mini = 100; // To start the maximum / minimum temperature int i; Zero setup () {serial.begin (9600); // start serial communication} zero loop () {for (i = 0; i & lt; = 7; i ++) {// sample samples of [i] = (5.0 * analog read (pin) ) * 100.0) / 1024.0; Tempc = tempc + samples [i]; Delay (1000); } Tempc = tempc / 8.0; // better precision tempf = (tempc * 9) / 5 + 32; // if converted to Fahrenheit (tempc> Maxi) {maxi = tempc; } // set maximum temperature (tempc "); Serial.print (maxi, dec); Serial. Print ("max,"); Serial.print (mini, dec); Serial. Printline ("minimum"); Tempc = 0; Delay (1000); // delay before the loop}
It would be good to know what the problems are, but There are some things to consider here:
- You're average of many samples. This is a good step.
- You can make a better small average by doing a voltage-to-trigger conversion later and not in the loop itself. In the loop, just add
analog read to read some values, then change it to temperature before printing. This way you want to avoid some potential floating-point round errors. - If you do do do this, at least the samples should be
float s -
- Make sure your voltage is constant Keep a good big bypass capacitor between Arduino's power and ground pin, especially if you are running on the battery.
- You do not show how to tilt the LM35 can be part of the problem. Also, if I remember correctly, its capacity is very limited to running capacitive weight. If your LM is 35 long, then the stars will contain some naturally occurrence. Take a look at LM 35 to see how the relationship between LM 35 and microcontroller can be made stronger.
- If you want to get more technical, look at increasing the AVR ADC accuracy, however, this can not be applied depending on the Arduino you use.
However, the big problem may be the underlying precision of your circuit. At 25 degrees, LM 35 outputs .25V, which shows your reading at 51 on the ADC, and receives a change in temperature of each + 1 degree from ADC, so the ADC is accurate to 1/2 degree. LM35 is perfect for 1/2 degree at room temperature, so now you are at +1 1/1 degree accuracy, and this can be the reason for your jitter. If you measure the temperature under just 100 degrees Celsius, then you can use the 3.3 V reference for your ADC (again which Ardine you use), which will give you better precision.
However, Something is a jumble.
Comments
Post a Comment