Activity Forums Questions & Troubleshooting Software & Firmware Data sent to Serial2 shows up in Serial Monitor

  • Data sent to Serial2 shows up in Serial Monitor

     Max updated 3 years, 7 months ago 2 Members · 3 Posts
  • Max

    Member
    May 3, 2021 at 4:27 pm

    Hi Forum members,

    i worked a bit with arduino and controllino for some basic projects. But now I have to setup a serial connection between a Nextion Display and a Controllino Mega.

    I am encountering a strange behaviour.
    My Controllino is connected to my PC by USB.
    The Nextion Display is connected to the Controllino by Pin 16 / 17 of X2.
    As my Controllino runs with 24V I am supplying the Nextion Display with a 5V power source.

    Now, when I execute the following code, everything I print to Serial2 is sent to the Serial Monitor instead to the Nextion Display. Weird.

    I spent days of searching, reading and trying. But I assume I need some professional help ;-).

    uint32_t interval = 1000; //milliseconds

    uint32_t nextMillis;

    uint8_t in_byte=0x00;

    uint8_t ndt[3]={255,255,255};

    void setup() {

    Serial.begin(115200);

    Serial2.begin(115200);

    Serial.println("Serial started");

    Serial.println(" ");

    nextMillis = millis();

    }

    void loop() {

    if(millis()-nextMillis >= interval) {

    Serial.print(millis());

    execute();

    nextMillis += interval;

    }

    }

    void execute() {

    Serial.print(" Bytes: ");

    Serial.print(Serial2.available());

    Serial.print(" Data: ");

    while (Serial2.available()) {

    in_byte = Serial2.read();

    Serial.print(char(in_byte));

    Serial.print(" ");

    }

    Serial.println();

    Serial2.print("t0.txt=\"");

    Serial2.print(nextMillis);

    Serial2.print("\"");

    Serial2.write(ndt,3);

    }

  • Lukas

    Member
    May 18, 2021 at 9:54 am

    Hi Max,

    have you tried to supply the display from the 5V at the CONTROLLINO pinheader? If you are using external 5V adapter – have you interconnected GND of CONTROLLINO and GND of the display?

    From your description it seems that RX and TX are interconnected at the display side …

    Any progress so far?

    Thanks,

    Lukas

  • Max

    Member
    May 18, 2021 at 3:57 pm

    Hi Lukas,

    thank you for your reply. It pointed me to the problem.
    As the Nextion Display requires more power than the pinheader supplies I connected it to an external 5V power supply.

    Now, I connected the 5V GND’s of the external power supply and the Controllino pinheader.
    Now i am getting a clean signal.

    Thank you for directing me towards the solution!

    Best Regards,

    Max

Viewing 1 - 3 of 3 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now