0

I am trying to wire a fss1-102z 5v ssr relay to my arduino nano but i cant get it to work here is my circuit. It stays stuck on and i cant get it to turn off.

enter image description here

Bluetooth control code

char val;         // variable to receive data from the serial port
int ledpin = 2;  // LED connected to pin 2 (on-board LED)

void setup()
{
  pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
  pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT

    Serial.begin(9600);       // start serial communication at 115200bps

}

void loop()

{
  if( Serial.available() )       // if data is available to read
  {
    ;
  }
  val = Serial.read();         // read it and store it in 'val'

  if( val == 'a' )               // if 'a' was received led 2 is switched off
  {
    digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2
  }

  if( val == 'A' )               // if 'A' was received led 2 on
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
  }

  if( val == 'b' )               // if 'b' was received led 3 is switched off
  {
    digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3
  }

  if( val == 'B' )               // if 'B' was received led 3 on
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
  } //else (ledpin = 3, LOW)        //set led pin 3 to low state

  if( val == 'C' )               // if 'C' was received led 2 on for 1 second
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
  }

  if( val == 'D' )               // if 'D' was received led 3 on for 1 second
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin, HIGH);      // turn Off pin 3
  }

  if( val == 'E' )               // if 'E' was received led 2 on for 5 seconds
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
    delay(5000);                     // wait 500 milli seconds
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
  }

  if( val == 'F' )               // if 'F' was received led 3 on for 5 seconds
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
    delay(5000);                     // wait 500 milli seconds
    digitalWrite(ledpin, HIGH);       // turn Off pin 3
  }

  if( val == 'G' )               // if 'G' was received turn led pin 2 on for 500ms then switch off and turn on pin 3 for 500 mili seconds then off
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
    delay(500);                     // wait 500mili second
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 2
    delay(500);                     // wait 500 mili second
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
  }

  if( val == 'h' )               // if 'h' was received switch off all pins
  {
    digitalWrite(ledpin = 13, LOW);    // turn Off pin 13
    digitalWrite(ledpin = 2, HIGH);      // turn Off pin 2
    digitalWrite(ledpin = 3, HIGH);      // turn Off pin 3
}

  if( val == 'H' )               // if 'H' was received switch pin 2 on and off 1000 times

  for(int i = 0; i < 1000; i++)
  {
    digitalWrite(ledpin = 2, HIGH);  // turn ON pin 2
   delay (1000); //wait 1000 mili seconds
    digitalWrite(ledpin = 2, LOW);  // turn Off pin 2
   delay (1000); //wait 1000 mili seconds

  }

}
2

According to its datasheet, the FSS1-102Z doesn't work with DC-voltage. Also the minimal voltage required is 50VAC. Here is the excerpt from the datasheet:

enter image description here

| improve this answer | |
  • @jfpoilpret So when i hook it up to a 240v 80w pump it will work fine? – Timothy Oct 11 '14 at 20:59
  • 1
    Yes, 240V AC will work with this SSR (just be careful). 80 Watts is around 0.4A, so well below the maximum 2A rating. – Gerben Oct 11 '14 at 21:09
  • @jfpoilpret Should i put a diode on the input to stop current back-flow or is that only needed with coil relays? – Timothy Oct 12 '14 at 0:46
  • It's Photo Isolated, so a diode isn't needed. Though I find it kind of strange that there is a coiled-relay, inside a solid state relay. Solid state generally means there are no moving parts. Most SSRs use triacs, I think. – Gerben Oct 12 '14 at 18:31
  • so i can just wire it like in the image but to a 240v load? – Timothy Oct 12 '14 at 23:23
0
  • Is it really 5v relay?
  • Need your code.
  • Check your output is really 5v.

You do a lot of mistakes:

Int ledPin2=2;
Int ledPin3=3;
...
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
...
digitalWrite(ledPin2,HIGH);

I am on way now. I will edit and my answer when get back. Now correct your code

EDIT

You should improve your code... I edited it with switch cases. Also edit your comments because they are wrong!!! In the end there is Serial.printout states of pins. If you want uncomment them.

Here is the edited code:

char val;         // variable to receive data from the serial port
int ledpin2 = 2, ledpin3 = 3, ledpin13 = 13;  // LED connected to pin 2 (on-board LED)
bool status = true;

void setup()
{
  pinMode(ledpin2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
  pinMode(ledpin3, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  pinMode(ledpin13, OUTPUT);
  Serial.begin(9600);       // start serial communication at 115200bps

}

void loop()

{
  if( Serial.available() )       // if data is available to read
  {
  val = Serial.read();         // read it and store it in 'val'
  switch (val){
    case 'a':
    digitalWrite(ledpin2, HIGH);    // turn ON pin 2
    status = true;
    break;

    case 'A':
    digitalWrite(ledpin2, LOW);
    status = true;
    break;

    case 'b':
    digitalWrite(ledpin3, HIGH);
    status = true;
    break;

    case 'B':
    digitalWrite(ledpin3, LOW);
    status = true;
    break;

    case 'C':
    digitalWrite(ledpin2, LOW);  // turn OFF pin 2
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin2, HIGH);      // turn ON pin 2
    status = true;
    break;

    case 'D':
    digitalWrite(ledpin3, LOW);  // turn OFF pin 3
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin3, HIGH);      // turn ON pin 3
    status = true;
    break;

    case 'E':
    digitalWrite(ledpin2, LOW);       // turn OFF pin 2
    delay(5000);                      // wait 500 milli seconds
    digitalWrite(ledpin2, HIGH);      // turn ON pin 2
    status = true;
    break;

    case 'F':
    digitalWrite(ledpin3, LOW);  // turn ON pin 3
    delay(5000);                     // wait 500 milli seconds
    digitalWrite(ledpin3, HIGH);       // turn Off pin 3
    status = true;
    break;

    case 'G':
    digitalWrite(ledpin2, LOW);  // turn ON pin 2
    delay(500);                     // wait 500mili second
    digitalWrite(ledpin2, HIGH);      // turn Off pin 2
    digitalWrite(ledpin3, LOW);  // turn ON pin 2
    delay(500);                     // wait 500 mili second
    digitalWrite(ledpin3, HIGH);      // turn Off pin 2
    status = true;
    break;

    case 'h':
    digitalWrite(ledpin13, LOW);    // turn Off pin 13
    digitalWrite(ledpin2, HIGH);      // turn Off pin 2
    digitalWrite(ledpin3, HIGH);      // turn Off pin 3
    status = true;
    break;

    case 'H':
    for(int i = 0; i < 1000; i++)
  {
    digitalWrite(ledpin2, HIGH);  // turn ON pin 2
    delay (1000); //wait 1000 mili seconds
    digitalWrite(ledpin2, LOW);  // turn Off pin 2
    delay (1000); //wait 1000 mili seconds
  }
  status = true;
    break;
  }
  }

  /* Print out state of pin */
  /*
  if (status) {
   Serial.print("ledpin2 = ");
   Serial.print(bitRead(PORTD,2));
   Serial.print(" ,ledpin3 = ");
   Serial.print(bitRead(PORTD,3));
   Serial.print(" ,ledpin13 = ");
   Serial.println(bitRead(PORTD,7));
   status = false;
  }*/
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.