433MHz module attached to the Arduino

433MHz module attached to the Arduino

Recently it happened frequently that some of our friends needed to take their bikes inside our garden after a nerding night. It was a boring situation where we had to constantly find the remote, open the gate, wait for them to take their bikes and then open again. Well, it wasn’t so boring, but you know, we needed a reason.
So, we tought about our last project where we successfully made arduino talk with Raspy using NRF24L01+ and dumbly toggling lights. This time we decided to go a step further and open our gate using, guess what, our smartphones.

Learning

At first we tried to achieve our goal using the standard RCSwitch library (and sketches) to listen the original remote’s signal, but as you might imagined, we poorly failed.
The wiring was pretty simple:

The Receiver wiring

The Receiver wiring

Keeping in mind that we were working with a fixed combination remote, we initially guessed a number of different problematics, even that our receiver was not operating in the same frequency as the remote. After some attempts (where we’ve found the frequency was right by looking the quartz),  we decided to hack a bit the original receiver sketch, forcing the arduino to receive the signals even if they were not conformed to the standard it used to know:

When we’ve uploaded the sketch we were able to see some raw messages. Actually, they were not messages, but these numbers on the serial monitor represent the interval between the changes of state (from 0 to 1 and reverse).

I suppose these numbers being just a representation of the signal noise. So, while listening with the arduino,  we’ve pressed the button on the remote and BABOOM, here is what came out:

A lot of very nice numbers…   What helped a lot understand what was going on was the link in the arduino sketch which translate these numbers in a more understandable form (yes, it’s a squared wave):

Squared wave

Squared wave

As you may noticed, the values (in microsecond), except  for the first one being really long, are doubles of ~320 µs. I suggest to approximate the unit value (in our case 320 µs ) to the average of one interval, since the signal is surely disturbed by the uninsulated components of the arduino, and because of the usb cable, even by your bad boy computer.

Tuning and Speaking

Once we successfully received the message we had to send it back to the gate. We tried to use the message raughly received by the arduino, but we found out that we had to tune it a bit to make it work, maybe because of some latency or noise.

Try/Guess Environoment

Try/Guess Environoment

We setted up a try/guess environment (pic above) with two arduinos, one with the 433 Mhz receiver we’ve setted up earlier and the other one with the twin transmitter module. We kept editing and sending the message untill we obtained the same message on the receiver as we were getting by the original remote.

The Transmitter wiring

The Transmitter wiring

In this process we’ve found out two important fact:

1- The initial long length (11672 µs in our case) was received completely wrong, while the others were in the range of ±20
2- Our message was not completely transmitted (it was actually missing the last 3~4 intervals)

For the first problem we just tuned it easily with some tries, but the other  was  a little bit more complicated, which we roughly solved by sending multiple times the last intervals (if you have any better solution feel free to suggest!).   Remember that to avoid misinterpretation by the gate receiver, the message has to be sent by the arduino at least 4 times.

Please note that some part of this sketch are taken from another sketch which we don’t remember where we took. If you are the author, please send us a mail with the link to your website and we’ll be glad to write your name and a backlink.

After all the final sketch resulted as following:

Raspberry Integration

As I said at the beginning, the whole project was meant to give our friends access to their bike with their smartphones, so we decided to use the previous project we made about switching light using a node.js web app.

Sketching

The sketch is pretty easy and it’s a mix from the switching light post and the one we’ve used to open the gate:

Wiring

For the wirings, refer to the following picture:

NRF24l01, Arduino and 433

NRF24l01, Arduino and 433

Node application for Raspberry

Since we recently upgraded all the software, we could easily adapt our previous application to the new shiny remote. Here is the link to the Github repo.

To install it please follow the instruction on the switching light article, in particular the The Node.js Lamp Application section.

Comments

22 Comments

