How to send two or more ADC values to chirpstack

Hi everyone, I need to send two analog data (potentiometer), but I have problems when I send to chirpStack.

This is a example only in the arduino ide, its ok, works.

// I use the device LoRa 32 V2 915 Mhz
/* pins 25 and 37 I will use to read the data that i need to send*/
#define AnPin1 25//to read the analog potenciometer
#define AnPin2 37//to read the analog potenciometer
int val1, val2;

/I think that the value that I want to send through lora must be string, this is the reason text1 and text2/
String text1 ="";
String text2 ="";

void setup()
{
Serial.begin(115200);
Serial.setTimeout(50);

}

void loop()
{
val1 = analogRead(AnPin1);
val2 = analogRead(AnPin2);
text1 = (String)val1;
text2 = (String)val2;

/* I made this part to probe that val1 was convert to string, not problem val1 is a string */
if (text1 == “55” or text1 == “47” or text1 == “59” or text1 == “25” ){
Serial.println(“Hi, text1 is a string”);
}
//here I should send to chirpstack
Serial.println(text1);
Serial.println(text2);
Serial.println();
delay(1000);
}

Can you help me please to do the same with chirpstack.

I’m using the DHT11 example, but i don’t know what method I must use to send some values to the chirpstack. Please help me.

you can just use the lorawan examples.
sneding data to any LoRaWAN server is the same.

is your gateway connected to your chirpstack server?

1 Like

Thank you. Yes with chirpstack.

@karl for example in the OTAA_OLED you can find this two lines at the void loop ()

uint8_t msg[] = “Msg test 43”;
PrepareMsgFrame( AppPort, msg , sizeof(msg)-1);

You must change the msg[] to what u wanna to send. Furthermore you need a decoder at chirpstack side in order to check the received msg.

1 Like

Hi @andrelmbraga1, I tried this

uint8_t num = 44;
// int num = 44;//this represent the analog data
uint8_t msg[] = “Msg test 43”;
String msg1 ="";// to convert num to string
msg1 = (String)num;
PrepareMsgFrame( AppPort, msg , sizeof(msg)-1);
PrepareMsgFrame( AppPort, msg1 , sizeof(msg1)-1);// here is the problem
LoRa.DeviceStateSend();

IT GIVES THIS ERROR

Arduino: 1.8.10 (Linux), Board: “WiFi LoRa 32(V2), Disabled, default_8MB, 240MHz (WiFi/BT), QIO, 80MHz, 8MB (64Mb), 921600, None”

/tmp/arduino_modified_sketch_97713/OTAA_OLED.ino: In function ‘void loop()’:
OTAA_OLED:200:54: error: cannot convert ‘String’ to ‘uint8_t* {aka unsigned char*}’ for argument ‘2’ to ‘void PrepareMsgFrame(uint8_t, uint8_t*, uint8_t)’
PrepareMsgFrame( AppPort, msg1 , sizeof(msg1)-1);// here is the problem
^
Multiple libraries were found for “board.h”
Used: /home/karl/Arduino/libraries/ESP32_LoRaWAN
Multiple libraries were found for “SPI.h”
Used: /home/karl/.arduino15/packages/Heltec-esp32/hardware/esp32/0.0.4/libraries/SPI
Multiple libraries were found for “Wire.h”
Used: /home/karl/.arduino15/packages/Heltec-esp32/hardware/esp32/0.0.4/libraries/Wire
exit status 1
cannot convert ‘String’ to ‘uint8_t* {aka unsigned char*}’ for argument ‘2’ to ‘void PrepareMsgFrame(uint8_t, uint8_t*, uint8_t)’

DO YOU KNOW SOME EXAMPLE TO SOLVE THIS ISSUE, PLEASE.