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

Thread: RCSwitch library

  1. #1

    RCSwitch library

    Hi,

    Does anybody know why RCSwitch library is not working on Teensy2.

    Same problem with Teensy 3.

    Thanks

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,536
    Nope, don't even know which library that really is. Maybe this one?

    https://github.com/sui77/rc-switch

  3. #3
    Quote Originally Posted by PaulStoffregen View Post
    Nope, don't even know which library that really is. Maybe this one?

    https://github.com/sui77/rc-switch
    Yes this one!

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,296
    Looking at the code and the #defines, this library seems just not to be intended to run on Teensy. You should either ask the author for adding Teensy support, or you fork the library, add Teensy support yourself and do a pull request afterwards.

    But when it comes to control RC servos, the PulsePosition library which comes with Teensyduino is much more powerful and available immediately.

  5. #5
    Quote Originally Posted by Theremingenieur View Post
    But when it comes to control RC servos, the PulsePosition library which comes with Teensyduino is much more powerful and available immediately.
    I don't need the send parts but need to data from receiver.

    Unfortunately I don't have the level to rewrite/design such a library:-(

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,839
    I looked at the link quickly and it links to RF 433 radio …

    it isn't clear what part RCV or Xmit is desired for the controls … more details would help

  7. #7
    Thanks.

    Just the RVC parts is needed. To run this example:
    https://github.com/sui77/rc-switch/b...emo_Simple.ino

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,536
    Regarding PulsePosition

    https://www.pjrc.com/teensy/td_libs_PulsePosition.html

    Quote Originally Posted by 2n3055 View Post
    I don't need the send parts but need to data from receiver.

    Unfortunately I don't have the level to rewrite/design such a library:-(
    Good news for you - the receive parts are separate from the transmit parts. You can use either, or both. So if you only want to receive PPM but not send it, all you need to do is use the PulsePositionInput and simply not use PulsePositionOutput. Easy peasy!

    But do be aware PulsePosition only works on Teensy LC, 3.1, 3.2, 3.5 & 3.6. It doesn't work on Teensy 2.0.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,536
    But looking quickly at the RCSwitch.cpp code, it's not clear to me whether it's really doing PPM or something else. Will look again when I have a little more time.

    I do see code for both sending and receiving stuff RCSwitch.cpp, if that matters to you...

  10. #10
    Thanks Paul,

    But it's not to control/receive servo motor data (PPM coding). But to decoded radio frame coming from a radio remote control. Switching on/off AC power socket!

  11. #11
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,839
    @2n3055 - giving a link to the radio in use would help. It might be a generic one - but if from a know maker sFun/AdaF or like one of their products getting the to the right library will be faster.

  12. #12
    Quote Originally Posted by defragster View Post
    @2n3055 - giving a link to the radio in use would help. It might be a generic one - but if from a know maker sFun/AdaF or like one of their products getting the to the right library will be faster.
    I don't find many information but some timing diagram (Intertechno):
    HTML Code:
    https://esp-32.com/index.php/2017/06/15/433mhz-signal-pattern-inspection/#comment-44
    With an Arduino, decoding with RCSwitch library works perfectly (tried Virtualwire without success). But apparently it's not a piece of cake to adapt it with Teensy...

  13. #13
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,864
    For what it is worth have used RCSwitch in in both modes with a T3.2 without any particular hassle other than the input pins for the library being built around the Arduino Uno interrupt pins, has been a while since I was in the code but:

    mySwitch.enableReceive(2);

    configures it to receive on pin 2, despite comments in the code saying otherwise.

    What I have had a lot of trouble with is some of the transmitter modules being pretty rubbish and ones that worked with 5V power on a slower Uno lost 50-75% of their range at 3.3V with a faster and noiser peripherals running alongside it. Suspect your problem is at least in part electrical.

    Possibly complicating things is that the version I use is from some random part of the internet some years ago and left alone because it works so will need to check if the linked library above is actually what shows up on my machine as 'RC switch'.

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,536
    Quote Originally Posted by 2n3055 View Post
    But apparently it's not a piece of cake to adapt it with Teensy...
    Can you tell us what you've actually tried which did not work?

    I installed the library and opened the ReceiveDemo_Simple example. It compiles without any error.

    I looked at the code in more depth. It appears to use only the very standard Arduino functions, which do work on Teensy. The input signal in received using a function from attachInterrupt with "CHANGE", which is will supported on Teensy. The Teensy boards (and other hardware this library supports) runs *much* faster than Uno, but the library is doing all the timing by getting microseconds from the Arduino micros() function, which works on all Teensy boards.

    The only "gotcha" I can see, which GremlinWrangler already mentioned, is it takes the interrupt number rather than pin number. On Uno & Mega, the int number and pin numbers are different, as the comment in the code explains. On Teensy 3.2 (and most other newer boards) the int number and pin number are the same. So that ReceiveDemo_Simple will listen for the signal on pin 0.

    This library really should "just work". If you're getting some sort of error message, or you're running it and getting wrong results, or no results at all, perhaps the problems are not incompatible software, but some sort of mistake or misunderstanding you've made? We can try to help, but we can't even see what you've really done. In fact, from your messages, I can't even tell if you've even tried using the library yet, or if this all based on your assumption it wouldn't work if you tried.

  15. #15
    I need to apologies for my mistake.

    After your remarks, I made some tests and something else was changed!!
    Tried RCSwitch with an another (oldest!!!) remote and... it works...

    It time to understand why. With logic analyzer I saw.

    Intertechno has updated his coding. Now it's code is not the same. The ID device is now 26 bits lang. https://waschto.eu/intertechno-433-m...hem-einbinden/
    (sorry it's only in German, see under "neue Steckdose – selbst lernend – 32-stelliger Code").

    Click image for larger version. 

Name:	Capture d’écran 2019-02-24 à 14.07.02.jpg 
Views:	1 
Size:	12.8 KB 
ID:	16001
    Click image for larger version. 

Name:	Capture d’écran 2019-02-24 à 14.07.21.jpg 
Views:	1 
Size:	29.4 KB 
ID:	16002

    Now I need to found a new library to decode this new frame...

    If somebody has an idea...

    Thanks and sorry again

Posting Permissions

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