UART - sending from pyboard to PC

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
ulrich
Posts: 14
Joined: Thu Nov 27, 2014 7:17 pm

Re: UART - sending from pyboard to PC

Post by ulrich » Mon Dec 08, 2014 9:13 pm

Hi Dave,

Thanks for all your hints!! - unfortunately this is not the issue as well (I've tried all variables everywherer..:)

Maybe I failed to explain the problem correctly: How do I send information from my pyboard to a program running on my PC (the latter being written in python, of course...).

I connect by USB cable using screen to the pyboard. When I enter tmp = usb.send(b'testup') - I want the string "testup" to appear in the programm running at my pc and not on the pyboard in the variable tmp.

Any ideas?

Greatings from Hambug to Canada!

Ulrich

fma
Posts: 164
Joined: Wed Jan 01, 2014 5:38 pm
Location: France

Re: UART - sending from pyboard to PC

Post by fma » Mon Dec 08, 2014 10:03 pm

Why don't you use a real UART on the pyboard, and connect it to your PC using a USB-TTL cable (FTDI)? This way, you keep your usb line for console and program transfert (using pyboard.py), and you have a dedicated serial line to send your own commands...
Frédéric

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: UART - sending from pyboard to PC

Post by Damien » Mon Dec 08, 2014 11:52 pm

The issue is that you can't connect to the pyboard's serial device (/dev/ttyACM0) with 2 different programs. In this case your 2 different programs are "screen" (to get the REPL), and your script running on your PC.

Try the following:

On pyboard run this:

Code: Select all

>>> usb = pyb.USB_VCP()
>>> def output():
...   while True:
...     usb.write("hello!\n")
...     pyb.delay(1000)
...
>>> output()
Then make sure you quit from screen/picocom/minicom.

Then run this on your PC:

Code: Select all

>>> import serial
>>> ser = serial.Serial('/dev/ttyACM0',9600, timeout=1)
>>> ser.readline()
That should work: you should get "hello\n" returned back to your PC.

ulrich
Posts: 14
Joined: Thu Nov 27, 2014 7:17 pm

Re: UART - sending from pyboard to PC

Post by ulrich » Tue Dec 09, 2014 9:57 pm

Great! Thanks a lot, this did it! Problem solved!

Knowing it now, it seems so obvious....

Adam
Posts: 2
Joined: Thu Mar 05, 2015 6:58 am

Re: UART - sending from pyboard to PC

Post by Adam » Mon Mar 09, 2015 8:42 pm

As soon as I get permission I can post up some progress I made with the hc05. Admin has me locked out from the new registration process.

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: UART - sending from pyboard to PC

Post by blmorris » Tue Mar 10, 2015 1:14 pm

@Adam - looks like your posts are showing up now. I think that once a new user has two posts that clear moderation then you can post freely.
-Bryan

priis
Posts: 26
Joined: Tue Mar 31, 2015 9:52 pm

Re: UART - sending from pyboard to PC

Post by priis » Tue Mar 31, 2015 9:59 pm

Does someone have a simple example of reading a sensor, for instance the built-in-accelerometer, and sending the value back to the computer (reading with a python-program based on pyserial)?

Poul Riis

hbgmysite
Posts: 2
Joined: Thu Apr 02, 2015 2:28 pm
Contact:

Re: UART - sending from pyboard to PC

Post by hbgmysite » Fri Apr 10, 2015 10:48 am

I still looking this thread, thanks for sharing

Post Reply