0

Adafruit feather 32u4 sending message problem
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit feather 32u4 sending message problem

by cansatlaskorain on Thu Jan 17, 2019 1:05 pm

Hi everyone,

We have a problem with the Adafruit feather 32u4. We want to send some information from one Adafruit feather 32u4 to another.

We can send some data but we want to add some new variables. Where and how do we have to do it?

We will leave our program below, if anyone have any suggestions please feel free to help.


Code: Select all | TOGGLE FULL SIZE
void loop(){
  if (digitalRead(10) == HIGH)
  {
    Paratxuta = 0;
    delay(10);
  }
  else
  {
    Paratxuta = 7;
  }
 
  char status;
  double T,P,A;
 

//Get data
  bmp.getData(T,P);
   
  // T= T*100; //Dezimalak kendu
   Tbe= T*100; //Dezimalak kendu
  Pbe=P;
  if (Pbe<0){
    Pbe=0;
     }
   if (Pbe>32000){
    Pbe=32000;
     }   
 //Display data
  Serial.print("Absolute pressure: ");
  Serial.print(P,2);
  Serial.println(" mb.");
  Serial.print("Temperature: ");
  Serial.print(T,2);
  Serial.println(" deg C.");

  //-------Calculamos la altitud--------
          A= bmp180.altitude(P,PresionNivelMar);
          Serial.print("Altitud: ");
          Serial.print(A);
          Serial.println("m ");   

          //Send Data
  sprintf(payload,"T: %dºC, Pb: %d mb. , A: %d m, Paratxuta: %d",(int)Tbe,(int)Pbe,(int)A,(int)Paratxuta);      [b]//we send the data here[/b]
  Serial.println(payload);
  radio.send(GATEWAYID, payload, 50);
  Serial.println("Send complete");
 
  delay(500);
   
  /*
  status = bmp180.startTemperature();//Inicio de lectura de temperatura
  if (status != 0)
  {   
    delay(status); //Pausa para que finalice la lectura
    status = bmp180.getTemperature(T); //Obtener la temperatura
    if (status != 0)
    {
      status = bmp180.startPressure(3);//Inicio lectura de presión
      if (status != 0)
      {       
        delay(status);//Pausa para que finalice la lectura       
        status = bmp180.getPressure(P,T);//Obtenemos la presión
        if (status != 0)
        {                 
          Serial.print("Temperatura: ");
          Serial.print(T);
          Serial.print(" *C , ");
          Serial.print("Presion: ");
          Serial.print(P);
          Serial.print(" mb , ");      */
       
       // }     
       
//    }   
//  }
  delay(1000);
}




Thank you in advance,
Last edited by adafruit_support_bill on Thu Jan 17, 2019 1:45 pm, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

cansatlaskorain
 
Posts: 1
Joined: Thu Jan 17, 2019 12:25 pm

Re: Adafruit feather 32u4 sending message problem

by adafruit_support_bill on Thu Jan 17, 2019 1:48 pm

We can send some data but we want to add some new variables. Where and how do we have to do it?

Add the additional parameters to your sprintf statement:
sprintf(payload,"T: %dºC, Pb: %d mb. , A: %d m, Paratxuta: %d",(int)Tbe,(int)Pbe,(int)A,(int)Paratxuta);

sprintf is a well documented function:

http://www.cplusplus.com/reference/cstdio/sprintf/
https://www.tutorialspoint.com/c_standa ... printf.htm

adafruit_support_bill
 
Posts: 71787
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.