Go Down

Topic: Earthquake switch for a ceiling fan (Read 2 times) previous topic - next topic

kmpres

Hi Guys,
This is my first post.  I hope you're all well.
Though I've written a few small sketches for testing purposes, I'm still a newbie to Arduino and what it can do.

I live in earthquake prone Japan, and for my first project I want to build an automatic shutdown switch for a ceiling fan that will power it down in the event of an earthquake.  The thought of five blades 52" in diam spinning around over our heads with an earthquake in progress is not very comforting.  The catch is that the command to shut it down must come from the remote control receiver that came with the fan.  This is because the built-in control unit has a "instant stop" feature that stops the rotation in a few seconds instead of a minute or more if the power were cut by simply hitting the fan's wall switch.

My thought is to rig an earthquake sensor switch at the fan mount (easily done) and have it output a logic level to an Arduino housed just above the fan body.  The Arduino would then transmit the "fan off" radio code to the fan's receiver located in the canopy, which is the metal cone that hides the wire connections and physical attachment to the ceiling.  The distance from the Arduino to the rx is only a foot or so so high power is not necessary.  To Keep It Simple and improve reliability, however, I would rather not hack into the existing receiver, only tap into it with radio waves, as it was intended to be operated.  That will avoid voiding the warranty and allow me to easily revert back to the original design if the project fails to meet its objectives.

I need to know how to do the following:

1.  How to capture the RF stop code from the remote tx on an oscilloscope.  What circuit do I need?
2.  How to duplicate the stop code using Arduino software.
3.  How to build, or what to buy, a mini tx with the same frequency as the handheld remote that will transmit the stop code from the Arduino.  What shield do I need?

The fan is an American Hunter, model 26420, with Hunter Remote model 27224.  The remote uses RF, not IR.  I don't know the frequency.  That too, would need to be determined.

Many thanks in advance for any help you can give!

zoomkat

You can probably just use a transistor across the stop button pins in the remote to keep things simple.

http://web.comporium.net/~shb/irmods.htm
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

thegeekway

I would take a guess at it being 433mhz, as most RF switches usually are.  Luckily there is a library for this very problem, its called RCswitch and allows you to read the code from the control and transmit the code once you know what it is.

All you need is a 433mhz RX and TX module, the cheap chinese models will work fine.  Once you have them wired up its as simple as:

Code: [Select]

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();
int ldrValue;
int ldrPin = 0;
void setup() {

  Serial.begin(9600);
 
  // Transmitter is connected to Arduino Pin #10 
  mySwitch.enableTransmit(10);

  // Optional set pulse length.
  // mySwitch.setPulseLength(320);
 
  // Optional set number of transmission repetitions.
  // mySwitch.setRepeatTransmit(15);
 
}

void loop() {

ldrValue = analogRead(ldrPin); 

  Serial.print("Analog reading = ");
  Serial.print(ldrValue);   

  if (ldrValue < 300) {
    mySwitch.send(4927279, 24); //here is the code for my transmitter, found using the RCswitch lib
  } else if (ldrValue > 301) {
    mySwitch.send(4927271, 24);

  }
  delay(100);
}


Excuse the messy code, it works ;)  This allows me to turn my lights on and off depending how dark it is(its set up with a LDR). 
With the  mySwitch.setRepeatTransmit(15); option you could set it to repeatedly send the code to ensure it is recieved by the fan.  This should do the job and seems relatively cheap to get up and running, Im sure you could pick up the RF modules from Akihabara if you're nearby.

kmpres

Many thanks, thegeekway, for this info!  That certainly is a good start. 

I assume that one of these tx/rx pairs would work:  http://www.robotshop.com/ca/433mhz-high-sensitivity-transmitter-receiver-pair-rxa33.html

I'm still confused, however, on how the Arduino sends the stop code to the mini-tx so the fan's rx can decode and execute it.  If I read the referenced library correctly, it suggests attaching the handheld remote to the Arduino just long enough to store the code in the Arduino's memory.  I assume that it will convert the code into some text form that I will then write into the Arduino's program.  My intention is to thereafter detach the Arduino from the handheld and move it to the fan where it will reside permanently in a box above the fan body.  Attached to the Arduino's output pin will be the input to the mini-tx.  When an earthquake occurs, the Arduino will detect the event and send the stop code to the mini-tx, which will then broadcast it to the fan's built-in rx, which will then execute the command.  The mini-rx that comes with the mini-tx/rx pair isn't needed as the fan's built-in rx will be retaining its normal functions.  Is this the normal approach to solving these problems?

Questions:

1. The fan's rx has dip switches that are used to change frequencies to avoid interference from other household devices.  Is the mini-tx similarly adjustable?
2. Will the mini-tx convert the code to the proper modulation format or does the Arduino do this?  If the latter, how do I make the Arduino do this?

I don't want to permanently attach anything to my handheld as that will "borgify" it to the point where it won't be used.  The idea is to retain the original handheld as is and have the Arduino duplicate its stop code signal when an event occurs.

Again, many thanks for your help on this!

thegeekway

Hi, that RX/TX will work fine, you just need to ensure the fan is setto 433mhz, which after a little browsing seems to be the case.  You wont need to modify anything,first of all just plug in the RX module to your Arduino (VCC, GND, Data[Pin2]) and load up the sketch RecieveDemo from the examples folder.  Once running press the stop button on your remote and in the serial monitor it should give you the remote code information.  Copy and paste it somewhere safe for now and create and simple sketch to test it works:

Code: [Select]
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

 Serial.begin(9600);
 
 // Transmitter is connected to Arduino Pin #10  
 mySwitch.enableTransmit(10);

 // Optional set pulse length.
 // mySwitch.setPulseLength(320);  
 
}

void loop() {

 /*using decimal code */
 mySwitch.send(5393, 24); //replace 5393 with your code

 delay(20000);
}


And if everything is working ok, your fan should stop.  Then it is just a case of hooking up your detection method and using a little extra code to get it working.

Go Up