Upload
habaoanh
View
218
Download
0
Embed Size (px)
Citation preview
8/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
1/7
n Arduino blog that follows the footsteps of an enthusiastic Arduino user, from the ground up. Level : Basic
rduino Basics
Home Arduino Basics Projects Page Fe edback Page
20 July 2014
433 MHz RF module with Arduino Tutorial 3
n the first tutorial, I introduced the 433 MHz Transmitter and Receiver with a simple sketch to test theirunctionality. 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 signalseceived 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 isdifferent from that used to turn the light off. In tutorial 2, we were able to "listen to" or receive the signal fromhe RF remote using the RF receiver. I thought it would be possible to just play back the signal received on
he Arduino's analogPin, but the time it takes to perform a digital write is different to the time it takes to do anAnalogRead. Therefore it won't work. You need to slow down the digitalWrite speed.
Project 3: RF Remote Control Emulation
Sea
Search This Blog
Chn Ngn ng
c h tr bi Dch
Translate
Arduino Basics Projects P
Arduino Basics YouTubeVideos
Feedback Page
Home
Pages
Subscribe
Posts
Comments
powered by
My Arduino Videos
7 Lin kt khc Blog tip theo To Blog
http://2.bp.blogspot.com/-lXz2lUaDBSk/U6mnypcD3oI/AAAAAAAAA6Q/TFd1Ct0zkUE/s1600/Code+Comparison.jpghttp://2.bp.blogspot.com/-lXz2lUaDBSk/U6mnypcD3oI/AAAAAAAAA6Q/TFd1Ct0zkUE/s1600/Code+Comparison.jpghttp://arduinobasics.blogspot.com/p/arduino-basics-youtube-videos.htmlhttp://4.bp.blogspot.com/-5oPFTU4oizo/U67kMfDFJ3I/AAAAAAAAA7A/6GD7USwp6sE/s1600/433MHzTutorial3TitlePage.jpghttp://arduinobasics.blogspot.com/p/feedback.htmlhttp://arduinobasics.blogspot.com/p/feedback.htmlhttp://www.youtube.com/http://arduinobasics.blogspot.com/http://arduinobasics.blogspot.com/2014/06/433-mhz-rf-module-with-arduino-tutorial_27.htmlhttps://translate.google.com/http://arduinobasics.blogspot.com/p/arduino-basics-projects-page.htmlhttp://arduinobasics.blogspot.com/http://arduinobasics.blogspot.com/p/arduino-basics-projects-page.htmlhttp://arduinobasics.blogspot.com/2014/06/433-mhz-rf-module-with-arduino-tutorial_27.htmlhttp://arduinobasics.blogspot.com/http://arduinobasics.blogspot.com/2014/06/433-mhz-rf-module-with-arduino-tutorial.html8/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
2/7
would like to find out if it is possible to apply this delay to all 433 MHz signal projects, however, I only haveone 433 MHz remote.
f the delay in your project is the same as mine (or different) I would be keen to know - please leave acomment at the end of the tutorial.
We are going to use trial and error to find the optimal digitalWrite delay time. We will do this by slowlyncrementing the delay until the transmission is successful. The transmission is considered successful if thean-light turns on/off. All we have to do is count the number of transmissions until it is successful, then we
should be able to calculate the delay.
Arduino UNO or compatible board
Breadboard
Wires
RF Module (433 Mhz) - Transmitter and Receiver pairor the 315 Mhz version
Mercator Ceiling Fan/Light with Remote
Parts Required
The Transmitter Fritzing Sketch
RF Calibration - Arduino Sketch
2014(9)
November(1)
October(1)
September(2)
August(1)
July(2)
433 MHz RF
module withArduinoTutorial 4:
433 MHz RFmodule with
ArduinoTutorial 3
June(2)
2013(13)
2012(11)
2011(25)
Blog Archive
1,052,625
Total Pageviews
http://3.bp.blogspot.com/-mJ7vshWvfzs/U8qOuwMbwTI/AAAAAAAAA8k/YJJ8EOZNZrQ/s1600/433MHz_Transmitter_Fritzing.jpghttp://arduinobasics.blogspot.com/search?updated-min=2013-01-01T00:00:00%2B08:00&updated-max=2014-01-01T00:00:00%2B08:00&max-results=13http://www.icstation.com/product_info.php?ref=25&products_id=3516&affiliate_banner_id=1http://www.icstation.com/product_info.php?ref=25&products_id=1402&affiliate_banner_id=1http://void%280%29/http://void%280%29/http://arduinobasics.blogspot.com/search?updated-min=2011-01-01T00:00:00%2B08:00&updated-max=2012-01-01T00:00:00%2B08:00&max-results=25http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial_30.htmlhttp://void%280%29/http://arduinobasics.blogspot.com/2014_11_01_archive.htmlhttp://void%280%29/http://void%280%29/https://ceilingfanswarehouse.com.au/shop/hayman-ceiling-fan-with-light-52-in-antique-brass-by-mercator/http://arduinobasics.blogspot.com/2014_07_01_archive.htmlhttp://arduinobasics.blogspot.com/2014_08_01_archive.htmlhttp://void%280%29/http://void%280%29/http://arduinobasics.blogspot.com/2014_10_01_archive.htmlhttp://arduinobasics.blogspot.com/search?updated-min=2012-01-01T00:00:00%2B08:00&updated-max=2013-01-01T00:00:00%2B08:00&max-results=11http://arduinobasics.blogspot.com/2014_06_01_archive.htmlhttp://arduinobasics.blogspot.com/2014_09_01_archive.htmlhttp://void%280%29/http://void%280%29/http://www.icstation.com/product_info.php?ref=25&products_id=1554&affiliate_banner_id=1http://void%280%29/http://arduinobasics.blogspot.com/search?updated-min=2014-01-01T00:00:00%2B08:00&updated-max=2015-01-01T00:00:00%2B08:00&max-results=9http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html8/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
3/7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1516
17
18
19
20
21
22
23
24
25
26
27
28
29
3031
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
5960
61
62
63
64
65
66
67
68
69
70
71
72
73
7475
76
/*
Transmit sketch - RF Calibration
Written by ScottC 17 July 2014
Arduino IDE version 1.0.5
Website: http://arduinobasics.blogspot.com
Transmitter: FS1000A/XY-FST
Description: A simple sketch used to calibrate RF transmission.
------------------------------------------------------------- */
#define rfTransmitPin 4 //RF Transmitter pin = digital pin 4
#define ledPin 13 //Onboard LED = digital pin 13
constintcodeSize = 25; //The size of the code to transmit
intcodeToTransmit[codeSize]; //The array used to hold the RF code
intlightON[]={2,2,2,2,1,4,4,4,4,5,1,4,4,4,4,4,4,5,2,2,1,4,4,4,6}; //The RF codintlightOFF[]={2,2,2,2,1,4,4,4,4,5,1,4,4,4,4,4,4,5,2,2,2,2,2,2,3}; //The RF co
intcodeToggler = 0; //Used to switch between turning the light ON and OFF
inttimeDelay=5; // The variable used to calibrate the RF signal lengths.
voidsetup(){
Serial.begin(9600); // Turn the Serial Protocol ON
pinMode(rfTransmitPin, OUTPUT); //Transmit pin is an output
pinMode(ledPin, OUTPUT);
//LED initialisation sequence - gives us some time to get ready
digitalWrite(ledPin, HIGH);
delay(3000);
digitalWrite(ledPin, LOW);
delay(1000);
}
voidloop(){
toggleCode(); // switch between light ON and light OFF
transmitCode(); // transmit the code to RF receiver on the Fan/Light
timeDelay+=10; //Increment the timeDelay by 10 microseconds with every tr
delay(2000); //Each transmission will be about 2 seconds apart.
}
/*----------------------------------------------------------------
toggleCode(): This is used to toggle the code for turning
the light ON and OFF
-----------------------------------------------------------------*/
voidtoggleCode(){
if(codeToggler){
for(inti = 0; i
8/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
4/7
77
78
79
80
81
82
83
84
85
86
87
88
89
90
9192
93
94
95
96
97
98
99
100
101
102
103
104
105
106107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
-------------------------------------------------------------------*/
voidtransmitCode(){
// The LED will be turned on to create a visual signal transmission indicato
digitalWrite(ledPin, HIGH);
//initialise the variables
inthighLength = 0;
intlowLength = 0;
//The signal is transmitted 6 times in succession - this may vary with your
for(intj = 0; j
8/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
5/7
Now that I have the timeDelay variable, I should be able to simplify the steps required to replicate a remotecontrol RF signal. Maybe there is room for one more tutorial on this topic :)
Update: Here it is - tutorial 4Where you can record and playback an RF signal (without using your computer).
Video
+7 including Gary
Replies
Reply
6 comments:
Rafael 21 July 2014 at 19:02
How far range did you get? May I suggest a tutorial 4: antennas (home made). Thanks for thetutorials!
Reply
Scott C 21 July 2014 at 20:10
Hi Rafael,Without an antenna, I was able to turn the light on and off from the next room. But this
distance is much further than I need. I am not interested in transmitting beyond theboundaries of my house (or that room for that matter). Thank you for the suggestion, Iwould have to seek advice as to whether the use of an antenna would break any laws in
Australia... Perhaps somebody can help me out here and provide some advice. I am notinterested in breaking laws. But if I am legally allowed to, I might do a tutorial on antennas.What about antennas do you want to know?
Anonymous 28 July 2014 at 00:26
I must congratulate you on such a fine blog. I discovered it today and i can't stop reading it. I wish youall the luck in the future works
http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial_30.htmlhttp://arduinobasics.blogspot.com/search/label/Fanhttp://arduinobasics.blogspot.com/search/label/RFhttp://arduinobasics.blogspot.com/search/label/Arduinohttp://www.blogger.com/share-post.g?blogID=4060435813840662690&postID=6028895322690737053&target=facebookhttp://arduinobasics.blogspot.com/search/label/tutorialhttp://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html?showComment=1405940551963#c4172416303954878618http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html?showComment=1406478374820#c4237050298514189674http://arduinobasics.blogspot.com/search/label/Mercatorhttp://www.blogger.com/share-post.g?blogID=4060435813840662690&postID=6028895322690737053&target=twitterhttp://arduinobasics.blogspot.com/search/label/Transmitterhttp://arduinobasics.blogspot.com/search/label/ArduinoBasicshttp://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html?showComment=1405944609547#c5157340184362521586http://www.blogger.com/profile/10944146171403980152http://www.blogger.com/share-post.g?blogID=4060435813840662690&postID=6028895322690737053&target=pinteresthttp://arduinobasics.blogspot.com/search/label/Remotehttp://www.blogger.com/profile/10071004090415946390http://www.blogger.com/share-post.g?blogID=4060435813840662690&postID=6028895322690737053&target=emailhttp://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.htmlhttp://www.blogger.com/share-post.g?blogID=4060435813840662690&postID=6028895322690737053&target=bloghttp://arduinobasics.blogspot.com/search/label/Lighthttp://arduinobasics.blogspot.com/search/label/433Mhz8/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
6/7
Replies
Reply
Reply
Miroslav Jernejek Perec 19 August 2014 at 19:32
Hi Scott,
This. IS. Amazing.
Thank you for your tutorial a 1000 times...I've been busting my brain with the rcswitch library as Ihave 2 different remote socket sets and they work with different protocols and I was able to controlone, but not the other set.
YOU made it work for me! Thank you again.
So i made it a bit simpler for me, but there is a lot of room for improvement, including the scanner thatwould display a code to use, perhaps even with calculated timeDelay.
What I did was to use M$ Excel for code calculation, where I used the combination table, upgraded itaccording to my previously non-working socket (added High medium low) set and used it to calculatecombinations.
I must point out, that the pairs (HI,LO) in your sketch are correct, but not also in the table, as youalready mentioned. I figured out from received timeouts, that pair 0,255 should be 0 for HI and 255for LO as it should be "silent" for a while.
So at this point I have 3+4 sockets, I can control with your code fragments, but it also lets me believewe could replicate almost any "as simple as these" control signal...I still have a wireless doorbell to trywith.
As you already assumed, there should be different t imeDelay lengths as in my case one is 115 andthe other is 150 (middle values).
Keep up the good work and keep in touch.
Best regards,Miroslav J. Perec (mirojp)
Reply
Anonymous 2 December 2014 at 09:22
Hello Scott,
thank you very much for this tutorial and code. I am able to control my RC sockets which I got fromMaplin with the Arduino. Well written tutorial and great effort on your part. Thank you very much, Ican't wait to read trough your blog. Keep up the great work,
best regards,Vlada
Reply
Scott C 2 December 2014 at 10:16
Thanks for your feedback Vlada. I am glad it helped.
http://www.blogger.com/profile/08006184002627076627http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html?showComment=1417486563113#c7155155203702965010http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html?showComment=1417483324075#c581867709563523443http://www.blogger.com/profile/10071004090415946390http://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial.html?showComment=1408447955530#c65204306989879959178/10/2019 Arduino Basics_ 433 MHz RF Module With Arduino Tutorial 3
7/7
Newer Post Older PostHome
Subscribe to: Post Comments (Atom)
Enter your comment...
Comment as: Google Accou
Publish
Preview
Feel free to leave a comment :
Create a Link
Links to this post
2.3k
33 MHz RF module with Arduino Tutorial 1
HC-SR04 Ultrasonic Sensor
Simple Arduino Serial Communication
Bluetooth Tutorial 1
Bluetooth Android Processing 1
This Week's Most Popular Posts
One in a million
DIY Canon Intervalometer using Arduino
Arduino Selfie
Relay Module
Grove Water Sensor
Recent Posts Widget by Helplogger
Most Recent Posts
Awesome Inc. template. Powered by Blogger.
http://arduinobasics.blogspot.com/2014/06/433-mhz-rf-module-with-arduino-tutorial_27.htmlhttp://arduinobasics.blogspot.com/2014/09/arduino-selfie.htmlhttp://arduinobasics.blogspot.com/2014/09/relay-module.htmlhttp://helplogger.blogspot.com/http://arduinobasics.blogspot.com/2014/11/one-in-million.htmlhttp://arduinobasics.blogspot.com/feeds/6028895322690737053/comments/defaulthttp://arduinobasics.blogspot.com/2014/10/diy-canon-intervalometer-using-arduino.htmlhttp://arduinobasics.blogspot.com/2013/01/arduino-basics-bluetooth-tutorial.htmlhttp://arduinobasics.blogspot.com/http://arduinobasics.blogspot.com/2014/08/grove-water-sensor.htmlhttp://arduinobasics.blogspot.com/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.htmlhttp://helplogger.blogspot.com/2012/04/recent-posts-widget-for-bloggerblogspot.htmlhttp://arduinobasics.blogspot.com/2014/07/433-mhz-rf-module-with-arduino-tutorial_30.htmlhttp://www.blogger.com/http://arduinobasics.blogspot.com/2013/03/arduino-basics-bluetooth-android.htmlhttp://www.blogger.com/blog-this.ghttp://arduinobasics.blogspot.com/2014/06/433-mhz-rf-module-with-arduino-tutorial.htmlhttp://arduinobasics.blogspot.com/2012/07/arduino-basics-simple-arduino-serial.html