srnet:
Possibly code or settings differences and possibly faulty hardware.
You must have a pair of the same devices working well and very reliably, using example code with each as a TX and RX.
Then and only then, try one of the other devices.
Thank you for your answer.
From TTGO board to TTGO board, using the RX and TX example I have no issue when they communicate, the same happen between the Pycom LoPy and Heltec LoRa32 boards, which, even if they are different boards communicate between them without issues and packets loss.
With the example provided by Arduino, the TTGO can listen some packets sent by the Pycom/Heltec lora boards. “Some” means that half of the packet or more get lost. While if I send Lora messages from one TTGO to the Pycom/Heltec boards, 98/99% of packets are lost.
I’m pretty sure that the settings (SF, frequency, coding rate and BW) are the same.
frankly spoken, you are doing something wrong - but we can’t see it as you have NOT posted any of your codes, nor any links to any devices.
Thank you for your answer. Ok, let me share the code running on my TTGO T-beam. I have two of them, but actually only one is up.
#include <LoRa.h>
#include "utilities.h"
int counter = 0;
// lora config
int lora_coding_demoninator = 5;
int lora_signal_bandwidth = 125E3;
int lora_spreading_factor = 7;
int lora_frequency = 868E6;
void setup()
{
initBoard();
// When the power is turned on, a delay is required.
delay(1500);
Serial.println("LoRa Sender");
LoRa.setPins(RADIO_CS_PIN, RADIO_RST_PIN, RADIO_DI0_PIN);
if (!LoRa.begin(868E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
LoRa.setCodingRate4(lora_coding_demoninator);
LoRa.setSignalBandwidth(lora_signal_bandwidth);
LoRa.setSpreadingFactor(lora_spreading_factor);
LoRa.setFrequency(868E6);
// register the receive callback
LoRa.onReceive(onReceive);
}
void onReceive(int packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
for (int i = 0; i < packetSize; i++) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
//Serial.println(LoRa.packetFrequencyError());
}
void loop()
{
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("TTGO ");
LoRa.print(counter);
LoRa.endPacket();
// listen incoming packets
LoRa.receive();
counter++;
delay(10000);
}
As you can see, the board initialise, send a Lora message and then listen incoming messages for ten seconds, repeating the loop.
Here instead we have the code of the Heltec Lora32 V2, which actually send a lora message every 10 seconds. This is the Arduino proposed Example for this board:
#include "heltec.h"
#define BAND 868E6 //you can set band here directly,e.g. 868E6,915E6
int counter = 0;
// lora config
int lora_coding_demoninator = 5;
int lora_signal_bandwidth = 125E3;
int lora_spreading_factor = 7;
void setup() {
//WIFI Kit series V1 not support Vext control
Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
LoRa.setCodingRate4(lora_coding_demoninator);
LoRa.setSignalBandwidth(lora_signal_bandwidth);
LoRa.setSpreadingFactor(lora_spreading_factor);
}
void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
/*
* LoRa.setTxPower(txPower,RFOUT_pin);
* txPower -- 0 ~ 20
* RFOUT_pin could be RF_PACONFIG_PASELECT_PABOOST or RF_PACONFIG_PASELECT_RFO
* - RF_PACONFIG_PASELECT_PABOOST -- LoRa single output via PABOOST, maximum output 20dBm
* - RF_PACONFIG_PASELECT_RFO -- LoRa single output via RFO_HF / RFO_LF, maximum output 14dBm
*/
LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
LoRa.print("Lora32 ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(25, LOW); // turn the LED off by making the voltage LOW
delay(9000); // wait for a second
}
And then there is the code of the two Pycom LoPy boards, which is uPython. I share it, but these two boards have been used a lot in the last year, so they work as should.
count = 0
while True:
lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, bandwidth=LoRa.BW_125KHZ, sf=7)
# create a raw LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
print("Sending Lora message")
s.setblocking(True)
message = 'LoPy '+ str(count)
s.send(message)
print("Listening on Lora...")
# get any data received...
t_end = time.time() + 10
while time.time() <= t_end:
#s.setblocking(False)
msg = s.recv(64)
if len(msg)>=2:
print(msg)
print(lora.stats())
count = count + 1
s.close()
As told before, no packets loss/communication issues between the two loPy boards and the Heltec board, while these three board can’t almost receive any packets from the TTGO board (just a message in a couple of hours, if i remember well). Also, the TTGO receive just some packets from the Pycom and Heltec boards, let’s say 50% of the packets sent, while all the messages sent from the second TTGO board are received correctly.
I also thought that the issue is due to too much packets collisions, but I’m using just five boards with a message period between each message of at least 10 seconds, which given SF7 and the small payload, should not be an issue at all. i also started the board in order to let them send messages without any overlap.
That’s all.