Open phraktle opened 7 years ago
You need to do some little changes to the board configuration and on the board itself:
DIO0 = 4
Hi, I did two changes: DIO0 =4 and the pins 22 to 24 jumper. But I still have issues when running test_lorapy or (lora_util.py) on the RPI3. I put some print in the code to get it, but I do not understand why I get an "unknown dio3 mapping!" Do you any hint ?
Thanks, Ludovic
pi@raspberrypi:~/pysx/pySX127x $ python lora_util.py
/home/pi/pysx/pySX127x/SX127x/board_config.py:51: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.LED, GPIO.OUT)
((' self.dio_mapping[3]: ', None)'selfmode',
1Traceback (most recent call last):
File "/home/pi/pysx/pySX127x/SX127x/LoRa.py", line 196, in _dio3
)
raise RuntimeError("unknown dio3 mapping!")
('selfmode', 3)
RuntimeError: Traceback (most recent call last):
unknown dio3 mapping!
File "lora_util.py", line 35, in <module>
lora = LoRa(verbose=False)
File "/home/pi/pysx/pySX127x/SX127x/LoRa.py", line 100, in __init__
self.rx_chain_calibration(calibration_freq)
File "/home/pi/pysx/pySX127x/SX127x/LoRa.py", line 858, in rx_chain_calibration
self.set_freq(freq_bkup)
File "/home/pi/pysx/pySX127x/SX127x/LoRa.py", line 284, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
(' self.dio_mapping[3]: ', None)
AssertionError
I suspect you changed the dio_mapping and entered the Raspberry pin number. (I’m not quite sure what “and the pins 22 to 24 jumper” means – I take it that you use different pins on the Raspberry.)
Background: The SX127x have 6 DIOs that you can assign a function to. DIO0, for example, can output RxDone (0), TxDone (1) or CadDone (2). These 0,1,2 values have nothing to do with Raspberry pin numbers, they just identify SX127x functionality. A value of 4 would be illegal (and actually impossible to set). If you want to know more, look at the datasheet, starting with table 18. on p.46.
Instead, change the pin numbers in board_config.py.
Hi, I had the same issue, indeed you need to set DIO0 = 4 but make sure you change SWITCH to something else (I used 21) and change DIO3 (which is NC on the Dragino shield) to something toher than 25 or you will conflict with the SPI CS pin (since you have now soldered board-pins 22 & 24 together (which are BCM pins 25 & 8). Make sure to reboot as well as your GPIO setup will be all weird, but now I have it working. @mayeranalytics what are your thought on making a Dragino subclass with the correct pins that would allow this to work out of the box? If someone also knows to to software re-map GPIO to avoid the soldering step this could also be nice.
@artificialsheep Thanks for the input. I don't have a Dragino shield, so I can't test anything. But if you have figured it out, and if you have the time, why don't you just make a pull request?
Raspberry Pi stretch has an overlay for this included. To remap the SPI CE0 pin to work with the Dragino add the following to the /boot/config.txt file dtoverlay=spi0-cs,cs0_pin=25 where 25 is the BCM designation for the GPIO (physical) pin 22. you can also remap the SPI CE1 pin if you ever need to e.g. dtoverlay=spi0-cs,s0_pin=25, cs1_pin=xx The pin definitions for GPIO, BCM and wiring PI definitions can be found at https://pinout.xyz/ A couple of extra points to watch out for. Firstly if you remap the CS then you don't need to solder pin 22 to 24 and also make sure the RESET pin is asserted (high) specifically by setting the BCM pin 17 (physical pin 11).
Hi,
I'm also trying to use this library with a Dragino Lora GPS Hat v1.4 board on a RPi3, which has to retrieve some data from a RN2483 on a Waspmote Pro v1.5 and is giving me some problems aswell.
I've also soldered the BCM 25 & 8 together and connected the DIO3 to BCM1 since it isn't connected on the board as seen here: PDF
At the moment I can recieve data, but only something like once a few minutes if it's sending every 2 second. Only the first 3 bytes have the correct values most of the time while the rest is partly correct, and sometimes it just gets a dump of data.
The code I'm using is a remake of the rx_cont.py:
main.py
And when I run the code for some time:
main.py
- Console Notice that the printout is decoded from byte to char, so the 120588ccf2
was the only close result here which should have been 120588FF88
which was send from the waspmote.
I'm suspecting it's something with the settings not being the same on both modules maybe?
If it's any help I do get the following errors when I'm trying to run lora_util.py
and test_lora.py
, and I have to restart the RPi to get the main.py
code to work again after:
lora_util.py
- consoletest_lora.py
- consoleAnyone have an idea what is missing?
Thanks, Bakhoj
EDIT:
Had made some changes tolora_util.py
which gave another error then the original code, it is changed now to only have the GPIO changed and is showing the correct error now.
I fixed my problem with the partly incorrect data from the RN2483.
The Dragino LoRa GPS hat v.1.4's schematics referes to the LoRa module as "RFM92_93W" and I could not find out if it was using RFM92W or RFM93W. The main difference between the 2 is the spreading factor range, which for 92 is 6-12 and the 93 it is 6-9. After changing the setup to use SF9 instead of 12 it worked. The error with lora_util.py is gone aswell but the same error is still present when running test_lora.py is it something to be worried about? I understand it's something with the module being in the wrong mode?
Hi Bakhoj I'm facing exactly the same issue. but even more over two dio0 and dio1: File "/home/pi/pySX127x-master/SX127x/LoRa.py", line 164, in _dio0 raise RuntimeError("unknown dio0mapping!") RuntimeError: unknown dio0mapping! Traceback (most recent call last): File "/home/pi/pySX127x-master/SX127x/LoRa.py", line 177, in _dio1 raise RuntimeError("unknown dio1mapping!")
Just wondering if you managed to overcome the issue
I am trying to get the Dragino board running on a Pi 3 but keep getting the following error:
Traceback (most recent call last):
File "tx_ttn.py", line 40, in <module>
lora = LoRaWANsend(False)
File "tx_ttn.py", line 15, in __init__
super(LoRaWANsend, self).__init__(verbose)
File "/home/pi/LoRaWAN/SX127x/LoRa.py", line 100, in __init__
self.rx_chain_calibration(calibration_freq)
File "/home/pi/LoRaWAN/SX127x/LoRa.py", line 856, in rx_chain_calibration
self.set_freq(freq_bkup)
File "/home/pi/LoRaWAN/SX127x/LoRa.py", line 282, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
AssertionError
At this point in the code, self.mode = 0
I have applied the CS remap as suggested by mkshrps and I have modified the LoRa.py file DI0=4 value.
Does anyone have any suggestions on how to resolve this issue?
This type of error usually occurs when SPI communication with the LoRa chip isn't working properly. All the error message is saying is that the LoRa chip isn't in the state it should be in.
In this case the best approach is to go back to basics: Establish reliable communication, for example by reading out the RegOpMode register (0x01) and then toggling Sleep, Standby and Receiver mode and check whether the chip does really is in the appropriate state.
You can use LoRa.py
in this library as a guide for how to do the communication in python. There's also plenty of info on the interweb. I suggest you install ipython on the Rasp and debug SPI/raspberry/LoRa chip in the REPL.
On the Rasp in can be worthwhile trying to change the SPI frequency.
When you get stuck, establish facts by eliminating error sources: E.g. try the Dragino with an Arduino and establish the board is fine. Then work forward. When SPI communication refuses to work then a Logic analyser can be useful.
This whole process can be quite frustrating, but if you proceed logically you can figure it out.
Or maybe someone else has already done that particular dance and can contribute the solution.
I've had issues with a recent upgrade in raspbian where I had to enable only SPI communication in raspi-config (disable one-wire and I2C). Also make sure you are in the spi and gpio groups.
On 19/11/2018 12:26, Mayer Analytics wrote:
This type of error usually occurs when SPI communication with the LoRa chip isn't working properly. All the error message is saying is that the LoRa chip isn't in the state it should be in.
In this case the best approach is to go back to basics: Establish reliable communication, for example by reading out the RegOpMode register (0x01) and then toggling Sleep, Standby and Receiver mode and check whether the chip does really is in the appropriate state. You can use |LoRa.py| in this library as a guide for how to do the communication in python. There's also plenty of info on the interweb. I suggest you install ipython on the Rasp and debug SPI/raspberry/LoRa chip in the REPL. On the Rasp in can be worthwhile trying to change the SPI frequency.
When you get stuck, establish facts by eliminating error sources: E.g. try the Dragino with an Arduino and establish the board is fine. Then work forward. When SPI communication refuses to work then a Logic analyser can be useful.
This whole process can be quite frustrating, but if you proceed logically you can figure it out.
Or maybe someone else has already done that particular dance and can contribute the solution.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mayeranalytics/pySX127x/issues/21#issuecomment-439861544, or mute the thread https://github.com/notifications/unsubscribe-auth/Ag2pYWR4Fx_Y0OL3jUpLuq4YutggQ70Zks5uwpVlgaJpZM4OWFgU.
-- Gabriel Dulac-Arnold blacksheep.ai
Ideally you should use an oscilloscope to check what the pins are actually doing in particular the CS pin. If you can write a loop which reads a register you can then check the cs, Mosi,miso and sclk pins are doing something. This would confirm the remapping dtoverlay=spi0-cs,cs0_pin=25 is working . Also make sure the Reset pin is set high.
For anyone that is interested, I got this working with the following configuration on a fresh install of Raspbian Stretch:
Implement the /boot/config.txt changes that mkshrps suggested by adding "dtoverlay=spi0-cs,cs0_pin=25" to the config.txt record.
Use the following values in board_config DIO0 = 4 DIO1 = 23 DIO2 = 24 DIO3 = 21 LED = 18 SWITCH = 7
ADD THE FOLLOWING LINES TO constants.py @add_lookup class SPI_BAUD_RATE: MAX_SPEED_HZ = 5000 @add_lookup class SPI_MODE: SPI_MODE = 0b01
ADD THE FOLLOWING LINES TO LoRa.py at the top of the class definition right after " spi = BOARD.SpiDev() ": spi.max_speed_hz = SPI_BAUD_RATE.MAX_SPEED_HZ spi.mode = SPI_MODE.SPI_MODE
With these changes / additions I was able to get the Dragino Hats talking to each other over the Pi's without having to do any soldering on the Hat.
HI there, i'm facing with similar problem. I made the modification as MikeRouten suggested and the test_lora.py works as expected. But when i run the rx_cont.py or any other example i get this:
/home/pi/pySX127x-master/SX127x/board_config.py:58: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.LED, GPIO.OUT)
Traceback (most recent call last):
File "rx_cont.py", line 101, in <module>
print(lora)
File "/home/pi/pySX127x-master/SX127x/LoRa.py", line 945, in __str__
s += " pa_dac %s\n" % ['default', 'PA_BOOST'][self.get_pa_dac()]
File "/home/pi/pySX127x-master/SX127x/LoRa.py", line 56, in wrapper
return func(self, self.spi.xfer([register_address, 0])[1])
File "/home/pi/pySX127x-master/SX127x/LoRa.py", line 818, in get_pa_dac
raise RuntimeError("Bad PA_DAC value %s" % hex(pa_dac))
RuntimeError: Bad PA_DAC value 0x3
any suggestion?
Hi there.
We spent some time on revamping these libraries to be used within our Terkin Datalogger. While adding some bits from the community and general polishing, the main contribution from our pen was https://github.com/daq-tools/dragino/commit/772f552d, in order to be able to configure the Dragino class at runtime to become independent of the dragino.ini
file. We hope this is as useful for the community as it was important to us.
The trees we have modified:
The code is driven by terkin.network.lora.LoRaDriverDragino. You might want to use this as an example blueprint.
This outlines an ad hoc way of getting the bits and pieces installed together in a coherent manner. Tearing the libraries apart and publishing them to PyPI would have been the better option, but we will postpone this into the future for now.
mkdir lib
# Install driver support for Dragino LoRa Hat.
curl --location https://github.com/daq-tools/dragino/archive/terkin.tar.gz | tar -C lib --strip-components=1 -xzvf - dragino-terkin/dragino
# Install updated pySX127x driver.
curl --location https://github.com/daq-tools/pySX127x/archive/dragino.tar.gz | tar -C lib/dragino --strip-components=1 -xzvf - pySX127x-dragino/SX127x
Thanks a bunch to
Cheers, Jan and Andreas.
Hi,
I am new to using LoRa and the Dragino Hat for Raspberry pi. I am currently working on a project that I would like to have the Heltec LoRa32 talk to the Dragino Hat locally. Is there any suggestions on how to get started or if this is a possibility? I've ran the lora_test.py and I get this error:
Thank you!
The failed test tells you that the LoRa chip is not in the correct mode, or registers don't have the expected values. This usually means that there are communication problems. When I look at your log, I see that the read commands seem to always return 0
, and that is quite suspicious.
I end up using Heltec LoRa32 as my gateway since I'm having so much trouble with Dragino LoRa Hat for the RPi.
Hi again,
following up on our last post at https://github.com/mayeranalytics/pySX127x/issues/21#issuecomment-620695583, we would like to bring to your attention that @BNNorman picked up the torch and has been working on his fork ^1 continuously since May 2021.
For further information, see also https://github.com/daq-tools/dragino-lorawan/issues/1 where Brian shared an overview about the improvements and features he has been working on, status November 2021.
With kind regards, Andreas.
/cc @tonkenfo
Thank you so much @amotl ! I will look into it. I really appreciate it
I end up using Heltec LoRa32 as my gateway since I'm having so much trouble with Dragino LoRa Hat for the RPi.
Did you really mean Gateway? Gateways are supposed to be able to receive on 8 channels simultaneously. Single channel gateways are not supported by TTN (AFAIK).
Check your Dragino LoRA/GPS HAT version is V1.4 - it has DIO signals wired that previous versions do not. That may be your real issue with RPi.
Hi,
I'm trying to use the library with a Dragino Lora GPS Hat v1.4 board on a RPi3, with no luck so far (assertion error in set_freq during calibration). Has anyone successfully used this board? With what settings?
Thanks, Viktor