Electron - digitalread turns off PIN?

I have been using an Electron for several years as a very basic control to turn on heat at our remote cottage. It is connected to a Particle relay board and I have been using one of the relays to turn on a heater at the cottage.

As we don't have Internet service at the cottage I have been using the Electron with SIM card and to keep costs down I was using the Tinker app to simply turn on pin 3, which enabled relay 1 and turned on my heat (I did this before leaving my house). Subsequently, when leaving I would use Tinker to turn off Pin 3, which would turn off the relay (and heat).

This fall I noticed that Tinker is no longer available as an app so I was trying to use the Web console and the digitalwrite and digitalread commands to set pin 3 high or low. The console allows me to key a value but it seems to have no effect on the Electron, even though it shows online in the console.

So far, the only way I have been able to enable pin3 is using the CLI. If I issue a digitalwrite D3,HIGH the relay will turn on. The problem I am having is if I try to check the status remotely and use the CLI with digitalread D3, it turns the relay off. In the past this would simply list a status of 1 or 0. With the way it works now when I am remote from the device, I have no idea if the relay is on or not.

Any idea why a digitalread would turn the relay off? Any idea why using the Web Console digitalread and digitalwrite commands seem to have no effect?

I apologize if this seems a simple question, it has honestly been several years since I set this up and looked at this. Any help would be appreciated.

Hey @ruggles531. The Tinker application does indeed change the pin mode when reading or writing to a digital pin. So it changes to INPUT mode every time you do a digitalread command and to OUTPUT mode when a digitalwrite command is used. Since the digitalread command sets the pin as an INPUT, it no longer drives the relay, turning it OFF.

As you indicated, the Particle mobile app is no longer supported but he Tinker functionality is available as a web page.

For your application where you want to "read" the relay setting, it is possible to create a modified version of the Tinker code which, instead of doing a regular read for pin 3, would instead return the on/off state of the relay that can be stored in a variable by the digitalwrite command. Hopefully that makes sense.


Thanks for the info about Tinker. I didn't realize it was still available but will take a look at this.

1 Like