I agree. I also changed the code to 2 bytes assuming less data means also less change for corrupted data. Ok let´s merge then the two threads. Who can do that?
A moderator, click on the flag on your last post and ask them to merge the two threads.
Hello,
i probably have an Arduino failure due to parasitic power when i use the main power off switch in my project. This main switch powers off all devices apart of the PC and the UNO powered via USB 24/7. I don´t know if it happens on power off or on or both. I look for guidance on how to protect the UNO of getting stuck and needing a reset.
All gear and wires a very close to each other (20 cm next to the cable shaft) due to the very limited space. I can not say where the possible parasitic power comes from and jams the UNO. Everything works fine once all is powered up and the PC gets a reboot or is switched on after the main switch is on. The aim is that the PC runs 24/7 while the other gear is cut from power completly if the installation is not used.
Based on your drawing, you can not have a parasitic power problem. There must be more to that drawing.
What is all connected to the Uno?
You show a loop with 8m of Ethernet wire on one side of a switch going to an Arduino pin and the other side of the switch to gnd via a very different route. Is this accurate? Loops like that are perfect for picking up noise, noise causes all sorts of problems.
Just the the switch and the USB cable. The UNO is in a metal case. No Wifi.
No this is no correct, sorry. It is a ll in one ethernet cable which runs in the cable shaft.
Is the switch across one pair of the cable, or have you used wires from 2 different pairs? The switch must use one pair, not 2 pairs, this is essential for noise reduction. If the other pairs are not used you could also connect both wires of each unused pair to gnd at one end of the cable (only one end).
If none of that help then I have no further ideas based on that diagram.
Connect the case to gnd, if not already connected.
Could it be another probelm that is triggered by the main power off/on? Maybe my assumption of parasitic power is totally wrong?
Can I connect it to the ground of the USB port or any ground on the Arduino board?
Running long cables directly connected to I/O pins is never a great plan.
You need to look at opto isolation for such signals .
( inputs to Arduino are high impedance , and therefore very sensitive to interference )
Connect to ground on the Arduino board. What do you mean by 'ground of the USB port'? Is that not also on the Arduino board? It is the same thing.
I think your assumption is. Parasitic power means that one device that is powered powers a non-powered device through the input signals (e.g. two Unos connected together).
@PerryBebbington is (and others here are) far more experienced in hardware than I am. But I think that with long wires you should add some filtering at the Arduino side.
Here is a link that I found; the first image shows a simple RC filter, the second one is more comprehensive.
To be clear:
The only thing I can see based on that diagram that might cause problems is the long cable to the switch, so, either that's the cause of the problem or something else is going on. Given that the diagram did not correctly show the switch wiring I am suspicious that the diagram is wrong in other ways. If trying the suggestions you already have doesn't fix the problem then please create a new diagram having more care about its accuracy and post that as a new reply (leave the old diagram where it is). Some photos might help too.
Thank you.
Connecting pin8 to ground without a resistor is a dead short.
I would disconnect the Uno from the Usb3 power supply that runs in the duct. Then, I would run a power supply from the computer to the Uno avoiding the mains cables. See if that makes a difference.
I would also disconnect any other devices from the computer, and introduce them one at a time, just in case they are picking up transients.
Thanks so far. i will apply / try all suggestions asap. The installation currently in use so i have to wait until tomorrow.
This wont work, i transmit the data via usb to a python application.
Of course it is; but that is not a problem if a pin is configured as input (with or without (internal) pull-up resistor). How else would you connect a switch?
I do beg your pardon. Heaven knows what I was thinking when I wrote that!
: ) No worries at all. I am so happy people here helping me.
