Relay shield with active Low for my wine and Liquor Bar...

Hi
I am making a bar with some blind motors and IKEA wardrobe doors. To avoid my younger siblings from stealing alcohol from me I decided to make it go into the ceiling when not in use, hence the blinds motors.

So I have two sections, one for wine and one for liquor. I am using blind motors and these motors runs on 230V and have 4 wires, one neutral,ground and up and down. The key thing is that up and down should never be connected at the same time. So I have 230 v running to the relay box as well as 5 wires, 1 for ground and to each trigger pin for the relay. Inside the relay box I also have 230v to 5v power supply since the relay board needs power.

Then 2 meters away i have my other box with buttons and an arduino to control the whole thing. I had everything up running nicely by using internal pullup for the 4 switches and then using pin d8 to d12 to control the relays.

Then one day, the worst thing happend, the power supply to the arduino was out for a few seconds making the arduino reboot. What happend then was that since the relay board were active by low my alcohol started to dissaper into the ceiling, to get it down when that happens and no communication to relay board is possible i have to use a saw and destroy it to save the alcohol. Luckily this time wine part burnt one relay an inch before fully closed and i were able to save my alcohol.(motor up and down were active at the same time.)

So I have ordered a new , relay board , now. So my question is how do I connect it, do I connect the motors to normally open or closed on the relay, and what kind of resistor should i use to do the external pullup/down. And how do i connect this resistor, between the 5v and pin on the relay board? Since its active on low?

A circuit, photo of the mechanicals and a program may make it possible to work out what you are doing.

Weedpharma

I'm guessing without seeing your schematic but a DPDT or SPDT relay might work for direction. The basic logic that the common terminal can't be connected to the Normally Open and Normally Closed terminals at the same time... It's one or the other...

So, you might use one relay for on/off and a 2nd relay for direction.

...i have to use a saw and destroy it to save the alcohol.

You may need some kind of "back door" mechanical lock (unlock). For example, I wouldn't want a safe that opens with a keypad only. If something happens to the electronics or the keyapad (which could be deliberate if someone was trying to break in) the contents would not be accessible.

The relay board shows only SPDT relays. Using DPDT would allow safer switching.

Weedpharma

Schematic, There is also the shortening option to bypass the relays drawn in. Hope it makes sense, Now its connected to Normally Open, maybe it should be changed to Normally Closed.

Can't make a lot of sense of this. There appears to be separate motors to drive up and down.

This sort of system needs to be "fail safe" so the in any failure, it is safe. Yours appears not to be so. You need to redesign the circuit so that under all circumstances it cannot fail in a bad way.

Weedpharma

I hoped one of you guys could help out on how to wire it correctly, i think i need to add some pulldown resistors:) Its OK if it goes down in case of 5v failure to relays or vcc failure to arduino. The motor is similiar to one of these.

The reason why I want to use arduino is that then I can connect it to openhab(smart home system/rpi), set password for it when I rent out my flat on airbnb and that i physically i couldn't find any small switches to fit that could handle the current and I wanted some nice looking switches.

