New Project - Steam room controller - Photon and Relay

Hey tinkerers!
I had a project a while back where I was trying to get the garage door hooked up to particle with a relay and controlled via iftt. That all worked great, however, the wifi interfered with my car’s garage door remote and I had to remove the photon.
I am now embarking on a project to get the photon and relay installed to remotely turn on our steam room pump.

To set the stage, we moved in here about 1.5 years ago and I have been trying to automate where possible. There is a good size steam room in the basement that my wife and I use occasionally. We use it after long runs when it’s cold outside. The problem is, it takes 15 minutes for the system to heat up. I want to heat it up remotely so that when I come back home, its ready to go. Enter, the photon! I have a photon along with a sunfounder 2 channel relay setup with a breadboard.

I am very novice and new to coding, so please bare with me.

I grabbed my old setup from the garage and decided to repurpose it. I have a few questions here…

  1. There is a button on the wall outside of the shower, its a single button and its only purpose is to turn on the steam room (not adjust any controls). I looked behind the wall and it’s hard wired to the unit. I thought that I could put this system “in line” with the button and very similar to the garage, put in a relay that turns it on. Is this sound thinking or am I doing something dumb.

  2. I am assuming the #1 isn’t insance, so I started to test my old setup. I am not connected to anything aside from power for this step, i just wanted to get the code working and hear that familiar (TICK) on the relay when i use the commands I setup in iftt) I created a new project and used my old garage door code and put it into the new project and removed the references to the 2nd relay as it’s not needed. I updated the code as below. Does this look like it would work?

Coding isn’t second nature and I haven’t touch this code for a year.

void resetAll() 
{
  digitalWrite(D0, LOW);
}

Timer switchOffTimer(1000, resetAll, true); // create a 1-second-one-shot timer that calls resetAll()

char auth[] = "woohoocodewhoohoo";
int SteamOn (String command);

void setup()
{
  
  Particle.function("SteamOn", TurnOnSteam);
  Serial.begin(9600);
  pinMode(D0, OUTPUT);

}
void loop()
{

}

int TurnOnSteam(String command)
{
  command.trim(); // remove possible leading/trailing white space
  int retVal = 0;

  if(command == "SteamOn")
  {
    digitalWrite(D0, HIGH);
    retVal = 1;
  }
 
  else // something went wrong, so be save and switch off immedeately
  {
    switchOffTimer.stop();
    resetAll(); 
  }
  
  if (retVal > 0) 
    switchOffTimer.start();

  return retVal;
}
  1. One problem that I am seeing is that when I flash the code, the relay opens up and stay open! I hear them TICK on and the light stays red! I don’t recall this from the last time I did it.

Setup
(Grey) GND (relay) <—> GND (photon)
(Purple) VOC (relay) <—> 3v3 (photon)
(Orange) IN1 (relay) <–> D0 (photon)

This should be working : /

PS. I’ll link a picture in a few minutes.

@ledfortr, those are 5v relays so you should power the relay board by connecting Vin on the Photon to Vcc on the relay board. The Vin pin is connected to Vusb through a protection diode so the voltage is just below 5v. Also, Vin can supply more current (limited by your USB adapter or PC port) than the 3.3v line which is limited to about 100mA.

1 Like

Thanks, I swapped it over to Vin. There is no change in the issue.

@ledfortr, disconnect the wire from D0 and connect it to 3V3 on the Photon and observe the relay. Then connect it to GND of the Photon and see what happens. Report back.

Maybe put a pulldown resistor between D0 and GND? That should hold the line low at power up until you set the pin to OUTPUT.

Connecting to 3v3, no lights on the relay and no TICK. When connecting to GND on photon, red light on the relay turns on and stays TICKED.

It worked in the previous installation / application of this same hardware. I didn’t use a resistor.

I’m thinking its programmatic.

Wait, so the relay is going active when you set its input low, not high?

seems to me if you put this system “in line” with the button you will still need to press the button. the system will only activate/deactivate the button. unless, i misunderstand what you mean by “inline with the button”

1 Like

It seems that your relay is a Normally Closed (NC) relay. That means when no voltage is applied to the relay coil, the relay is closed. And when you apply voltage to the relay coil, it opens the relay. Is that what your testing confirms? I wasn’t following your results that well with the references to the light and “ticked”. Do you have a link to the relay or datasheet to confirm?

But I will say, they are 5V relays and you are trying to drive the coil with only 3.3v. We also don’t know how much current is required to energize the relay. You may need to connect your D0 to a MOSFET in order to supply the required 5V to the relay control pin.

@dkryder is also correct… if you want the switch and the relay to work independently, you would want it to be in-parallel with the steam room switch. If your requirement is that anytime you want to use the steamroom, you must activate both the physical switch and the relay, then you put the relay in-line with the switch.

It seems so. Its something in the code. I just erased everything but this

void resetAll() 
{
  digitalWrite(D0, LOW);
}

The Relay actually does close. So i’m doing something silly in the code. ugh.

I think it’s something stupid i did in the code. It isn’t a NC relay. This worked on a previous application, I tested the below code applied the firmware. It booted up and stayed closed.

void resetAll() 
{
  digitalWrite(D0, LOW);
}

does someone have sample code with 1 channel that I can edit that publishes a function to ifttt, I can start with that. Its something in the code for sure!

What timer library are you using? I tried to find a timer library called “Timer” but there wasn’t one. Definately doesn’t look like the popular SparkIntervalTimer.

I took out the timer references and get the same thing. I took out a couple other things that were referencing blync. This is the entire sketch. Am I somehow issuing the “SteamRoomOn” command?

void resetAll() 
{
  digitalWrite(D0, LOW);
}

int Steam (String command);

void setup()
{
  
  Particle.function("SteamOn", SteamOn);
  Serial.begin(9600);
  pinMode(D0, OUTPUT);

}
void loop()
{

}

//Function to turn on steam room
int SteamOn (String command)
{
  command.trim(); // remove possible leading/trailing white space
  int retVal = 0;

  if(command == "SteamRoomOn")
  {
    digitalWrite(D0, HIGH);
    retVal = 1;
  }
 
}

I person by the name of ScruffR helped me with my garage code and I don’t believe a library was called for the timer to work. I don’t see anything in the code that references “Timer”. It still compiled today without a problem. After removing all timer references, I think its something I am doing in the function.

@ledfortr, to turn ON the relay, you need to write a LOW. To turn it OFF, you need to write a HIGH. Your code seems to do the opposite. :wink:

1 Like

Switched the high’s and lows, still the same result.

This code does bring it up and keep the relay off

Entire sketch

void resetAll() 
{
  digitalWrite(D0, LOW);
}

I might be missing something but based on your tests, OFF would be setting D0 to HIGH, not LOW.

I redid the code completely and got it to work.

int button = D0;  

void setup() {
    pinMode(button, OUTPUT);
    digitalWrite(button, LOW);
    
    Particle.function("SteamRoomOn", SteamRoomOn);
}

int SteamRoomOn(String command){
    if(command == "SteamRoomOn" || command == "steamroomon"){
        digitalWrite(button, HIGH);
    return 1;
    }
}

void loop() {
    SteamRoomOn("SteamRoomOn");
}

Now to test on ifttt/google home!

1 Like