So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By matthah1
#84569 Took me a while to figure out why my new board wouldn't work... the serial baud rate was set at 74880 baud, which was unexpected. Once I figured that out by trial and error I started making progress. I hope to put together a house temperature monitor "emailer" gizmo so I'll know furnace is running when I am away from home during the winter. Here is the code I played with to get basic operations going in case it is useful for someone.

//#include <>
// Simple LED and serial test for the ESP8266 ESP-12E NodeMCU
//
void setup()
{
Serial.begin(74880); // this should not be necessary, serial baud rate came from factory at 74880 baud, seems odd but works fine with serial monitor
delay(1000);
pinMode(2, OUTPUT); // LED away from USB connector near WiFi antenna
pinMode(16, OUTPUT); // LED nearest USB connector
digitalWrite(2, LOW); // both LEDs initialized to on
digitalWrite(16, LOW);
Serial.println(" ");
Serial.println("Running at 74880 baud, both LEDs should be on");
Serial.println("enter 0 or 1 to toggle illumination states of the LEDs on the ESP8266 ESP-12E NodeMCU");
}

void loop()
{
int inchar = 0;

delay(50);
inchar = Serial.read();
if (inchar != -1)
{
//Serial.println(inchar);
switch (inchar)
{
case '0': // user entered 0 via serial monitor
digitalWrite(2, LOW); // LED away from USB connector near WiFi antenna turn the LED off (HIGH is the voltage level)
digitalWrite(16, HIGH); // LED nearest USB connector turn the NodeMCU LED off (HIGH is the voltage level)
Serial.println("LED near USB connector off, LED near WiFi antenna on");
break;
case '1': // user entered 1 via serial monitor
digitalWrite(2, HIGH); // LED away from USB connector near WiFi antenna turn the LED on by making the voltage LOW
digitalWrite(16, LOW); // LED nearest USB connector turn the NodeMCU LED on by making the voltage LOW
Serial.println("LED near USB connector on, LED near WiFi antenna off");
break;
case 10: // do nothing with the valid input of a line feed
break;
case 12: // do nothing with the valid input of a carriage return
break;
default: // user enter unrecognized character
{
Serial.println("Unrecognized character");
}
}
}
}



Serial monitor output
******************************************************************
14:25:13.374 ->
14:25:13.374 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
14:25:13.374 ->
14:25:13.374 -> load 0x4010f000, len 1384, room 16
14:25:13.374 -> tail 8
14:25:13.374 -> chksum 0x2d
14:25:13.374 -> csum 0x2d
14:25:13.374 -> v482516e3
14:25:13.374 -> ~ld
14:25:13.413 -> V2
14:25:13.413 -> Mo
14:25:13.445 -> ,⸮
14:25:14.462 -> Running at 74880 baud, both LEDs should be on
14:25:14.462 -> enter 0 or 1 to toggle illumination states of the LEDs on the ESP8266 ESP-12E NodeMCU
14:25:24.854 -> LED near USB connector off, LED near WiFi antenna on
14:25:28.669 -> LED near USB connector on, LED near WiFi antenna off