Hi All,
I'm having a similar problem. I'm running a photoresistor and a TMP36 and logging the data on an arduino.
The temperature sensor is fine but the photoresistor is very noisy. Any tips?
Details, the photoresistor is in a voltage divider with a 1K resistor (the lower resistor is there to increase the range).
I've tried the tricks suggested and then some, here's an excerpt of code for example:
Code: Select all
analogRead(gndPin);
delay(100);
analogRead(photocellPin);
delay(100);
int photocellReading = analogRead(photocellPin);
delay(100);
analogRead(gndPin);
delay(100);
analogRead(tempPin);
delay(100);
int tempReading = analogRead(tempPin);
delay(100);
// converting that reading to voltage, for 3.3v arduino use 3.3, for 5.0, use 5.0
float voltage = tempReading * aref_voltage / 1024;
float temperatureC = (voltage - 0.5) * 100;
float voltage1 = photocellReading * aref_voltage / 1024;
// float temperatureF = (temperatureC * 9 / 5) + 32;
//Converts Photocell Reading to Lux Reading, This will be unique for each Sensor and will change between diodes/Photoresistors
// Sensor 12 (C) = y = 626.06x6 - 3395.4x5 + 7395.5x4 - 7264.1x3 + 3743.7x2 - 148.26x
double luxReading = ((626.06*(pow(voltage1,6)) -(3395.4*(pow(voltage1,5))) + (7195.5*(pow(voltage1,4))) - (7264.1*(pow(voltage1,3))) + (3743.7*(pow(voltage1,2))) - (148.26*voltage1)));
The ground pin is a 5K resistor tied to ground to try and flush the ADC cap between measurements. The 6th order polynomial is my attempt to get an accurate lux measurement from one of these sensors. (I calibrated using an OLED taped to the top of a dremel tube and a lux meter)
Here's an output under a controlled light source
Code: Select all
Seconds (S) Light (10 bit) Light (lux)
1 244 544.59
2 265 607.21
3 275 638.49
4 251 565.03
5 245 547.49
6 276 641.67
7 256 579.89
8 247 553.3
9 276 641.67
10 272 629
11 254 573.92
12 253 570.95
13 276 641.67
14 254 573.92
15 245 547.49
16 271 625.86
17 276 641.67
18 248 556.22
19 250 562.09
20 275 638.49
The measurements quoted above under fluorescent, I must dig out the response times of these sensors in case its light flicker I'm seeing...
Any help would be greatly appreciated guys, micro's are not my strong point!