[resolved] pinMode output and reset/power-on state

Hi,

I experience some troubles with an arduino UNO and a low activated relay.

Let me explain : I want to use the relay (Normaly Open) to generate a pulse (500 ms). It's working well but I generate an unwanted pulse on reset/power-on.

I read on this website the work around is to digitaWrite the pin value before setting the pin mode :
http://arduino-info.wikispaces.com/ArduinoPower

But in fact, it's not working.

Can someone explain me how to solve my problem?

It's blocking for me because I want to use the arduino to open a garage door and I may not take the risk to open the door each time I face an electrical problem.

Thanks,
Jeremy

Here is my code (I've tried to add many delay to exclude concurent access)

void setup() 
{
  // start the Ethernet connection
  Ethernet.begin(mac, ip);

  // start the server
  server.begin();
  
  // init pin mode
  pinMode(BOTTOM_SENSOR, INPUT_PULLUP);
  pinMode(TOP_SENSOR, INPUT_PULLUP);
  
  delay(1000);
  
  // init out pin value
  switchCurrentValue = HIGH;
  digitalWrite(DOOR_SWITCH, switchCurrentValue);
  
  delay(1000);
  pinMode(DOOR_SWITCH, OUTPUT);

  // init and force ip update
  updateIpTime = millis();
  UpdateIpAddress(true);
  
  //Check that all relays are inactive at Reset
  delay(4000); 
}

How about some information on this relay?

Are you energising the coil directly from an Arduino pin?
[If the coil resistance is less than 150? then that's not good.]

Do you have "that diode" placed across the relay coil? [Suspecting it's not.]

  1. Which pin is the relay connected to?

  2. Are you controlling it with an NPN low-side transistor?

  3. If so, do you have a pull-down resistor on the base?

Thanks for your fast anwser,

In fact it is a module comming from ebay
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=390511068332&ssPageName=ADME:L:OC:BE:3160

I connect gnd to arduino gnd,
vcc to arduino 5v pin
and in1 to arduino pin 4

Thanks,
Jeremy

This simple code gives me the behaviour

If I pin IN1 to pin4 I see the relay activated for 1 second,
If I pin IN1 in another pin (default input), i don't have the problem

I don't know what to think about this

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 4;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  digitalWrite(led, HIGH);  
  pinMode(led, OUTPUT);   
  
}

// the loop routine runs over and over again forever:
void loop() {

}

If the relay is activated with a HIGH then you don't want a pull-up and in fact you want to make that pinMode an OUTPUT and LOW as soon as possible (first thing).

I cannot tell from the ebay listing whether it has a pull-down resistor, to eliminate any "floating" condition - that would help.

Ok, sorry guys, it seems that's pin 4 is problematic with ethernet shield.

I forgot to explain this little detail.

And thanks a lot for you help.

My problem is solved.