Use of Sigfox with Una Shiled V2S

category: radio
tags: sigfox

A brief procedures are:

  1. Attach Una Shield V2S with Arduino Uno, and transfer the sketch to the Arduino Uno.
  2. Configure the Web server to accept Webhook.
  3. Configure Sigfox backend cloud to send data to your own web server.

Configuration of the web server

Place the file named, for example, index.php to accept a webhook.

<?php
$LOGFILE = './hook.log';
$postdata = file_get_contents("php://input");
file_put_contents($LOGFILE, date("Y-m-d H:i:s")." ".$_SERVER['REMOTE_ADDR']." ".
$postdata."\n", FILE_APPEND|LOCK_EX);
$payload = json_decode($postdata, true);
foreach($payload as $key => $value) {
  file_put_contents($LOGFILE, "  ".$key.": ".$value."\n", FILE_APPEND|LOCK_EX);
}
?>
OK.

Please make sure that a file hook.log is writable. You can check the function by typing

curl -X POST [URL of the webhook] -d '{"name":"test"}'

Configuration of the Sigfox backend cloud

The procedures are as follows:

  1. Log in to Sigfox Backend Cloud.
  2. Click “DEVICE TYPE” near top of the page, and click “Unabiz” in Name link. And click “CALLBACKS” at the left sidebar.
  3. Click “New” at the top right button.
  4. Set DATA and UPLINK as “Type”, and set URL as “Channel.” Type
t1::uint:16 ctr::uint:16:little-endian t2::uint:16 tmp::uint:16:little-endian t3::uint:16 vlt::uint:16:little-endian

as “Custom payload.” Type your Webhook address in “Url pattern,” set Post as “Use HTTP Method.” Please check “Send SNI” if you use a virtual server. Type application/json as “Content type.” And type

  {"time":"{time}",
  "station":"{station}",
  "rssi":"{rssi}",
  "snr":"{snr}",
  "data":"{data}",
  "counter":"{customData#ctr}",
  "temperature":"{customData#tmp}",
  "voltage":"{customData#vlt}",
  "t1":"{customData#t1}",
  "t2":"{customData#t2}",
  "t3":"{customData#t3}"
}

as “Body.” Then click “Ok.”

You may obtain results such as

2018-xx-xx xx:xx:xx ip-address {"time":"xxxxxxxxxxx","station":"xxxx","rssi":"-123.00","snr":"18.21","data":"920e5ab4b051610194592000","counter":"46170","temperature":"353","voltage":"32","t1":"37390","t2":"45137","t3":"37977"}

  time: xxxxxxxxxxx
  station: xxxx
  rssi: -123.00
  snr: 18.21
  data: 920e5ab4b051610194592000
  counter: 46170
  temperature: 353
  voltage: 32
  t1: 37390
  t2: 45137
  t3: 37977

Please note the temperature and voltage are multiplied by 10 times to fit each float value to a 2-byte integer.