question about linux computer with Arduino and relais / relay

Thread Starter

drspro

Joined Jun 23, 2022
6
dear Forum,

I have a circuit running which scans a QR code through Sparkfun scanner connected in serial port , Python receives this code
and connects with Arduino on other serial port ,

arduino makes a Call to a 5 Volt relais.

the problem is that the serial connection from the computer to arduino gets lost periodically after 2 days.

in my opinion this should occur as a following of a electro magnetic Flux caused somewhere.

after I reconnect with Python everything works again as it should.

my question: how can i avoid this Disconnect?

I already made a Metal box with grounded around the arduino ,

Should I place a Diode in the wire which goes to the Relais?

I thought that most relais already have stuff aboard to avoid Fluxes?

Thankyou
 

strantor

Joined Oct 3, 2010
6,685
the serial connection from the computer to arduino gets lost periodically after 2 days.

in my opinion this should occur as a following of a electro magnetic Flux caused somewhere.

after I reconnect with Python everything works again as it should.
What is the error and traceback information provided by python?

I have experienced a similar issue (perhaps the very same issue, not enough information to say 100%) issues but it had nothing to do with EMI. It was caused I think by non-ideal driver which emulates a hardware COM port, such as the USB COM port that arduino uses. It is like a buffer fills up somewhere; not the serial data buffer, but another one related to emulated hardware resources - I suspect a memory leak. I don't remember exactly the terminology but if you post the trace back I will be able to recognize it (or not). The result was that after a few days my python script would lose the ability to use the emulated COM port, but if I would stop the script and re-run it, it would work just fine.
 

Thread Starter

drspro

Joined Jun 23, 2022
6
dear Strantor, thankyou for your information,
i do not receive any error messages from python,

python script keeps behaving and active,

only the arduino doesnt open the relay anymore.

I use Ubuntu 20 in this computer, so in your information
I could look to try to update the Ubuntu serial port drivers?

thankyou
 

strantor

Joined Oct 3, 2010
6,685
dear Strantor, thankyou for your information,
i do not receive any error messages from python,

python script keeps behaving and active,

only the arduino doesnt open the relay anymore.

I use Ubuntu 20 in this computer, so in your information
I could look to try to update the Ubuntu serial port drivers?

thankyou
If you are not getting any error in Python then I think you are having a different issue than what I described

When you said this:
after I reconnect with Python everything works again as it should.
...what did you mean exactly?
When you terminate and re-start the python script?
When you reset the arduino?
something else?
 

Thread Starter

drspro

Joined Jun 23, 2022
6
* When you terminate and re-start the python script?

Yes: after terminate and re-start the python script

the relais and Arduino is working again without error messages

( before that the arduino and relais do not react upon
python serial messages , serial port seems to be lost )
 

strantor

Joined Oct 3, 2010
6,685
* When you terminate and re-start the python script?

Yes: after terminate and re-start the python script

the relais and Arduino is working again without error messages

( before that the arduino and relais do not react upon
python serial messages , serial port seems to be lost )
That is strange. There should be an error if the serial messages are not being sent. Maybe your issue is like mine, but you get no error.

What I would suggest is don't just simply send commands to arduino. Program arduino to send a confirmation reply in response to received commands. Make your python script send the command, then wait for the reply. If no reply comes within a few seconds, the python script closes the COM port, deletes the serial.Serial object, creates a new serial.Serial object, reopens the COM port, then attempts to send the command again. That is how I got past my issues.
 

Thread Starter

drspro

Joined Jun 23, 2022
6
dear Strantor,

thankyou for the information, i will try to use this solution, i will enhance the python code and arduino code,

your information helped me to go on this path.

when succeeded i will post it here


thankyou
 
Top