Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By ian
#20254 I tried your code on a ESP12, grounded the analogue in, it reads 0 & doesn't crash.
How exactly have you wired your LDR? A potential divider?
User avatar
By Tawhiz20
#20260
ian wrote:How exactly have you wired your LDR? A potential divider?

It is a simple Voltage-divider with 2 resistors: 10k to Vcc and 4k7 to Gnd (giving 1,1V in the middle -without the LDR)
The LDR is put in parallel over the 4k7 so potential will vary with light.

Here are some values that show up in my monitor (without the LDR for testing purposes):
(ADC attached to GND)
0
0
0
242
0
332
332
0
288
288
0
302
302
0
317

(or, with my Voltage-divider (shows 1,1V on my meter))
1023
419
1023
1023
1023
419
1023
1023
419
1023
419
450
1023
1023
417
1023
417
411

Exchanged the ESP-201 for another (although under NodeMCU and Lua it works fine)... same errors.
Exchanged the power-source (although my meter showes the correct values)... same errors.

ian wrote:it reads 0 & doesn't crash.

When using these ( https://github.com/sandeepmistry/esp8266-Arduino ) instructions with 1.6.4.
I get a stream of values from the ADC but most of them are incorrect (8 out of 10 - the other 2 are correct-)

When using these ( https://github.com/esp8266/Arduino ) instructions with 1.6.4.
I get 3 or 4 correct values from the ADC but my ESP resets!

Which would suggest it is a software-problem... or not?? :shock:
User avatar
By Tawhiz20
#20264 I flashed NodeMCU on the ESP-201 again (without changing the breadboard)
and used this little program:
Code: Select allfunction look()
waarde=adc.read(0)
print("Value : "..waarde)
end

tmr.alarm(0, 1000, 1, function() look() end )

which produces a stable stream of correct values in my ESPlorer:
NodeMCU firmware detected.
=node.heap()
21216
> dofile("ldrtest.lua")
Value : 0 (connected to GND)
Value : 0
Value : 0
Value : 0
Value : 0
Value : 0
Value : 0
Value : 1024 (connected to the Voltage-divider without LDR)
Value : 1024
Value : 1024
Value : 1024
Value : 1024
Value : 1024
Value : 1024
Value : 1024
Value : 1024
Value : 744 (and with the LDR in place)
Value : 600
Value : 598
Value : 598
Value : 598
Value : 597
Value : 592
Value : 598
Value : 597
Value : 592
Value : 597

Which would lead to the conclusion that it is not a hardware-problem (buttttt I could be VERY wrong.. "presumption is the mother of all F*@#ups" :lol:)

I cant be the only user having these problems... or?
User avatar
By cal
#20272 Moin,

you didn't say what version of nodemcu you are using.
Reading the ADC seem to conflict with some WIFI usages and I remember that a workaround was added
to nodemcu to switch the wifi mode before doing the read.
If you do the same you may be fine in C, too. Should be wifi.c

Cal