Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device not detectd #3

Open
ToninoTarsi opened this issue Jan 30, 2018 · 5 comments
Open

Device not detectd #3

ToninoTarsi opened this issue Jan 30, 2018 · 5 comments

Comments

@ToninoTarsi
Copy link

ToninoTarsi commented Jan 30, 2018

Hi David ,
Maybe you can help me and address me to a solution.
I just got two Dragino Bee board : http://wiki.dragino.com/index.php?title=Lora_BEE
and I'm trying to use them with two RaspberriPI Zero. Connection is standard : SpDev0.0 interrupt GPIO25. When I try to use your library the device is not detected :

pi@swpi ~/pyRF95 $ sudo python
Python 2.7.3 (default, Jun 22 2016, 03:14:32)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rf95
>>> lora = rf95.RF95(0, 25)
>>> print lora.init()
False

So I installed RadioHead library (from https://github.com/hallard/RadioHead) to test also with the original library :

pi@swpi ~/RadioHead/examples/raspi/spi_scan $ sudo ./spi_scan
Checking register(0x42) with CS=GPIO06 => Nothing!
Checking register(0x10) with CS=GPIO06 => Nothing!
Checking register(0x42) with CS=GPIO07 => Nothing!
Checking register(0x10) with CS=GPIO07 => Nothing!
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO08 => Nothing!
Checking register(0x42) with CS=GPIO26 => Nothing!
Checking register(0x10) with CS=GPIO26 => Nothing!

so the SX1276 looks to be correctly detected on CS0 and TX RX works fine.

Any idea where the problem could be ?
Thanks
Tony

@ToninoTarsi
Copy link
Author

ToninoTarsi commented Jan 30, 2018

The problem looks like to be related in the continuous open and close of spi port for every operation.

If I do not close it on Init() and modify every read/write like for example :

    def spi_read(self, reg):
        #self.spi.open(self.port,self.cs)
        data = self.spi.xfer2([reg & ~SPI_WRITE_MASK, 0])
        #self.spi.close()
        return data[1]

xfer2 works fine.

Now the problem left is related to functions like lora.available() or lora.wait_packet_sent() that never exit.
Tony

@ladecadence
Copy link
Owner

This code was just tested with the RFM95 modules so it's nice to see the code been tested with other chips.
I don't know why the SX1276 behaves badly with the opening and closing of the spi port, but well, perhaps I need to get one of those modules to test it and for now I can leave that opening and closing as an option of the library.
That functions rely on the interrupts being generated by the LoRa module, how are you connecting the Gpio25 pin to the module? usually you need to connect DIO0, DIO1 and DIO2 pins from the LoRa module to the interrupt pin, and to do so, you'll need to put diodes to form an OR (and prevent current to flow to the other pins), like I did in my board:
imagen
Tell me if this works.

@ToninoTarsi
Copy link
Author

ToninoTarsi commented Jan 31, 2018

Thanks David ,
As matter of fact the problem is the interrupt feature. Looking at RadioHead examples with RaspberryPI it uses an interrupt less approach. I just added some code to also have interrupt less in your library

Constructor is now :

__init__(self,port=0,cs=0,int_pin=25,reset_pin=None):

and if int_pin = None register reading is used instead of interrupt as in RadioHead

My branch is on : master...ToninoTarsi:master

But not yet tested.
Tony

PS. I only connected DI0 to GPIO25

@ToninoTarsi
Copy link
Author

This version (https://github.com/ToninoTarsi/pyRF95) works with my SX1276 in interrupt less mode.
It would be interesting to know if it works also on your device
Tony

@ladecadence
Copy link
Owner

Hello!, I'll test the code ASAP and perhaps we can merge both codebases.
I don't know why your interrupts aren't working, I've reading the SX1276 datasheet and the interrupts are the same ones than the rf95. They should be all enabled by default, but perhaps you can try to unmask all interrupts using self.spi_write(REG_11_IRQ_FLAGS_MASK, 0) at the init method. The DIO0 pin carries RX and TX interrupts, and DIO1 RX timeout interrupt, they respond to the configuration of the RegDIOMapping1 register, and the configuration is the same in the SX1276 and the rf95, so this should be ok. Do you have any means of looking at the interrupt pin (DIO0) to see if it's triggering (logic analyzer, oscilloscope in trigger mode...) ?
Anyway, good work!
David.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants