0

I am trying to send serial message from one nodemcu to two arduino boards. However, i am able to use only one uart pin of nodemcu which is TX pin. I can send message without any problem. But how can i send serial message from another uart. Node mcu documentation shows that it have two uart pins which are TX and GPIO15. Can someone share the syntax or example to use GPIO15. I have attached the program that i used to send message from TX pin but no idea for GPIO15.

import machine
from machine import UART
uart = UART(0) #For TX pin
uart.write("Hello \n")
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
nawas
  • 41
  • 1
  • 10

1 Answers1

1
from machine import UART
uart = UART(1, 9600)                         # init with given baudrate
uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters
uart.write("Hello \n")
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Donald Duck Aug 03 '17 at 11:03
  • Tx Pin on GPIO15 is UART1. and Syntax i have written here is copied from Micropythons UART class. – Himanshu Gajjar Aug 08 '17 at 11:29
  • Yes, it works. Thank you. I was able to setup 2400 baud 7 data bits, 2 stop bits and no parity. I'm not sure about the polarity though. – nagylzs Apr 22 '18 at 19:23