TTGO T-Beam V1.0 GPS UART problems

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
T-Wilko
Posts: 30
Joined: Thu Sep 19, 2019 8:08 am

TTGO T-Beam V1.0 GPS UART problems

Post by T-Wilko » Mon Dec 02, 2019 5:11 pm

Hi all,

Firstly, I'm rather new to uPy (second ESP32 project)

I'm wanting to use Lilygo TTGO T-Beam V1.0

https://www.aliexpress.com/item/3296722 ... ttps://www.

for a datalogging weather balloon project for my uni club requiring GPS. I thought, since it's an ESP32, that the integrated NEO-6M GPS module would be relatively easy to communicate with over UART (currently assuming that's the correct method to do so) as there are several micropython drivers written for it already. e.g. https://github.com/lemariva/wipy2.0-GPS

I successfully flashed uPy v1.11 and all seemed normal. Several attempts at enabling GPS later, nothing seemed to work (including any data from simple UART tests of the listed rx=12 tx=34). Further digging revealed something that seemed to be an 'official' TTGO driver adaptable for the axp192 power distribution chip present on my board. https://github.com/lewisxhe/AXP202_PythonLibrary

Question:
- Am I missing a fundamental understanding of the power distribution setup of this board? Do I need to, through some driver like the one above, manually turn 'on' the GPS chip? All my previous projects which largely involved sensor breakout boards never required any power management. It is important to note that the LED that is described on the board's aliexpress listing as indicating 'GPS working' has not flashed on even once since flashing uPy, but I assume that's not a hardwired LED.

Just to clarify, at this point the only thing I need working is the GPS functionality of the chip

Any assistance or input would be great

Thomas

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: TTGO T-Beam V1.0 GPS UART problems

Post by pythoncoder » Mon Dec 02, 2019 5:28 pm

I wrote this driver which is derived from micropyGPS. It was tested with a different GPS chip, but they mostly work the same way with NMEA-0813 sentences passed over a serial interface. My driver uses asynchronous code.

Your GPS appears to be similarly connected so you should be able to access it via a UART on pins 12 and 34. In my experience the GPS chip can take several minutes to acquire a signal, but I'd normally expect it to do this without any special intervention. If in doubt take it outdoors where there is a clear view of most of the sky.

Your board does seem to have some kind of power management: an AXP192 chip. Are there any docs?
Peter Hinch
Index to my micropython libraries.

User avatar
T-Wilko
Posts: 30
Joined: Thu Sep 19, 2019 8:08 am

Re: TTGO T-Beam V1.0 GPS UART problems

Post by T-Wilko » Tue Dec 03, 2019 2:31 am

I've found this datasheet:

https://pdf1.alldatasheet.com/datasheet ... XP192.html

But in all honesty, I'm a bit out of my depth there and I'm not sure what to look for/what to enable.

I'll give your driver a go in a couple of hours, the GitHub readme seems super helpful.

I was a little worried with earlier testing because I was getting essentially no UART data output even with the simplest test code. Also just to make sure, when initialising the UART object, would it be correct to write:

uart = UART.init(1, 9600, rx=34, tx=12)

Since the listed rx and tx in the coloured boxes in the Pinout Pic on aliexpress are the GPS rx & tx, and thus are flipped when defining the chipset's rx and tx?

Also, what does the '1' in the first first position of the UART.init function do?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: TTGO T-Beam V1.0 GPS UART problems

Post by pythoncoder » Tue Dec 03, 2019 6:58 am

Your UART initialisation looks correct. The 1 is the ESP32 UART number: you might have a project which uses more than one UART in which case you'd use a different number (and different pins) for each. If the GPS is receiving power and working it should send messages periodically. I would expect you to start receiving them with simple uart.readline() commands. If this doesn't work, using different drivers won't help.

It is possible that the power management chip is preventing the GPS from receiving power. That datasheet does not give enough information to determine whether or not that is the case. The simplest way may be to ask the supplier. Is there any user forum for the device? To be honest this is the problem with buying things from China. Modules from Adafruit are more expensive but their documentation and support is first class.

[EDIT]
To make sure I remembered this correctly I connected a 3.3V power source to my GPS module and checked the serial output with an oscilloscope - no processor involved. The GPS sent regular messages. The LED flashed as expected - rapidly until it had acquired a fix, then slowly.
Peter Hinch
Index to my micropython libraries.

User avatar
T-Wilko
Posts: 30
Joined: Thu Sep 19, 2019 8:08 am

Re: TTGO T-Beam V1.0 GPS UART problems

