You can automatically measure temperature, humidity, pressure, board tilt (acceleration sensor) and send them to the cloud simply by connecting Una Shield, Arduino Uno (or its compatible board) and USB power supply. The number of information that can be gathered per day on the Sigfox network is limited to 140 times, but still it is fun to collect these information every 15 minutes.
We can send data of 12 bytes to the Sigfox network at a time. Temperature, humidity, and atmospheric pressure are expressed as 2-byte integers, and the three-dimensional acceleration representing the slope is multiplied by 10 respectively to make it 2-byte integers, making it a total of 12 bytes.
Open pages of Adafruit Unified Sensor Driver, [Adafruit BME 280 Library] (https://github.com/adafruit/Adafruit_BME280_Library), and Adafruit MMA 8451 Accelerometer Driver, and press the “Clone or download” and “Download ZIP” to download the libraries.
Next, the following program is compiled and transfer to the Arduino Uno board.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_MMA8451.h>
#include <SIGFOX.h>
/*
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
*/
Adafruit_BME280 bme;
Adafruit_MMA8451 mma = Adafruit_MMA8451();
static const String device = "";
static const bool useEmulator = false;
static const bool echo = true;
static const Country country = COUNTRY_JP;
static UnaShieldV2S transceiver(country, useEmulator, device, echo);
void setup() {
Serial.begin(9600);
if (!bme.begin(0x76)) stop("BME280 is missing.");
if (!mma.begin(0x1c)) stop("MMA8451 is missing.");
mma.setRange(MMA8451_RANGE_2_G);
if (!transceiver.begin()) stop("Unable to init SIGFOX module.");
}
void loop() {
float Temp = bme.readTemperature();
float Press = bme.readPressure() / 100.0F;
float Humid = bme.readHumidity();
sensors_event_t event;
mma.getEvent(&event);
float x = event.acceleration.x;
float y = event.acceleration.y;
float z = event.acceleration.z;
static int counter = 0;
word sTemp = Temp * 1.0;
word sHumid = Humid * 1.0;
word sPress = Press * 1.0;
word sx = x * 10.0;
word sy = y * 10.0;
word sz = z * 10.0;
Serial.print("Temp = "); Serial.print(sTemp); Serial.println(" degC");
Serial.print("Humid = "); Serial.print(sHumid); Serial.println(" %");
Serial.print("Press = "); Serial.print(sPress); Serial.println(" hPa");
Serial.print("x = "); Serial.print(sx); Serial.println(" x 10^(-1) m/s^2");
Serial.print("y = "); Serial.print(sy); Serial.println(" x 10^(-1) m/s^2");
Serial.print("z = "); Serial.print(sz); Serial.println(" x 10^(-1) m/s^2");
// format:
// temp::int:16:little-endian humid::int:16:little-endian \
// press::int:16:little-endian x::int:16:little-endian \
// y::int:16:little-endian z::int:16:little-endian
String msg = transceiver.toHex(sTemp)
+ transceiver.toHex(sHumid)
+ transceiver.toHex(sPress)
+ transceiver.toHex(sx)
+ transceiver.toHex(sy)
+ transceiver.toHex(sz) ;
Serial.println(msg);
if (!transceiver.sendMessage(msg)) Serial.println("Send failed.");
counter++;
Serial.println("Waiting 15 minutes..."); delay(900000);
}
/*
Temp = 25 degC
Humid = 35 %
Press = 990 hPa
x = 8 x 10^(-1) m/s^2
y = 4 x 10^(-1) m/s^2
z = 97 x 10^(-1) m/s^2
19002300de03080004006100
*/
Log in to Sigfox Backend Cloud, and click “DEVICE TYPE”, “Unabiz”、”CALLBACKS” on left side, “New” on right side, and write in “Custom payload” as
temp::int:16:little-endian humid::int:16:little-endian press::int:16:little-endian x::int:16:little-endian y::int:16:little-endian z::int:16:little-endian
Then, type Body as
{
"device": "{device}",
"time":"{time}",
"station":"{station}",
"rssi":"{rssi}",
"snr":"{snr}",
"data":"{data}",
"seq": "{seqNumber}",
"temp":"{customData#temp}",
"humid":"{customData#humid}",
"press":"{customData#press}",
"x":"{customData#x}",
"y":"{customData#y}",
"z":"{customData#z}"
}
Other settings are the same as described in The use of Sigfox with Una Shiled V2S.
Arduino Uno, Una Shileid, Information on the board to which the USB power supply is connected should be collected as follows.
device: xxxxxx
time: xxxxxxxxxx
station: 50E3
rssi: -123.00
snr: 9.48
data: 11003600f003f4fff1ff5f00
seq: 2791
temp: 17
humid: 54
press: 1008
x: -12
y: -15
z: 95
This indicates that the temperature is 17 degrees Celsius, the relative humidity is 54%, and the atmospheric pressure is 1008 hPa. Also, since the gravitational acceleration is 9.8 m/s^2, you can see that the board is slightly tilted.
As seen in Sigfox Backend Cloud, “The feature send duplicate and the following information: snr, station, avgSnr, lat, lng, rssi, will not be available anymore for customers in the DATA callback feature from the first of June 2019.”
The signal-to-noise power ratio (snr) and the signal strength (rssi) will not be displayed from the beginning of June next year. When “Send duplicate” is turned on, different data of snr, rssi and station are also displayed, and you can see that three different transmissions are received by three different base stations. I’m expecting a location service with use of Sigfox network.