Stick lite V3 LoRa packet to send

Hello,

i have the problem i dont have an example how i must modify the old datastring from sx1272 module to work with sx1262…
the old one is:

dataMessage = String(ID) + “\t” + String(De) + “\t” + String(Sn) + “\t” + String(L3) + “\t” + “\r\n”;

LoRa.beginPacket();
LoRa.print(dataMessage);
LoRa.endPacket();

but the new code from examples/heltec esp 32 dev boards/lora basic/ lora sender is complete different, and i dont find a working example how the datapacket must be …or the config of them…
heltec change all what they can do, that you cant use codes from other esp32 boards easily …when i know that before i bought them…i am not a pro user… for me is heltec = HELLTECH … dokumentation catastrophic ! and i am not alone with this thinking…

PLAESE HELP ME !!!

where is my little tiger who helped me ??? i love cats…Pete ? can u here me ? :slight_smile:

Well, the LoRa radio setup is quite different, but that is all included in the examples. When it comes to actually sending your data, what you have quoted:

I think would just be replaced by something like:

Radio.Send( (uint8_t *)dataMessage, strlen(dataMessage) );

The first problem is that the library from
#include <OneWire.h>
#include <DallasTemperature.h>
dont work together with heltec sx1262 lib

test it…
examples/heltec esp 32 dev boards/lora basic/ lora sender and put the libs in…you need no maincode for one wire - try to uploade it - u see the errorcode.
this libs dont work together

and this also dont work…
Radio.Send( (uint8_t *)dataMessage, strlen(dataMessage) );
i must send 10 different sensor datas, the sx1278 is working so fine and easy

the funktions of this board are great…thats the only…for the sx1262 chip i found no examples that works…
and i try it now for 10 days. i will send direct to other sx1262, i can use LoraWan - no accsesspoint.
I put it on an anvil and use a hammer…this board is not compatible with other esp32 programs or libs

OK, then there’s some detail missing in there somewhere because I use pretty much these exact elements together quite regularly to communicate with a range of other boards. You perhaps need to provide some more detail about your operating environment and the exact code that is not working.

If you do post code, please enter “```” (that’s 3 backward quote characters, the key on the top left corner of a QWERTY keyboard, not including the double quote characters), press return, then paste your code, then press return again and enter another 3 backward quote characters and press return again. That should format and encapsulate your code in a scrollable box that makes it much easier for forum readers to scan through.

Or highlight the code and use the </> tool!

Hello this is the code from heltec for LoRa sender from examples.
then i put onewire lib to the sketch. Thats all… and the compiler brings the error

#include <OneWire.h>

/* Heltec Automation send communication test example

#include “LoRaWan_APP.h”

#include “Arduino.h”

#define RF_FREQUENCY 915000000 // Hz

#define TX_OUTPUT_POWER 5 // dBm

#define LORA_BANDWIDTH 0 // [0: 125 kHz,

                                                          //  1: 250 kHz,

                                                          //  2: 500 kHz,

                                                          //  3: Reserved]

#define LORA_SPREADING_FACTOR 7 // [SF7…SF12]

#define LORA_CODINGRATE 1 // [1: 4/5,

                                                          //  2: 4/6,

                                                          //  3: 4/7,

                                                          //  4: 4/8]

#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx

#define LORA_SYMBOL_TIMEOUT 0 // Symbols

#define LORA_FIX_LENGTH_PAYLOAD_ON false

#define LORA_IQ_INVERSION_ON false

#define RX_TIMEOUT_VALUE 1000

#define BUFFER_SIZE 30 // Define the payload size here

char txpacket[BUFFER_SIZE];

char rxpacket[BUFFER_SIZE];

double txNumber;

bool lora_idle=true;

static RadioEvents_t RadioEvents;

void OnTxDone( void );

void OnTxTimeout( void );

void setup() {

Serial.begin(115200);

Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);



txNumber=0;

RadioEvents.TxDone = OnTxDone;

RadioEvents.TxTimeout = OnTxTimeout;



Radio.Init( &RadioEvents );

Radio.SetChannel( RF_FREQUENCY );

Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,

                               LORA_SPREADING_FACTOR, LORA_CODINGRATE,

                               LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,

                               true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );

}

void loop()

{

if(lora_idle == true)

{

delay(1000);

txNumber += 0.01;

sprintf(txpacket,"Hello world number %0.2f",txNumber);  //start a package



Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket));

Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out

lora_idle = false;

}

Radio.IrqProcess( );

}

void OnTxDone( void )

{

Serial.println(“TX done…”);

lora_idle = true;

}

void OnTxTimeout( void )

{

Radio.Sleep( );

Serial.println("TX Timeout......");

lora_idle = true;

}
… and no other changes i do - only the onewirelib in the first row

Backticks ` not full stops (periods) .

Or use the </> tool!

You could go back and edit your post with the pencil tool. Easy to read an issue = faster response from volunteers, just saying!

It would have been helpful if you had also included the compilation error message.

Nonetheless, when I fix up the quote (") characters, which are incorrectly translated when you don’t quote the code as suggested, the only compilation problem I see is with the statement:

Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);

