<< return to Vizycam.com

Serial input/output examples?

Hey there, I’m looking at https://docs.vizycam.com/doku.php?id=wiki:api_vizypowerboard#vizypowerboard.VizyPowerBoard.io_set_mode and see that I can use some of the pins on the power board for serial input/output… are there any examples that do this that I can review?

Thanks!

Hello,
To use the serial port, here is some code you can run in Python:

import serial
import vizy.vizypowerboard as vpb
v = vpb.VizyPowerBoard()

# set channels 2 and 3 to serial (get out of the way of serial communication)
v.io_set_mode(2, vpb.IO_MODE_SERIAL)
v.io_set_mode(3, vpb.IO_MODE_SERIAL)

# open serial port, 115K baud
ser = serial.Serial('/dev/serial0', 115200, timeout=0.1)
data = ser.read(5) # read 5 bytes
ser.write(b"hello") # write some bytes

Hope this helps!

Edward

Thanks, I was wondering which device to use, that does the trick!