Closed ctday closed 4 years ago
Sorry about the strike-through.
first, make sure you have the most recent version of all python libraires - you can use https://stackoverflow.com/questions/2720014/how-to-upgrade-all-python-packages-with-pip or similar then, run the default examples and post the output third, check your soldering, and verify you have nothing else attached on SPI
FYI -- I just verified that TinyLora_simpletest.py works with a Pi ZeroW and rfm95 bonnet Did you try the rfm9x_radio_check.py? What pins are you using? I use
cs = digitalio.DigitalInOut(board.CE1)
irq = digitalio.DigitalInOut(board.D25)
rst = digitalio.DigitalInOut(board.D17)
also - I removed the use of the D13 LED for the pi. code below.
Here are the installed libraries:
-------------------------------- ---------
Adafruit-Blinka 4.1.0
adafruit-circuitpython-busdevice 4.0.1
adafruit-circuitpython-framebuf 1.2.1
adafruit-circuitpython-rfm9x 1.2.2
adafruit-circuitpython-ssd1306 2.7.0
adafruit-circuitpython-tinylora 2.0.2
adafruit-io 2.4.0
Adafruit-PlatformDetect 2.3.0
Adafruit-PureIO 1.0.4
spidev 3.4
code run with keys REDACTED
import time
import busio
import digitalio
import board
from adafruit_tinylora.adafruit_tinylora import TTN, TinyLoRa
# Board LED
#led = digitalio.DigitalInOut(board.D13)
#led.direction = digitalio.Direction.OUTPUT
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.CE1)
irq = digitalio.DigitalInOut(board.D25)
rst = digitalio.DigitalInOut(board.D17)
# TNN Configuration
# always 4b, msb
devaddr = bytearray([REDACTED])
# always 16b, msb
app = bytearray([REDACTED])
# always 16b, msb
nwkey = bytearray([REDACTED])
ttn_config = TTN(devaddr, nwkey, app, country='US')
lora = TinyLoRa(spi, cs, irq, rst, ttn_config)
while True:
data = bytearray(b"\x43\x57\x54\x46")
print('Sending packet...')
lora.send_data(data, len(data), lora.frame_counter)
print('Packet sent!')
# led.value = True
lora.frame_counter += 1
time.sleep(1)
# led.value = False
No soldering; ordered rmf9x with headers installed. Nothing but the bonnet on RPiZero W.
All installed Python modules:
pi@LoRa-Edge:~$ pip3 list Package Version
Adafruit-Blinka 4.1.0
adafruit-circuitpython-bitmap-font 1.0.5
adafruit-circuitpython-busdevice 4.2.1
adafruit-circuitpython-framebuf 1.2.2
adafruit-circuitpython-rfm9x 1.2.2
adafruit-circuitpython-si7021 3.1.5
adafruit-circuitpython-ssd1306 2.7.3
adafruit-circuitpython-tinylora 2.0.2
Adafruit-PlatformDetect 2.3.0
Adafruit-PureIO 1.0.4
asn1crypto 0.24.0
certifi 2018.8.24
chardet 3.0.4
cryptography 2.6.1
entrypoints 0.3
idna 2.6
keyring 17.1.1
keyrings.alt 3.1.1
pip 18.1
pycrypto 2.6.1
pyftdi 0.44.2
PyGObject 3.30.4
pyserial 3.4
python-apt 1.8.4.1
pyusb 1.0.2
pyxdg 0.25
requests 2.21.0
rpi-ws281x 4.2.3
RPi.GPIO 0.7.0
SecretStorage 2.3.1
setuptools 40.8.0
six 1.12.0
spidev 3.4
ssh-import-id 5.7
sysv-ipc 1.0.1
urllib3 1.24.1
wheel 0.32.3
pi@LoRa-Edge:~$
I don’t know where rfm9x_radio_check.py is.
pi@LoRa-Edge:~$ python3 tinylora_simpletest.py
Traceback (most recent call last):
File "tinylora_simpletest.py", line 36, in
it is in the guide https://learn.adafruit.com/adafruit-radio-bonnets/rfm9x-raspberry-pi-setup
Oh, you gave it a different name last time. Ok, that test has no console output, but “RFM9x: Detected” appears on the rfm9x screen, and all the buttons work.
Sounds good. Can you post the code that is failing? Did you set the pins correctly in tinylora_simpletest?
I took the pins as set in the test program. Besides, those are supposed to be set by the rfm9x board module.
I have proper LoRaWAN keys, but that shouldn’t effect the failure which occurs earlier than any use of them.
pi@LoRa-Edge:~$ less tinylora_simpletest.py import time import busio import digitalio import board from adafruit_tinylora.adafruit_tinylora import TTN, TinyLoRa
led = digitalio.DigitalInOut(board.D13) led.direction = digitalio.Direction.OUTPUT
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.D5) irq = digitalio.DigitalInOut(board.D6) rst = digitalio.DigitalInOut(board.D4)
devaddr = bytearray([0x00, 0x00, 0x00, 0x00])
nwkey = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
app = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
ttn_config = TTN(devaddr, nwkey, app, country='US')
lora = TinyLoRa(spi, cs, irq, rst, ttn_config)
while True: data = bytearray(b"\x43\x57\x54\x46") print('Sending packet...') lora.send_data(data, len(data), lora.frame_counter) print('Packet sent!') led.value = True lora.frame_counter += 1 time.sleep(1) led.value = False
Those are not correct for the bonnet on a Raspberry Pi. They are for a different MCU board. Use the ones I posted above.
Compare the settings in the "rfm9x_check" program to the ones in tinytora_simpletest.py The rfm9x_check works... those are the correct pins for the bonnet on a Raspberry Pi. tinylora_simpltest.py also uses the RST pin, not used in the rfm9x_check.py
and there is no D13 LED on a raspberry Pi.
Ok. Would be nice if examples worked.
Is it working for you now? Is it OK to close this issue?
Working. You can close.
Don't let this discourage you. The tinylora examples were not written for the bonnet/Raspberry Pi. I think that is why you have found them confusing. They were written for a more general case of using an RFM9x breakout board (or featherwing) with a microcontroller.
Glad it is working -- good luck with your projects.
I have a newly purchased RFM9x bonnet on a new RPi Zero W, and am trying to run the tinylora_simpletest.py program. This fails every time with the claim that the rfm is the wrong version. Basically, the program attempts to read register 0x42 of the rfm, expecting 0x12 to be returned. It appears that the read never happens.
Here is Python3 debug session isolating the problem:
pi@LoRa-Edge:~$ ls pycache rfm9x_check.py rfm9x_transmit.py tinylora_simpletest_si7021.py font5x8.bin rfm9x_rpi_interrupt.py tinylora_simpletest.py tinylora_simpletest_single_channel.py
pi@LoRa-Edge:~$ python3 tinylora_simpletest.py
The relevant point is that the SpiDev device’s method self._spi.writebytes2(buf[start:end]) doesn’t work. In fact, it doesn’t even appear in dir(self._spi). I assume the actual code of this method is supposed to be in the spidev.cpython-37m-arm-linux-gnueabihf.so file coming from the spi.cc C++ code somewhere; I can’t find it.
I installed all the python locally as a user. Hers what I’ve go.
pi@LoRa-Edge:~$ ls -a .local/lib/python3.7/site-packages/ . adafruit_circuitpython_si7021-3.1.5.dist-info neopixel_write.py .. adafruit_circuitpython_ssd1306-2.7.3.dist-info pulseio.py Adafruit_Blinka-4.1.0.dist-info adafruit_circuitpython_tinylora-2.0.2.dist-info pyftdi Adafruit_PlatformDetect-2.3.0.dist-info adafruit_framebuf.py pyftdi-0.44.2.dist-info Adafruit_PureIO adafruit_platformdetect pyserial-3.4.dist-info Adafruit_PureIO-1.0.4.dist-info adafruit_rfm9x.py pyusb-1.0.2.dist-info RPi adafruit_si7021.py rpi_ws281x RPi.GPIO-0.7.0.dist-info adafruit_ssd1306.py rpi_ws281x-4.2.3.dist-info pycache adafruit_tinylora serial _rpi_ws281x.cpython-37m-arm-linux-gnueabihf.so analogio.py spidev-3.4.dist-info adafruit_blinka bitbangio.py spidev.cpython-37m-arm-linux-gnueabihf.so adafruit_bus_device board.py sysv_ipc-1.0.1.dist-info adafruit_circuitpython_bitmap_font-1.0.5.dist-info busio.py sysv_ipc.cpython-37m-arm-linux-gnueabihf.so adafruit_circuitpython_busdevice-4.2.1.dist-info digitalio.py usb adafruit_circuitpython_framebuf-1.2.2.dist-info microcontroller adafruit_circuitpython_rfm9x-1.2.2.dist-info micropython.py pi@LoRa-Edge:~$
Help or pointers would be appreciated. Thank you.