Pages: [1]   Go Down
Author Topic: serial interface with raspberry pi (python)  (Read 1768 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 2
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone,

i have an arduino MEGA which controls my aquariums light, pumps and also senses temperatures via 2x ds18b20... The sketch runs good but when I connect the mega via the USB to the raspberry pi in order to send email alerts, monitor and other userful, the mega reboots everytime the serial port is opened by the python script...

The script runs 24/7 and is monitored by a supervisor so  when the process dies off for some reason it starts back up again, but everytime this happens the arduino reboots... I tried putting a 110ohm resistor as stated in this link: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection
the resistor didnt work, I also tried disabling hangup on the linux terminal with no luck: stty -F /dev/usbTTY0 -hupcl

anyone know what else I can try?

Here is the open serial function from the python script:

Code:
port='/dev/ttyACM0' #port that arduino is plugged in to
global tank_temp, led_temp, blue, white #variables to monitor
global start
flag = False
start = 0

def Open_serial():
    global ser
    ser = serial.Serial(port,9600)
    ser.flushInput()
    time.sleep(1)


    global child
    fd = os.open(port, os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY)
    child = fdpexpect.fdspawn(fd) # Note integer fd is used instead of usual string.
    child.logfile_read = sys.stdout
    child.logfile_send = sys.stdout
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I added a 1uF cap to the reset-gnd pins, it hasnt rebooted since... hopefully it stays that way
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it's working... the 110 resistors didnt work, or the hangup on close disabling... but the cap worked like a charm! Hope this helps someone else!
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13676
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for sharing!
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: