The LCD works fine when the relay box isn't plugged into a 120V outlet, but as soon as I plug it into the wall, the LCD screen starts messing up. I'm guessing it has something to do with the current/voltage that goes through everything as soon as I plug it into the wall. My knowledge of electronics is kinda on the beginner side so is there anything I can do to remedy this?
I don't know if temp sensor/lcd/both are being affected but I know that everything works fine as long as the relay isn't plugged into my 120V power source.
PLease post code and schematics as we cannot see your project ..
possible cause:
Relay's draw a lot of current and it maybe just too much.
==> Give it a separate powersource , don't forget to connect the ground of the Arduino with the ground of the Relay's.
// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight
// Data wire is plugged into pin 8 on the Arduino
#define ONE_WIRE_BUS 8
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress insideThermometer = { 0x28, 0x58, 0xBC, 0xE3, 0x02, 0x00, 0x00, 0x71 };
//Timer
const int relayPin = 7; // the number of the Relay pin
int relayState = LOW; // Relay state when start
long previousMillis = 0; // will store last time relay was updated
long interval = 10000; // interval at which to blink (milliseconds)
void setup(void)
{
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
pinMode(relayPin, OUTPUT);
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
} else {
lcd.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(void)
{
delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);
lcd.print("Temp (F): ");
printTemperature(insideThermometer);
//relay timer
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the relay
previousMillis = currentMillis;
// if the relay is off turn it on and vice-versa:
if (relayState == LOW)
{
relayState = HIGH;
interval = 10000; // turn on for 5000ms
} // end if was low (and is now high)
else
{
relayState = LOW;
interval = 5000; // turn off for 8000ms
} // end of was high (and is now low)
// set the Relay with the relayState of the variable:
digitalWrite(relayPin, relayState);
}
All the devices receive power from the +5V on the arduino and go to the same GND from the arduino. The relay box has 3 leads, one going to the +5V (white wire) on the arduino, GND (green wire) on the arduino, and a digital output pin (black wire) to know when it turns on and off.
All work flawlessly (I can hear the relay clicking on and off)..but when it gets plugged into wall outlet (via 3 prong gray cord), it goes crazy like I said. LCD starts spitting out garbage and eventually turns off.
You have two different situations mentioned in your posts so you will have to clarify things a bit.
Original post: "and whenever my relay turns on, the LCD screen either spits out garbage, or turns off completely. "
Reply #3: "All work flawlessly (I can hear the relay clicking on and off)..but when it gets plugged into wall outlet, it goes crazy like I said."
What is the relay controlling. Do you have the problem when there is no load plugged into the circuit that the relay is controlling?
Sorry. I haven't plugged anything into the outlet that the relay controls yet. The relay is a 30A SPST relay that allows me to plug things into a GFCI outlet, which is powered by that gray cord and plugs into the wall. Eventually, I will plug a 1000W Grow Light into the relay box.
When the relay flips to the ON position and is sourcing from 120V, things get messy. I still haven't tested it when there is a load (the Growlight) plugged into the circuit that the relay is controlling. So for now, I can't even get the GFCI outlet to work either. Sometimes, even the GFCI outlet is tripped and shuts off on itself so I'm guessing that it's a problem with current.
Can you show a picture of the wiring of the relay?
Do you have a multimeter to measure current drawn from the arduino pin that controls the relay? I suspect the current exceeds maximum, 40mA on the arduino pin, this could be bad to your arduino or seeeduino.
Do you have a multimeter to measure current drawn from the arduino pin that controls the relay? I suspect the current exceeds maximum, 40mA on the arduino pin, this could be bad to your arduino or seeeduino.
The second link in his first post indicates that the relay he is using is on a pc board that also contains a transistor driver. So if he is indeed using that board then this is not the problem. The diode on that board should suppress relay generated transients but if he isn't using that board then he may not be using a diode either. We do need the picture of the relay connections.
You're right floresta! The stock picture is missing a 10K resistor (silk screen) between base and arduino pin. I hope he used the right resistor. A picture will tell.
Ok here's a pic of the relay. There is a 1N4148 diode next to the 10k resistor but you can't see it.
The 3 leads (green,black,red) go into the arduino. I guess the only thing that I deviated from was that I didn't use a 3 pin screw terminal for those leads, I just soldered the wires right to the PCB.
I'll post the circuit diagram once I get to a scanner.
I think I got it! A friend suggested to put diodes on every connection going back to the arduino and it worked haha. I used the same diodes that were used in the relay box.
I am having the same problem; can you give a little bit more information what you mean by "putting diodes on every connection going back to the arduino"? Thanks.
What I have done is used alligator clip jumper cables to "try" the diode on the offending device and see if it helps before doing a lot of soldering.
The long term solution is to solder a diode from the positive to the negative terminals of the offending device. To be honest I forget which way the diode goes! My memory tells me the diode band goes to the positive terminal. It will only work one way though, that is for sure!
I've only done this on DC devices (solenoids and relays) and it suppressed the noise that was interfering with the arduino and thus the display.
The other thing that helped was having a common ground for all the devices and the arduino.
1st_joker:
I am having the same problem; can you give a little bit more information what you mean by "putting diodes on every connection going back to the arduino"? Thanks.
That's a bit of a worry in itself, as it does not clarify what the problem was, or provide a "fix" that is meaningful in any other case; it is simply a completely random move that happened to solve the problem at that moment by accident.
The actual problem will have been one of two things, either the power supply was insufficient to reliably actuate the relay, or some impulse was being caused by switching the mains circuit, that was conveyed to the Arduino and caused an interruption of its program. It is certainly the case that there should always be a diode across the relay to absorb the inductive voltage impulse when it is turned off, the direction being such that the diode does not conduct when the relay is being energised by the transistor.
To all that have weird characters on LCD screen when you run 117 Volts from a relay using the Arduino!
This is what I found. Put a 470 uf electric capacitor across the SIGNAL pin on the relay and ground. That fixed all the issues for me.
I driving the relay with a separate power supply, which didn’t work which led me to believe It could be the signal pin and sure enough it was. Hope this works for everyone else having the same issue.
1/11/2018