TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: DENNIS LEE BIEBER
date: 2019-08-09 16:40:00
subject: Re: GPIO problem

On Fri, 9 Aug 2019 20:34:12 +0100, Adrian  declaimed
the following:


>Strangely, the behaviour today has changed.  Rather than consistently
>registering an "on" state, it is doing it on an intermittent basis.
>

 Sure sounds like it needs either a pull-up or a pull-down... random
currents could be taking the voltage above and below the threshold for 1/0
state (Note that most IC modes have a dead zone between 1/0 where anything
can happen. For CMOS that is normally 30-70% -- on a 3.3V system, that
would mean ~2.4+V => 1, 1.0-V => 0, and 1.0-2.4 could give anything)

 Documentation implies that it uses the internal pull-up (and the sensor
tips it to LOW/GND) -- but if that has failed, you might need an external
resistor connecting the GPIO to 3.3V

 Alternatively, since this is a rain gauge (based upon your comments in
the source code) -- possibly the switch circuit has gotten wet and is
conducting (grounding) the output.


 Just as an aside: given that you are relying upon a tight mesh of

open
read/write
close

you might want to consider using a context manager style in the code

with open() as fid:
 read/write

 The context manager will automatically close the file on block exit.


--
 Wulfraed                 Dennis Lee Bieber         AF6VN
 wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.