Development

General / Frame:

» Frame 04: Binary multiple

This example creates a BINARY frame with a multiple-field sensor value (Accelerometer in this case) and shows it.

Required Materials

1 x Waspmote PRO
1 x Battery
1 x MiniUSB wire

Code

/*  
 *  ------ FRAME_04_binary_multiple - WaspFrame Binary multiple -------- 
 *  
 *  Explanation: This example creates a binary frame with a multiple field
 *  and shows it. 
 *  
 *  Copyright (C) 2014 Libelium Comunicaciones Distribuidas S.L. 
 *  http://www.libelium.com 
 *  
 *  This program is free software: you can redistribute it and/or modify 
 *  it under the terms of the GNU General Public License as published by 
 *  the Free Software Foundation, either version 3 of the License, or 
 *  (at your option) any later version. 
 *  
 *  This program is distributed in the hope that it will be useful, 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *  GNU General Public License for more details. 
 *  
 *  You should have received a copy of the GNU General Public License 
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 *  
 *  Version:           0.2
 *  Design:            David Gascón 
 *  Implementation:    Joaquín Ruiz, Yuri Carmona
 */

#include <WaspFrame.h>
  
// define the Waspmote ID 
char moteID[] = "node_01";

// hypothetical GPS values
float latitude  = 1.4465431234;
float longitude = -0.8842734321;


void setup()
{
  // Init USB port & Accelerometer
  USB.ON();    
  ACC.ON();
  
  // set the Waspmote ID
  frame.setID(moteID);
}

void loop()
{
  // Create new frame (BINARY)
  frame.createFrame(BINARY);
  
  // set frame fields (multiple)
  frame.addSensor(SENSOR_ACC,(int) ACC.getX(),(int) ACC.getY(),(int) ACC.getZ());
  
  // set frame fields (multiple)
  frame.addSensor(SENSOR_GPS, latitude, longitude);

  // Print frame
  frame.showFrame();

  delay(5000);
}

Output

E#
===============================
Current BINARY Frame:
Length: 34
Frame Type (decimal): 0
Number of fields: 2
HEX: 3C 3D 3E 00 1D 12 9E 14 17 6E 6F 64 65 5F 30 31 23 00 3F 03 00 C0 FF 07 04 35 53 28 B9 3F BE 5F 62 BF
String: <=>žnode_01#ÿ5S(¹?¾_b¿
===============================
===============================
Current BINARY Frame:
Length: 34
Frame Type (decimal): 0
Number of fields: 2
HEX: 3C 3D 3E 00 1D 12 9E 14 17 6E 6F 64 65 5F 30 31 23 01 3F 04 00 BB FF 00 04 35 53 28 B9 3F BE 5F 62 BF
String: <=>

Quick Publish: