Skip to content

Instantly share code, notes, and snippets.

@ma2shita
Last active October 9, 2017 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ma2shita/4447928fca35879efff432ba61874780 to your computer and use it in GitHub Desktop.
Save ma2shita/4447928fca35879efff432ba61874780 to your computer and use it in GitHub Desktop.
Example for "Sigfox Shield for Arduino (UnaShield V2S)" with SORACOM Harvest
/* Get temperature from on-board sensor, sending SORACOM Harvest via Sigfox */
#include "SIGFOX.h"
static UnaShieldV2S transceiver(COUNTRY_JP, false, "NOTUSED", true); /* ref: https://unabiz.github.io/unashield/ */
void setup() {
Serial.begin(9600);
if (!transceiver.begin()) stop(F("Unable to init SIGFOX module, may be missing"));
}
void loop() {
float t;
transceiver.getTemperature(t); /* from on-board sensor */
char buf[7];
dtostrf(t, -1, 1, buf); /* Arduino UNO R3 cannot cast float to char (ZZ.9) */
Serial.println(buf);
char json[11];
sprintf(json, "{\"t\":%s}", buf);
Serial.println(json);
transceiver.sendString(json);
delay(10000); /* waiting for next send */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment