CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pic to pic with LoRa

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

pic to pic with LoRa
PostPosted: Mon Dec 27, 2021 12:52 pm     Reply with quote

Hi,
I want to send a string from one PIC to a second PIC, wirelessly using two radio modules RFM95W.
The radio module has SPI interface, with so many registers to set that I feel lost. https://www.hoperf.com/data/upload/portal/20190801/RFM95W-V2.0.pdf

I found a simple example of using that radio module with Arduino.
https://randomnerdtutorials.com/esp32-lora-rfm95-transceiver-arduino-ide/

Is it a good idea to port a Arduino LoRa library to PIC?
https://github.com/sandeepmistry/arduino-LoRa/blob/master/src/LoRa.cpp

Or should I go directly with the native CCS spi_write() function?

It is the first time I use SPI. To my understanding I have to:
- set CS low
- spi_write(address I want to write into)
- spi_write(data in byte format)
- set CS high
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Dec 27, 2021 1:44 pm     Reply with quote

FWIW, CCS has four LoRa/LoRaWAN related files (dated 5/2020) in the
drivers directory but these are for the RN2903 module that requires a UART.
_________________
Google and Forum Search are some of your best tools!!!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Tue Dec 28, 2021 4:04 am     Reply with quote

It is perfectly logical and sensible to translate the Arduino code, but you
would do that by using the native CCS functions (spi_xfer, not spi_read/
spi_write).
Rewrite the Arduino spi transfers to use the PIC functions, and then the rest
of the code would pretty much run 'as is'. Things you have to watch for
are the data sizes (remember a default integer in the Arduino is an int16).
robertoemiliani



Joined: 10 May 2022
Posts: 1

View user's profile Send private message

Re: pic to pic with LoRa
PostPosted: Tue May 10, 2022 2:54 am     Reply with quote

Hello everyone.
I have the same problem.
I must write a simple C-Code to interface two PIC microcontroller (PIC18F66K80) with two RFM95 radio module.
FSK or LoRa mode, for me it is no relevant.
I have not particular requirements.
I must send and receive only two byte between the microcontrollers.

The SPI works well, and I have no problem with it.
I need the list of set-up of radio module.

I have not found any application on the web.
ALL THE APPLICATIONS IN THE WORLD ARE ARDUINO BASED...
But I don't use Arduino platform (and I am happy).
The data sheet of RFM95 is very complex and it has'nt a simple tutorial or quick start guide.

Is there anyone that can send me a simple C-code example to help me?
Thanks in advance.



webgiorgio wrote:
Hi,
I want to send a string from one PIC to a second PIC, wirelessly using two radio modules RFM95W.
The radio module has SPI interface, with so many registers to set that I feel lost. https://www.hoperf.com/data/upload/portal/20190801/RFM95W-V2.0.pdf

I found a simple example of using that radio module with Arduino.
https://randomnerdtutorials.com/esp32-lora-rfm95-transceiver-arduino-ide/

Is it a good idea to port a Arduino LoRa library to PIC?
https://github.com/sandeepmistry/arduino-LoRa/blob/master/src/LoRa.cpp

Or should I go directly with the native CCS spi_write() function?

It is the first time I use SPI. To my understanding I have to:
- set CS low
- spi_write(address I want to write into)
- spi_write(data in byte format)
- set CS high
temtronic



Joined: 01 Jul 2010
Posts: 9236
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue May 10, 2022 7:12 am     Reply with quote

The simple way is to just take the Ardunio C code, convert to CCS C code
or..
use Google to locate someone else's CCS C code...
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue May 10, 2022 10:07 am     Reply with quote

temtronic wrote:
The simple way is to just take the Ardunio C code, convert to CCS C code
or..
use Google to locate someone else's CCS C code...


I have worked with LoRa and LoRaWAN for the last few years initially using the RFM96, then the RN2903 and these days, the more feature rich Seeed E5 modules.

LoRa and LoRaWAN are still early in their life cycle (immature) and are undergoing continuous enhancements which are not necessarily backward compatible. The RFM96 is a low level MAC layer device, this means, if you use this device, you should be expecting to upgrade the both the low level interface as well as the LoRaWAN stack for these devices including ones already deployed to the field. Is LoRa and LoRaWAN stack management something you really want to do?

An alternative is something like the Seeed E5 LoRaWAN modules which themselves are using an embedded STM32 which has the LoRa and LoRaWAN stack provided by STM in the processor. You can either program the STM32 natively or simply use AT commands for both LoRa and LoRaWAN applications. If changes need to be made to the stack, STM handle that - you still need to upgrade your code for devices in the field if required however this takes significantly less effort for a device developer than having to maintain the stack themselves.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed May 11, 2022 12:45 am     Reply with quote

And to reinforce what Asmallri has just said, the code to talk to the
intelligent controller, will be a few serial lines. The code to talk directly to
the Mac layer device will instead be thousands of lines. On smaller PIC's,
this is not going to be doable at all. On larger PIC's it is still going to use
a lot of ones available space, and even more time..... Sad

Another comment. All the Lora stuff I know of is at heart 3.3v. You really
need to be using a 3.3v PIC to work with any of these units. Unreliability
and massive complexity result if you don't. The 5v Arduino piggyback
boards often rely on the fact that the Arduino inputs accept 2.4v as a
logic '1'. The PIC serial/SPI inputs do not. Result problems....

On the 'everything is Arduino' comment, this is simply untrue. There are
libraries for the Raspberry Pi as well (have used these). I have driven a
RFM95 with a PIC using Lora (much simpler for point to point than
LoraWan), with modified versions of the Pi libraries and SPI. However
even this was perhaps ten times as much code as using the smart
module.
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Sun May 15, 2022 5:27 am     Reply with quote

We have used more than 50 pcs. of this LORA module in a wireless node system.
The modules are stable and work nice.

https://www.cdebyte.com/products/E22-900M22S
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group