You can download our own demos to both your Pi’s with:
wget securipi.co.uk/cc1101.zip
unzip cc1101.zip
ls
Here’s the list of files downloaded & what they do:
TX_DemoPir.cpp Transmits a PIR2 message whenever the PIR detects movement
RX_DemoPir.cpp Receives a signal and prints “PIR2 Triggered” to console.
RX_DemoPir2.cpp as above, with time and date logging to file test.txt
RX_DemoPir4.cpp as above, but also flashes an LED connected to GPIO4 when PIR triggered
Each of the cpp files are source code which needs to be compiled in the same way as the other
demos. So for example, to use TX_DemoPir.cpp
sudo g++ TX_DemoPir.cpp cc1100_raspi.cpp -o TX_DemoPir -lwiringPi
sudo chmod 755 TX_DemoPir
sudo ./TX_DemoPir -v -a1 -r3 -i1000 -t5 -c1 -f434 -m100
In the silent folder there’s another version of the receiver demo code, with all the printf statements
commented out and an exit(0) command immediately after it receives a valid code. We’ve done that
so you can call the receiver code from a shell script, and when a valid message is received by the
shell script you could send an email to your phone, or turn on an LED, or switch a relay controlling
a water pump, or open a door lock.
cd silent
ls
RX_DemoPir.cpp receiver with no message to screen, prints PIR2 and exits
receive.sh shell script, prints “PIR 2 triggered” to console. Loops
receive2.sh shell script, as above but doesn’t loop
receive3.sh as above, and turns on LED connected to GPIO4 for 3 seconds.
To use the silent versions of the receiver
sudo g++ RX_Demo.cpp cc1100_raspi.cpp -o RX_Demo -lwiringPi
sudo chmod 755 RX_Demo
chmod a+x receive3.sh
sudo ./receive3.sh
You can inspect & modify the contents of the source .cpp files and .sh files with nano. Example:
nano receive3.sh
You could use the TX_DemoPir program on several different Raspberry Pi’s, all with PIR modules
attached and just modify the message sent to PIR1, PIR2, or PIR3 on each different Pi. Then on the
receiver code, change this line, which currently looks for the number 2 → if( Rx_fifo[6] == 0x32)
to look for PIR1 with 0x31 or look for PIR3 with 0x33.