2

Background

I'm working on a robotics project that requires using an ESP8266 based board (Lolin D1 mini pro v2) as a microcontroller. I have Micropython on this board along with a set of functions that I have to be able to call from an Nvidia Jetson Nano over UART.

Setup

I have the Jetson's UART1_TXD pin wired to the D1's RX pin, and the D1's TX pin to the Jetson UART1_RXD pin. (https://developer.nvidia.com/embedded/learn/jetson-nano-2gb-devkit-user-guide#id-.JetsonNano2GBDeveloperKitUserGuidevbatuu_v1.0-40-PinHeader(J6))

On the Jetson this interface is /dev/ttyTHS1.

Using machine.UART on the D1, and pyserial on the Jetson.

Micropython version: esp8266-20210202-v1.14

Process so far

Initially I attempted to setup a simple connection between these two devices both at baud=9600 with default settings (which I check and I believe to workout the same). I ran a while True loop on the Jetson to run print(ser.readline()), ser being the serial object I had set up.

At the same time I ran a while true loop containing uart.write(b'hello world\n') on the D1. uart being the machine.UART object initialized with the above parameters.

This left the Jetson continually printing blank lines. I switched the Jetson's loop to run print(ser.read()) to read a byte at a time, to see if data was getting through at all, this gave me the same situation as before.

Micropython REPL

Since this wasn't working I'm now attempting to use a known interface on one side, the raw Micropython REPL. This is actually preferable to me as if I can directly send the REPL commands to execute I can import my Library on the microcontroller and run an arbitrary method.

The documentation is a little hazy on whether you can access the REPL directly over UART (as opposed to through the USB serial converter) however I believe it to be possible form what I have read (If it isn't, then this problem falls back to getting the original simple UART connection working).

With the above physical setup, I removed the program from the D1 which tried to use UART0 so that the REPL would be left on this port as default on boot. And using a terminal simulator on the Jetson attempted to connect to it on /dev/ttyTHS1 -b 115200.

picocom -b 115200 /dev/ttyTHS1 shows the parameters of the connection but then the prompt is blank as opposed to the >>> and wont accept any input.

rshell --port /dev/ttyTHS1 --baud 115200 waits forever on connecting.

screen /dev/ttyTHS1 115200 produces a black screen, no prompt.

I also attempted to establish a connection to /dev/ttyTHS1 and baud 115200 using pyserial and listen for some kind of response, however this gave nothing.

My Question

So my question is, if it is possible, how can I connect to the raw Micropython REPL directly over UART and send commands to the D1, and otherwise how can I establish my own connection on each side to send strings between the two devices?

This is the first time I'm attempting to use UART in this way and I am not overly familiar with micro python (I rarely venture out my IDE into the world of IoT projects) so I could be making some big oversights.

I understand this is a rather wide problem, and I wouldn't usually post something so open ended on here but I haven't been able to narrow this down and I am limited to a schedule with the project so all help would be appreciated.

Jack Walton
  • 181
  • 11
  • Troubleshoot the D1 with an oscilloscope (or really anything that can indicate that it's doing something ... an LED even). Once you know the D1 is doing something try the REPL again. If nothing, troubleshoot the Jetson. I've been in your shoes a few times. You have 2 boards and at least one problem. Figure out which board is the problem, first. If you have an oscilloscope, use it. Being able to see the waveform of what those pins are outputting is priceless. With just an LED or multimeter all you know is "something" is happening, but that "something" could be just a bunch of noise. – OneMadGypsy Apr 18 '21 at 16:00
  • There are free oscilloscope programs. Usually they work via the microphone jack. One of those is better than nothing, at all. You'll have to destroy a pair of earbuds, and some alligator clips might be helpful. – OneMadGypsy Apr 18 '21 at 16:05
  • Hi Michael, as much as id love to get my hands on an oscilloscope the student budget doesn't quite allow it (and unfortunately Unis are still closed). I'll definitely look into oscilloscope software sounds like it could be pretty useful here and in future. Cheers! – Jack Walton Apr 19 '21 at 11:23
  • One thing you might want to consider is finding free oscilloscope software that works over USB. The reason is: headphone wire tends to practically be fabric. USB wire tends to be more like proper wire. All this is under the assumption that you don't have parts laying around that you can simply make a compatible wire from. If the assumption is correct, I would strip a USB cable, before trying to get a connectable hair out of some earbuds. You'll probably need a USB cable that has the data leads. Cheap 'Gas station" cables probably won't cut it. – OneMadGypsy Apr 19 '21 at 14:22
  • Only thing I'm missing wires wise is the USB/jack connector. Luckily I have a stash of USB data cables iv collected over time for this reason, so I'll happily cut open one of those and attach some gpio wires with a drop of solder. – Jack Walton Apr 20 '21 at 12:32

1 Answers1

2

So my question is, if it is possible, how can I connect to the raw Micropython REPL directly over UART and send commands to the D1, and otherwise how can I establish my own connection on each side to send strings between the two devices?

I have MicroPython (v1.14) running on a Wemos D1 mini. I'm currently using this to connect to the REPL over the UART. I didn't have to make any configuration changes to the D1 itself; the entire process was:

  1. Connect TX wire from serial adapter to RX pin on D1
  2. Connect RX wire from serial adapter to TX pin on D1
  3. Run picocom -b 115200 /dev/ttyUSB0

I was also able to get it to work by connecting directly from the TX/RX pins on a Raspberry Pi (Pi TX -> D1 RX, etc...), also using picocom (although in this case, the serial port on the Pi was /dev/ttyAMA0).


In addition to the diagnostic steps suggested by Michael Guidry, if you have any other devices available locally (another Jetson? A Raspberry Pi? Something else?) that you can use to establish a "known working" configuration (that is, a configuration in which you're able to successfully communicate using the Jetson's serial pins), that gives you a good starting point.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • With regards to the serial adapter unfortunately I have quite limited access to usb ports on the Jetson (it has to fit into a miniature mars rover for a national student competition, the chassis of which has already been designed and manufactured). I do have a RPi to hand and its useful to know you were able to use picocom to access the REPL directly. Testing Pi to Jetson and Pi to D1 is definitely my next step however may become time consuming (as with everything in this project the pi nor the software I used to program the D1 are working off the bat either.) – Jack Walton Apr 19 '21 at 11:29
  • Thanks for your time, I'll come back with more info once I have had time to try these things out (I will accept answer then) – Jack Walton Apr 19 '21 at 11:30