433 MHz RF module with Arduino Tutorial 2




There are 4 parts to this tutorial:
To get the most out of this tutorial - it is best to start at tutorial Part 1, and then progress to Part 2 then Part 3 and then do Part 4 last. Doing the RF tutorials in this order will help you to understand the process better.


Project 2: RF Remote Copy

In the previous project, we transmitted a signal wirelessly from one Arduino to another. It was there to help troubleshoot communication between the modules. It was important to start with a very short distance (1-2 cm) and then move the RF modules further apart to test the range. The range can be extended by soldering an antenna to the module, or by experimenting with different voltage supplies to the modules (making sure to keep within the voltage limits of the modules.)
In this project - we aim to receive a signal from an RF remote. The remote that I am using is a Mercator Remote Controller for a Fan/Light. (Remote controller code is FRM94). It is important that you use a remote that transmits at the same frequency as your receiver. In this case, my remote just happens to use a frequency of 433MHz. I was able to receive RF signals from from a distance of about 30cm without an antenna (from my remote to the receiver).


Video





Here are the parts that you will need to carry out this project:
 

Parts Required


Remote Controller


You can quickly test your remote, by pressing one of the buttons in close proximity to the RF receiver (using the same sketch as in Project 1), and you should see the LED flicker on an off in response to the button press. If you don't see the LED flickering, then this project will not work for you.

Here is a picture of the remote controller that I am using:

 
 

Arduino Sketch - Remote Receiver

The following sketch will make the Arduino wait until a signal is detected from the remote (or other 433 MHz RF device). Once triggered, it will turn the LED ON, and start to collect and store the signal data into an array.
I did my best to keep the signal reading section of the sketch free from other functions or interruptions.The aim is to get the Arduino to focus on reading ONLY... and once the reading phase is complete, it will report the signal data to the Serial monitor. So you will need to have the Serial monitor open when you press the remote control button.
The remote control signal will be made up of HIGH and LOW signals - which I will try to illustrate later in the tutorial. But for now, all you need to know is that the Signal will alternate between HIGH and LOW signals, and that they can be different lengths.
This sketch aims to identify how long each LOW and HIGH signal is (to make up the complete RF remote signal). I have chosen to capture 500 data points(or 250 LOW/HIGH combinations).You may wish to increase or decrease the dataSize variable to accomodate your specific RF signal. In my case, I only really needed 300 data points, because there was a "flat" signal for the last 200 data points (characterised by 200 repetitions of a LOW signal length of 0 and HIGH signal length of 255)

--------------------------------------------------


Receiver Fritzing Sketch



Results

After pressing the button on the RF remote, the data signal is printed to the Serial Monitor. You can copy the data to a spreadsheet program for review. This is an example of the signal produced after pushing the button on the remote for turning the fan/light on.
The following code was produced from pushing the button responsible for turning the light off:
The code sequence above may seem a bit random until you start graphing it. I grabbed the LOW column - and produced the following chart:
The chart above is a bit messy - mainly because the timing is slightly out... in that sometimes it can squeeze an extra read from a particular signal. But what is important to note here is that you can differentiate a LONG signal from a SHORT signal. I have drawn a couple of red dotted lines where I believe most of the readings tend to sit. I then used a formula in the spreadsheet to calibrate the readings and make them a bit more uniform. For example, if the length of the signal was greater than 4 analogReads, then I converted this to 6. If it was less than 4 analogReads, then I converted it to 2. I used a frequency table to help decide on the cutoff value of 4, and just decided to pick the two values (2 for short, and 6 for long) based on the frequency tables below. I could have chosen 5 as the LONG value, but there were more 6's overall.

  **The meaning of "frequency" in the following tables relate to the "number of times" a specific signal length is recorded.


And this is the resulting chart:

You will notice that the pattern is quite repetitive. I helped to identify the sections with vertical red lines (near the bottom of the chart). In other words, the signal produced by the remote is repeated 6 times.
I then did the same for the HIGH signal column and combined the two to create the following chart:



 
You will notice that the HIGH signals also have a repetitive pattern, however have a Very long length at the end of each section. This is almost a break to separate each section.
This is what a single section looks like zoomed in:



SL = [Short LOW] signal. - or short blue bar
SH = [Short HIGH] signal - or short yellow bar
LL = [Long LOW] signal - or long blue bar
LH = [Long HIGH] signal - or long yellow bar
VLH = [Very long HIGH} signal - or very long yellow bar (~92 analogReads in length)


  You will notice that there are only about 6 different combinations of the signals mentioned above. We can use this to create a coding system as described below:


 
