Not sure if it is the best place to post this… I am sorry If not.
My problems is with arduino interrupts.
(Mainboard used is Arduino UNO. (I will switch to mega, since the sketch is getting too big for a UNO))
I made a weather station … all good and working great, except the rain sensor (who has a reed relay) and it’s working with interrupts to count rain. (on Pin 2)
Problem is, that sometimes, it counts even if the switch in the rain gauge is not activated. There is not a general rule for this. Yesterday for example, it passed 1 hour without any count, then it started to count.
I will attach the code, since it is too big to post it here. The problematic part is the one that handles the RainSensorPin intrerrupt, and isr_rg void.
Intrerrupt Is used also in win sensor speed (on pin 3), and it is working great.
Attached, you see the schematic of the rain gauge connection.
It has a contact bounce time in the sketch… this value was 15, but I changed this to 1400, because it counts 3 to 4 times at a single relay switch.
The rain sensor is wired with approx. 10 m of speaker cable (red and black cable 2 x 0.35 mm ) If this matters… I even tried to put a smaller resistor instead of 10k… but no effect. Can this be a problem? I need some shielded cable? Does it pick up interference? Don’t know what to think anymore.
Even more, this morning I disconnect the rain gauge totally…and it started to count like crazy.
I did not understand why… because nothing is now connected to RainSensorPin D2. Why it detects intrerupt now?
pws-wunder.zip (5.55 KB)