433mhz PIR Interface

ZOR

Senior Member
Thanks hippy. It would be so nice to find a clear to understand article on doing all this. I just spent time making up leads to run 2 08M2 project boards to a solderless breadboard in attempt to try setting up serout and serin. So when I was ready I went to my trusted manual 2 and started reading about it. I do not have a serial lcd. I could not find a wiring plan, I know you have to specify a serout pin, thats it. If I could find out how to send passwords "Imaclown" and get it back I would be a happy person.
 
Last edited:

hippy

Technical Support
Staff member
If I could find out how to send passwords "Imaclown" and get it back I would be a happy person.
First you need to send your password out, and it would make sense to tell the receiver that it's a password being sent so it can more easily detect that, so for the initial transmitter ...

Code:
; Transmitter (first step)
#Picaxe 08M2
Symbol TXPIN  = C.2
Symbol TXBAUD = N2400
Do
  SerOut TXPIN, TXBAUD, ( "PASSWORD:", "Imaclown", CR, LF )
  Pause 5000
Loop
That will now send out "PASSWORD:imaclown<CR><LF>" through pin C.2 every 5 seconds.

Now on to the receiver which needs to receive your 8 character password and sends it back. Let's connect C.2 out of the transmitter to C.3 so that's the input, and let's echo what's received out of pin C.2 ...

Code:
; Receiver
#Picaxe 08M2
Symbol RXPIN  = C.3
Symbol TXPIN  = C.2
Symbol TXBAUD = N2400
Do
  SerIn  TXPIN, TXBAUD, ( "PASSWORD:" ), b1,b2,b3,b4,b5,b6,b7,b8
  SerOut TXPIN, TXBAUD, ( "RECEIVED:", b1,b2,b3,b4,b5,b6,b7,b8, CR, LF )
Loop
Then back to the transmitter, which has to now send the password, wait for the reply, and check that reply was what was sent. We connect the C.2 echo out of the receiver to the C.2 input so we can read the reply ...

Code:
; Transmitter
#Picaxe 08M2
Symbol TXPIN  = C.2
Symbol RXPIN  = C.3
Symbol TXBAUD = N2400
Do
  SerOut TXPIN, TXBAUD, ( "PASSWORD:", "Imaclown", CR, LF )
  SerIn  RXPIN, TXBAUD, ( "RECEIVED:" ), b1,b2,b3,b4,b5,b6,b7,b8
  If b1 = "I" Then
    If b2 = "m" Then
      If b3 = "a" Then
        If b4 = "c" Then
          If b5 = "l" Then
            If b6 = "o" Then
              If b7 = "w" Then
                If b8 = "n" Then
                  ; Received "Imaclown"
                End If
              End If
            End If
          End If
        End If
      End If
     End If
  End If
  Pause 5000
Loop
 

Jeremy Harris

Senior Member
For testing, just set up a loop on the transmitter to send a two or three "U" ASCII characters in succession, followed by an identifier (say "DATA") , followed by the string of characters that you want to send, at a defined baud rate and polarity (use a low baud rate to start with, for reliability and make sure it's inverted, so you don't transmit solid carrier between data bursts). Have this loop set up to transmit at a rate of, say, one transmission every 5 seconds, using a pause in the loop.

Set up a receiver using the serin instruction on the pin the receiver is connected to using the same baud rate settings at the transmitter and set up serin to use a qualifier that matches the identifier that you've transmitted, so in this case put ("DATA") in brackets like this, after the baud rate definition. Then add enough byte variables to receive the length of your data string.

Here's an example using pin C.4 on both the send and receive Picaxes:

Code:
;transmitter code
main:
serout C.4, N1200_4, ("UUU","DATA","IAMHERE")
pause 5000
goto main

END

;receiver code
#terminal 4800
main:
serin C.4, N1200_4, ("DATA"), b0, b1, b2, b3, b4, b5, b6
sertxd (b0, b1, b2, b3, b4, b5, b6, CR, LF, CR, LF)
goto main

END
This should open the terminal window on the receiver Picaxe (leave it connected after programming) and the terminal should display the transmitted data string of 7 characters every 5 seconds or so.
 
Last edited:

ZOR

Senior Member
Many thanks Jeremy, I have just found via Google this Forum thread, and at long last of trying to find a circuit to connect 2 Picaxes together I find you have to join with resistors one on each side with a resistor to ground. It's in this thread, but the person cannot remember resistor values. I don't know where this information is in the manuals but I never saw it until now.
http://www.picaxeforum.co.uk/showthread.php?17636-Serin-and-serout-o8M-to-08M

Once I can get two Picaxes together I can try things you are suggesting.

Thanks again
 

hippy

Technical Support
Staff member
at long last of trying to find a circuit to connect 2 Picaxes together I find you have to join with resistors one on each side with a resistor to ground
That is not true and may in fact introduce problems. If you are running the two PICAXE's from the same supply you can connect the output pin from one direct to the input pin of the other. Though a single 1K resistor instead of a straight wire will add current limiting protection should things go wrong while experimenting.
 

techElder

Well-known member
All these security layers upon layers upon layers trying to fool the unseen bad guy!

Reminds me of biscuits my wife used to make ... the more you chewed on them ... the bigger they got! ;)
 

ZOR

Senior Member
Many thanks hippy, missed your earlier thread whilst going back to Jeremy. Now I have lots there to play with so now there will be a greatful interlude of silence.
Texasclodhopper, maybe your wife was trying to choke you?
 

ZOR

Senior Member
Thanks hippy and Jeremy, got there!! Now I can work on things further. Have a good week.
 
Last edited:

rossko57

Senior Member
Still pondering radio...
An approximation of a "rolling code" scheme, where each message carrys a secret code and differs. Recent discussions have covered how Picaxe BASIC "random" number generator will give a repeatable result from a given seed number i.e. N -> X.
A message could include both N and X, a receiving Picaxe could then check validity by generating a "random" based on N and see if that matches X.
The transmitter would change N (and generate a new X) at each new message.
You have to send N because the receiver doesn't know what it should be.
It's hardly military security, but difficult for an intercepting hacker to guess what is going on at all. If they do guess the technique, they then have to guess you are using a Picaxe or do heavyweight maths to work out the randomising algorithm.

That would still have the risk of record/playback hacking - a more robust "rolling" part is needed. Since we are sending both "key" and "code" in the same message, it might help to hide the key in plain sight too. Adding an incrementing message number, and using that as the key N, brings other benefits - the receiver can now tell if messages are getting dropped/lost, because it knows what message number to expect next. You'd probably allow for 3 or 4 dropped messages before worrying, to allow for bad reception. You would not allow messages arriving from "the past", to deal with a record/playback attack.
Something similar could be done with timestamps instead of a simple incrementing counter ; you really wouldn't want the faff of RTC synchronising and so in a PIR with one-way communication - but you might exploit Picaxe M2's ticker-timer for a crude method.
 
Top