which simply suggests that you have not set up your software development environment correctly or, at least, it needs to be updated. This may also mean that you have not selected the correct board type.

The following is the example LoRaSender.ino sketch, plus the Wire.h and DallasTemperature.h library includes, from my development environment (pasted in between sets of 3 backward quote characters, or backticks, as originally suggested):

#include <OneWire.h>
#include <DallasTemperature.h>
/* Heltec Automation send communication test example
 *
 * Function:
 * 1. Send data from a esp32 device over hardware 
 *  
 * Description:
 * 
 * HelTec AutoMation, Chengdu, China
 * 成都惠利特自动化科技有限公司
 * www.heltec.org
 *
 * this project also realess in GitHub:
 * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
 * */

#include "LoRaWan_APP.h"
#include "Arduino.h"


#define RF_FREQUENCY                                915000000 // Hz

#define TX_OUTPUT_POWER                             5        // dBm

#define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                              //  1: 250 kHz,
                                                              //  2: 500 kHz,
                                                              //  3: Reserved]
#define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
#define LORA_CODINGRATE                             1         // [1: 4/5,
                                                              //  2: 4/6,
                                                              //  3: 4/7,
                                                              //  4: 4/8]
#define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT                         0         // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON                  false
#define LORA_IQ_INVERSION_ON                        false


#define RX_TIMEOUT_VALUE                            1000
#define BUFFER_SIZE                                 30 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

double txNumber;

bool lora_idle=true;

static RadioEvents_t RadioEvents;
void OnTxDone( void );
void OnTxTimeout( void );

void setup() {
    Serial.begin(115200);
    Mcu.begin();
	
    txNumber=0;

    RadioEvents.TxDone = OnTxDone;
    RadioEvents.TxTimeout = OnTxTimeout;
    
    Radio.Init( &RadioEvents );
    Radio.SetChannel( RF_FREQUENCY );
    Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                                   LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                                   LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                                   true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); 
   }



void loop()
{
	if(lora_idle == true)
	{
    delay(1000);
		txNumber += 0.01;
		sprintf(txpacket,"Hello world number %0.2f",txNumber);  //start a package
   
		Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket));

		Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out	
    lora_idle = false;
	}
  Radio.IrqProcess( );
}

void OnTxDone( void )
{
	Serial.println("TX done......");
	lora_idle = true;
}

void OnTxTimeout( void )
{
    Radio.Sleep( );
    Serial.println("TX Timeout......");
    lora_idle = true;
}

You should be able to cut and paste that code into your development environment and compile it. If it doesn’t compile, which it probably won’t given what we’ve seen so far, you have a problem with your software setup and if you provide the relevant details, readers might be able to help further.

i try to compilate your code.
the compiler mark the
Mcu.begin();
with errorcode:

C:\Users\jbrei\AppData\Local\Temp.arduinoIDE-unsaved202505-13868-1v0bfp2.c4yy\sketch_jan5a\sketch_jan5a.ino: In function ‘void setup()’:
C:\Users\jbrei\AppData\Local\Temp.arduinoIDE-unsaved202505-13868-1v0bfp2.c4yy\sketch_jan5a\sketch_jan5a.ino:57:14: error: no matching function for call to ‘McuClass::begin()’
57 | Mcu.begin();
| ~~~~~~~~~^~
In file included from c:\Users\jbrei\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src/LoRaWan_APP.h:8,
from C:\Users\jbrei\AppData\Local\Temp.arduinoIDE-unsaved202505-13868-1v0bfp2.c4yy\sketch_jan5a\sketch_jan5a.ino:18:
c:\Users\jbrei\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src/ESP32_Mcu.h:59:7: note: candidate: ‘int McuClass::begin(uint8_t, uint8_t)’
59 | int begin(uint8_t board_type,uint8_t ex_32k);

c:\Users\jbrei\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src/ESP32_Mcu.h:59:7: note: candidate expects 2 arguments, 0 provided

exit status 1

Compilation error: no matching function for call to ‘McuClass::begin()’

OK, that’s not really a surprise and it’s related to the version of the Heltec support software that you have installed.

The good news, perhaps, is that I can now reproduce your problem on a fresh installation of the IDE (2.3.4) after loading Espressif esp32 (3.0.7) through the Board Manager and Heltec ESP32 Dev Boards (2.1.2) through the Library Manager. I also had to load a couple of Adafruit libraries—Adafruit BusIO (1.16.2) and Adafruit GFX Library (1.11.11)—(Library Manager) to run the Heltec LoRaSend.ino example and the OneWire (2.3.8) and DallasTemperature (3.9.0) libraries to complete this test.

And just by the way, if you want people to help you solve a problem, providing that level of detail about your environment at the outset will make it much easier for them to help you.