We can use this coding system to describe the signals. The charts below show the difference between turning the LIGHT ON and LIGHT OFF.


 


 
PLEASE NOTE: You may notice when you copy the signals from the Serial monitor that you get a series of (0,255) combinations. This is actually a timeout sequence - which generally occurs after the signal is complete.

 Here is an example of what I mean.



This is the end of tutorial 2. In the next tutorial, we will use the code acquired from the remote to turn the FAN LIGHT on and off (using the 433 MHz RF transmitter).

Click here for Tutorial 3

Comments

  1. Thanks for this tutorial.

    it's easy to follow, good explanation,

    i have managed to retrieve the code from a pir sensor.

    please can you give a hint or better write a tutorial how to receive the code found in tutorial 2 to start a sub in the sketch?

    thanks for this great work,

    Jeroen,

    ReplyDelete
    Replies
    1. Hi Jeroen,
      Can you please explain what you mean by "Start a sub in the sketch" ??
      If you want to know how to transmit the code you acquired in tutorial 2, then continue on to tutorial 3.
      Please be aware that somewhere in tutorial 1&2 I have managed to get LOWs and HIGHs mixed up. Or maybe I haven't. Anyway - you will find that when you are transmitting the code, that you have to transmit them the other way around (LOWs become HIGHs and vice versa).
      See how you go.

      Delete
    2. Hi Scott, thanks for your reaction,
      i have also read tutorial 3 where you send the code with the Arduino.

      but that is not my question, i want to receive de code with the arduino!

      i have a pir sensor sending 433Mhz codes.
      as i say, i have found the code.
      Now i want to receive and let the arduino make a sound or something like that..

      i have no idea how to start arduino listen only to the found code ?

      i hope my question is now better.
      (sorry my english is not very good)

      Delete
    3. Hi Jeroen,
      I think I understand your question. You want the Arduino to listen for a specific code, and then get it to do something else ONLY when it receives that code.
      This kind of question is always best served within an Arduino forum - where multiple respondents can provide relevant info and code snippets etc, plus the flow of information is specific to your question.
      Having said that - your best bet is to have a look at tutorial 4 - which will show you how to get the Arduino to listen for the signal. This signal will be stored within the array called storedData[].
      You can then use a function to clean up the signal using "IF" statements. eg.

      if(storedData[i]<4){
      storedData[i]=2;
      }

      You will need to do this also for values above or equal to 4.
      Once you have cleaned up the code, you may only be interested in the first 10 or first 1000 values..... And would have to find a way to match these values in the storedData[] array with the pre-defined code you speak of. I can't go through the details here - because it would almost be a whole tutorial in itself - but please post your question on the Arduino Forum - and feel free to come back a leave a link to your forum query in the comments.
      Good Luck

      Delete
    4. Hi Scott,

      This. IS. Amazing.

      Thank you for your tutorial a 1000 times...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 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 that would 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 it according to my previously non-working socket (added High medium low) set and used it to calculate combinations.

      I must point out, that the pairs (HI,LO) in your sketch are correct, but not also in the table, as you already mentioned. I figured out from received timeouts, that pair 0,255 should be 0 for HI and 255 for 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 believe we could replicate almost any "as simple as these" control signal...I still have a wireless doorbell to try with.

      As you already assumed, there should be different timeDelay lengths as in my case one is 115 and the other is 150 (middle values).

      Keep up the good work and keep in touch.

      Best regards,
      Miroslav J. Perec (mirojp)

      Delete
    5. Thanks for the feedback Miroslav !!
      I know I have somehow managed to reverse HIGHs and LOWs somewhere in my investigation process, and may need to go back and revisit where I have gone wrong...
      Tutorial 4 is where I wanted to end up, whereas Tutorial 1-3 just show how I got there.
      I wanted a quick way to record the signals and play them back without the need of Excel or a computer... and I managed to do this is in tutorial 4.
      Glad to hear that it worked for you !!

      Delete
    6. can i know the price of this module

      Delete
    7. The most up to date prices can be located by clicking on the relevant part within the "Parts Required" section of the tutorial.

      Delete
  2. Hi Scott,
    great tutorial — thank you for the work. I'm trying to read a weather station's signal (and ultimately decode it), and I'll give this method a go.
    So far I've often seen the suggestion to hook up the receiver to your computer's Mic In and record the signal with Audacity, and then simply analyze the waveform visually. The audio ADC's sample rate is high enough to produce a very detailed graph.

    Anyway, I'm thinking of increasing the Arduino's analogread speed to improve the resolution. (In the hope of getting the best of both worlds.) Is your code available under an open license? I'd throw the result on Github (assuming I produce something sensible).

    Tom

    ReplyDelete
    Replies
    1. Hi Tom,
      When I started this project, I did not know if it was going to work or not. When it did work, I did a little happy dance. Not sure if it works for anyone else.

      Providing that your project is legal, I don't mind how you use my code.
      I would be interested to hear how your project turns out, and would be happy with just a reference link back to this blog somewhere in your code or Github.


      Delete
  3. Hi, I found this tutorial and it's great job!
    I've got a question:
    how set the receiver to work on 433mhz, because now I receive a lot of noise, and don't know how can I receive clear signal?

    Jakub

    ReplyDelete
    Replies
    1. The receiver is already set to work at 433mhz. I found that using 3V instead of 5V worked better for me as it reduced the range of the receiver. The greater the range, then the more likely you are to receive stray/interfering signals from other sources. You could use something to boost the signal of the transmitter to penetrate through the noise. However, you would need to seek advice to make sure that this is lawful in your country. I used trial an error.
      The other alternative is use a different frequency (e.g.315mhz) - once again you will need to check that this (or any) frequency is acceptable in your country.
      I was able to work without an antenna without any real issues.

      Delete
    2. Thank You, yesterday I finally read the code using Your program above. I've set the receiver to 433mHz using a screw on the receiver =D

      Delete
  4. Absolutely awesome set of tutorials Scott.
    I now have a beautiful Excel graph for one of my remote control signals. I have tweaked the settings in your sketch that transmits the signal but no joy. With my DVB-T system I now see virtually identical data from the signal from the remote control as I do from the Arduino but no response from the RF device.
    It is a fairly basic RF socket and I have all the code details but I wanted to test your system before I went on to a more complex device. I have reduced the 10 microseconds down to 3 so there are several attempts within the zone I know I need to work at.

    The graph (for off signal) and the comparison between remote signal and arduino signal (for on signal) can be seen at http://www.raspberrypi.org/forums/viewtopic.php?f=37&t=96807

    Any ideas why the RF socket is not activating with your excellent code?

    ReplyDelete
    Replies
    1. See tutorial 4 for my response to your question there

      Delete
  5. I think you are based in Australia Scott so I thought I would do further tests whilst you sleep with the more 'difficult' RF device I have. Followed your procedure and retained my tweaks in the sketch and it worked FIRST time.
    Strange thing is with yesterdays tweaks for the 'easy' RF device the signals reported from DVB-T system for todays 'difficult' device show quite different readings (between actual remote and Arduino signal). Yet the Arduino controls the device just fine.

    So I changed most of the sketch back to your original settings and the Arduino continues to control the device. As you have said in your tutorials there is quite a bit of flexibility in what is an acceptable signal for the RF devices.

    I have 2 of the 'difficult' RF devices, which I will now rename as type 2 and they 'work' as opposed to the 'easy' RF devices which I would have expected to work as type 1, but don't work.

    Type 2 devices have DIP switches and the 2 units I have are set to different codes. The working Arduino sketch will only activate 1 of the devices even when I send the revised code to the unit. The revised code being worked out as I know the binary sequence to send and DVB-T confirms it is sent correctly.

    I have just changed the DIP switches on the none working type 2 device to match those of the working type 2 device. Arduino now controls both units. I did this just to check that one unit didn't have a different tolerance to the other.

    So there is something I (or the Arduino) doesn't quite understand. Why will type 1 units not work even though the signals seem to match very well and why will type 2 units not work when set to a different code?

    ReplyDelete
    Replies
    1. See tutorial 4 for my response to your question there

      Delete
  6. What about using interrupt instead of polling for signal change? I think this post (http://forum.arduino.cc/index.php?topic=129201.0) does exactly this.
    Would you get a better measurement?

    ReplyDelete
  7. Hi Filippo,
    Better measurement ? Not sure.
    Feel free to give it a go and let me know.
    The method used above worked fine for me, so I had no reason to look any further.

    ReplyDelete
  8. Hi Scott

    Am i still able to use the system if i have 5 meters to communicate?

    Thx.

    ReplyDelete
    Replies
    1. Hi emre - if you are talking about communicating between Arduinos, then this is not the right tutorial. If you are talking about using this to communicate with a fan/light receiver over a distance of 5m, then yes - I was able to send signals to the light/fan from a distance of 5m. Performance may vary depending on your module, the power being supplied, other interfering devices etc etc

      Delete
  9. Thanks scott, it's a very good blog

    please witch spreadsheet software you need .

    thnks

    ReplyDelete
    Replies
    1. Hi Gogo,
      Thank you for the positive feedback.
      I used Microsoft Excel, but you could get away with any other comparable spreadsheet program.

      Delete
  10. Hi Scott,
    can you help me to calibrate sinal what formula you use to do that

    thanks

    ReplyDelete
    Replies
    1. Hi Gogo,

      If you are talking about the Frequency table in the picture above, you need to enter an array formula...

      Step1 :Create the left side column (by choosing numbers that match your data),
      Step 2: Highlight the cells in the column to the right, and enter this formula at the top

      =FREQUENCY(data_array, bins_array) CTRL-Enter

      Where
      data_array is your RF data
      bins_array is the column to the left (from Step1)

      See an example in YouTube

      Delete
    2. Hi Scott!

      I think i need you to explain the Excel a little bit more, maybe a video?
      I dont get it, i have the value.
      I dont get Step 1, and how do you clean up?

      Sam.

      Delete
    3. Hi eShrek,

      Ok so you have the signal, and you have copied and pasted into Excel.
      Just plot the values (using a bar chart), for the Low column. It should look something like this , however it will not have the red lines.... I just put them there so that you could see that the majority of points on that graph tend to sit at those two values. What you are trying to do is differentiate a LONG signal from a SHORT signal. So in my example, you can see that a long signal is around 5, and a short signal is around 2.

      Now do the same for the HIGH column.

      In my case, the HIGH column had 3 places of interest. It had a SHORT signal, a LONG signal and a VERY LONG signal. The short signal was roughly around 3, the long signal was around 6, but there was also a somewhat repetitive very long signal that was about 92 in length.

      So this is tricky... on the LOW side the short length is 2, and on the HIGH side the short length is 3.

      Also on the LOW side, the long length is 5, but on the HIGH side the long length is 6.

      In reality, the length may be somewhere between these two values, but we want to make short and long lengths consistent for each column... which is what I mean by "calibrate"... so I decided to draw a line in the sand and call a short length a value of 2, and long length a value of 6.

      Delete
    4. You could tell that any value less than 4 was a short length. And any value greater than 4 was a long length. This was true for both columns. So for any value that was less than 4, I CHANGED the number to a 2, and for any value greater than 4 I CHANGED to a 6.
      So when I plot the LOW column it should now look like this .

      On the HIGH column, I just had to be a little bit more careful, because remember, I did have those repetitive VERY LONG lengths to take into consideration. So for the HIGH column, any value that was greater than 50, I changed to 92. Once again I had to draw a line in the sand to keep the values consistent.

      If you were to now plot both columns on the same chart, you should see something like this.

      But obviously, that is a bit hard to see... so maybe just plot the first chunk of data, before it repeats itself. It should look like this.

      Delete
    5. You can see from that picture, that I started to label it with things like SL and SH, LL and LH. I just used a naming convention to identify whether it was a SHORT LOW signal (SL), or a LONG LOW signal (LL), and did the same for a SHORT HIGH signal (SH) and LONG HIGH signal (LH).

      So when you receive an RF signal, it will ALTERNATE between LOW and HIGH. But it does so for different durations... eg. It may stay LOW for 2 beats, and then jump HIGH for 6 beats, then back LOW for 2 beats and then back HIGH for 6 beats etc etc.... and we have just charted that pattern.

      The signal always alternates between LOW and HIGH, and will stay low or high for a SHORT, LONG or VERY LONG time.

      Now you could just program that pattern as is, but I have taken it one step further.
      I have just created a specific CODE for each LOW-HIGH pair (eg. SL + SH = 1).

      So when the signal is LOW for a SHORT amount of time (SL), and then switches to HIGH for a SHORT amount of time (SH).... this pair is equal to CODE (1)...as per my table here.

      You can create a code for each of the other pairs that you are likely to encounter. Thankfully, there are only 6 combinations. But you may have more.

      Once you create a code table, you can label your chart like this, so that you can create your SIGNAL CODE which may look something like this.

      Delete
    6. Alright. I think I got it!
      How do you change the values, are there any simple way? Not familiar with spreedsheets.

      Anyway, thank you and you have very nice blogg. Will be fun to follow you! :)

      Delete
    7. Create Two new columns for the new data - one new column for the calibrated LOW and one for the calibrated HIGH.
      Let us assume that the original LOW data is in Column A and starts at Row2 (i.e. A2).
      And the original high data starts in B2.

      The New calibrated LOW data will exist in Column C, and new calibrated HIGH data in Column D

      So in cell C2 - you would write this formula:
      =IF(A2>50,92,IF(A2>4,6,2))

      This is known as a nested IF statement.
      And you can read it like this:
      "If Cell A2 is greater than 50, change the value to 92, if not then check to see if Cell A2 is greater than 4. If it is greater than 4 change the value to 6, otherwise change it to 2"

      In Cell D2 you would write this formula:
      =IF(B2>50,92,IF(B2>4,6,2))

      Notice that it is essentially the same, but we are checking the cell B2 instead of A2.

      Once you enter the formula, you can either copy and paste it down to the bottom of the column or use this short-cut.

      1. Enter the formula into Cell C2: =IF(A2>50,92,IF(A2>4,6,2)) Press Enter
      2. Select cell C2
      3. Press: Ctrl+Shift+End Press these 3 buttons all at the same time
      (this will select the column)
      4. Press: Ctrl+D to copy the formula down that column.

      You can repeat that process in column D, but use the correct formula as described.

      ==================================
      Thank you for your feedback - feel free to share this blog post on social media.
      You can follow me on Google+, Twitter, Instagram (and of course you can follow this blog). I am also on Pinterest and Tumbler - but not very active.

      Delete
    8. This is what i get:
      http://s10.postimg.org/5qkgto1op/what.png

      Im not sure if that will be simple to decode...

      Delete
    9. Hi sShrek,

      I am not sure what formula you were using, but it doesn't look right.
      What is the LOW1 column ?
      Why does it change from 100 down to 99,98,97.... ?

      Looking at your signal - you can see that it goes
      HIGH for 82 beats,
      LOW for 59 beats,
      HIGH for 255 beats (which is the maximum signal length)
      LOW for 0 beats
      HIGH for 114 beats
      etc etc

      The fact that you are getting many LOWs at 0 beats just after a HIGH of 255 beats, means that you need to adjust this line in the Arduino code.

      int maxSignalLength = 255; //Set the maximum length of the signal

      You will need to set it to something like 400.

      And then try to receive the signal again.
      Post your results within the ArduinoBasics forum - and I will help you from there.

      Delete
  11. first of all thanks For your valuable information you put.
    can you upload the code in which it compare the the remote code with the one i store and if it true turn on led or any output and if is not discard it ?

    ReplyDelete
  12. Hello Scott C,

    I just started this Arduino thingy and im not very good in it. First of all I would like to say that your videos are very good made and your blog is very interessting to watch.

    Sadly I realy do not understand when you bring your datas from the serial monitor to the (Excel) sheet its one long line with something like that ...

    2,42
    1,8
    2,8
    7,2
    2,8
    1,8
    7,2
    2,8
    1,8
    2,8
    1,8
    7,3
    7,2
    ...
    it looks the same on my side. How do you seperate them into High and Low? Because i only have this one line with lots of numbers but not a second one. Hope you can help me because im kind of fustrated to bring my 433mhz device to work.

    ReplyDelete
    Replies
    1. Hi Vin,

      Thank you for your feedback.

      You have two numbers per row, separated by a comma.
      You can use Excel's "text to columns" feature to split them into two columns of data. Alternatively, you could paste the data into a notepad/wordpad document and save it with a .csv extension.
      And then import that file into excel... you could do it either way.

      Delete
    2. Hey Scott,

      thanks for that information. Now i had the next problem. I made here the Excel sheet

      https://drive.google.com/folderview?id=0B66G7sV8o5BjMUc3WGw5eVRIN00&usp=sharing

      its in xls and xlsx and when you open it and cant see values change to the sheet two there i made the calculations with english formulation.

      Anyway i tried the code i got from it and it doesnt work. I checked the datas you put in the programm and saw there a value VLL but you wrote in this tutorial VHL so i was big confused.

      I hope againe you can help me because i plan a project to control 433mhz switches with the universal remote control of a tv.The IR part works at the moment i just need to figure out how i can manage to get the code from the 433mhz transmitter.

      Thanks a lot Vin

      Delete
    3. Hi Vin,

      I know at some point in the process I got the HIGHs and the LOWs mixed up. I am not sure at which point of the process. So perhaps try sending LOWs as HIGHs and HIGHs as LOWs and see if that works for you.
      I can tell from your spreadsheet that you are receiving a decent signal. You can make up your own coding system if you want to, or just play back what you received (see tutorial 4). I also noticed that you calibrated the long signals to a value of 6. I don't think this is right for your project... try pick a value that is close to what you are actually getting. For short signals you seem to be getting a value of 1 or 2 (so choosing a value of 2 should be fine).. For long signals you are getting values of 7 when it is a LOW, and 8 when it is a HIGH... you may need to incorporate this into your code somehow.
      Your very long value of 42 is likely to be a spacer between the signals - which is why I think that column should be LOW values and not HIGH values - sorry I know I have muddled this up.. but I cannot pinpoint where my muddle starts.

      There are a few examples of the process within the ArduinoBasics Forum. And I would say that if you cannot get it to work after this reply - then to post further queries related to this topic within the forum:
      http://arduinobasics-forum.1116184.n5.nabble.com/Quick-questions-about-ArduinoBasics-projects-f3.html.. And we can work through this together.

      I apologize for the confusion.


      Delete
  13. Vin,

    Have you worked through tutorials 3 and 4?

    ReplyDelete
  14. Hello Anonymous,

    i tried both of them and both didnt work on my devices. Still dont know how to do it.

    ReplyDelete
  15. Vin,
    We have cracked some fairly complex RF codes with scott's stuff so it does work. As Scott suggests post on his forum where you are up to and I'm sure we can get you up and running. Sometimes you need to tweak the data a bit. We were getting lows and highs mainly as 1's and 7's but we new from other posts on the internet that the high was 3 X the low. When we changed 1's and 7's to 2's and 6's it all worked perfectly.

    ReplyDelete
  16. Hello
    is it possible to see the signalstrengh between the transmitter and the receiver on a display?
    for example to detect the transmitter behind a wall?
    Thanks Alex

    ReplyDelete
  17. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. You are not receiving a signal.
      I don't think you really needed to paste the whole output into the comments... and if you really need to - then perhaps move this discussion to the ArduinoBasics forum (link in the tab at top of page).

      Delete
  18. hi , i can never get a patten on the low signal, does this matter? Im very new to arduino!

    ReplyDelete
    Replies
    1. Hi Chris,

      When you say you are not getting a pattern on the low signal, do you mean that the signal pattern keeps changing every time you record it ? Are you getting any common sections between reads... for example
      Read 1: SL, SL, LL, LL, SL, LL, SL, LL
      Read 2: SL, LL, LL, SL, LL, SL, LL
      Read 3: LL, SL, SL, LL, LL, SL, LL, SL, SL

      While it seems that each read is different, you will notice that they are similar. Read 2 is the same as Read 1 IF you remove the first SL from Read 1. Read 3 is the same as Read 1 IF you add a LL to the beginning of Read 1... so when you say you can never get a pattern on the low signal - you have to be a bit more specific about what you mean.
      What happens on the HIGH signal side ?
      Can you differentiate between a long signal and a short signal for either the HIGH or LOW side?

      Delete
  19. hi thanks for the quick reply, the signal looks the same ( bunch of 4 and 5's),but it doesn't appear to be any precise pattern. Also I should be more clear on high , low, short, long! On the high's I get a reputation around every 67, an exact copy of what was before. I was hoping the low's would also repeat around 67. It does appear that , the low's do "want" to follow a pattern , i.e a short length of short then a short length of long repeating, but no where near as precise as the high's, which is identical after 67 .I plotted it in excel, and straight away it appears to have no pattern. I understand there would be a few unusual readings but as I say on the low's all I get are 4 and 5's , nothing huge.
    cheers

    ReplyDelete
    Replies
    1. Hi Chris,
      What values are you getting for your short highs and your long highs?
      It might just be that all of your LOWs are the same. I don't think that 4 and 5 is "different enough" for you to be able to differentiate them.. so if it were me, I would just choose the most common value, and change all LOWs to that number. And then proceed with the tutorial... If your short HIGHs have a length of 4 or 5 then I would choose to be consistent and call these LOWs a "short low" or SL.

      I hope that made sense.

      Delete
  20. The high's , I was getting readings of 11,10,2 and 1. I tidied them up to 2 and 10 and it looks very tidy a definite symmetrical pattern with a very high start of 97 like your picture above. As I say the lows obviously has a long and a short , and a very scruffy pattern , but certainly no ware near symmetrical. The highs repeated at 67 , there is certainly no repeat for the lows at 67! i will try what you suggest tonight thank you

    ReplyDelete
  21. Do you have skecth and cooding rf433mhz with pushbutton and 2 arduino uno or projectboard without using remote mercator ceilling fan/light?

    ReplyDelete
  22. Really educative post, so this is how remotes are done! Thanks for sharing!

    ReplyDelete
  23. it work , thanks

    int lightON[]={2,4,4,4,4,2,4,2,4,4,4,2,2,2,2,4,2,4,2,4,4,4,2,2,6};

    for(int j = 0; j<6; j++){
    for(int i = 0; i<codeSize; i++){
    switch(codeToTransmit[i]){
    case 1: // SH + SL
    highLength=3;
    lowLength=3;
    break;
    case 2: // SH + LL
    highLength=1;
    lowLength=10;
    break;
    case 3: // SH + VLL
    highLength=3;
    lowLength=92;
    break;
    case 4: // LH + SL
    highLength=10;
    lowLength=1;
    break;
    case 5: // LH + LL
    highLength=7;
    lowLength=7;
    break;
    case 6: // LH + VLL
    highLength=3;
    lowLength=99;
    break;
    }

    9,2
    9,2
    9,2
    9,2
    2,9
    9,2
    2,9
    9,2
    9,2
    9,2
    2,9
    2,9
    2,9
    2,9
    8,3
    2,9
    8,3
    2,9
    8,3
    8,2
    9,2
    3,8
    3,8
    3,8
    3,99


    just got a little bit problem , the board voltage is 3v and i given input 5v from arduino to that rf board , and the problem is , the board will hang.....why?? i need to change the output voltage from 5v to 3v?




    ReplyDelete
    Replies
    1. I don't know what board you have, but the one I have will operate at 5V without any issues. If you look at the link for the transmitter, you will see that the operating voltage is from 3-12V. And the XY-MK-5V Receiver operates at 5V.

      So no idea why your board is "hanging"??

      Delete
  24. Hello Scott, I need help, i received the code from controller but, i dont have idea to convert the received signal to code.

    The part repeat is

    2 5
    2 6
    5 2
    5 3
    2 5
    2 6
    5 2
    2 6
    2 6
    1 6
    2 6
    2 5
    5 3
    2 5
    2 6
    2 6
    5 2
    2 6
    1 6
    2 6
    2 5
    2 6
    2 5
    5 3
    2 6
    5 2
    5 3
    5 2
    2 6
    2 5
    2 6
    5 3
    1 6
    2 6
    1 6
    5 3
    1 6
    2 6
    2 5
    5 3
    41 13


    Any Formula to covert ,

    ReplyDelete
    Replies
    1. Hi Victor,
      In your case, any time you see a 1, change it to a 2.
      Am not sure about what you should do about all the 3s. Perhaps just leave them like that for now.
      And any time you see a 5, convert that to a 6.

      You do not necessarily have to convert them to a code if you don't want to... you could just have a couple of arrays that you use to replay the sequence by using a for-loop.

      Have a look at my review of the EspoTek Labrador on my YouTube channel... In that review, I use the Labrador to intercept the signal of my RF remote... it might help you to visualise the signal that you are trying to reproduce.
      Here is the link to the EspoTek Labrador review that I am talking about: click here for the review

      Delete
  25. Hi Scott,
    My name is Roberto. Thanks for sharing such a good inofrmation. My problem very simple. Regarding tutorial 2 I have several 433 MHz remotes but no information is detected in the serial monitor. I have changed bateries, arduino board, RF receiver....everything and don't know what more can I do. I would appreciate your help, any sugestion?
    Thanks in advance

    ReplyDelete
    Replies
    1. Have you tried tutorial 4 ?
      See if that one works.

      Also - how did you go with tutorial #1.
      This will help test your modules.

      Delete
    2. Another trick is to make sure you press the remote button right next to the receiver module. And some people also report that they have to press the remote button around the same time as resetting the Arduino (attached to the receiver).
      Try pressing the button before, at the same time, slightly after, and shortly after pressing the reset button.
      Once the LED lights up, it has started to receive a signal. So pay attention to the LED, and make sure that interference is not affecting your ability to receive signals.

      Delete
  26. Hi Scott,
    My name is Moshe and My problem is, after I was able to receive and transmit, everything works fine until I press on the original remote control again, and then I see the code is different each press on the original remote control.
    I do not understand how the original receiver can know what is the next code that transmit from the original remote control, even tried to pull the battery from the remote control and then returned, trying to figure if there any master code.
    Please if you can explain it drives me crazy.
    Best regards,
    Moshe

    ReplyDelete
  27. I think, I didnt understand this :(

    1st of all, why we connect receiver to A0 ?? Shouldnt we have a digital out from receiver ?

    ReplyDelete
    Replies
    1. It doesn't matter. The analog pin essentially shows you the voltage of a HIGH reading. You could connect it to a digital pin if you want.
      We are just counting how long it stays high and how long it stays low. There are many ways you could do this. And yes - if I chose to do this project again (knowing what I know now), I would probably do it differently. But I think it is important to leave it the way it is, so that people can see an alternative way of doing things and expand their knowledge.

      Delete
    2. Voltage = (Analog reading /1023) * 5

      Delete
    3. Ok, I now understand the logic. Thanks for your time and replying all comments.

      But I still have difficulties with decoding signals. Here is what I do;

      1-I isolated the receiver with alum foil from electromagnetic noise.
      2-I analogread the output of the receiver

      On serial monitor the signal is always bouncing between 0 - 700. Is it normal? According to my logic, without any signal serial monitor should not move that much.

      Delete
  28. After frying a couple of receivers I finally got part 1 complete.

    I would like to use this in a practical example but to do this I need to have the transmitter working off 433.92Mhz. I have a transmitter that can do this. But before I can transmit anything I need to learn what I need to send if you catch my drift.

    How easy is it to convert one of these modules to receive 433.92Mhz transmissions? Do I just need to swap out the resonator?

    ReplyDelete
  29. Aha.

    So thats why I was able to get a >700 reading off A0 when transmitting.

    Thanks Scott, once again.

    I find the Short and Long difficult to get my head around. Would:

    10100110

    Translate to:
    SH,SL,SH,LL,LH,SL ? For example

    ReplyDelete
    Replies
    1. Yes - that is essentially correct.
      That assumes that the transmitted rate is exactly the same as the read rate.

      Let's say you read the state of the pin, but can now do it twice as fast. The number would appear as:
      1100110000111100
      --__--____----__

      SH,SL,SH,LL,LH,SL

      I hope that made sense, but yes you are on the right track.

      Delete
  30. I was one step from quitting my project, and I saw your tutorial.
    It gave me a great help.
    Thanks

    ReplyDelete
    Replies
    1. Hi Yannis,
      I am very glad that it helped you.
      Feel free to share this tutorial on your social channels so that others in the same boat as you can benefit as well.

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
    3. Hi Santiago,

      I do think you are experiencing interference, but there is a hint of a repetitive pattern in your results. I have deleted your query, because the results you posted take up about 10 pages of comment space... but here is what I would do.
      Firstly, get the transmitter and receiver as close together as possible.
      Record the results multiple times and look for patterns between the results... they may be offset, but charting the results helps alot.
      Try pressing the record button just before you press the transmit button, and it doesn't hurt to play around with the timing of this button press. Try it early, try it late, try it at the same time, but keep plotting the results and look for patterns. Eventually you will get an idea of what is Normal and what is interference. You will also get an idea of when you need to press the button in order to record the entire signal. You may also need to modify the sketch to capture a longer duration in order to capture the entire signal.

      Delete
  31. Hi Scott,

    I'll work on that.

    Thanks for your help.

    ReplyDelete
  32. Hi Scott,

    First, I just want to thank you for a good tutorial!

    I just have a small question regarding a project I’m working with. I’m trying to decode a remote for a gate I have. I seem to get the correct values and I can see that there is a pattern. It looks like it repeats the signal 3 times but with one thing different. The first block ends with an “LL + VLH”, but the 2 other blocks end with “SL + VLH”. How should I handle this when I sending it in your opinion? Please see the link for more information: https://ufile.io/97do1

    Best Regards
    Tim

    ReplyDelete
    Replies
    1. Hi Tim,
      If the 3 codes are consistent. Then just transmit the codes in the same way that you receive it.
      Rather than try to send 3 separate signals, just transmit one signal that encapsulates (or contains) the 3 signals. Use the same timing/spacing as your captured pattern.

      For example, when you received the signal. It may have had a pattern like xAxBxBx.
      Where x may have been a specific time between signals A and B.
      Rather than trying to write Arduino code to transmit x, and then transmit A, and then x again... etc etc.
      Why not just transmit the single signal xAxBxBx.
      You recorded the signal, just play it back.

      You may want to look at tutorial 4. Which shows how to record and play back a signal without using excel.

      Delete
  33. Hi Scott, the instructions advise that if the LED does not blink while pressing the remote, this will not work for me. Here is what is happening for me:

    1. I have a 433Mhz receiver which I know for a fact is working because I was able to capture the RF signals using the in-line of my sound card and I can clearly see the short and long pulses

    2. when I load the above sketch for the receiver onto the Uno board, the serial monitor display a number stating somewhere above 400 and it gradually reduces to 293-295. This is without pressing the remote buttons at all.

    3. When I press the RC button, nothing happens, there is no change to the number displayed in the serial monitor

    I am not sure how to interpret this. Could you elaborate on why the LED not blinking means I cannot use this tutorial? and can you suggest a way that I can get to use the Arduino board to read those RF signals?

    Many thanks,
    Gaetano.

    ReplyDelete
  34. Hi, my sketch start recording before I pressed one button on my remote :D why?

    ReplyDelete
    Replies
    1. Same problem here :-(

      Delete
    2. Receiving stray signals / interference.
      Just try multiple times, try to vary your timing.
      If you don't succeed on the first attempt, attempt again.
      Do it until it works.
      It is not perfect.

      Delete
  35. Hi Scoot,

    Can you please tell me why I am getting different codes for pressing the same button?

    Can anyone please help me in making the graph, I am doing this for first time. my skype ID: uday.kumar2555

    I am trying to hack RF codes using 4-5 ways. I want to be successful using this approach too. If anyone help me I will show lots of hack tricks in IOT

    ReplyDelete

Post a Comment

Feel free to leave a comment about this tutorial below.
Any questions about your particular project should be asked on my Arduino Tutorials Discord Server.

Comments are moderated due to large amount of spam.

Popular Posts