Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

esp8266 uart write byte value to TX

mehdi_esmehdi_es Irvine
edited March 19 in mJS JavaScript engine

Hi,
I am using a Nextion LCD which works with serial data.
Based on their documentation I have to terminate my string with 3 bytes of 0xFF 0xFF 0xFF (here)
This is the working code on Arduino:

void setup() {
  Serial.begin(9600);
}

void loop() {
  data = "t0.txt=\"Hello\"";
  Serial.print(data);
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
}

I am trying to do same thing with mongoose os and uart but I am not successful.
I am using esp8266 nodemcu dev board v 1.0
this is my code:

load('api_gpio.js');
load('api_timer.js');
load('api_uart.js');

let uartNo = 0;   // Uart number used for this example

UART.setConfig(uartNo, {
  baudRate: 9600,
  esp8266: {
    gpio: {
      rx: 3,
      tx: 1,
    },
  },
});

Timer.set(1000, Timer.REPEAT, function () {
  let data = "t0.txt=\"Hello\"";
  UART.write(uartNo, data+'ÿÿÿ'+'\n'); // no success
  // UART.write(uartNo, data+'x0ff'+'x0ff'+'x0ff'+'\n'); // no success
 // UART.write(uartNo, data+'\xFF'+'\xFF'+'\xFF'+'\n'); // no success
}, null);

There are few possible issues with my code.
1) uartNo
2) gpios
3) writing byte value 0xff

Can anybody help me on this?

Sign In or Register to comment.