Go Down

Topic: LCD messes up whenever my relay turns on (Read 7600 times) previous topic - next topic

konke

I'm using a 16x2 LCD http://www.seeedstudio.com/depot/lcd-162-characters-green-yellow-back-light-p-62.html?cPath=163_164, and whenever my relay turns on, the LCD screen either spits out garbage, or turns off completely. My relay turns on and off every 10 minutes.

The relay I am using comes from the Sparkfun tutorial http://www.sparkfun.com/tutorials/119. I'm using the Ds18B20 temp sensor to output to the LCD.

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.

Suggestions please :)

robtillaart

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.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

konke

Code: [Select]
// 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);
  }



konke

#3
Apr 19, 2011, 03:57 am Last Edit: Apr 19, 2011, 04:02 am by konke Reason: 1




http://blog.chrisgilmer.net/wp-content/uploads/2009/03/Arduino-Controlled-Relay-Box.pdf
I used this exact tutorial when making my relay box.

The LCD/temp sensor is hooked up exactly like this http://arduinotronics.blogspot.com/2010/12/two-ds18b20-temp-sensors-on-lcd-display.html

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.

floresta

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?


Don

konke

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.

liuzengqiang

Grow light? Arduino controlled weed house?!  :smiley-mr-green:

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.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

floresta

#7
Apr 19, 2011, 05:51 pm Last Edit: Apr 19, 2011, 05:54 pm by floresta Reason: 1
Quote
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.

Don

liuzengqiang

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.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

konke

:) ok guys, I'll get those pics up ASAP. I also drew a ghetto circuit diagram on paper  :D

konke

#10
Apr 19, 2011, 09:44 pm Last Edit: Apr 19, 2011, 09:46 pm by konke Reason: 1



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.

liuzengqiang

Alright. I think the resistors look right. How about the direction of the diode? Are you sure you got it currently orientated?
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

konke

Hey guys, still can't figure it out.

I checked all my connections, the diodes are the right way. Is there anything I can do to help see what is exact source of the problem?

I have no idea what to do at this point. Remember, it only starts bugging out when the relay is activated and completes the load to the wall outlet.

floresta

Try a non-GFI outlet and see if that makes any difference.

Don

konke

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.

Go Up