ESP8266 ADC divider resistor for using LDR - Page 1
Forum section: electronics / beginners

author: sairfan1
author_rank: Frequent Contributor
timestamp: June 12, 2025, 04:01:46 pm
content: I have two types of LDRs with me, based on available light one varies from 0 ohm to 40k, and the other 40k to 1M.As we know ESP8266 ADC can handle max 1v, I believe for this we will use ohm's law with a resistor divider, I tried but could not understand how can I calculate value of fixed resistor so that we do not go above 1 volt and stay in between 0 to 1v while changing resistor on LDR from full light to dark.

author: lakis70
author_rank: Contributor
timestamp: June 12, 2025, 09:29:40 pm
content: you must supply the voltage divider with 1V instead of 5V or 3.3Vhow you will create 1V supply? Look for ic voltage references of use another voltage divider to step down the supply voltage.

author: xvr
author_rank: Frequent Contributor
timestamp: June 13, 2025, 12:14:18 pm
content: Set 1V of output on maximum LDR resistance.https://xvrxvr.github.io/ResDiv/index.htmlVin - 3.3V (Base)Vout - 1V (Target)R2 - 40K (Restricted)Solution for R1 - 91K

author: ledtester
author_rank: Super Contributor
timestamp: June 13, 2025, 03:10:40 pm
content: In this circuit:Code:3.3 ---/\/\/---o---/\/\/---GNDR OUT LDRyou want OUT to be 1V when LDR is the maximum resistance. That means the current flowing through the LDR (and also R) is:I = 1V/LDR_maxThe voltage drop across R is 3.3-1 = 2.3 volts and so by Ohms Law:2.3 = I*RSo, R = 2.3/I = (2.3V/1V) * LDR_max

author: sairfan1
author_rank: Frequent Contributor
timestamp: June 13, 2025, 08:12:59 pm
content: Thanks, as I'm quite dumb I have a question.1. In last line why did you divide voltage to target voltage ie (2.3V/1V)2. Does it matter that R should be connected to V+ ?

author: ledtester
author_rank: Super Contributor
timestamp: June 13, 2025, 08:34:37 pm
content: Quote from: sairfan1 on June 13, 2025, 08:12:59 pmBecause we know:2.3V = I*RI = 1V/LDR_maxSo:2.3V = (1V/LDR_max)*Ror:2.3V/1V * LDR_max = RQuote from: sairfan1 on June 13, 2025, 08:12:59 pmYes, this is a different situation:Code:3.3 ---/\/\/---o---/\/\/---GNDLDR OUT RIn this case if we want Vout <= 1V then we have the condition:Vout = I*R <= 1Vso:R <= 1V/Iand since I is also the current through the LDR:I = (3.3-1)/LDRthus:R <= (1V/2.3V)*LDR for all possible values of LDRSo this circuit will only work if the LDR has a non-zero minimum resistance.For the 40K-1M LDR you can use an R of <= 40K/2.3 = 17K.For the 0-40K LDR you can't use this arrangment.However, you can always impose a minimum resistance for the LDR by adding another resistor in series. If you added a 5K resistor in series with the 0-40K LDR then it becomes a 5K-45K LDR and a R <= 2.1K would work.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: June 13, 2025, 09:08:29 pm
content: Per this page, any dev board should have 3v3 for the ADC. If you're just using the chip directly, look at what they did on the schematic for the dev boards.https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

author: sairfan1
author_rank: Frequent Contributor
timestamp: June 27, 2025, 10:06:31 pm
content: I setup everything and found a little difference.I had 47k resistors so putting them in series gave me 94k (just above) after setting up when i measure voltage at division point it was around 0.56 volts with full dark, with full light it went down to mili voltsI tried 70k resistor that bring it up to 0.96 volts when full dark,just sharing here if we are missing anything to consider?