Wemos D1 Mini UART RX pin in MicroPython?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
peterkz
Posts: 5
Joined: Mon Mar 05, 2018 8:00 am

Wemos D1 Mini UART RX pin in MicroPython?

Post by peterkz » Mon Mar 05, 2018 8:10 am

Hi! I am trying to talk to a MH-Z19B CO2 sensor over serial UART from Micropython on a Wemos D1 mini. For debugging I would like to be connected to the REPL of the D1 mini while talking serial to the sensor (via computer USB cable). I have trouble receiving data on the RX pin though. Transmitting seems fine but receiving gives an OS error as it seems to be used by the REPL.

Is it possible to use other pins than the TX RX marked pins on the D1 mini for UART communication? If so, how do I set those up in MicroPython?

torwag
Posts: 219
Joined: Fri Dec 13, 2013 9:25 am

Re: Wemos D1 Mini UART RX pin in MicroPython?

Post by torwag » Mon Mar 05, 2018 8:48 am

Hi,

if the sensor communication does not require a lot of fast data sending, try the SoftUART approach.
viewtopic.php?f=16&t=2204&hilit=softuart

I was able to talk to a serial display from a d1mini using this library.

peterkz
Posts: 5
Joined: Mon Mar 05, 2018 8:00 am

Re: Wemos D1 Mini UART RX pin in MicroPython?

Post by peterkz » Mon Mar 05, 2018 10:54 am

Thank you! The sensor transmits at 9600 so it should be fine I guess. Will have a look!

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: Wemos D1 Mini UART RX pin in MicroPython?

Post by cefn » Mon Mar 05, 2018 1:46 pm

Do you mean you have successfully used https://github.com/ashareye/softuart or a different implementation?

DMWidgets
Posts: 8
Joined: Fri Feb 16, 2018 4:28 pm

Re: Wemos D1 Mini UART RX pin in MicroPython?

Post by DMWidgets » Tue Mar 06, 2018 3:34 am

Curious to know an answer to this myself. Got an HC05 bluetooth module today and I'm trying to make it work. Couldn't make much out of the posted thread, though.

My understanding is UART 0 is...used by the REPL or something and UART 1 works, but only for TX (which won't work for me). I finally got the module to respond to an AT command, but it's just throwing errors. initializing on 0 disables my local terminal access and while the webREPL still works, receiving what I assume to be a response from the module only fills my terminal window with a repetition of "ERROR:(0)" followed by a syntax error (as if the receipt is getting entered as a command), after which the module seems to reboot itself out of AT mode. All the info I've found seems to gloss over what's causing the conflict, so I'm kind of stumped.

cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Re: Wemos D1 Mini UART RX pin in MicroPython?

Post by cefn » Tue Mar 06, 2018 12:56 pm

Not answering your question, but if I recall, the HC-05 switches between AT mode and through mode with a pull-up on some pin or another. Hopefully this pin isn't free-floating and switching itself between modes.

However, there remains the issue around using the UART vs. having it for REPL which I don't know the answer to, but I am also curious to understand how to switch it properly, see...

viewtopic.php?f=16&t=4491

Post Reply