Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ This is a port of the RFM69 library for arduino from https://github.com/LowPower

Attach the RFM69 as follows:

| RFM pin | Pi pin
| ------- |-------
| 3v3 | 17
| DIO0 | 18 (GPIO24)
| MOSI | 19
| MISO | 21
| CLK | 23
| NSS | 24
| Ground | 25
| RESET | 29
| RFM pin | # | Pi pin header description| Pi pin header description | # | RFM pin
| ------- |----|-------------- |------------- |----| -------
| 3v3 | 17 | 3.3V Power | (GPIO24) | 18 | DIO0
| MOSI | 19 | MOSI (GPIO10) | GND | 20 | Ground
| MISO | 21 | MISO (GPIO9) | (GPIO25) | 22 |
| CLK | 23 | SCLK (GPIO11) | CE0 (GPIO8) | 24 | NSS (CS)
| Ground | 25 | GND | CE1 (GPIO7) | 26 |
| | 27 | ID_SD (N/A) | ID_SC (N/A) | 28 |
| RESET | 29 | (GPIO5) | GND | 30 | Ground

You can change the interrupt pin (GPIO24) in the class init.

Expand All @@ -37,3 +36,14 @@ cd py-spidev
sudo make install
```

And don't forget to enable the SPI interface:

```bash
sudo raspi-config
```

Select "Interface Options", -> "SPI", choose "Yes" to enable it and reboot.

```bash
sudo reboot
```
26 changes: 18 additions & 8 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@
if test.sendWithRetry(2, "blah", 3, 20):
print "ack recieved"
print "reading"

while True:
test.receiveBegin()
while not test.receiveDone():
time.sleep(.1)
print "%s from %s RSSI:%s" % ("".join([chr(letter) for letter in test.DATA]), test.SENDERID, test.RSSI)
if test.ACKRequested():
test.sendACK()
print "shutting down"
test.shutdown()
try:
test.receiveBegin()
while not test.receiveDone():
time.sleep(.1)
print "%s from %s RSSI:%s" % ("".join([chr(letter) for letter in test.DATA]), test.SENDERID, test.RSSI)
if test.ACKRequested():
test.sendACK()
except KeyboardInterrupt:
userAnswer = raw_input('Enter "yes" to cancel or "no" to keep running [yes/no]:').strip().lower()

if userAnswer == 'yes':
# quit as requested by user
print "shutting down"
test.shutdown()
break
else:
continue
56 changes: 32 additions & 24 deletions radio1.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,41 @@

print "starting loop..."
sequence = 0
while True:

msg = "I'm radio %d: %d" % (NODE, sequence)
sequence = sequence + 1
while True:
try:
msg = "I'm radio %d: %d" % (NODE, sequence)
sequence = sequence + 1

print "tx to radio 2: " + msg
if radio.sendWithRetry(2, msg, 3, 20):
print "ack recieved"
print "tx to radio 2: " + msg
if radio.sendWithRetry(2, msg, 3, 20):
print "ack recieved"

print "start recv..."
radio.receiveBegin()
timedOut=0
while not radio.receiveDone():
timedOut+=TOSLEEP
time.sleep(TOSLEEP)
if timedOut > TIMEOUT:
print "timed out waiting for recv"
break
print "start recv..."
radio.receiveBegin()
timedOut=0
while not radio.receiveDone():
timedOut+=TOSLEEP
time.sleep(TOSLEEP)
if timedOut > TIMEOUT:
print "timed out waiting for recv"
break

print "end recv..."
print " *** %s from %s RSSI:%s" % ("".join([chr(letter) for letter in radio.DATA]), radio.SENDERID, radio.RSSI)
print "end recv..."
print " *** %s from %s RSSI:%s" % ("".join([chr(letter) for letter in radio.DATA]), radio.SENDERID, radio.RSSI)

if radio.ACKRequested():
print "sending ack..."
radio.sendACK()
else:
print "ack not requested..."
if radio.ACKRequested():
print "sending ack..."
radio.sendACK()
else:
print "ack not requested..."
except KeyboardInterrupt:
userAnswer = raw_input('Enter "yes" to cancel or "no" to keep running [yes/no]:').strip().lower()

print "shutting down"
radio.shutdown()
if userAnswer == 'yes':
# quit as requested by user
print "shutting down"
radio.shutdown()
break
else:
continue
63 changes: 35 additions & 28 deletions radio2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,40 @@

sequence=0
print "starting loop..."
while True:


msg = "I'm radio %d: %d" % (NODE, sequence)
sequence = sequence + 1

print "tx to radio 1: " + msg
if radio.sendWithRetry(1, msg, 3, 20):
print "ack recieved"

print "starting recv..."
radio.receiveBegin()
timedOut=0
while not radio.receiveDone():
timedOut+=TOSLEEP
time.sleep(TOSLEEP)
if timedOut > TIMEOUT:
print "timed out waiting for recv"
while True:
try:
msg = "I'm radio %d: %d" % (NODE, sequence)
sequence = sequence + 1

print "tx to radio 1: " + msg
if radio.sendWithRetry(1, msg, 3, 20):
print "ack recieved"

print "starting recv..."
radio.receiveBegin()
timedOut=0
while not radio.receiveDone():
timedOut+=TOSLEEP
time.sleep(TOSLEEP)
if timedOut > TIMEOUT:
print "timed out waiting for recv"
break

print "end recv..."
print " ### %s from %s RSSI:%s " % ("".join([chr(letter) for letter in radio.DATA]), radio.SENDERID, radio.RSSI)

if radio.ACKRequested():
radio.sendACK()
else:
print "ack not requested..."
except KeyboardInterrupt:
userAnswer = raw_input('Enter "yes" to cancel or "no" to keep running [yes/no]:').strip().lower()

if userAnswer == 'yes':
# quit as requested by user
print "shutting down"
radio.shutdown()
break

print "end recv..."
print " ### %s from %s RSSI:%s " % ("".join([chr(letter) for letter in radio.DATA]), radio.SENDERID, radio.RSSI)

if radio.ACKRequested():
radio.sendACK()
else:
print "ack not requested..."

print "shutting down"
radio.shutdown()
else:
continue