You are on page 1of 7

7

Liên kết khác

Blog tiếp theo»

Tạo Blog

Đăng nhập

Arduino Basics
An Arduino blog that follows the footsteps of an enthusiastic Arduino user, from the ground up. Level : Basic
Home

Arduino Basics Projects Page

Feedback Page

20 July 2014

Search This Blog

433 MHz RF module with Arduino Tutorial 3

Search

Translate
Chọn Ngôn ngữ
Được hỗ trợ bởi

Dịch

Pages
Arduino Basics Projects Page
Arduino Basics YouTube
Videos
Feedback Page
Home

Subscribe
Posts
Comments

My Arduino Videos

Project 3: RF Remote Control Emulation
In the first tutorial, I introduced the 433 MHz Transmitter and Receiver with a simple sketch to test their
functionality. In the second tutorial, the 433MHz receiver was used to receive a signal from an RF remote.
The RF remote signal was coded based on the pattern and length of its HIGH and LOW signals. The signals
received by the remote can be described by the code below:

Code comparison table

The RF remote that I am using transmits the same signal 6 times in a row. The signal to turn the light on is
different from that used to turn the light off. In tutorial 2, we were able to "listen to" or receive the signal from
the RF remote using the RF receiver. I thought it would be possible to just play back the signal received on
the Arduino's analogPin, but the time it takes to perform a digital write is different to the time it takes to do an
AnalogRead. Therefore it won't work. You need to slow down the digitalWrite speed.

pow ered by

Transmitter and Receiver pair or the 315 Mhz version Mercator Ceiling Fan/Light with Remote 433 MHz RF module with Arduino Tutorial 4: 433 MHz RF module with Arduino Tutorial 3 ► June (2) ► 2013 (13) ► 2012 (11) ► 2011 (25) The Transmitter Fritzing Sketch Total Pageviews 1. If the delay in your project is the same as mine (or different) I would be keen to know .625 RF Calibration .please leave a comment at the end of the tutorial.052. We will do this by slowly incrementing the delay until the transmission is successful.Arduino Sketch .I would like to find out if it is possible to apply this delay to all 433 MHz signal projects. All we have to do is count the number of transmissions until it is successful. Blog Archive ▼ 2014 (9) ► November (1) ► October (1) ► September (2) ► August (1) ▼ July (2) Parts Required Arduino UNO or compatible board Breadboard Wires RF Module (433 Mhz) . We are going to use trial and error to find the optimal digitalWrite delay time. however. then we should be able to calculate the delay. I only have one 433 MHz remote. The transmission is considered successful if the fan-light turns on/off.

2.4. 30 digitalWrite(ledPin.3}.2. //The array used to hold the RF code 15 int lightON[]={2.4.4. //Used to switch between turning the light ON and OFF 18 int timeDelay=5. OUTPUT).5. 55 } 56 57 } else{ 58 for(int i = 0.com 6 Transmitter: FS1000A/XY-FST 7 Description: A simple sketch used to calibrate RF transmission.4. 71 72 SH = short high or LH = long high 73 PLUS 74 SL = short low or LL = long low or VLL = very long low 75 76 . HIGH). // switch between light ON and light OFF 38 transmitCode().5.4.2.4. // transmit the code to RF receiver on the Fan/Light 39 40 timeDelay+=10.1. //The RF code that will turn the light OFF 17 int codeToggler = 0.2.4.2.RF Calibration 3 Written by ScottC 17 July 2014 4 Arduino IDE version 1.blogspot. //Each transmission will be about 2 seconds apart.1. // The variable used to calibrate the RF signal lengths.2. 60 } 61 } 62 codeToggler=!codeToggler.4.4.2.gives us some time to get ready 28 digitalWrite(ledPin. 31 delay(1000).2. There are 6 different HIGH-LOW signal combinations. //Increment the timeDelay by 10 microseconds with every transmission 41 delay(2000).1.2.5 5 Website: http://arduinobasics. 63 } 64 65 66 67 68 /*----------------------------------------------------------------69 transmitCode(): Used to transmit the signal to the RF receiver on 70 the fan/light. i++){ 54 codeToTransmit[i]=lightON[i]. 32 } 33 34 35 36 void loop(){ 37 toggleCode().4.1.4. i++){ 59 codeToTransmit[i]=lightOFF[i].5.1. 19 20 21 22 void setup(){ 23 Serial.4. //The RF code that will turn the light ON 16 int lightOFF[]={2.4. i<codeSize.4. OUTPUT). // Turn the Serial Protocol ON 24 pinMode(rfTransmitPin.0. 42 } 43 44 45 46 47 /*---------------------------------------------------------------48 toggleCode(): This is used to toggle the code for turning 49 the light ON and OFF 50 -----------------------------------------------------------------*/ 51 void toggleCode(){ 52 if(codeToggler){ 53 for(int i = 0.6}.*/ 9 10 #define rfTransmitPin 4 //RF Transmitter pin = digital pin 4 11 #define ledPin 13 //Onboard LED = digital pin 13 12 13 const int codeSize = 25.4. 8 ------------------------------------------------------------. LOW).2.4. i<codeSize.4.4.4.4.2.2.5.begin(9600).4. //Transmit pin is an output 25 pinMode(ledPin.2.4. //The size of the code to transmit 14 int codeToTransmit[codeSize]. 26 27 //LED initialisation sequence .2.4.1 /* 2 Transmit sketch . 29 delay(3000).

