Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: Solid State Relay not working w/ Teensy

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    10

    Solid State Relay not working w/ Teensy

    Hi,

    I have some questions about my first ever project using a Teensy. This is also my time trying to build anything really so sorry if I ask any really basic question.

    I'm trying to control a fan and a solenoid valve using solid state relays and a Teensy 3.2.

    Here's my code:

    int relayFan = 5; //Setting the pin of the fan
    int relaySol = 10 //Setting the pin of the solenoid valve


    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    pinMode(relaySol, OUTPUT); //Sets pin mode to output
    pinMode(relayFan, OUTPUT);

    }

    void loop() {
    // put your main code here, to run repeatedly:
    digitalWrite(relaySol, HIGH); //Turns solenoid on

    digitalWrite(relayFan, HIGH); //Turns solenoid on
    delay(5000); //Delays for 5000ms (5s)
    Click image for larger version. 

Name:	CircuitDiaTemplate.jpg 
Views:	36 
Size:	81.2 KB 
ID:	20979
    digitalWrite(relaySol, LOW);
    digitalWrite(relayFan, LOW);
    delay(5000);
    }

    I attached a really rough circuit diagram in case my hardware setup is incorrect.

    After I uploaded the code to the Teensy and plugged in the power, for some reason, the fan and solenoid stayed on constantly regardless of if the pin output was high or low. I'm extremely new to this so any help would be grreatly appreciated. Let me know if there is anything else that could be helpful.

  2. #2
    Junior Member
    Join Date
    Jul 2020
    Posts
    10
    The power supply is 12v as well as the fan and solenoid. I used a step-down transistor to supply the teensy with power.

  3. #3
    Junior Member
    Join Date
    Jul 2020
    Posts
    10
    Just checked and the SSR I am using requires a 3.5v input, is this too high for the Teensy 3.2?

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    348
    The CX240D5 as shown in the diagram is rated for 3--15V, its just an AC relay using SCRs and with zero-crossing switch-on, so can't work for DC loads.

    Is this the one you have?

  5. #5
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    Hi Kevin,

    Mark is right, read this for more background.
    Using an N-channel logic-level MOSFET like the affordable IRLZ44N is a much better option to switch 12Vdc by a Teensy. More info here.

    Paul

  6. #6
    Senior Member
    Join Date
    Mar 2016
    Posts
    202
    The SSR won't work because it's specified for AC. It may turn on but probably won't turn off.

    Your wiring is wrong. You need a common ground for the teensy, fan, pump and power supply to start with. Your diagram shows no connection from the power supply. Secondly, I'd be surprised if the EMI from the motors didn't mess up the teensy.

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,423
    What you called a step-down transistor is a voltage regulator. If you really are using a L7812CV, as shown in your diagram, it is the wrong one and would probably have burned out the T3.2 instantly. That outputs 12V from a higher DC input voltage. You would need L7805CV.

    Pete

  8. #8
    Junior Member
    Join Date
    Jul 2020
    Posts
    10
    Sorry, I think the picture on the graph is wrong, I actually do have the 7805.

  9. #9
    Junior Member
    Join Date
    Jul 2020
    Posts
    10
    The SSR in the picture is incorrect. The one I'm using is a CPC1219Y. The input voltage is 3.5v. Is this too high for a Teensy?

  10. #10
    Senior Member
    Join Date
    Mar 2016
    Posts
    202
    It is really a good idea to have accurate information when asking for help.

    That SSR is normally closed. Is that what you want?

    Your wiring is still incorrect. Everything must have a common ground. And your voltage reg needs to have capacitors - read the datasheet for details (or look at one of the about 1M www pages talking about it).

  11. #11
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,423
    I think this is the datasheet you need. See Figure 5 at the bottom of page 4.

    Pete

  12. #12
    Junior Member
    Join Date
    Jul 2020
    Posts
    10
    So should the power supply also be connected to the ground pin on the Teensy? Sorry for the simple questions, this is my first project.

  13. #13
    Senior Member
    Join Date
    Mar 2016
    Posts
    202
    Electricity needs 2 wires to work: a + and a -. Without those, the electrons won't flow. That's why we call it a circuit. We often call minus ground or 0V. So yes, you need the ground too.

    Start small. Load a blink sketch into the teensy, disconnect it from USB and power it via your power supply. If it blinks, it worked. If not, figure out what's wrong. Then start adding other pieces. Don't just throw parts at it. Read up on how the part is used and what other parts it needs to work correctly. For example, that 7805 you say you have, it needs 2 capacitors, one on input and one on output. It may sort of work without them but it also may not.

    Also, if you want to continue, some tasks for you:
    • Get a multimeter - even a cheapo $5 harbor freight one is better than nothing. Measure various outputs. You will soon get a sense of what works and what doesn't.
    • Get a solderless breadboard and some jumper wires. The SBB holds your parts securely and avoids accidental shorts. Plus a picture is easy to understand than a snarl of wires.
    • Instead of driving SSRs, start with LEDs (and a resistor) to see if your signals are getting sent. I always have a couple of LEDs with resistors that I can touch to outputs to see if they are working. It's a great and incredibly cheap diagnostic tool.
    • Learn how to read datasheets. They have (almost) everything you need to know about using a part. Even if 95% of it is over your head, the 5% that you do get will soon become 10%. and then 20% and then... And if you ask questions, a link to the data sheet will encourage people to help you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •