1

I am having difficulty understanding the output from my ADC. I am using a 10-bit MCP3008 with a photoresistor and CT current sensor connected into the analog inputs. I am reading the signals with this module. The module has a 'read_adc' function which 'Reads the current value of the specified ADC channel. The values can range from 0 to 1023 (10-bits).'

So far in the photoresistor channel, I am seeing values range from 100-200 (when the lights are low) to near 1000 when the lights are very bright. What exactly do these values mean? Are they a value of voltage being passed through the analog input port? Are they some sort of voltage measurement as a proportion of the reference voltage?

Same goes for the current sensor. The values remain steady at around 6 (which is the same for other grounded analog inputs), but then jumps to around 60-80 when a load the sensor is monitoring turns on, put then plummets back down to 6 after a few samples. Are the 60 and 80 values again reading voltage ?

Sorry if this is a simple question about ADCs. Thanks for the help!

-Tuomas

  • What voltage do you have on the Aref pin? The ADC output is a comparator value against Aref in 10-bits (zero to 2^10, which is 0 to 1023). So if Aref is 3.3V and the ADC value is 666 then the voltage on the pin is (666/1023)*3.3V == 2.148V. – Dougie Sep 25 at 22:37
  • I forgot if you are still using LDR. You might consider BH1750: (1) BH1750 Digital Light Sensor Instructable instructables.com/id/BH1750-Digital-Light-Sensor (2) BH175050FVI Digital Light Sensor BH175050FVI sunrom.com/p/digital-light-sensor-bh1750fvi – tlfong01 Sep 26 at 2:50
  • And I forgot which current sensor you are using. Give me a web link and I might like to share experiences. – tlfong01 Sep 26 at 2:57
  • How is your LDR connected? – Fred Sep 26 at 7:55
  • Ah very cool! Thanks for the info guys. Learning slowly but surely! @Dougie Aref voltage is 5V – Tuomas Talvitie Sep 26 at 11:45
2

In general, if your ADC is 10-bit with a 0-1023 return range, this value indicates a voltage that is proportional to the V_REF (reference voltage) input on your ADC. If your V_REF was 5 V, then a value of 1000 would indicate that the ADC is reading

octave:1> 5*1000/1023
ans =  4.8876

4.9 volts. What this voltage means then depends on your sensor type.

An LDR is usually constructed as part of a voltage divider circuit. Assuming the LDR goes between +5 V and the ADC pin, and ground goes to the the ADC pin via a 10K resistor (R), then the resistance measured by the LDR is calculated by R*V_IN/V_OUT+R which in this case gives

octave:2> 10000*5/4.88-10000
ans =  245.90

where V_IN is the reference 5 V voltage and V_OUT is the measured voltage. The datasheet for the LDR may give a calibration from resistance to Lux, a measurement of light intensity, like this datasheet does for the GL5528. Reading off the graph gives the relationship lux = exp((ln(R/1000) - 4.125)/-0.6704) which in this case gives

octave:3> exp((log(245.9/1000) - 4.125)/-0.6704)
ans =  3810.7

around 4000 lux. Note there will be pretty big error bars on this though and shade makes a huge impact!

The datasheet for the current meter should give a similar relationship between voltage and current.

  • Thanks! Great Answer, one issue is that I connected it without any resistors. All I did was take this [link] (startingelectronics.org/tutorials/arduino/modules/…) stick the appropriate pins in (AO, ground, 5v). The reason I avoided resistors is because I thought one was built into the sensor itself. IS this okay? How would I go about calculating lux from there? – Tuomas Talvitie Sep 26 at 11:52
  • @Fred, Your formula (lux = exp((ln(R/...) - ...)/ ...)) is very good, reminding me the relation between "exp" and "ln", which I never thoroughly understood. – tlfong01 Sep 26 at 12:50
  • @TuomasTalvitie If you have that exact sensor module, it includes the resistor going between ground and the analog pin as I've described. In that case, all you need to do to calculate Lux then should be to follow the equations as I've already outlined. startingelectronics.org/pinout/photo-resistor gives the resistance range as 80 to 20M ohms which is larger than the range of the datasheet I linked, but going by allaboutcircuits.com/projects/… which has a similar formula, it should be close enough. – Fred Sep 26 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.