ESP8266 ADC readings

Hello!

I’m learning arduino on Sparkfun ESP8266 Thing Dev board.

I have connected photoresistor to the Thing using this example -

http://static.cactus.io/img/hookups/bre … dboard.jpg

The code is simple :

int LDR_Pin = A0;
void setup() {
    Serial.begin(9600);
    Serial.println("LDR Light Sensor | cactus.io");
}
void loop() {
   Serial.println(analogRead(LDR_Pin));
   delay(100);
}

The problem is with the analog reading values - they are fluctuating when photoresistor is reading rooms lights and values looks more like a sinusoidal wave. When the sensor is covered and in the dark, the values are more linear.

Serial plotter screenshot :

https://snag.gy/DqFxsa.jpg

Any ideas what I’m doing wrong?

You do not have a time base on the x-axis, but I’ll bet this corresponds to 120Hz. The brightness of most lights changes with 2x the line frequency. Its a power function. Looks like you have an incandescent light bulb. This converts current to heat and then heat to light at roughly 2% efficiency. Since the bulb is heating and cooling at 120Hz you will see 120Hz ripple. But since the bulb stays hot (or cools only a small amount at 120Hz) you get a DC brightness plus some ripple.