The LED is turned on at the beginning of each transmission. case 3: // SH + VLL highLength=3. //initialise the variables int highLength = 0. /* Transmit a LOW signal . HIGH). //The signal is transmitted 6 times in succession . j<6. int lowLength = 0. which is right about the middle of the range. lowLength=3. digitalWrite(ledPin. } /* Transmit a HIGH signal . The short and long lengths were identified from the experiments performed in tutorial 2 (using the RF receiver). LOW). for(int j = 0. delayMicroseconds(highLength*timeDelay).LOW).77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 -------------------------------------------------------------------*/ void transmitCode(){ // The LED will be turned on to create a visual signal transmission indicator. lowLength=3.this may vary with your remote. break. case 4: // LH + SL highLength=7. delayMicroseconds(lowLength*timeDelay). 2 represents a SHORT HIGH and a LONG LOW combination. break. break. The timeDelay variable starts at 5 microseconds. lowLength=7. i<codeSize. lowLength=7. Each number within the code represents a specific sequence of HIGH and LOW lengths. lowLength=92. The Mercator Fan/Light will turn on and off when the timeDelay variable is anywhere between 75 and 135 microseconds in length. It also seems to transmit successfully when the timeDelay variable is 175 microseconds. a long length = 7. and is incremented by 10 microseconds with every transmission. In the video. So in theory. lowLength=92. I think I will use a value of 105. we should be able to use any value between 75 and 135. break. } I used an array to hold the RF code for light ON and light OFF. digitalWrite(ledPin. case 6: // LH + VLL highLength=7. i++){ switch(codeToTransmit[i]){ case 1: // SH + SL highLength=3. A short length = 3. if we want to transmit a signal to the fan/light. you will notice that there is some flexibility in the timeDelay value. } } //Turn the LED off after the code has been transmitted. and then turned off at the end of the transmission. case 2: // SH + LL highLength=3. HIGH).the duration of transmission will be determined by the lowLength and timeDelay variables */ digitalWrite(rfTransmitPin. case 5: // LH + LL highLength=7. j++){ for(int i = 0. You need to multiply this by the timeDelay variable to identify how much time to transmit the HIGH and LOW signals for. break. For example. Each code is transmitted 6 times.the duration of transmission will be determined by the highLength and timeDelay variables */ digitalWrite(rfTransmitPin. . and a very long length = 92. however in future projects. break.

I am not interested in transmitting beyond the boundaries of my house (or that room for that matter).. But if I am legally allowed to. I am not interested in breaking laws. Thanks for the tutorials! Reply Replies Scott C 21 July 2014 at 20:10 Hi Rafael. But this distance is much further than I need. What about antennas do you want to know? Reply Anonymous 28 July 2014 at 00:26 I must congratulate you on such a fine blog. Maybe there is room for one more tutorial on this topic :) Update: Here it is . Posted by Scott C at 02:30 +7 including Gary Labels: 433Mhz. ArduinoBasics. Fan. Mercator. Without an antenna. RF. Transmitter. Perhaps somebody can help me out here and provide some advice. I might do a tutorial on antennas. I was able to turn the light on and off from the next room. Light. Arduino. Remote. I wish you all the luck in the future works . Thank you for the suggestion. I discovered it today and i can't stop reading it.tutorial 4 Where you can record and playback an RF signal (without using your computer). I should be able to simplify the steps required to replicate a remote control RF signal.. I would have to seek advice as to whether the use of an antenna would break any laws in Australia. tutorial 6 comments: Rafael 21 July 2014 at 19:02 How far range did you get? May I suggest a tutorial 4: antennas (home made).Video Now that I have the timeDelay variable.

255 should be 0 for HI and 255 for LO as it should be "silent" for a while.I've been busting my brain with the rcswitch library as I have 2 different remote socket sets and they work with different protocols and I was able to control one. but there is a lot of room for improvement. including the scanner that would display a code to use..Reply Miroslav Jernejšek Perec 19 August 2014 at 19:32 Hi Scott. IS. So i made it a bit simpler for me. Vlada Reply Replies Scott C 2 December 2014 at 10:16 Thanks for your feedback Vlada. there should be different timeDelay lengths as in my case one is 115 and the other is 150 (middle values). I am able to control my RC sockets which I got from Maplin with the Arduino.. that the pairs (HI. but not also in the table. Well written tutorial and great effort on your part. that pair 0. I figured out from received timeouts.I still have a wireless doorbell to try with.. I can control with your code fragments. Thank you for your tutorial a 1000 times. Keep up the good work and keep in touch. where I used the combination table. I can't wait to read trough your blog. as you already mentioned.LO) in your sketch are correct. I am glad it helped. perhaps even with calculated timeDelay. thank you very much for this tutorial and code. Thank you very much. As you already assumed. YOU made it work for me! Thank you again. but not the other set. Keep up the great work. Reply . This. best regards. Perec (mirojp) Reply Anonymous 2 December 2014 at 09:22 Hello Scott. I must point out. So at this point I have 3+4 sockets.. Amazing. Best regards. What I did was to use M$ Excel for code calculation. upgraded it according to my previously non-working socket (added High medium low) set and used it to calculate combinations. but it also lets me believe we could replicate almost any "as simple as these" control signal. Miroslav J.

. template.Enter your comment. Comment as: Publish Google Account Preview Feel free to leave a comment : Links to this post Create a Link Newer Post Home Older Post Subscribe to: Post Comments (Atom) 2.. . Powered by Blogger.3k This Week's Most Popular Posts Most Recent Posts 433 MHz RF module with Arduino Tutorial 1 One in a million HC-SR04 Ultrasonic Sensor DIY Canon Intervalometer using Arduino Simple Arduino Serial Communication Bluetooth Tutorial 1 Arduino Selfie Relay Module Grove Water Sensor Bluetooth Android Processing 1 Recent Posts Widget by Helplogger Awesome Inc.