Hey guys, new to the forum. I'm kinda new regarding the ESP32 so I'm starting the learning curve.
Right now I'm having issues while trying to get communication wit a Ublox 6M GPS. I've already connected everything, however when I try to get a response via UART I'm not getting anything, right now the code looks like this:
#DATA GPS READER
from machine import UART, Pin
import utime
import os
#pin nummber, baud
#Guessing baud rate between GPS, ESP module
uart = UART(1, baudrate=9600, bits=8, parity=None, stop=1, tx=32, rx=33, rts=-1, cts=-1, txbuf=256, rxbuf=256, timeout=500)
now = utime.ticks_ms()
sentence=uart.readline()
#printing machine name...
idName = os.uname().machine
print(idName)
if uart.any():
print("im getting something...")
b = uart.read()
else:
print("nothing yet...")
I keep getting the "nothing yet..." response, so I don't know what may be happening. Also, I doubled checked everything is connected as it should be. Thanks a lot for your help
UART using ESP32 WROOM 32
-
- Posts: 1
- Joined: Thu Mar 21, 2019 6:19 am
Re: UART using ESP32 WROOM 32
It looks like you are calling uart.readline() a few lines before you call uart.any().
This will consume any input data on the serial port, so uart.any() will always return 0.
This will consume any input data on the serial port, so uart.any() will always return 0.
Re: UART using ESP32 WROOM 32
I am using UART2 like this. Change the baud rate as needed. Once you see GPS data switch to using readline().
Code: Select all
# ESP32 UART2 dump incoming data in hex
from machine import UART
uart = UART(2, tx=17, rx=16)
uart.init(115200, bits=8, parity=None, stop=1)
while True:
data = uart.read(1)
if data is not None:
# Show the byte as 2 hex digits then in the default way
print("%02x " % (data[0]), end='')
print(data)
-
- Posts: 2
- Joined: Wed Mar 20, 2019 3:32 pm
Re: UART using ESP32 WROOM 32
I'm sorry I took a few days to reply, been offline due to several reasons (ISP). Thanks a lot for your reply, with your help I was able to get the UART working!