6 Replies Latest reply on Feb 12, 2015 7:34 AM by RndMnkIII

    intel edison python with uart


      Will the mraa support for the uart function on python?

        • 1. Re: intel edison python with uart

          Hello lzyun


          In 0.4.5 version they have added Uart C++ class with python & node support. So, I think it will support for uart function on python.

          For reference, you can have a look on this website mraa/index.md at master · intel-iot-devkit/mraa · GitHub



          • 2. Re: intel edison python with uart

            >>> import mraa

            >>> mraa.getVersion()


            >>> mraa_uart = mraa.Uart(0)

            >>> dir(mraa_uart)

            ['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__swig_getmethods__', '__swig_setmethods__', '__weakref__', 'getDevicePath', 'this']


            I just could not find the write or setting function like i2c.

            So, now i try to use pyserial to control the uart interface and it also works, thanks.

            • 3. Re: intel edison python with uart

              arfoll is mraa missing functions (write ...) on UART for Python?

              • 4. Re: intel edison python with uart

                mraa still doesn't haveuart capability, all we do is enable the muxes for you and can return the correct tty device to use. See mraa: Uart Class Reference.

                • 5. Re: intel edison python with uart

                  I've used libmraa and python serial libraries for Uart communication between an intel edison arduino board and an arduino mega adk board.

                  You need initialize first the uart pins used. I've used pins 0 and 1 (/dev/ttyMFD1). You can used the following code:

                  import libmraa


                  #check the port was initialized



                  You can use any example for python using serial library for continue from here. Before initialice the uart you can check and set the uart baudrate with the following commands from edison shell:

                  stty -F /dev/ttyMFD1 #check baudrate

                  stty -F /dev/ttyMFD1 9600 #Set baudrate to 9600bps


                  Edison Gnd <--------> Arduino Mega Gnd

                  Edison Tx  (pin1)<---------> Arduino Mega Rx2

                  Edison Rx (pin0)   <---------> Arduino Mega Tx2


                  In the arduino mega upload a sketch that echoes back to the edison uart the characters received from the edison to test the connection.

                  • 6. Re: intel edison python with uart

                    from time import sleep

                    import serial

                    import mraa



                    ser = serial.Serial('/dev/ttyMFD1', 9600) # Establish the connection on a specific port

                    counter = 32 # Below 32 everything in ASCII is gibberish

                    while True:

                         counter +=1

                         ser.write(str(chr(counter))) # Convert the decimal number to ASCII then send it to the Arduino

                         print ser.readline() # Read the newest output from the Arduino

                         sleep(.1) # Delay for one tenth of a second

                         if counter == 255:

                         counter = 32