Go Down

Topic: LoRaWAN arduino (Read 611 times) previous topic - next topic

dimitris21

Hello..im absolute begginer to this subject and i have some issues.Im trying to do a lorawan connection from one arduino to a raspberry pi.Arduino have a temperature sensor and send it to print the value to raspberry pi well i have do correclty this communication between them so my problem is that to send packets with lorawan protocoll the packet must be hex string for example "30322E321" and the value of the temp sensor is float for example 24.60 so i convert the float value to ascii string and then to a hex string correclty  with this code:
Code: [Select]
dtostrf( temp, 1, 2, float_str);
 
  // use snprintf() to include the float representation
  snprintf( message, sizeof(message), "%s", float_str);
  //Serial.println( message );

Utils.hex2str((uint8_t*)message, payload_hex, strlen(message));


So my problem is that i cant do the opposite i receive the hex string packet correclty but i cant to convert it to ascii string again to print it

can you help me?Im new to this and im a little confused

jremington

If you have a problem with the receiver code, post that.

Quote
i cant to convert it to ascii string again to print it
Why not?

dimitris21

So do you know about my problem or i must ask it in new post with that you said?Am i in wrong topic?

Robin2

Stay with this Thread.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

srnet

You could post all your code so we know which LoRa library you are using.

Are you sure your using LoRaWAN, there is a differance between that and LoRa itself ?
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

dimitris21

I use arduPiLoRaWAN.h to raspberry which is the receiver of the packet and Wire.h, arduinoUART.h,arduinoUtils.h,arduinoLoRaWAN.h to arduino which is the sender of the packet.And I do a connection P2P.



srnet

I have not used the RN2483 myself, but be aware that although the library may be called LoRaWAN, your not in fact using LoRaWAN itself, that has no concept of P2P connections.

It just hapepns that the RN2483 also supports P2P mode.
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

dimitris21

So which librarie has a function that can do this?(hex string to asci string)or can i do it manualy?without a librarie and fuctions?

srnet

So which librarie has a function that can do this?(hex string to asci string)or can i do it manualy?without a librarie and fuctions?
I am not aware of a library that will parse the received buffer automatically into a mixture of ASCII HEX and a float sent as text.

So your probably going to need write the code to parse the buffer yourself. How you do that with the RN2483 I dont know.
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

dimitris21

i have a variable for my situation LoRaWAN._buffer which saved the sending packet  from arduino this variable has  a hex string value and i want  to print it as ascii string.I write in arduino ide so in c language why suppose module RN2483 or libraries for lorawan block my code?If i want to build a fuction which do that converter is possible right?but my problem is that i dont know to do that fuction im absolute begginer :(

Robin2

@dimitris21, if you really want help then post the complete program you are using and describe in as much detail as possible what happens when you run it. Then tell us what you want it to do that is different.

A few examples of the data that is sent to the Arduino would be very useful and the corresponding data as received by the Arduino.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

dimitris21

I did guys thank for your attetion if anyone has the same problem i can share the code i did  :)  :)

srnet

#12
Jun 15, 2018, 12:24 pm Last Edit: Jun 15, 2018, 02:12 pm by srnet
I did guys thank for your attetion if anyone has the same problem i can share the code i did  :)  :)
I cant work out what you mean by that ?


And so that the thread is useful as a reference to others, post the code so that after you have long gone the 'solution' is known.
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

dimitris21

here is the function that do my job the hex stirng into ascii string

Code: [Select]
void hexStrToStr(char *x_hex_string){
 
  char sub_payload[2+1];
  uint8_t x_index=0;

  for(uint8_t i=0; i<(uint8_t)strlen(x_hex_string); i=i+2){
    strncpy(sub_payload, x_hex_string+i, 2);
    sub_payload[2] = '\0';
    x_hex_string[x_index] = (char)strtol(&sub_payload[0], NULL, 16);
    x_index++;
  }
  x_hex_string[x_index] = '\0';
}

Go Up