Post a comment
  1. recep #
    June 28, 2016

    which program did you used to create “Squared wave” picture?

  2. HannaDarling #
    February 28, 2016

    I know nothing about how you did it but I appreciate that you do these things and make cheeky videos, Edo.

    Xoxo,

    Hanna

  3. December 29, 2015

    Hello Edoardo, I’m writing a little course on Arduino. Could I insert your link in my lesson? I have a remote controller with a similar coded transmission but a little different from your so I want to cite you about the use of RCSwitch library to receive raw info and decode it.

    • December 29, 2015

      Sure, no problem!

      • December 29, 2015

        Thank you! You can find it in a pair of days at my website clicking on my name 🙂

  4. John #
    December 21, 2015

    Hi Guys,
    Great project!
    I’m new to the programming game but wanted to give this a go.
    Would it be feasible to try this using an ‘Onion Omega’ with a transmitter module?!
    I can get the gate code from my SDR (software defined radio) USB stick.
    I’m only learning c# at the moment, do you think I could use this through Linux to broadcast the code?!

    Cheers guys!
    John

    • December 21, 2015

      Hi,
      yes , a onion omega is certainly a good solution, wasn’t available at the time of the writing. You would still need a 433 mhz TX module.
      C# (Microsoft) on linux is something I wouldn’t dare to try, basically because of compatibility issues you may find.
      Since you are managing to do it with an onion, I would suggest to put a little web server on the onion and building some basic RESTful APIs ( example: “http://192.onionIp.10.2/gate0/open”) .

      • John #
        December 21, 2015

        That sounds even better!
        Looking forward to working it out!

        That link is down though (http://192.onionIp.10.2/gate0/open)

        any other suggestions for where to get some example code?!

  5. Heather #
    March 5, 2015

    Hi, and congratulations for this tutorial which permitted me to improve my project (which is almost the same as yours !). Can you tell the brand/reference of your original remote/garage door, so that I may see if mine is compatible with your work ? Because as far as I’ve read, my remote (a came top 432na) does not use the protocol you implement here (or maybe am I just too much tired). Thanks for your reply.

    • December 12, 2015

      My remote it’s just a common 433Mhz NOT rolling combination model, compatible chinese version 😀

  6. Vlado #
    January 5, 2015

    Apparently the solution is to replace ” with ”

    Hope this helps other people.

    • Vlado #
      January 5, 2015

      That was supposed to say

      replace ” with ‘\’ ie. backslash zero.

      • January 11, 2015

        Hi! Would you point me to the file and the line of code please? Just so I can correct it if there’s a typo. Many thanks and hope you enjoy it.

        • Angelo #
          May 30, 2015

          I also have the same mistakes at line 54, 67, 89

          “empty character constant”

          I think the problem are the quotes, but replaces them with those twins, generate more errors … did you find the solution?

          Thanks

          bye bye

          • Angelo #
            May 30, 2015

            Ok, thanks, I solved,
            replace the ‘ ‘ (at line 54, 54, 67, 89) with ‘′

            bye bye

  7. Vlado #
    January 4, 2015

    I tried compiling the first sketch with Arduino IDE 1.0.5 however I’m getting these errors

    Receive.pde:54:22: error: empty character constant
    Receive.pde:54:42: error: empty character constant
    Receive.pde:67:23: error: empty character constant
    Receive.pde:89:20: error: empty character constant

    It appears it’s complaining about lines like these

    while (bin[pos] != ” && bin[pos+1] != ”) {

    Any idea how to fix that ?

    • Chris #
      August 21, 2015

      Hey… Turn a Space between the ‘ ‘. This fix the Problem in Line 54,67 and 89 🙂

  8. disak #
    November 3, 2014

    Hello guys, very good article. I have some problems with receiving . I got a lot of noise, i use the same rx tx kit as you 😉 did you notice some problems with it ?

    • November 16, 2014

      Thank you! Actually nope, no noise, but a lot of things today are running on 433Mhz (radio, weather stations, remote AC switch …).

Leave a Reply

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

By continuing to use the site, or scrolling, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close