Menu

Remote control of 433MHz RF sockets

2020-05-14
2020-05-28
  • Dermot Donnelly

    Dermot Donnelly - 2020-05-14

    Hi,
    I want to try and control a remote 433MHz RF plug with a PIC and cheap transmitter.
    I’ve searched the forum but couldn’t find anything specific on this question although there is a lot on RF transmission and reception.

    I have been able to sniff the codes using an Arduino and a library called RCSwitch.h. See the attached file and the raw code here:

    Decimal: 6725231 (24Bit) Binary: 011001101001111001101111 Tri-State: not applicable PulseLength: 315 microseconds Protocol: 1
    Raw data: 9788,204,116,348,468,136,104,80,96,272,364,248,828,332,832,1004,256,960,224,316,888,920,264,244,412,68,408,48,92,236,168,304,240,100,616,108,212,276,84,372,256,72,88,268,76,164,120,224,308,

    1. Would a PIC be capable of sending this data at these speeds using GCB?

    2. What type of PIC would be recommended? I have a few 16F684.

    3. To replicate the above would it just be as simple as using pulseout and wait commands?

    4. If anybody could point me in the direction of some code snippets I’d appreciate it.

    Thank you
    Regards
    Dermot

     
  • Anobium

    Anobium - 2020-05-14

    Would a PIC be capable of sending this data at these speeds using GCB?
    Yes. Great Cow BASIC is true ASM. So, it is fast.

    What type of PIC would be recommended? I have a few 16F684.
    Go and buy some new PICs. Like 16F18313, an Xpress board?, or an 18FnnK42 (64 MHz internal clock!)

    To replicate the above would it just be as simple as using pulseout and wait commands?
    Someone else can advise. But, you can create customised protocols with ease.

    If anybody could point me in the direction of some code snippets I’d appreciate it.
    @williamroth may be good bet for this.

    :-)

     
    • Dermot Donnelly

      Dermot Donnelly - 2020-05-15

      Thanks for that info.

       
  • jackjames

    jackjames - 2020-05-14

    xDermot:
    The code in your example is the HS1527 encoding.
    This corresponds in a sequence of 24 bits composed only of the values ​​0 and 1.
    Unlike the PT2262-2272 coding which instead also includes the value "F", ie floating.
    The composition of the sequences to distinguish the levels L, H and F is similar for both codes and differs slightly.
    Some time ago I wrote a code in another Basic language to be able to transmit with both encodings and with a few modifications you can convert it to GCBasic.
    The PT2262 encoding requires the sending of the 12 byte phrase in an example string format: "FF10F11F0001".
    The first 8 bytes are the address, the last 4 bytes are the number of the corresponding key.
    The HS1527 encoding instead, that of your example, I managed it using 4 variable bytes.
    The first two correspond to the 16 bytes high, then a third variable follows which correspond to the remaining 4 bytes to reach 20 and thus form the address.
    The last byte variable indicates the data, that is the key pressed.
    In the attached file there are two routines to use, the others are service routines to allow their operation.
    The first is the
    "Sub SendHS (Dim Ind0, Ind1, Ind2, Value As Byte)".
    The second is the "Sub SendPt" where the 12 character string is to be passed.
    The duration of the delays for the formation of the codes has been calculated and is the optimal one.

     
  • jackjames

    jackjames - 2020-05-14

    I forgot ...
    I used a 12F683 without problems ...

     
    • Dermot Donnelly

      Dermot Donnelly - 2020-05-15

      Thank you very much for the info and code. It is more than generous. I'll study what you've given me carefully and I'll also try simply using the pulsout and wait commands as I already have the codes and just want to turn one socket on and off.
      Thanks again for your help and code.

       
  • Chris S

    Chris S - 2020-05-21

    So I have used those cheap 433Mhz pairs and I have some small working code. I found out that you have to limit your Baud Rate 2400. Also what I found is that you need two Byte of random data to get the thing up and running, hence why the FF and AA code before it sends everything.

    This was just a test and may not be a final working program (but it does work last tested). Range was about 30 ft or roughly about 9.14 meters.

    Transmitter:

     #chip 18F25K20, 8
     #config '[todo]
    
    ' #include '[todo]
    
    #define USART_BAUD_RATE 2400
    #define USART_BLOCKING
    ; ----- Constants
    
    
    ; ----- Variables
    Dim CounterVar as Byte
    Dim Checksum as Byte
    ; ----- Quick Command Reference:
      '[todo]
    
    
    ; ----- Main body of program commences here.
    Do
    Checksum = "H" xor "2"
    
      HSerPrint 0xFF
      HSerPrint 0xAA
      'For CounterVar = 0 to 2
        'HSerPrint 0xAA
      'Next
            HSerPrint "H"
            HSerPrint "2"
            HSerPrint Checksum 'should be 122
            HSerSend 13
            HSerSend 10
     ' For CounterVar = 0 to 255
     '   HSerPrint CounterVar
     '   wait 100 ms
     ' Next
    
    
    wait 1000 ms
    Loop
    end
    

    Receiver code

    '''A demonstration program for GCGB and GCB.
    '''--------------------------------------------------------------------------------------------------------------------------------
    '''This program
    '''RF modules seem to need up to 10 bytes to send correctly. Otherwise
    ''' they work fine. Range is about 30ft.2400 max bps
    '''@author
    '''@licence GPL
    '''@version
    '''@date    01.11.2015
    '''********************************************************************************
    
    ; ----- Configuration
    
     #chip 18F13K22, 8
     #config '[todo]
    
    ' #include '[todo]
    
    #define USART_BAUD_RATE 2400
    #define USART_BLOCKING
    ; ----- Constants
    #define DataByte1 DataBytes(1)
    #define DataByte2 DataBytes(2)
    
    ; ----- Variables
    Dim CounterVar as Byte
    Dim Rec as Byte
    
    Dim DataBytes(2)
    ; ----- Quick Command Reference:
      '[todo]
    
    
    ; ----- Main body of program commences here.
    Do
      HSerReceive (Rec)
    
    'Check to see if we have a datapacket and then receive the data.
    ' Shove it into an array.
      If Rec = "H" then
    
        For CounterVar = 1 to 2
          HSerReceive (DataBytes(CounterVar))
        next
    
        HSerPrint DataBytes(1)
        HSerSend 13
        HSerSend 10
        HSerPrint DataBytes(2)
        HSerSend 13
        HSerSend 10
      End If
    
    Loop
    end
    
    ; ----- Support methods.  Subroutines and Functions
    
     
  • Dermot Donnelly

    Dermot Donnelly - 2020-05-28

    Thanks for that Chris. I'll study your code and see can I make it work.
    Regards
    Dermot

     

Log in to post a comment.