Data format send to beckand ?

Hello,

I have problem with arduino UNO and Sigfox modul TD1207.Trying basic program and you can not view the data in beckandu. You do not know what should be the format And how to correct the error?

/* Akeru.h - sendMultipleValues.ino
 * 
 * Copyleft Snootlab 2016
 * 
 * How to send 3 variables in a row on the Sigfox network :
 *  - counter : how many loops we've done (int)
 *  - light : analog value from a LDR on A1 (int)
 *  - temperature : analog value from a LM35DZ on A2 (float)
 * 
 * Note that Sigfox messages are 12 bytes long max
 * So here with two ints (2*2 bytes) + one float (4 bytes)
 * we still have 4 bytes available for other data
 */

#include <Akeru.h>

// TD1208 Sigfox module IO definition
/*   Snootlab device | TX | RX
               Akeru | D4 | D5
               Akene | D5 | D4
            Breakout | your pick */
#define TX 2
#define RX 3

// Sigfox instance management 
Akeru akeru(RX, TX);

unsigned int counter = 0;

void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Starting...");

  // Check TD1208 communication
  if (!akeru.begin())
  {
    Serial.println("TD1208 KO");
    while(1);
  }
  
  //akeru.echoOn(); // uncomment this line to see AT commands
}

float getTemp(int pinValue) 
{
  // Convert [0...1024] to [0.0...5.0v]
  float volts = pinValue * (5.0/1024.0);
  // LM35DZ sends 10 mV/deg
  return volts * 100.0;
}

void loop() 
{
  //int light = analogRead(A1);
  float temp = getTemp(analogRead(A2));

  //Serial.print("Counter = "); Serial.println(counter);
  //Serial.print("Light   = "); Serial.println(light);
  Serial.print("Temp    = "); Serial.println(temp);

  // Convert to hexadecimal before sending
  //String c = akeru.toHex(counter);
  //String l = akeru.toHex(light);
  String t = akeru.toHex(temp);

  String msg =  t; // Put everything together

  // Send in the mighty cloud!
  // akeru.send() returns 0 if message failed. 
  if (akeru.sendPayload(msg))
  {
    Serial.println("Message sent !");
  }

  counter++;
  
  // Wait for 10 minutes.
  // Note that delay(600000) will block the Arduino (bug in delay()?)
  for (int second = 0; second < 600; second++) 
  {
    delay(1000);
  }
}

You do not know what should be the format

Well, you are right about that.

We have no clue what hardware you are using (post a link), where you got the library (post a link) or what the problem is.

Sorry..

I have Arduino Uno and Sigfox module TD1207, temperature sensor is LM35DZ.

Serial output is: http://imgur.com/a/MbmOo

But Sigfox Beckand show temperature as: http://imgur.com/a/5zv9Q

TD1207 http://rfmodules.td-next.com/modules/td1207/

Sample code: https://github.com/Snootlab/Akeru

I can't figure out why the examples convert the values to Strings in HEX format. But, it appears that the program you are sending the data to is not converting it back to a float.

Add a Serial.println() statement to print msg. See if you get the same output that you see in the other app.

Output is

Starting... Temp = 20.51 0010a441 Message sent !

Not hex value?

Not hex value?

Well, it is not clear what you printed. Anonymous printing sucks.

But, 0010a441 bears a strong resemblance to a HEX value.

What showed up in the app you are sending the data to? The value you printed, if it was msg, looks a lot like the values you showed in the picture of the app that is receiving the data.

In Beckand I have the same value as the program :slight_smile:

In library is this code for transmition to HEX:

String Akeru::toHex(float f)
{
	byte * b = (byte*) & f;

	String bytes = "";
	for (int i=0; i<4; i++)
	{
		if (b[i] <= 0xF) // single char
		{
			bytes.concat("0"); // add a "0" to make sure every byte is read correctly
		}
		bytes.concat(String(b[i], 16));
	}
	return bytes;
}

I need to ASCII in the field were displayed temperature must be 25.5. help display settings?

Not every computer/microntroler use the same representation of floats. I would recomend against using floats on comunications unless absolute necessary. You can use something like:

#include <stdint.h>

int64_t float2fixed (float f) {
    return f * 10000;
}

float fixed2float(int64_t l) {
    return (float)l / 10000.0;
}

If you know you need only 5 decimals and that the max value you will read will not overflow int64. Then send the int64 to your other computer. Just beware of the endianess of the integers.

Just my two decimal mista ... Could jst emi show up on my program How to apply your solution? I still can not. :(

/* Akeru.h - sendMultipleValues.ino
 * 
 * Copyleft Snootlab 2016
 * 
 * How to send 3 variables in a row on the Sigfox network :
 *  - counter : how many loops we've done (int)
 *  - light : analog value from a LDR on A1 (int)
 *  - temperature : analog value from a LM35DZ on A2 (float)
 * 
 * Note that Sigfox messages are 12 bytes long max
 * So here with two ints (2*2 bytes) + one float (4 bytes)
 * we still have 4 bytes available for other data
 */

#include <Akeru.h>

// TD1208 Sigfox module IO definition
/*   Snootlab device | TX | RX
               Akeru | D4 | D5
               Akene | D5 | D4
            Breakout | your pick */
#define TX 2
#define RX 3

// Sigfox instance management 
Akeru akeru(RX, TX);

unsigned int counter = 0;

void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Starting...");

  // Check TD1208 communication
  if (!akeru.begin())
  {
    Serial.println("TD1208 KO");
    while(1);
  }
  
  //akeru.echoOn(); // uncomment this line to see AT commands
}

float getTemp(int pinValue) 
{
  // Convert [0...1024] to [0.0...5.0v]
  float volts = pinValue * (5.0/1024.0);
  // LM35DZ sends 10 mV/deg
  return volts * 100.0;
}

void loop() 
{
  //int light = analogRead(A1);
  float temp = getTemp(analogRead(A2));

  int temp2 = temp * 100; //Temperature with only 2 decimals

  //Serial.print("Counter = "); Serial.println(counter);
  //Serial.print("Light   = "); Serial.println(light);
  Serial.print("Temp    = "); Serial.println(temp);
  Serial.print("Temp2    = "); Serial.println(temp2); //Just for checking

  // Convert to hexadecimal before sending
  //String c = akeru.toHex(counter);
  //String l = akeru.toHex(light);
  String t = akeru.toHex(temp2); //Use only int on the transmission

  String msg =  t; // Put everything together

  // Send in the mighty cloud!
  // akeru.send() returns 0 if message failed. 
  if (akeru.sendPayload(msg))
  {
    Serial.println("Message sent !");
  }

  counter++;
  
  // Wait for 10 minutes.
  // Note that delay(600000) will block the Arduino (bug in delay()?)
  for (int second = 0; second < 600; second++) 
  {
    delay(1000);
  }
}

When receiving just divide the result by 100 and you will have your float back.

   int received_val;
   float temp;

   /** put here the code to fill the var **/

   temp = (float)received_val * 100.0;

Program WORKS !!! :) But ... after restart suplly VCC (arduino) program now send wrong once wrong number (data) and block. How fix it?