Development

Sensors / Ambient Control:

» AM 05: Frame Class Utility

This is the basic code to create a frame with every Ambient Control sensor.

Required Materials

1 x Plug & Sense! Ambient Control
1 x Luminosity (Luxes Accuracity)
1 x Digital Humidity & Temperature Probe

Notes

- This example can be executed in Waspmote v15.
- If you are using Waspmote v12, you MUST use the proper sensor fields

Code

/*  
 *  ------------  [AM_05] - Frame Class Utility  -------------- 
 *  
 *  Explanation: This is the basic code to create a frame with every
 * 	Ambient Control sensor
 *  
 *  Copyright (C) 2016 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:		 3.0
 *  Design:          David Gascón
 *  Implementation:  Luis Miguel Marti
 */

#include <WaspSensorAmbient.h>
#include <WaspFrame.h>

float digitalTemperature; 
float digitalHumidity; 
float analogLDRvoltage;
float digitalLuxes; 
char node_ID[] = "Node_01";


void setup() 
{
  USB.ON();
  USB.println(F("Frame Utility Example for Ambient Control"));  
  
  USB.println(F("******************************************************"));
  USB.println(F("WARNING: This example is valid only for Waspmote v15"));
  USB.println(F("If you use a Waspmote v12, you MUST use the correct "));
  USB.println(F("sensor field definitions"));
  USB.println(F("******************************************************"));

  // Set the Waspmote ID
  frame.setID(node_ID); 
}

void loop()
{
  ///////////////////////////////////////////
  // 1. Read sensors
  ///////////////////////////////////////////  

  // Read the temperature sensor
  digitalTemperature = SensorAmbient.getTemperature();
  // Read the humidity sensor
  digitalHumidity = SensorAmbient.getHumidity();
  //Sensor LDR reading
  analogLDRvoltage = SensorAmbient.getLuminosity();
  // Read the Luxes sensor
  digitalLuxes = SensorAmbient.getLuxes(OUTDOOR);



  ///////////////////////////////////////////
  // 2. Create ASCII frame
  /////////////////////////////////////////// 

  // Create new frame (ASCII)
  frame.createFrame(ASCII);

  // Add temperature
  frame.addSensor(SENSOR_AMBIENT_TCB, digitalTemperature);
  // Add humidity
  frame.addSensor(SENSOR_AMBIENT_HUMB, digitalHumidity);
  // Add LDR value
  frame.addSensor(SENSOR_AMBIENT_LUM, analogLDRvoltage);
  // Add Luxes
  frame.addSensor(SENSOR_AMBIENT_LUXES, digitalLuxes);


  // Show the frame
  frame.showFrame();

  //wait 2 seconds
  delay(2000);
}

Output

H#
Frame Utility Example for Ambient Control
===============================
Current ASCII Frame:
Length: 70
Frame Type: 134
frame (HEX): 3C3D3E86042333413836373036334439333734323834234E6F64655F30312330235443423A2D33392E37312348554D423A2D322E31234C554D3A302E313033234C55583A3023
frame (STR): <=>�#3A867063D9374284#Node_01#0#TCB:39.71#HUMB:32.1#LUM:0.103#LUX:0#
===============================
...

Quick Publish: