UART Loop

General discussion about topics related to OpenMV.
Tim H
Posts: 5
Joined: Tue Apr 24, 2018 11:21 am

UART Loop

Postby Tim H » Tue Jun 05, 2018 8:26 am

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))
    
User avatar
kwagyeman
Posts: 2407
Joined: Sun May 24, 2015 2:10 pm

Re: UART Loop

Postby kwagyeman » Tue Jun 05, 2018 11:46 am

Please use uart 3. Also, use the any() method to check for bytes first followed by read() if there are bytes.
Nyamekye,
Tim H
Posts: 5
Joined: Tue Apr 24, 2018 11:21 am

Re: UART Loop

Postby Tim H » Thu Jun 07, 2018 6:02 am

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())
User avatar
iabdalkader
Posts: 596
Joined: Sun May 24, 2015 3:53 pm

Re: UART Loop

Postby iabdalkader » Sun Jun 24, 2018 5:57 pm

Try a higher timeout_char (1000).
OutoftheBOTS
Posts: 88
Joined: Tue May 29, 2018 4:15 am

Re: UART Loop

Postby OutoftheBOTS » Sun Jun 24, 2018 6:01 pm

U do know that u need to connect the TX (transmit pin) one device goes to the RX (receive pin) on the other device.
Tim H
Posts: 5
Joined: Tue Apr 24, 2018 11:21 am

Re: UART Loop

Postby Tim H » Tue Jul 03, 2018 5:09 am

Sure, all works fine, the cable wasnt that good connected. But works fine

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 291 guests