I have a project to connect Wi-Fi Lora 32 (v3) as a receiver, listen to another module as a transmitter , connect the receiver module to Arduino Clou,d and view the received RSSI and SNR value in a dashboard , after several trial I finally succeeded in making the module online, but I cannot run any code in the skitch, I need to save the received RSSI and SNR to the cloud
here's the code which is already run using Arduino IDE:
#include "thingProperties.h"
#include <heltec.h>
#include "LoRaWan_APP.h"
#include "Arduino.h"
#define RF_FREQUENCY 915000000 // Hz
#define TX_OUTPUT_POWER 14 // 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];
static RadioEvents_t RadioEvents;
int16_t txNumber;
int16_t rssi,rxSize;
bool lora_idle = true;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(115200);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE);
txNumber=0;
rssi=0;
RadioEvents.RxDone = OnRxDone;
Radio.Init( &RadioEvents );
Radio.SetChannel( RF_FREQUENCY );
Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
0, true, 0, 0, LORA_IQ_INVERSION_ON, true );
}
void loop() {
ArduinoCloud.update();
// Your code here
if(lora_idle)
{
lora_idle = false;
Serial.println("into RX mode");
Radio.Rx(0);
}
Radio.IrqProcess( );
}
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
{
rssi=rssi;
rxSize=size;
memcpy(rxpacket, payload, size );
rxpacket[size]='\0';
Radio.Sleep( );
Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize);
lora_idle = true;
}
Too much badly presented code to look at. First do a Tools/Auto Format, then either select all and Edit/Copy for Forum (Markdown) OR click the CODE button above and paste into the highlighted spot.
The second problem is it sounds like you wrote the sketch in the normal IDE, got that working and then pasted it into a cloud template. I have a hunch that will not work. Try starting a cloud project from the start, do as much as you can do in the cloud than selectively add your code in places that are NOT marked as DO NOT EDIT.
Thanks, @sonofcy, for your reply. I have edited the question for better readability. As you can see, after the code is working fine in Arduino IDE, I create a new sketch from Scratch and copy and past my code where it should be the issue is the library keeps giving me errors even when I'm trying to use a custom library that I have already used in IDE
Ok, if you want to do it your way then best of luck. I have built a few cloud apps, have yet to put any code into them other than the event hooks, that's how it works.
I appreciate your insight and experience with cloud applications! Since I'm still getting familiar with cloud development, I’d really value some guidance. I’m currently working with the Heltec WiFi LoRa 32 (V3), but I’ve encountered some challenges specific to this kit. I was wondering if you’ve worked on a retrieving Lora receiver data before from another lora module , i only need to receive the packet as string no sensors attached or any thing. If you have any recommendations based on your experience. Any advice would be greatly appreciated!
Hi @esraa_eissa. Support for specific boards in Arduino Cloud is provided by an Arduino boards platform. For the "Heltec WiFi LoRa 32 (V3)" board, the support is provided by the "esp32" platform. Version 2.0.17 of the "esp32" platform is installed on the Arduino Cloud servers.
The "Heltec ESP32 Dev-Boards" library is written for use with version 3.0.2 or higher of the "esp32" platform. There have been some very significant changes to the "esp32" platform since the time of the 2.0.17 release, and so the library is not compatible with the version 2.0.17 of the platform installed on Arduino Cloud. So, until such time as the Arduino Cloud developers update the "esp32" platform installation on the Arduino Cloud servers, you won't be able to compile sketches that use this specific library with Arduino Cloud Editor.
If you need to use this library in your sketches, you can use Arduino IDE instead of Arduino Cloud Editor
Arduino IDE has Arduino Cloud integration, which provides convenient access to the sketches from your Arduino Cloud account.
I'll provide instructions you can follow to set up Arduino IDE and upload your sketch:
Install Arduino IDE by following the instructions here.
Start Arduino IDE.
Install the "esp32" boards platform by following the instructions here.
Connect Arduino IDE to your Arduino Cloud account by following the instructions here
You should now see the list of sketches from your Arduino Cloud account in the "SKETCHBOOK" panel of the IDE window. Click on the sketch you would like to upload to your board.
Click the cloud with downward pointing arrow icon ("Pull Sketch") that appears to the right of the sketch name.
A "Synchronizing sketchbook, pulling ..." process will start.
Wait for the synchronization process to finish, as indicated by the appearance of a notification at the bottom right corner of the IDE window:
Done pulling ...
Double click on the sketch name in the "SKETCHBOOK" panel.
The sketch will open in a new Arduino IDE window.
Select the appropriate board from the IDE's Tools > Board > esp32 menu.
Select the appropriate port from the IDE's Tools > Port menu.
Select Sketch > Upload from the Arduino IDE menus.
The sketch should now upload successfully to the board.
ⓘ Note that you can use Arduino IDE for development of Arduino CloudThing sketches. It is convenient to use the Arduino Cloud web interface for the initial setup of the Thing, but after that you can open the sketch in Arduino IDE for editing and uploading to your board. You will see newly created Thing sketches under the "Cloud Sketchbook" tab of the IDE's "SKETCHBOOK" panel after you click the "Sync" icon at the bottom right corner of the panel.
Please let me know if you have any questions or problems while following those instructions.
Thanks, @ptillisch, for your clarification. Now I know why all my tries failed. It would be a great help if this approach works, but from the latest version of Andriod IDE2.3.4, there is no option for a remote sketchbook, any idea what I'm messing here
It looks like you disabled the Arduino Cloud integration via Arduino IDE's advanced settings. I'll provide instructions you can follow to enable the feature:
Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
A menu will appear on the editor toolbar:
Select the "Preferences: Open Settings (UI)" command from the menu. ⓘ You can scroll down through the list of commands to find it, or type the command name in the field.
A "Settings" tab will open in the Arduino IDE main panel.
Type arduino.cloud.enabled in the "Search Settings" field of the "Settings" tab.
Check the box under the "Arduino › Cloud: Enabled" setting.
Close the Preferences tab by clicking its X icon.
After doing that, you should be able to follow the tutorial I linked in my previous reply to access your Arduino Cloud sketchbook via Arduino IDE.
Thanks, Ptillisch for your reply. It helps a lot; now it works for me. However, I have a problem switching my workplace to sync my sketches in the shared workplace. However, I have an unlimited subscription, but it gives me limitations in my workspace, so I need to sync with my shared workspace under the same credentials. How to do so?