3

I just got a RPI zero w and I want to communicate to a device through serial comm. I also have a MAX232 board and a RS232 TTL converter. I want to use one of this boards to be able to communicate with that device because of what I red I can't dirrectly use the RPI's serial pins to add parity bits wich I need. I have tryed many thing to get this to work but it seems something I'm doing is wrong and can't figure it out. The code is in python and works great if I use a USB serial converter.

import time
import serial
import binascii
import re


ser = serial.Serial(
    port = '/dev/ttyAMA0',
    baudrate = 19200,
    parity = serial.PARITY_MARK,
    stopbits = serial.STOPBITS_ONE,
    bytesize = serial.EIGHTBITS,
    timeout = 2
    )


while True:
        print("Connected to: " + ser.name)
        counters = [0x01,0x0F]

        ser.write(counters)
        a = ser.read(30)
        state = binascii.hexlify(a)
        asd = re.sub(rb'([0-9, a-z, A-Z])(?!$)', rb'\1,', state)
        print(asd)

So that's the code I'm using and I don't get any data back.

These are the connections I made

I'm a beginner to all this stuff but I hope someone could help me make this work.

  • Run ./monitor.py 14 15 to see if there is any activity on the serial link. – joan Feb 2 at 18:42
  • I'm sorry but I don't know to configure that module. It gives me and error that it can't connect to that port – X Tzevu Feb 2 at 20:17
  • It requires the pigpio daemon to be running, sudo pigpiod to start the pigpio daemon. – joan Feb 2 at 21:09
  • I did run ./monitor.py 14 15 and it does nothing, just hangs in there. – X Tzevu Feb 3 at 6:37
  • That indicates nothing is being sent or received. Did you run your program after starting monitor.py ? – joan Feb 3 at 7:29
1

The RS232 converter works great aswell powered from the 3.3V on the RPI 2B. I'll get another pi zero in the future and hopefully don't burn it. Thank you for your help @joan

| improve this answer | |
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Feb 7 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.