The perhaps not so good news is that, while I can offer a procedure to get around the problem in the present case, it is by no means a satisfactory long term solution. There is a problem somewhere between the way the Arduino IDE compiles/loads software and, apparently, the way Heltec has recently decided to distribute its support software. I am still running v1.0.0 of the Heltec ESP32 support software on my main development host, and it handles everything I’m doing just fine, even with the V3 boards. But the latest version, v2.1.2, has a radically different structure to my v1.0.0 version making it almost impossible to identify the exact location of issues that arise as a result of recent changes. It now includes precompiled code units and there seems to be an issue with the order in which these, or elements within, are loaded by the IDE. I don’t know whether this is an IDE problem or a Heltec problem—you may have to go over to the IDE forum to work through that one.

The following is the sequence I had to follow to get the sketch provided above to compile in this environment. First of all, change the line:

    Mcu.begin();

to

    Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);

as it appears in the current version of the LoRaSender.ino example—and no, that’s not a typo there, the variable is SLOW_CLK_TPYE, not SLOW_CLK_TYPE.

Note to Heltec: If you decide to fix this misspelling at some point, be kind to your users and keep the misspelled version as well, so you don’t break existing code that depends on the original [mis]spelling. And it would also have been considerate to have retained a version of the Mcu.begin() method in the current library that did not require any parameters, for the same reason.

To compile this sketch then, I had to do the following:

  1. Open a new [empty] sketch
  2. Paste in the following #include statements before the [empty] setup() function
#include <Wire.h>
#include <DallasTemperature.h>

and compile that [empty] sketch.

  1. Now paste in the content of the LoRaSender.ino sketch, after the above two lines and over the currently empty setup() and loop() methods, and compile the resulting sketch.

You will now see a message like the following in the IDE Output panel

Library Heltec ESP32 Dev-Boards has been declared precompiled:
Using precompiled library in /Users/xxx/Documents/Arduino/libraries/Heltec_ESP32_Dev-Boards/src/esp32s3

and the compilation should complete successfully.

If you don’t follow this two-step compilation process, you never see this message and the compilation fails as you have noted, so it would seem that something goes amiss with this precompiled code unit—like I say, I don’t really know whether this is an IDE or a Heltec problem.

Someone with a deeper understanding than I, of how the IDE assembles code, might be able to explain more precisely what’s going on here but I believe that the IDE just reuses binaries that it’s already created if it doesn’t think the source code has changed. By compiling the library code in the above order, it would seem that we stop the compilation of the LoRaWan_APP library from interfering with the assembly of the Wire library, which would suggest that this might be more a problem that should be addressed by Heltec than the Arduino IDE developers.

Caveat emptor: I have not tried to actually execute any sketch so compiled, so I have no idea whether or not there are even deeper issues within…

2 Likes

WOW - what a problem.
And i think i was to stupid. I am not so good that i can find out so much deep problems. But you helped very much !
I try to follow your instuctions to compile my complete code - but i think it will not work because my code is 500 rows long…with I²C, SPI, OneWire and LoRa and a Ultrasonicsensor. I think my skills are to low for this huge Problem. But i can use my ESP32 Wroom with external LoRa - this one runs perfect (SX1272). But the Wireless Stick is a better solution for my project. I hope Heltec solve this big problem very fast ! I need many more of this Sticks, when they work.
Thank you for your great support !!!

CRAZY !!!
I tried your example to compile the 2 Libs first and then the rest. IT WORKS !
An idea that i never think about…

Bibliothek Heltec ESP32 Dev-Boards wurde als vorkompiliert angegeben:
Benutze vorkompilierte Bibliothek in c:\Users\jbrei\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src\esp32s3
Der Sketch verwendet 422352 Bytes (12%) des Programmspeicherplatzes. Das Maximum sind 3342336 Bytes.
Globale Variablen verwenden 22160 Bytes (6%) des dynamischen Speichers, 305520 Bytes für lokale Variablen verbleiben. Das Maximum sind 327680 Bytes.

Its a strange way - but at the moment the best to finish my code and testing.
I hope the problem is fixed very soon.

Probably most of us aren’t up to the job of debugging a big program with lots of sensors and many hardware interfaces

But most of us can debug small programs. Get the smallest program going first and then add one thing at a time. You can’t go from Zero to Hero in one go, it’s always one little extra skill a week - after a few weeks this starts to accelerate.

However, sure, the whole pre-compile thing is just crazy.

I built this code first for Arduino NANO - i start with one DS18B20, BH1750FVI and a RTC. Like the way you said - step for step. I learned so much with tutorials and examples.
then it grows up with SD Card, and many more. At one point i had not enought place for the code, then i changed to ESP32. My old Code runs in 2 days.
Then comes LoRa, all was good. Then i saw this Board, but i dont saw that this Chip have the sx1262 -
in the discription on top of the offer was written sx1276. And the hell started for me.

Sounds like a strategy that worked - but when you change from something like the Nano - nice tidy little run-around, to a big honking V8 with turbo charger that is the ESP32 range, sometimes you have to roll back to get the base working but then you should be able to quickly add in your prior work, as that’s the beauty of the Arduino eco-system and it does mostly work.

Overall the top tip is to try to not use the provided software - the hardware is fine but they do move components around that catches you out - but the software has so many gotchas that it is often easier to start out with other more user friendly libraries - like RadioLib to support the LoRa radio.