Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Teensy3 and RCSwitch Library for 433mhz home automation and alarm devices

  1. #1
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,938

    Teensy3 and RCSwitch Library for 433mhz home automation and alarm devices

    For anybody trying to interface the cheaper 433mhz power switches/alarm sensors the RCSwitch Library and examples almost work out of the box, only addition being adding pinMode(0, INPUT); to setup the RX pin as Teensy3.x doesn't default the pins as input like an Uno/Atmega328.

    Source:
    https://code.google.com/p/rc-switch/

    Notes:
    RCSwitch is designed to support a range of insecure 433 mhz specifications, what it won't do is allow you to interface to anything with a sane rolling code system so manage your expectations accordingly. See also expected 433mhz performance range described at https://www.pjrc.com/teensy/td_libs_VirtualWire.html

    Library usage is to specify the interrupt you want to attach the RX pin to, not the pin itself and the numbers differ on Arduino. Teensy 3 allows interrupts on all pins, so you can just insert whichever digital input pin works for your design and let the compiler and Paul's magic sort it out.

    Most of the RF modules operate on 5V or higher, level shift accordingly to the Teensy, especially if you are using a teensy3.0 with it's 3.3v inputs.

    Library produces the TX waveform via delay loops, so is blocking. RX loop is interrupt driven so will happily run in the background unless you start trying to push high data rates through it and in any case none of this has any error correction so code accordingly.

    If you are comparing to VirtualWire for use in a new project:
    VirtualWire adds a CRC, comes with two way communications examples and seems to have a more robust de-coding scheme that uses running averages.
    RCSwitch has a Raspberry Pi implementation if that's what you are looking for.

    Any device that you are talking to like this is inherently insecure, this may or may not matter to you. In my implementation I'm using motion sensors to feed lighting control in home automation so worst case of spoofing is lights get turned on, and can accept that at $10 a sensor.

    Have Fun

  2. #2

    Briefly, what GremlinWrangler said:

    RCSwitch mySwitch = RCSwitch();

    void setup() {
    pinMode(2, INPUT);
    mySwitch.enableReceive(2); // PIN 2 of Teensy
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •