LoRa communication and interfacing arduino and python

I have a python code that dynamically generates temperature values which are to be sent through LoRa module. I could make the LoRa connection using arduino IDE but the temperature values are in python code. I am unable to figure out how to send the temperature values from the python through arduiono through LoRa module.
Also if I can make an excel sheet of temperature values from the python code I dont know how to send the excel sheet through LoRa. It would be great if I can get help in either of these as it would completely solve the problem with my project

LoRa is just a communications method that sends and receives data in packets.

There are lots of of other radio modules that send data in packets, so they could be used as well.

Perhaps if you were prepared to reveal the details of what the project actually is doing and trying to achieve, the forum will be better able to advise.

I just need to send one excel sheet full of temperature values from one LoRa sender to LoRa receiver. I know that LoRa sends packets of data but if I want to send an excel sheet in terms of packets I would need the best possible program to be suggested for that. I’m unable to read an excel sheet in an arduino program.
this is my lora sender code which sends packets of data with a message hello:
#include <SPI.h>
#include <LoRa.h>

int counter = 0;

void setup() {
Serial.begin(9600);
while (!Serial);

Serial.println(“LoRa Sender”);

if (!LoRa.begin(915E6)) {
Serial.println(“Starting LoRa failed!”);
while (1);
}
}

void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);

// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();

counter++;

delay(5000);
Instead of hello i want to send an excel sheet. is it possible?

abhiramnvs:
I am unable to figure out how to send the temperature values from the python through arduiono through LoRa module.

Does that mean ...

Python ---- LORA --------------- LORA --- Arduino

or does it mean ....

Python --- Arduino --- LORA -------------- LORA --- Arduino

If it is the latter then this Simple Python - Arduino demo may help.

...R

python->arduino->lora sender->lora receiver->arduino
or
excelsheet-> arduino->lora sender->receiver->arduino

abhiramnvs:
Instead of hello i want to send an excel sheet. is it possible?

Possible, yes.

You need to appreciate that LoRa, like a lot of radio devices, sends data in small discrete packets, maximum of 255 bytes in the case of LoRa. So the Excel file needs to be split into a lot of small parts. Each part needs to be sent and then re-assembled into a file at the receiver end.

However there would also need to be a mechanism that identifies missing parts of the file and requests the re-transmission of the specific parts, an excel file with missing bits is likley to be useless.

I have not seen a LoRa library that provides the functionality to send and receive ‘files’ in this way, so you may need to write the code yourself, I would suggest that requires an experienced programmer.

I need the arduino code for the excel sheet which is not more than 255bytes to be sent in that case

abhiramnvs:
I need the arduino code for the excel sheet which is not more than 255bytes to be sent in that case

There are ways of sending very small amounts of data that Excel can read as a file, but an Excel sheet typically has a file size of a few kByte even when empty, you could have checked that for yourself.

Is there a reason you are not prepared to reveal what this project actually is doing and trying to achieve ?

I'm not trying to hide anything. there are a bunch of temperature values which are being measure raspberry pi using Lm35 sensor. I was assigned a work where I will have to take the values from the python code itself and then connect it to an arduino and then send through LoRa. My project is to interface beteen them.
As we know that the values from a python code be saved in an excel sheet, I just thought it would be easier if we can send the excel file directly

There is a long Thread about PLX-DAQ which allows Excel to communicate with an Arduino. I don't use Windows so I have no idea whether it can send data to an Arduino or whether it only works Arduino -> Excel.

...R

Im only able to add data in to an excel sheet using plx-daq but I'm unable to do other way round.I'm unable to read data from an excel sheet and send it using this. need help :slight_smile:

Its not at all clear why Arduinos need to be involved at all.

abhiramnvs:
I’m not trying to hide anything. there are a bunch of temperature values which are being measure raspberry pi using Lm35 sensor. I was assigned a work where I will have to take the values from the python code itself and then connect it to an arduino and then send through LoRa. My project is to interface beteen them.
As we know that the values from a python code be saved in an excel sheet, I just thought it would be easier if we can send the excel file directly

The complexity of this task is greatly increased by the Excel requirement, it’s not clear that it’s necessary, and debug will be difficult. Just send your temperature values as ASCII data and be done with it. If you need data in Excel format, convert it at the endpoint.

srnet:
You need to appreciate that LoRa, like a lot of radio devices, sends data in small discrete packets, maximum of 255 bytes in the case of LoRa. So the Excel file needs to be split into a lot of small parts. Each part needs to be sent and then re-assembled into a file at the receiver end.

I've been thinking of writing this for RadioHead; then it'd work on any wireless method supported by RadioHead. This library has already acknowledgement and so built in, so it's quite easy to keep track of which parts were sent successfully. I believe it also takes care of error checking. In my case that'd be for distribution of short sound clips in mp3 format, but the content of the file is of course irrelevant.

The main limitation is the working memory of the Arduino. The send/receive buffers and other overhead take a lot of memory, add to that the file system part (of course the file is on external memory - Flash or SD card) and there's not much left.

For the OP: no idea where the Arduino comes in. Whatever processor that Python thing is running on no doubt has the ability to control a LoRa or other wireless link. Especially if this happens to be a Raspberry Pi.

wvmarle:
I believe it also takes care of error checking.

It does and it does not. Very cat like.

Yes its normal to use the built in CRC facility for sending and receiving packets, reject a packet that fails CRC.

However, a LoRa receiver is capable of generating its own 'phantom packets' out of internal noise which if the library is not written carefully can be accepted as geniune. I looked at the RadioHead RH_RF95.cpp, and at first look the library looks vunerable.

With that said, you also need to account for the possibity that geniune LoRa packets from third party sources can be received so there needs to be a way of excluding these.

And for sure you can use LoRa on a Pi, you can even buy shields for it.

srnet:
With that said, you also need to account for the possibity that geniune LoRa packets from third party sources can be received so there needs to be a way of excluding these.

That's a tough one indeed.

RadioHead does offer addressing (it adds a from and a to address). If not addressed to you (or the broadcast address) a received packet will be ignored within the library. Not bulletproof, but it should take care of the vast majority of stray packets and noise packets. Basically a chance of 1:32000 or so that the packet is from the expected sender (1:256) and seen as addressed to you/broadcast (2:256).

I use addressing in my own libary too.

The first three bytes of a packet can be, packettype, destination_address, source_address.

For a sensor (BME280) transmitter and receiver application, I added at the end of the packet a 16 bit CRC check of the sensor data, this is checked for a match on receipt.

The effect of this is to provide 16 (CRC) + 8 (packettype) + 8 (destination_address) + 8 (source_address), which is maybe 40 bits of checking ..........................

You might look at converting the excel file into a comma delimited file, then send that.