Hi,
My friend and I built this temperature and humidity controller, which I've been using for the past 3 months, and no problems with the code.
What I realized is that my dehumidifier is too small, so I got a bigger one (the one in the picture). When I plugged into the controller the relay board can't control this dehumidifier. Once it goes off it doesn't come back on. So I investigated and made a bypass to the on/off button (the black cable on the dehumidifier picture), I tried manually (touching one end of the cable with the other end) and it works just fine. So my plan is to remove the varistor, fuse, and socket on the dehumidifier relay, plug the dehumidifier into the wall, and plug these button bypass cables into the relay board. This way I can get the dehumidifier to do what I want automated.
My problem here is that my friend is the actual "engineer" I developed the concept and told him how I think it should operate and he did all the code. The problem is he changed jobs and is loaded with work and says that doesn't have any time to help me out (which I think is bullshit, I think that takes literally 1 minute or even less for someone with his experience) so I'm hoping someone here can help me.
THE CODE:
Funcionamento Desumidificador:
var Sondas = global.get("sondas");
var SetPoints = global.get("configs");
var Estados = global.get("estados");
var humi1 = Sondas["IThumidade"];
var humi2 = Sondas["IBhumidade"];
var SP = SetPoints["DESUsetpoint"];
var DF = SetPoints["DESUdif"];
var humiMedia = ((humi1 + humi2) / 2.0).toFixed(2);
var msg2 = { payload: humiMedia };
var msg3 = { payload: (SP - DF) };
msg.payload = Estados["Desumidificador"];
if(humiMedia > (SP)){
msg.payload = true;
//return [msg, msg2, msg3];
}
if(humiMedia <= (SP - DF)){
msg.payload = false;
//return [msg, msg2, msg3];
}
return [msg, msg2, msg3];
Status
var Estados = global.get("estados");
var Manuais = global.get("manuais");
var Automatico = global.get("automaticos");
if((msg.payload === true
&& Estados["Desumidificador"] === false
&& Automatico["Desumidificador"] === true)
|| (Manuais["Desumidificador"] === true
&& Automatico["Desumidificador"] === false
&& Estados["Desumidificador"] === false )){
msg.payload = "LIGADA";
msg.color = "#00ff00";
Estados["Desumidificador"] = true;
global.set("estados", Estados);
return msg;
}
if((msg.payload === false
&& Estados["Desumidificador"] === true
&& Automatico["Desumidificador"] === true)
|| (Manuais["Desumidificador"] === false
&& Automatico["Desumidificador"] === false
&& Estados["Desumidificador"] === true )){
msg.payload = "DESLIGADA";
msg.color = "yellow";
Estados["Desumidificador"] = false;
global.set("estados", Estados);
return msg;
}
Relay control
if(msg.payload === "LIGADA"){
msg.payload = 0;
return msg;
}
if(msg.payload === "DESLIGADA"){
msg.payload = 1;
return msg;
}
Now that you already have an idea of the problem, this is my idea to solve the problem:
- Plug dehum to the wall
- Remove varistor, fuse and socket from the relay board
- Plug the on/off bypass cables instead
- Change the code on "Relay control"
- Add a 2s Delay
- Add another function afterwards called "Relay auto off"
Relay Control (code changed):
if(msg.payload === "LIGADA"){
msg.payload = 0;
return msg;
}
if(msg.payload === "DESLIGADA"){
msg.payload = 0;
return msg;
}
This goes to a 2 second delay node and the goes to the following node:
Relay auto off (new function node)
if(msg.payload === "LIGADA"){
msg.payload = 1;
return msg;
}
if(msg.payload === "DESLIGADA"){
msg.payload = 1;
return msg;
}
Do you think this will work? If not, any solutions?
Thanks in advance and happy projects!
Note:
Since the controller is operating 24/7 I don't have time to test a lot of options, otherwise, the temperature and humidity of my room will get too high and too humid. This is why I'm hoping someone here can help me