I also updated the schematic, now it also shows RPI and Switches, the boxes is to indicate the different modules, they are in reality placed far apart from each other, the RPI is 15m from the arduino and there runs a 4 wire cable to it, the power supply unit(230V and 5v is placed 1.5 meter from the relay box, the relay box is 2m from the arduino and the arduino is 1m from the switches.

Updated schematic

@DVDdoug: "DPDT or SPDT": ¿single pole double pole? ¿..DT?

@OP: There exists a technique to "enclavar" (I don't know how to say it in english: ¿mechanically block?) the realys so that they block each other: you need double pole ones. If you are interested I can post a sketch.

regards

I thought i could just leave both relays untriggered(open circuit to both motor wires) in quiet state and power failure, what am I missing here? I was thinking of doing all the switching to make sure both relays are not on in software. Then i have one relay with pull down(the one connected to motor down) and this connected to NO on relay, the other relay with NC and pull down to motor up.

If then arduino power is lost, the motor down pin see gnd and hence since relay is active low, it will start going down and my alcohol is safe. The other pin see also gnd, but since its NC it will opens and leave that motor unconnected.

if the 5v power module fails, nothing happens on trigger side, and the relays keeps last state?
This means that the motor will run up.

The motors has built in end switches which cuts power when it has reached the end fyi.

as safety i have this

so that i can drill two holes and and shortened the two wires, bypassing the relays, in case the relays one day burns. This will then connect l1 phase to the motor down. That was my idea, but i am sure there is better ways to do this.

Your safety seems pretty basic! The relays have mains voltage on them and this will be on the track of the PCB.

Anything that has mains power on it needs to be treated as live at all times that you do not have the power plug in your hand.

Weedpharma

skatun:
To avoid my younger siblings from stealing alcohol from me

This is your real problem (though you do mention airbnb - then again, if some random stranger you're renting to will steal alcohol from you, they are just as likely to steal other things from your flat too).

As far as these so-called "siblings" are concerned? Well - first off, family that steals from family shouldn't be considered "family". Secondly, your siblings are either alcoholics, or on their way to becoming such - and will probably do more than just steal alcohol in the future (ask me how I know).

So - maybe a technological solution is only part of the solution?

I can think of a few ways that could assist - violence is of course an option, but not a particularly useful one. You could also denature a few bottles - just clearly mark them as such. An alcoholic won't care (or notice), but when your siblings are blind, you could just subtly say to them "Well, maybe you should have purchased your liquor from a reputable source, eh?" - they'd likely never figure out the truth (but if they did - you'd be put away for life or worse).

Ok - so maybe a poison booby trap isn't in your nature (I like to indulge in a bit of "make 'em pay" thought experiments from time to time, but I would never put such a plan in action - unless it was seriously warranted and I had nothing left to lose).

A funny way might be to shame them! Do you and they have facebook?

Then add a camera plus RFID, maybe some bottle detection switches - and if the RFID tag isn't detected (this would assume your siblings don't have such a tag with the same encoded key on it) - it takes a photo, and posts it to your facebook page (or one set up for the purpose), and maybe links to their page in some manner as well - and title it "my alcoholic siblings funniest moments stealing from me" or something equally inane. Maybe also post it to their employer (if they have such a thing - which in my experience is a big fat "no").

SPST single pole single throw, 2 pins, connected, or not.
SPDT single pole double throw, 1 set of 3 pins, middle (common) connects to one outer or the other
DPDT double pole double throw, 2 set of 3 pins, middle (common) connects to one outer or the other

Many variations - toggle, momentary, middle position that is not connected to either of the outers.
Examples of Toggle switches, there are many other form factors as well:
http://www.digikey.com/product-search/en/switches/toggle-switches/1114212?k=dpdt&stock=1

Well, first of all.. using switches as you Crossroad said, is hard due to the fact that I can't get thick enough cables through to the motors(only managed to squeese through 5 .25mm signal cable.

Secondly I would like to have it integrated into the smart home, then I can automatically switch on the whisky mood lights or the wine mood lights. Not to mentioned all the fun logs that can be made:

you drink most wine on wednesday in february for instance... Are you getting sober, you havent been drinking for more then 12 days and so on..

In action

Maybe have the system be wireless then - only need to get a power cable in place.
With a serial cable as backup that you can plug in if needed.

Hi all, finally the parts arrived from China..

I did modify the setup, I now have connect one direction of the motor to Normally Closed and the other direction Normally Open on the Relay board, Then I have another relay that feed 230V into the common on that relay. This way I can stop the bar half open in case something happens. See picture here

The code I am running is displayed below,can I make this code simpler somehow or improve it?

// constants won't change. They're used here to
// set pin numbers:
const int buttonPinSpritOpp = 9;     // the number of the pushbutton pin
const int buttonPinSpritNed = 12;     // the number of the pushbutton pin
const int buttonPinVinOpp = 10;     // the number of the pushbutton pin
const int buttonPinVinNed = 11;     // the number of the pushbutton pin

const int ledPinSpritOpp = 7;     // the number of the pushbutton pin
const int ledPinSpritNed = 6;     // the number of the pushbutton pin
const int ledPinVinOpp = 4;     // the number of the pushbutton pin
const int ledPinVinNed = 3;     // the number of the pushbutton pin

const int motorPinVin =  A2;      // the number of the motor pin
const int motorPinOnOff = A3;//
const int motorPinSprit =  A0;      // the number of the motor pin


int intCode =-1;

long startTime = 0;
void setup() {
  // initialize the LED pin as an output:
 
  pinMode(motorPinSprit, OUTPUT);
  pinMode(motorPinVin, OUTPUT);
  pinMode(motorPinOnOff, OUTPUT);

  // initialize the pushbutton pin as an input:
  pinMode(buttonPinSpritOpp, INPUT_PULLUP);
  pinMode(buttonPinSpritNed, INPUT_PULLUP);
  pinMode(buttonPinVinOpp, INPUT_PULLUP);
  pinMode(buttonPinVinNed, INPUT_PULLUP);
  
  

  digitalWrite(motorPinSprit,HIGH);
  digitalWrite(motorPinVin,HIGH);
  digitalWrite(motorPinOnOff, HIGH);

  Serial.begin(9600);
  Serial.println("starting now...");
  
  
}

void loop() {

  
  if ( Serial.available()) // Check to see if at least one character is available
  {
    startTime = millis();
    char ch = Serial.read();
    if( isDigit(ch) ) // is this an ascii digit between 0 and 9?
    {
       intCode = (ch - '0');      // ASCII value converted to numeric value
    }
  }

  if (millis() -startTime> 2000 ){
    intCode=-1;
}
  
  if ((digitalRead(buttonPinSpritOpp) == HIGH && digitalRead(buttonPinSpritNed) == LOW) || intCode==1) {
    
    digitalWrite(motorPinSprit,HIGH);
    digitalWrite(motorPinOnOff,LOW);
    
    digitalWrite(ledPinSpritOpp,HIGH);
    digitalWrite(ledPinSpritNed,LOW);
    
    Serial.println("Sprit opp");
  }
 
  
  else if ((digitalRead(buttonPinSpritOpp) == LOW && digitalRead(buttonPinSpritNed) == HIGH)|| intCode==2) {    
    digitalWrite(motorPinSprit,LOW);
    digitalWrite(motorPinOnOff,LOW);
    digitalWrite(ledPinSpritNed,HIGH);
    digitalWrite(ledPinSpritOpp,LOW);
    Serial.println("Sprit ned");
  }

  else{
    digitalWrite(motorPinSprit,HIGH); 
    digitalWrite(motorPinOnOff,HIGH);  
    digitalWrite(ledPinSpritOpp,LOW);
    digitalWrite(ledPinSpritNed,LOW);
  }

  if ((digitalRead(buttonPinVinOpp) == HIGH && digitalRead(buttonPinVinNed) == LOW) || intCode==3) {
    
    digitalWrite(motorPinVin,HIGH);
    digitalWrite(motorPinOnOff,LOW);
    
    digitalWrite(ledPinSpritOpp,HIGH);
    digitalWrite(ledPinSpritNed,LOW);
    
    Serial.println("Vin opp");
  }
 
  
  else if ((digitalRead(buttonPinVinOpp) == LOW && digitalRead(buttonPinVinNed) == HIGH)|| intCode==4) {
    
    digitalWrite(motorPinVin,LOW);
    digitalWrite(motorPinOnOff,LOW);
    digitalWrite(ledPinSpritNed,HIGH);
    digitalWrite(ledPinSpritOpp,LOW);
    Serial.println("Vin ned");
  }
  else if (intCode==0){
    digitalWrite(motorPinOnOff,HIGH);  
    digitalWrite(ledPinSpritOpp,LOW);
    digitalWrite(ledPinSpritNed,LOW);
    Serial.println("Shutting off");
  }
  else{
    
    digitalWrite(motorPinVin,HIGH); 
    digitalWrite(motorPinOnOff,HIGH);  
    digitalWrite(ledPinSpritOpp,LOW);
    digitalWrite(ledPinSpritNed,LOW);
  }
   delay(400);
 
}

Thanks for all the input so far!