Switch wiring for dummies
https://industruino.com/forum/help-1/question/switch-wiring-229
I'm a mechanical engineer, no so electrically inclined, so I'm trying to follow the above switch wiring and I'v got the positive side of my power supply connected through a cheap float switch from Amazon good for 1/2 an amp current. I keep welding the contacts, At first I had it wired to ground as the post stated exactly as stated, but I kept welding the contacts and I'm pretty sure I kept tripping the overcurrent protection on that pin. I thought I had it fixed by wiring the positive to the input, but alas, it welded it again. Is this an issue with it being a cheap float switch or is this an issue with magnetic field flyback which I don't see how since I'm not using a relay. I just need a simple make or break signal to tell me a drain pan is full, or is this simply a matter of too much current. I'm running off of a 100 watt 24 volt power supply (we had it on hand) . Can I solve this with a 1n4004 diode and a resistor or something? I ordered a better float switch good for 20VA which is what close to 1 amp. Like I said, I'm a mechanical guy, I can design you an air conditioner, but struggle a little with electrical stuff.
Wired it like this the 2nd time
"Hi Albert, the wiring you describe is correct, you can connect the 24V of your PSU to a digital I/O channel of the IND.I/O via your switch. As far as i know, the best way would be to first declare the channel as digital output, write LOW to it, then change it to digital input, e.g. in the setup of your sketch.
Convert as an answer
on 10/9/16, 7:17 AM
Hi Tom. So there is no need to connect any resistor in between the psu and digital input? I can connect V+ from psu straight to digital input when switch is on?
I wired it like this first time:
"Hi Albert, that's right, you don't need a resistor between PSU and digital I/O. But as Stefano mentions, it's probably a good idea to use GND for your switch instead of 24V; define the channel as digital output, write HIGH (to enable the pull-up resistor), change the channel to digital input and read LOW when the switch is on."
I guess it's the current. I have the same code flashed to the Proto unit and have one end of the switch connected to the ground and one end connected to D4 and it seems to be fine...even with the same 24 volt 100W power supply hooked up. Thinking about adding a resistor to the circuit and see if that helps.
Ok I’ll give your code a try tomorrow and see what’s going on. Thanks!
Hi, i assume you mean the contacts are melting due to a high current passing through. That is strange; when i connect V+ (from the PSU) straight to an input channel (CH1), i measure only 4mA going through, hardly enough to melt anything.
Can you try with this basic code. It indeed forces CH1 to LOW for a very short time on startup, but that goes so fast it does not short circuit the system. If you insist, you can add a resistor in series with the switch, e.g. 500ohm 1W. Or a higher resistance and lower wattage, but you need to make sure the input channel sees at least 11V to read HIGH.
#include <Indio.h>
#include <Wire.h>
#include <UC1701.h>
static UC1701 lcd;
void setup() {
SerialUSB.begin(9600);
lcd.begin();
Indio.digitalMode(1, OUTPUT); // Clear CH1 to LOW
Indio.digitalWrite(1, LOW); // Clear CH1 to LOW
Indio.digitalMode(1, INPUT); // Set CH1 as input
}
void loop() {
lcd.setCursor(1, 3);
lcd.print(Indio.digitalRead(1)); // show 0 or 1
delay(1);
}
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 1/8/19, 5:18 PM |
Seen: 2054 times |
Last updated: 1/9/19, 1:55 AM |
Ok I’ll give your code a try tomorrow and see what’s going on. Thanks!