Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By bgowland
#39988
lord_alan wrote:I have flashed one of these with a new build of nodeMCU and am trying to read the LDR using LUA but
Code: Select allprint(adc.read(0))
always returns 65535 :-(


I don't know if you went any further with this but I was playing with ADC and the LDR last night and had some strange results.

You probably already know this but the docs at http://nodemcu.readthedocs.org/en/dev/en/modules/adc/ say...
Depending on the setting in the "esp init data" (byte 107) one can either use the ADC to read an external voltage, or to read the system voltage, but not both.

I initially tried...
Code: Select allprint(adc.read(0))

...as you did and also got a consistent 65535 but then I decided to try...
Code: Select allprint(adc.readvdc33())

...to see what happened.

According to the docs the return value of this is...
system voltage in millivolts (number)

If the ESP8266 has been configured to use the ADC for sampling the external pin, this function will always return 65535. This is a hardware and/or SDK limitation.

...but my initial reading was something like 1738 (decimal) which didn't make much sense for system voltage.

I then tried covering the LDR with a piece of card and the next reading was 232. Similarly, if I used a torch shining directly on the LDR I got readings of just over 4000. This seemed consistent with card / torch / casting shadows with my hand - all varying the return value.

This definitely doesn't tally - if, as the docs (above) say, the ADC is configured for external sampling (which I'd assume was the case for the LDR) then it SHOULD be returning a consistent 65535 but if it's NOT configured for external sampling I'd expect a fairly consistent value relating to system volage in millivolts instead of a variable value that is clearly affected by the light on the LDR. Totally confused.

Cheers,
Brian
User avatar
By Creo
#40968 1. I have a WIFI RGB strip controller: http://ru.aliexpress.com/item/RGBWW-Str ... e8a91a1adc
2. With my friend we downloaded full flash from controller.
3. Other friend helped to remove the protection on the MAC and remove pass for WI-FI.
4. There is only a problem with GPIO (grren and blue are mixed).
5. Android app in p.1 link (and of page)
6. Firmware in attach.
You do not have the required permissions to view the files attached to this post.