» MR-RB 01: Reading Radiation
This example shows how to measure radiation in uSv/h during a specific time.
Required Materials
1 x Waspmote
1 x Battery
1 x Radiation board
1 x Geiger tube
Notes
* Remember to connect the battery to Waspmote for proper operation.
* The connection of the sensor is described in the Radiation technical guide.
* When turning on the temperature sensor you will be powering all the low consumption group sensors. See the Radiation board technical guide for more information.
* Logger, Common and Radiation assemblies must be loaded in the mote.
* Please note that the output is in hexadecimal.
* Please note that Float.toLong() method has been used with a precission of 2 decimals. For example, a 3413 output in decimal base means 34.13. For more information of Float class, see http://localhost:5000/gac/saguaro-system-11.3.htm?fqn=r:com.ibm.saguaro.system.Float
* To compile this example: mrc --assembly=radp-1.0 --system=waspmote --ref=logger-#.# --ref=
Code
/**
* Copyright (C) 2013 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.html
*
* 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/>.
*
* Design: David Gascón
*
* @version 0.1
* @author Anartz Nuin Jiménez and Ignacio Ruiz Martín
*/
package com.libelium.examples.radiation;
import com.ibm.saguaro.logger.Logger;
import com.ibm.saguaro.system.Float;
import com.ibm.saguaro.system.GPIO;
import com.ibm.saguaro.system.Mote;
import com.ibm.saguaro.system.Util;
import com.ibm.saguaro.system.csr;
import com.libelium.common.Callback;
import com.libelium.common.Gpio;
import com.libelium.radiation.Radiation;
public class RadiationExample {
static GPIO gpio = Gpio.getInstance();
static Radiation rad = new Radiation();
static{
rad.ON();
rad.getRadiation((byte)0, new Callback(null) {
@Override
public int invoke(byte[] buf, int len) {
return interrupt(buf, len);
}
}, 10000);
}
static int interrupt(byte[] buf, int len) {
long result = Util.get32(buf, 0);
Logger.appendString(csr.s2b("Radiation measurement (usv/h): "));
Logger.appendHexLong(Float.toLong(result,(byte)2));
Logger.flush(Mote.INFO);
rad.getRadiation((byte)0, new Callback(null) {
@Override
public int invoke(byte[] buf, int len) {
return interrupt(buf, len);
}
}, 10000);
return 0;
}
}
Output
category: log
evname: MAPP
id: 7d
time: 11:21:10.830'000
severity: 5
module: MAPP
logmsg: MAPP: Radiation measurement (usv/h): 00005204