Post by T-Wilko » Wed Dec 04, 2019 2:05 am

So a quick update:

I've looked into the arduino code provided by Lilygo themselves on github, and it seems the power chip does need a driver of sorts to power up the GPS as it is mentioned in the intro comments in the code. Good news was, with arduino code I tested it and it started spitting out the GPS coords perfectly through serial, and the LED flashed every time it outputted data (1Hz). So the same guy that wrote the arduino code for the axp192 driver also wrote the micropython one that I linked earlier:

https://github.com/lewisxhe/AXP202_PythonLibrary

I've uploaded the necessary "constants.py" & "axp202.py" and tried running the function shown in the "main.py" file of axp202.PMU() to set things up. However, I get an OSError Errno 19 ENODEV after the code prints * initializing i2c and * initializing pins and cites errors in lines 78, 91 and 1 earlier line (I can't quite remember) in the axp202.py file.

Any suggestions on how to amend this error? I thought ENODEV stood for error no device so I'm stumped since the register in the constants.py files seem to be correct... I've also messaged the author of the driver and am awaiting a response

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: TTGO T-Beam V1.0 GPS UART problems

Post by pythoncoder » Wed Dec 04, 2019 8:56 am

Looking at the library above, the author has made significant changes in the last 3 hours (at 8:50UTC). You may want to try the new version. If this still fails, the error does indicate it can't find the I2C device. You could initialise I2C and run I2C.scan() to see exactly what devices are attached to the bus.

Another thing that comes to mind is that TBeam seem to be using the Loboris port. The file TBeamGPS.py has this odd line:

Code: Select all

gps = machine.GPS(uart)
Standard MicroPython does not have this class - so it must be specific to the Loboris port. I gather development of this port has stopped, so you may or may not want to use it.
Peter Hinch
Index to my micropython libraries.

User avatar
T-Wilko
Posts: 30
Joined: Thu Sep 19, 2019 8:08 am

Re: TTGO T-Beam V1.0 GPS UART problems

Post by T-Wilko » Wed Dec 04, 2019 9:58 am

pythoncoder wrote:
Wed Dec 04, 2019 8:56 am
Looking at the library above, the author has made significant changes in the last 3 hours (at 8:50UTC).
He actually got back to me over email straight away and amended the driver to work for axp192.

The Loboris port sounds like yet another problematic hurdle... Would this be where your NMEA sentence parser driver would step in, instead of relying on that unsupported GPS function?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: TTGO T-Beam V1.0 GPS UART problems

Post by pythoncoder » Thu Dec 05, 2019 9:04 am

My library, and the synchronous one it's derived from, work with standard firmware.
Peter Hinch
Index to my micropython libraries.

User avatar
thiago.nogueira
Posts: 2
Joined: Thu Aug 20, 2020 2:20 am

Re: TTGO T-Beam V1.0 GPS UART problems

Post by thiago.nogueira » Wed Aug 26, 2020 12:33 am

Hi!

Were you able to solve the problem?

I have the same problem as you! Using the same board and the same libraries.

User avatar
T-Wilko
Posts: 30
Joined: Thu Sep 19, 2019 8:08 am

Re: TTGO T-Beam V1.0 GPS UART problems

Post by T-Wilko » Sat Sep 12, 2020 11:36 am

Hi Thiago,

I ended up going the 'easy' route and using the loboris port of micropython instead of using pythoncoder's GPS library, since loboris implemented an easy to use GPS parser in his default flashes.

For initialisation of the GPS, here's what you need to do:

Code: Select all

import axp202, machine

GPS_RX_PIN = 34
GPS_TX_PIN = 12

axp = axp202.PMU(address=axp202.AXP192_SLAVE_ADDRESS)
axp.setLDO3Voltage(3300)   # T-Beam GPS  VDD    3v3
axp.enablePower(axp202.AXP192_LDO3) # GPS Power on

uart = machine.UART(2, rx=GPS_RX_PIN, tx=GPS_TX_PIN, baudrate=9600, bits=8, parity=None, stop=1, timeout=1500, buffer_size=1024, lineend='\r\n') # This specific set of parameters will only work with loboris' version of the UART module
gps = machine.GPS(uart)
gps.init()
gps.startservice()
And then, to read the parsed GPS data:

Code: Select all

gps.getdata()
You can tell if you've initialised the GPS correctly through the axp power chip commands, if a red LED comes on after a few minutes (with a decent LOS to the sky) on the board to signify gps lock.

Let me know if you hit any roadbumps. It took me a while to get it going so I'm happy to help someone on the same path as me.

Thomas

Post Reply