Page 1 of 1

UART Loop

Posted: Tue Jun 05, 2018 8:26 am
by Tim H
Hello, sorry for that Noobish Question, but how can i send a UART Message to the M7 back. I connected a Cable on both Pins. Rx and Tx but i get no answer. the read is still None.
Is there anything i miss to implement?

Greets Tim

Code: Select all

import time
from pyb import UART
from pyb import LED

#LED Control -----------------

red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
ir_leds = LED(4)

# Always pass UART 3 for the UART number for your OpenMV Cam.
# The second argument is the UART baud rate. For a more advanced UART control
# example see the BLE-Shield driver.
uart = UART(1, 19200, bits=8, parity=None, stop=1, timeout_char = 10)


while(True):

    blue_led.on()
    time.sleep(1000)
    blue_led.off()
    uart.write('Hallo\n')
        
    print(uart.read(5))
    

Re: UART Loop

Posted: Tue Jun 05, 2018 11:46 am
by kwagyeman
Please use uart 3. Also, use the any() method to check for bytes first followed by read() if there are bytes.

Re: UART Loop

Posted: Thu Jun 07, 2018 6:02 am
by Tim H
mhh ok is there anything i have to look to it, cause i get no message back, i use the pins 4 and 5, but still noch message is incoming.

Code: Select all

import time
from pyb import UART
from pyb import LED

#LED Control -----------------

red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
ir_leds = LED(4)

# Always pass UART 3 for the UART number for your OpenMV Cam.
# The second argument is the UART baud rate. For a more advanced UART control
# example see the BLE-Shield driver.
uart = UART(3, 19200, bits=8, parity=None, stop=1, timeout_char = 100)


while(True):

    blue_led.on()
    time.sleep(1000)
    blue_led.off()
    
    uart.write('Hallo\n')
    uart.any()    
    print(uart.read())

Re: UART Loop

Posted: Sun Jun 24, 2018 5:57 pm
by iabdalkader
Try a higher timeout_char (1000).

Re: UART Loop

Posted: Sun Jun 24, 2018 6:01 pm
by OutoftheBOTS
U do know that u need to connect the TX (transmit pin) one device goes to the RX (receive pin) on the other device.

Re: UART Loop

Posted: Tue Jul 03, 2018 5:09 am
by Tim H
Sure, all works fine, the cable wasnt that good connected. But works fine