1

I have simple app in python that should send data through serial port (serial0/ttyS0):

import RPi.GPIO as io
import time
import serial
import array

io.setmode(io.BCM)

ser = serial.Serial(port="/dev/serial0",
                        baudrate=38400,
                        parity=serial.PARITY_NONE,
                        stopbits=serial.STOPBITS_ONE,
                        bytesize=serial.EIGHTBITS,
                        xonxoff=False,
                        rtscts=False,
                        timeout=1)

text = "200\r\n"
ser.write(bytes(text.encode('ascii')))

And this app won't to send me data through serial port. How can I check if it really send anything? Maybe I can measure voltage on GPIO pin?

5
  • what's connected to the other end of the serial port? perhaps you have rx and tx connected incorrectly? Jan 15, 2018 at 3:00
  • To the serial port IR sensor are connected. RXD works, I get data when IR receive signal, but I cannot send signal from the second IR sensor that is connected to TXD
    – Robert
    Jan 15, 2018 at 7:05
  • 1
    so, TXD is connected to an IR emitter I hope (a sensor won't emit IR, it resieves it) - do you know how to check if anything is being sent via the IR emitter? if you have a mobile phone with a camera, watch the sensor through the camera when sending Jan 15, 2018 at 7:13
  • Yes, you're right. I've checked IR emitter and it emitted only one time. I've checked as you wrote - by using camera from phone. Then when I run application several times after this first time the senser (IR emitter) doesn't emit signal (I don't see nothing in camera). I restarted RPi but without result
    – Robert
    Jan 15, 2018 at 15:01
  • It works, problem was with text, it shoudn't contains \n at the end, probably python add eof by default. I removed \n and now it works
    – Robert
    Jan 17, 2018 at 11:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.