2
votes

I am beginner for NodeMcu. I brought a Adraxx ENTDEV019 ESP8266 NodeMcu WiFi Development Board. I am trying to program with arduino Ide. I tried some basic examples. Below is code I am trying for the board. I am using Serial1 port for debug communication. I connected:

  • Tx from board to Rx of Serial Adapter
  • Rx from board to Tx of Serial Adapter

I tried this for different baud rates. I powered NodeMcu with external power bank,but I don't see correct output in Serial Monitor.

Same code works fine if I use Serial port instead of Serial1 and connect with USB cable to Computer.

#define LED D0 
#define DBG_OUTPUT_PORT Serial1

// the setup function runs once when you press reset or power the board
void setup() {
  DBG_OUTPUT_PORT.begin(9600);
  DBG_OUTPUT_PORT.print("\n");
  DBG_OUTPUT_PORT.setDebugOutput(true);
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(LED, OUTPUT);  

}

// the loop function runs over and over again forev`er
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED, HIGH);// turn the LED off.(Note that LOW is the voltage level but actually 
  delay(2000);                       // wait for a second
  DBG_OUTPUT_PORT.print("Connected! IP address: \n");

  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW

  digitalWrite(LED, LOW); // turn the LED on.

}

enter image description here enter image description here

What mistake am I doing?

1
is your serial adapter a USB-to-UART?Andy
yes its USB-to-UARTSarfraj
yes its USB-to-UARTSarfraj
The software is evidently not an issue if it works for teh Serial object but not Serial1 - therefore the question is off topic on SO, and perhaps better asked at electronics.stackexchange.com. Or just read the documentation (such as it is). You are to be connected to RXD0/TXD0 (the same Serial UART already exposed via the USB). Serial1 supports TX only on D4 according to the IOCONN block at github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/….Clifford
I'm voting to close this question as off-topic because it is not a software issue electronics.stackexchange.comClifford

1 Answers

2
votes

From (https://arduino-esp8266.readthedocs.io/en/latest/reference.html#serial):

Serial uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling Serial.swap() after Serial.begin. Calling swap again maps UART0 back to GPIO1 and GPIO3.

Serial1 uses UART1, TX pin is GPIO2. UART1 can not be used to receive data because normally it’s RX pin is occupied for flash chip connection.


Pinouts that you connected seem like GPIO1(TX) and GPIO3(RX). GPIO2 is D4 pin.

(pinmap from: https://github.com/nodemcu/nodemcu-devkit-v1.0)