This example shows how to get the temperature value that this module provides.
Required Materials
1 x Waspmote PRO
1 x Battery
1 x MiniUSB wire
1 x SX1272 module (LoRa)
Notes
- The SX1272 module is provided with a special 4.5 dBi antenna, which enables maximum range. The only exception is Smart Parking; in this case the antenna is smaller, 0 dBi, to fit inside the enclosure.
- It is not recommended to work without an antenna screwed to the module. The module could be damaged due to RF reflections.
- The SX1272 module can only be used in special Waspmote units which have been modified to drive the SPI pins to SOCKET0. (only SOCKET0 is available for SX1272)
- This module does not save the configuration. So, the network settings as the mode or the channel MUST be configured every time it is switched on.
- This example can be executed in Waspmote v12 and Waspmote v15
Code
/* * ------ [SX_13] - Get Temperature -------- * * Explanation: This example shows how to get the temperature value * that this module provides. * * 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 . * * Version: 0.1 * Design: David Gascón * Implementation: Covadonga Albiñana, Yuri Carmona */// Put your libraries here (#include ...)#include<WaspSX1272.h>// status variableint8_t e;voidsetup(){// Init USB portUSB.ON();USB.println(F("SX_13 example"));USB.println(F("Semtech SX1272 module. Get Temperature"));// Init SX1272 module sx1272.ON();delay(1000);USB.println(F("Configuration finished")); }voidloop(){// Getting temperature e =sx1272.getTemp();// Check statusif( e ==0 ) { USB.print("Getting Temperature --> OK. "); USB.print(F("Temperature(celsius): "));USB.println(sx1272._temp); }else {USB.println(F("ERROR getting temperature")); } delay(1000);}
Output
H#
SX_13 example
Semtech SX1272 module. Get Temperature
Configuration finished
Getting Temperature --> OK. Temperature(celsius): 14
Getting Temperature --> OK. Temperature(celsius): 14
Getting Temperature --> OK. Temperature(celsius): 14
...
H#
SX_13 example
Semtech SX1272 module. Get Temperature
Configuration finished
Getting Temperature --> OK. Temperature(celsius): 14
Getting Temperature --> OK. Temperature(celsius): 14
Getting Temperature --> OK. Temperature(celsius): 14
...