Go Down

Topic: [SOLVED] NodeMCU V1 / ESP8266, Cannot print to UART1  (Read 130 times) previous topic - next topic

JohnRob

I've reduced my code to the absolute minimum and am unable to print to UART 1.

When I reboot the processor board I can see a debug message on D4/GPIO 2 / U1Tx but once the program starts there is no output on the D4 output pin.  I'm watching with an oscilloscope.

I guessing (hoping) there is something in the setup I missed but I have not been able to find it in any of the online docs.

Any help would be appreciated.

Thanks
John

SOLVED:
After further research I found the "LED_BUILTIN" is not the one on the NODE board but is the one on the ESP12 which is also the U1 Tx output.






Code: [Select]

/*
Serial communication test for UART0 and UART1

*/

#include <Arduino.h>
#include <ESP8266WiFi.h>  // for WIFI_OFF

//*****************************************************************************
// Operational Parameters:
//*****************************************************************************



//*****************************************************************************
// Pin Assignments:
//*****************************************************************************



// Prototypes:
//*****************************************************************************


// Globals:
//*****************************************************************************



// device setup:
//*****************************************************************************

void setup()
{

  // Disable WiFi radio:
    WiFi.mode( WIFI_OFF );
    //WiFi.forceSleepBegin();

    // Open serial communications:


    Serial.begin(4800, SERIAL_8E1);
    delay(200);
    /*After "Swap" U0 is on:  D7 = Rx
                              D8 = Tx   */
    Serial.swap();
 
    /* U1 is D4 = Tx
       U1 has no Rx port)   */
    Serial1.begin(115200, SERIAL_8N1);
    delay(1000);
    //Serial1.println("  Hello Dave .....");
 
  // setup hardware pins
    pinMode(PIN_LED, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);  // HIGH = LED off.
   
}  //  ...setup

// ================================================================================
// === MAIN LOOP ==================================================================
// ================================================================================


void loop() {
 


    Serial1.println(" Serial 1 output   ");

    delay(3000);






   
}  //  .... main loop


//*** subroutines *************************************************************
//*****************************************************************************


//  >>>>>>>>>>>>><<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>><<<<<<<<<<>
//  .... eof >:(
Please do not PM me with thread based messages.  If your thoughts are worth responding,  the group should benefit from your insight.

runaway_pancake

I believe that it's actually supposed to be
Serial.swap(15);
[ Should that have any bearing on D4 / Serial1 ? ]

I have used Serial1 (D4). Since it's 8N1 by default, I don't declare it (as you have).
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

PerryBebbington

Forget Serial1. Initialise serial then do Serial.swap().
Serial.swap doesn't swap serial with Serial1, it puts Serial on pins 13 and 15.

I'm using my phone and about to go to bed so can't check any details.

Try that and report back, if you don't get anywhere I'll look more closely tomorrow.

Go Up