Page 1 of 1

Wemos D1 Mini UART RX pin in MicroPython?

Posted: Mon Mar 05, 2018 8:10 am
by peterkz
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?

Re: Wemos D1 Mini UART RX pin in MicroPython?

Posted: Mon Mar 05, 2018 8:48 am
by torwag
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.

Re: Wemos D1 Mini UART RX pin in MicroPython?

Posted: Mon Mar 05, 2018 10:54 am
by peterkz
Thank you! The sensor transmits at 9600 so it should be fine I guess. Will have a look!

Re: Wemos D1 Mini UART RX pin in MicroPython?

Posted: Mon Mar 05, 2018 1:46 pm
by cefn
Do you mean you have successfully used https://github.com/ashareye/softuart or a different implementation?

Re: Wemos D1 Mini UART RX pin in MicroPython?

Posted: Tue Mar 06, 2018 3:34 am
by DMWidgets
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.

Re: Wemos D1 Mini UART RX pin in MicroPython?

Posted: Tue Mar 06, 2018 12:56 pm
by cefn
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