Software serial?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
mcauser
Posts: 334
Joined: Mon Jun 15, 2015 8:03 am

Software serial?

Post by mcauser » Tue Aug 02, 2016 1:55 pm

Is anyone working on a software serial library?

The ESP8266 has two hardware UARTs.
UART 0 - TX and RX is used by the REPL.
UART 1 - TX is free for use, however, RX is used by the onboard spi-flash.

I have a GPS module and I am not sure how I can connect it. I need a free RX pin.

Can I disable console REPL and use WebREPL to free up the UART 0 RX pin?

User avatar
deshipu
Posts: 1334
Joined: Thu May 28, 2015 5:54 pm

Re: Software serial?

Post by deshipu » Tue Aug 02, 2016 2:26 pm

I would be happy to help you if you want to start working on this. The easiest way is to use some existing code that provides software serial, and just write the MicroPython module to access it. Do you have a candidate for that? A quick google yields https://github.com/plieningerweb/esp8266-software-uart

mflmartin
Posts: 17
Joined: Sat Jul 23, 2016 7:30 pm

Re: Software serial?

Post by mflmartin » Tue Aug 02, 2016 7:48 pm

mcauser wrote: Can I disable console REPL and use WebREPL to free up the UART 0 RX pin?
I am using and testing a bluetooth module connected to the ESP8266-01 via UART. I use the Webrepl for testing, as my module is wired to RX/TX. It is a bit annoying when you have to restart, reconnect, etc, but overall is "usable".

jms
Posts: 108
Joined: Thu May 05, 2016 8:29 pm
Contact:

Re: Software serial?

Post by jms » Thu Aug 04, 2016 11:14 am

The REPL doesn't start if you put something in startup scripts (main.py) to do something else instead.

The problem is then dealing with the rubbish that comes out and I wrote about that at viewtopic.php?f=16&t=2078

User avatar
EasyRider
Posts: 94
Joined: Wed Dec 30, 2015 8:17 am
Location: Land Down Under

Re: Software serial?

Post by EasyRider » Wed Aug 10, 2016 12:19 am

I need a working UART port on the ESP.

I don't care about the garbage that comes out at the start or whenever, I will be filtering all the data using specific packet protocol with CRC.

My issue is disabling REPL on UART. WebREPL is providing the replacement functionality that I need.
The REPL doesn't start if you put something in startup scripts (main.py) to do something else instead.
:?

What do you put in main.py to do something else to disable REPL??

I am an application end user still learning python, can someone please provide a step by step guide/workaround on how to implement some sort of usable UART functionality. If it requires a hardware mod and if and how to disable REPL?

UART port on ESP8266 is implemented for most of the other language ports, LUA, Arduino, javascript and even ESPBasic that also has a second software UART implementation. I still don't understand why no priority has been given to implementing formal UART functionality in ESPmicropython.

markxr
Posts: 62
Joined: Wed Jun 01, 2016 3:41 pm

Re: Software serial?

Post by markxr » Thu Aug 11, 2016 7:43 pm

There is a second UART which is tx-only. It is on one of the gpio pins which varies from one module to another, but you can find it easily enough by attaching a scope of them in turn. (Curiously enough, on my modules it appears to have a blue led wired on the board too, I think it's gpio2)

You can use this uart through micropython, I assume you can't then use the same pin as gpio.

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

Re: Software serial?

Post by pythoncoder » Fri Aug 12, 2016 3:33 pm

One idea might be to use UART 0 for receive and UART 1 for transmit - that way the debug information goes out on U0 and the application data on U1.
Peter Hinch

User avatar
deshipu
Posts: 1334
Joined: Thu May 28, 2015 5:54 pm

Re: Software serial?

Post by deshipu » Sat Aug 13, 2016 8:08 am

pythoncoder wrote:One idea might be to use UART 0 for receive and UART 1 for transmit - that way the debug information goes out on U0 and the application data on U1.
The debug information from micropython can be easily disabled. The problem is the bootloader messages at startup, and they get spammed to both uarts.

konst
Posts: 1
Joined: Wed Aug 31, 2016 4:51 am

Re: Software serial?

Post by konst » Wed Aug 31, 2016 4:57 am

Any luck with software serial? Bunch of sensors need uart, I hope we will figure out something

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

Re: Software serial?

Post by pythoncoder » Wed Aug 31, 2016 4:24 pm

Writing a software UART is a nontrivial task. There are many parameters to accommodate, and timing needs to be quite precise (+-5% or thereabouts) so receive and transmit would need to be interrupt driven. To add to the complexity it needs to be able concurrently to send and receive. The first step is probably to characterise the ESP to determine timing precision, bit-banging in response to an interrupt. This would give a pointer to the likely maximum baud rate.

An interesting project, but if anyone takes it on they won't have it done in a day...
Peter Hinch

Post Reply