I currently have 3.3vdc coming out of one digital pin (OUTPUT set to HIGH) into a relay then out and into another digital pin taking the current as input (INPUT set to LOW). When other (5V) circuit is energized the relay is closed and allows the 3.3v to travel from the output pin to the input pin, thus triggering an action in the firmware. I could probably use an optoisolator here as well, but for now it’s a simple 5V 1A SPST relay.
My questions are this…
Do I need to ad anything to the 3.3v out/in circuit to slow the current flow?
I am still confused on the PULLUP/PULLDOWN resistor thing. Assuming this configuration is acceptable, what do I need to specify for the INPUT pin, INPUT_PULLDOWN or just INPUT?
A pin configured as an input is purely for reading the signal presented to it from the external circuit (high or low)
Sometimes depending on your circuit you might want to make a pin an input but you might also need to tie it weakly to +v or gnd. This is where you would use a input_pullup or input_pulldown.
For example a pin configured as an input but with no pullup or pulldown and no other circuit connected could read as either high or low when read multiple times. It could bounce back and forth. Otherwise known as floating.
If that same pin was configured as input_pullup it would always read as high until it is pulled low by a circuit say for example a switch that is used to pull it to ground.
I realized I did not try to answer your first question.
So as I understand it you are using an external 5 volts that comes on occasionally and you want to take some action when that happens. So what you are doing is energizing a relay coil with that 5 volts and are using the relays contacts to make or break a connection between 2 io pins. That works. You do not need to add a resistor inline with the 2 io pins, but there might be a better approach.
Depending upon this external circuit it maybe safe to connect it’s gnd to the particle gnd and connect the +5 volt signal to 1 of the particles 5 volt tolerant io pins. Then with the pin configured as input_pulldown it will read as low until the +5 volts comes on at which point it will read high.
@HardWater, when 5V is used on a Photon pin, you CANNOT use internal pull-up or pull-down as they will be damaged! It may be easiest to take the set of contacts the OP was originally using, connect one side to the Photon GND and the other to a digital pin configured as INPUT_PULLUP. Now when the relay is energized AND the contacts actually move, the input pin will be pulled to GND, reading a LOW. When open, it will read HIGH.
@HardWater, the ARE 5V tolerant as long as pull-up or pull-down resistors are not used. From Photon datasheet:
[1] FT = 5.0V tolerant pins. All pins except A3 and DAC are 5V tolerant (when not in analog mode). If used as a 5V input the pull-up/pull-down resistor must be disabled.
I had originally thought I would send the 5V signal from the switch directly to the Photon, but then I decided instead to use the relay. I did this because I was able to maintain an analog circuits (5V) and a digital circuits (photon) independently. This way a failure of the photon logic (aka my bad programming) would not affect the analog portion of the circuit. The 5V circuit is also connected to a SSR with 110VAC on the other side, so this way it will continue to work even if the photon is offline or inoperative. Well, that’s my goal, whether it works remains to be seen.
I think I get it now… for the purposes of my 3.3v out and back in circuit, I should probably use PULLDOWN for the input pin.
@Peekay123 I am quite surprised by this. It makes sense to me that there would be a lot more commonality between the core and the photon on these pins.
Is the problem really that the core’s D port pins are not 5 volt tolerant when using pullup and pulldowns?
@HardWater, if you pull-up to 3.3v with a 5v input, you have mayhem (delta voltage). If you pull-down to GND with 5v, you have mayhem (higher current through resistor). The Core had the same issue.
OK, rather than a schematic I will try to explain.
I have a 5V circuit powered by an old cell phone charger that connects to a microswitch mounted in a door lock, then connected to a Solid State DC to AC Relay. When the door is locked, the 5V circuit is closed and the relay turns on a light fixture. Truth be told, this is a bathroom door and this way when the door is locked we can tell from across the building that the bathroom is occupied. This was all implemented a week or two ago and works great.
The second phase of this project is to use the Photon to tweet out the bathroom’s status (occupied or unoccupied) so that people in parts of the building where the light cannot be seen can determine whether they should walk to the bath room or not. In addition, I’ve connected the twitter account http://twitter.com/IGATEBATHROOM to our Slack team so that desktop and mobile notifications can be received in real-time. I’ve already got the basic configuration bench tested and everything seems to be working great.
Phase 3, is the logic where someone can reserve the bathroom by either sending DM to the bathroom’s twitter account or pressing a button on a web page which will then make the light flash for 30 seconds to indicate someone is on their way.
Yes, this is all true. I work in a technology incubator / maker space and everyone is loving the light and is eagerly awaiting twitter integration. Here’s a picture of the light.
Ahh now that makes a lot more sense to me the problem / misunderstanding has been present all along. I had not run into this on the core as I tend to use external pullups or pulldowns.
That being said I don’t think it is an impossibility for the stm chip designers to have designed for tolerance with pullup or pulldowns with a 5 volt source but what could be possible and what was actually designed for can be very different things.
@HardWater, I neglected to mention the protection diodes which are the bigger reason (reverse biasing for example). The rest of the world has moved on to 3.3, 2.5 and 1.8V but Arduino is keeping us at 5V!
Not just arduino, some sensors are 5V based also, and 5V leaves more room for noise when used for connections off board, for example one-wire.
Some S0 outputs from meters have a minimum voltage in their datasheet of 5V also, but may still work at 3.3V.
When going to 3.3/2.5/1.8V you start to need support components before cables leaving the board, of cause in a professional board thats usually a good idea anyway.