Page 2 of 3

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 7:15 am
by gpson
I have Wemos D1 mini board and GPS module. Connected GPS Rx, Tx to Wemos Tx and Rx and trying the MP code from WebRTL


import machine
uart = machine.UART(0, 9600)
print( uart.readall() )

and the result is always None

When I connect GPS module over serial cable I see the output in the terminal on 9600 baud


is the MP modules not suitable for this task or I did something wrong?

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 7:42 am
by torwag
first of all, check the voltage levels. Does the GPS module use 3.3V logic. The esp8266 works only with 3.3V, you might damage the chip applying 5V to the GPIOs. It was reported that it can scope with 5V but it is far out it's specs. Better to use level shifters in that case. Just to make sure, the GPS module uses TTL logic levels? That is logic 0 is around 0V and logic 1 around 3.3V (or 5V). There is also differential logic using negative and positive voltages.
Did you connect Rx to Tx and vice versa?
Hope that this gives a starting point.

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 8:10 am
by gpson
@torwag thank you for the suggestions

I'm using this GPS module: ... 92334.html

I tested this module with 3.3V serial cable - messages are coming

connected gpsTx->espRx and gpsRx->espTx, powered GPS VCC from 3.3V output on the Wemos D1 board.

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 8:29 am
by deshipu
You need to cross the data lines -- tx goes to rx, and rx goes to tx. And don't forget to connect gnd too.

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 11:55 am
by torwag
Ok, did you do the serial cable test by powering the gps module via the wemos board?
Could be that the voltage regulator on the wemos can't deliver enough power for both the esp8266 and the gps. Try an external power supply. The Gps unit is given with rather low power consumption but never trust specs on AliExpress. The esp8266 is a good example by itself, it shows current peak power consumption which can easily bring a weak power supply in trouble, even if it should work pretty fine looking at the average power consumption. This together with some possible peaks for the GPS might knock off the on board regulator.

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 5:28 pm
by gpson
Powered my Wemos d1 mini from external battery. OLED and GPS modules are powered from 3.3V Wemos output. Orange wire goes from gpsTx to espRx.
DSC_2735.JPG (213.58 KiB) Viewed 10849 times
I took the orange cable out and connected to usb serial - you can see the result output in KiTTy window. New data is comming every second - 1Hz update rate.

When I connected the wire back to espRx, I started to get some data bursts from GPS module. Data is comming in random periods, not every second. And with data the control keys are coming - paste mode is activating and the webrepl is disconnecting.
Capture.PNG (204.4 KiB) Viewed 10849 times
Why GPS data is not captured to UART buffer? Any thoughts?..

Re: So you want to use the UART...

Posted: Sun Jul 31, 2016 11:51 pm
by mflmartin
I successfully connected a Bluetooth HM-10 via UART to the ESP8266 (Just for testing the UART and learning).

I found that I had to use, more than uart.readall():

Code: Select all

from machine import I2C, Pin
import utime
from machine import UART

uart = UART(0, 9600)

while True==True:
	val =
Also, maybe check that your battery is really providing 3.3 V to the ESP and 5.0V to your GPS module, with a multimeter. I can not see clear enough in the image. Does your board already incorporates a logic level converter? If not, you would need to interface both with it:


I had also a problem with not getting back the readings, and it was because my battery was outputing 2.9ish volts. So was not enought for the bluetooth module (or the ESP) but everything seemed ON.

I hope it helps.

Re: So you want to use the UART...

Posted: Mon Aug 01, 2016 10:12 am
by pythoncoder
@gpson The data looks as if it's terminated with a newline so I'd try the readline() method: this will block until either a line is received or the timeout elapses. Set the timeout to longer than the interval between messages so that in normal operation it won't occur. The issue of control characters is more of a problem: I'd query whether the GPS device should be sending them.

A previous post suggests that the solution to dealing with binary data is to put the device into raw REPL mode. The question is whether there is a way to do this programmatically.

Re: So you want to use the UART...

Posted: Mon Mar 20, 2017 11:07 pm
by BetterAutomations
So is this circuit required when the ESP will be listening for a command? I wouldn't think so since it's on the TX line but I want to confirm.

In my case a Pi will send the 's' command to a listening ESP.

Re: So you want to use the UART...

Posted: Tue Mar 21, 2017 7:46 am
by pythoncoder
The circuit is to ensure that the logic levels supplied to the ESP8266 don't exceed 3.3V.