221373
Posts: 1
Joined: Mon Mar 18, 2019 2:52 pm

MAX485 + RPi + python

Mon Mar 18, 2019 2:56 pm

Hi! I have module MAX485+ to change uart to rs485. Anyone have idea how to write python program to use this module? I try use serial and RpiGpio library but my code don't work. Maybe someone have properly work code?

Code: Select all

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import serial
import os

EN_485 = 18
GPIO.setmode(GPIO.BOARD)
GPIO.setup(EN_485,GPIO.OUT)

send_str = input("Wpisz cos: ")
ser = serial.Serial(port='/dev/ttyAMA0',baudrate =9600,bytesize=8,stopbits=1,timeout=1)
last_time = time.time()
now_time = time.time()
GPIO.output(EN_485,True)
time.sleep(0.01)
n = 80
send_str=str.encode("test")

try:
    while n>0:
        print("Test5")
        ser.write(send_str)
        print("Test66")
        n=n-1
        time.sleep(1)
        print(n)

except KeyboardInterrupt:
    GPIO.output(EN_485,False)



Heater
Posts: 12716
Joined: Tue Jul 17, 2012 3:02 pm

Re: MAX485 + RPi + python

Tue Mar 19, 2019 4:17 pm

I'd probably start by not posting a Python question in the Java sub forum.

Return to “Java”