Close

Arduino serial reset

A project log for R'lieh - Aquarium/ closed ecosystem management

An automated and connected aquarium management system

Audrey RobinelAudrey Robinel 05/22/2015 at 17:500 Comments

I encountered something that caused me trouble today. I set up the system for real world use, but each time i was sending a command to the arduino, i was having the relays turning of prior to everything.

Here is a quick test code :

#!/usr/bin/python
from time import sleep
import serial

print("opening serial")

ser = serial.Serial("/dev/ttyUSB0", 9600)
waitTime1=0.2

print ("waiting")
sleep(waitTime1)
print("sending cmd")
ser.write("R1Off")
sleep(waitTime1)
ser.write("R2Off")
sleep(waitTime1)
ser.close()
sleep(waitTime1)
This one turns off the relays, and there is another file for turning them on.

The problem was that on connect, all relays shut down. I figured out that when a serial connection is established to the arduino, it resets. Hence the shutdown of the relays. in order to handle that, the solution is to put a capacitor between the vcc line and the reset pin :

http://forum.arduino.cc/index.php/topic,28723.0.html

I don't yet know the minimal value that can be used, but it works with 220µF.

Thanks to this, i was able to have the commands working without resetting anything. I thus don't have to have a daemon connected to the arduino handling requests from other programs.

Discussions