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

Declaring different parameters for multiple nodes #13

Closed
SharathChandan opened this issue Mar 29, 2023 · 13 comments
Closed

Declaring different parameters for multiple nodes #13

SharathChandan opened this issue Mar 29, 2023 · 13 comments

Comments

@SharathChandan
Copy link

#8 (comment)

is there a way i could set two different spreading factor and bandwidth for two LoRa modules operating on same MCU? I mean when SF 8 500khz for one LoRa and SF 10 and BW 125khz for another. is it possible?

@SharathChandan
Copy link
Author

#8 (comment) i am using an ESP32, please let me know about the above using your code since its similar to mine only the pinouts differ.

@xg590
Copy link
Owner

xg590 commented Mar 29, 2023

I don't have LoRa devices at my sides so you can modify lora.py slightly for yourself so that the SX1276 class can accept new parameters. Lines 5, 104, 106 and 109 are interesting to you. This modification would only take you minutes.

@SharathChandan
Copy link
Author

SharathChandan commented Mar 30, 2023

Sure. I was unsure whether two SX1276 class can function simultaneously. i mean to use two LoRa modules with different parameters on the same MCU. will get it done and post.

@xg590
Copy link
Owner

xg590 commented Mar 30, 2023

Sure. I was unsure whether two SX1276 class can function simultaneously. i mean to use two LoRa modules with different parameters on the same MCU. will get it done and post.

Actually, there will be two instances of the same SX1276 class, which takes different modulation parameters during the initialization. Each instance has unique Pin specification and radio wave modulation parameters.

@SharathChandan
Copy link
Author

lora1 = SX1276(RST_Pin1, CS_Pin1, SPI_CH, SCK_Pin1, MOSI_Pin1, MISO_Pin1, DIO0_Pin1, DIO1_Pin1, LoRa_id, channelsHopping, Bandwidth, SF, CR )
lora2 = SX1276(RST_Pin2, CS_Pin2, SPI_CH2, SCK_Pin2, MOSI_Pin2, MISO_Pin2, DIO0_Pin2, DIO1_Pin2, LoRa_id2, channels2Hopping, Bandwidth2, SF, CR)

should i be calling the function like this
self.Bw = Bandwidth
self.CR = CodingRate
self.SF = SpreadingFactor

after this i'll remove the register mapped dictionary so in
self.spi_write('RegModemConfig1', Bw << 4 | CR << 1 | ImplicitHeaderModeOn['Explicit']) self.spi_write('RegModemConfig2', SF << 4 | TxContinuousMode['normal'] << 3 | RxPayloadCrcOn['enable'] << 2 | 0x00)

is this right?

@xg590
Copy link
Owner

xg590 commented Apr 4, 2023

is this right?

Let's say we want to set Coding Rate to 4/5 and 4/8, so we need made the following changes to lora.py

line 005    def __init__(self, RST_Pin, CS_Pin, SPI_CH, SCK_Pin, MOSI_Pin, MISO_Pin, DIO0_Pin, DIO1_Pin, SRC_Id, FHSS_list, plus20dBm=False, debug=False, CR=5):
line 104            self.spi_write('RegModemConfig1', Bw['125KHz'] << 4 | CodingRate[CR] << 1 | ImplicitHeaderModeOn['Explicit'])

following changes to receiver/receiver_1.py

line 20    lora_1 = SX1276(LoRa_RST_Pin, LoRa_CS_Pin, SPI_CH, LoRa_SCK_Pin, LoRa_MOSI_Pin, LoRa_MISO_Pin,
line 21                  LoRa_DIO0_Pin, LoRa_DIO1_Pin, LoRa_id, channels2Hopping, debug=False, CR=5)

and following changes to receiver/receiver_2.py

line 20    lora_2 = SX1276(LoRa_RST_Pin, LoRa_CS_Pin, SPI_CH, LoRa_SCK_Pin, LoRa_MOSI_Pin, LoRa_MISO_Pin,
line 21                  LoRa_DIO0_Pin, LoRa_DIO1_Pin, LoRa_id, channels2Hopping, debug=False, CR=8)
  • Be careful about the data type. You should use int 8 instead of string '8' for CR because I coded int 8 in line 102 of lora.py.

@SharathChandan
Copy link
Author

Thanks a lot! I'll try it on my setup asap.

@xg590
Copy link
Owner

xg590 commented Apr 5, 2023

Thanks a lot! I'll try it on my setup asap.

Out of curiosity, may I know what is your grade, university student? high schooler?

@SharathChandan
Copy link
Author

I am university undergrad student in ECE. I wanted to explore a new technology hoping to use it for my university projects and i found your repo.

@xg590
Copy link
Owner

xg590 commented Apr 5, 2023

I am university undergrad student in ECE. I wanted to explore a new technology hoping to use it for my university projects and i found your repo.

Since you are not a high schooler anymore, I would assume supportive information is better than actual code. ^_^ It is really cool to study engineering.

@SharathChandan
Copy link
Author

True. I sorted out the code

class SX1276:
def init(self, RST_Pin, CS_Pin, SPI_CH, SCK_Pin, MOSI_Pin, MISO_Pin, DIO0_Pin, DIO1_Pin, SRC_Id, FHSS_list,plus20dBm=False, debug=False, CR = 5, SF = 12, Bandwidth = '125KHz'):
now i'm able to pass this parameters in my code itself.

@SharathChandan
Copy link
Author

is it possible to store the received data. it usually gets printed in the console. should i be altering the brd_packet_handler?

@xg590
Copy link
Owner

xg590 commented Apr 11, 2023 via email

@xg590 xg590 closed this as completed Apr 27, 2023
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