-->
Page 1 of 1

Light Sensor Test, Works on Genuino Uno but not on ESP8266!!

PostPosted: Sun Jan 21, 2018 4:07 pm
by kidbreaker22
Basically what the title says!

I coded a light sensor test where it works on my Genuino Uno board and then tried on my ESP8266 V3 NodeMCU (http://www.smartarduino.com/nodemcu-bas ... 94571.html) and it gives me random stuff in the Serial Monitor. Am I doing something wrong or am I missing an information that I don't know about in ESP8266 that I can't do while it's allowed in Genuino Uno? Can someone please help me figure out with this stuff?

Thank you.

Code: Select allint sensorValue = 0;
int value = 0;

const int sensorPin = A0;
const int LEDPin = 8;

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  pinMode(LEDPin, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

  sensorValue = analogRead(sensorPin);
  delay(500);

  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);

  value = 255 - sensorValue/4;

  Serial.print("Analog Value of Pin D8: ");
  Serial.println(value);

  analogWrite(LEDPin, value);

}

Re: Light Sensor Test, Works on Genuino Uno but not on ESP82

PostPosted: Tue Jan 23, 2018 6:49 am
by schufti
there are modules where a 40MHz crystal is used instead of the common 26MHz.
If you push the reset button on your module, which selected baudrate (74880 / 115200) in the serial terminal gives you a readable boot message?

Re: Light Sensor Test, Works on Genuino Uno but not on ESP82

PostPosted: Tue Jan 23, 2018 12:27 pm
by jankop
Pin 8 is dedicated for flash memory! Your system colapsed. Change the pin to other free. I tried the program, it works.

here is your error message at 115200 baud:
Code: Select allwdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v4ceabea9
~ld