Last active
October 9, 2017 09:29
-
-
Save ma2shita/4447928fca35879efff432ba61874780 to your computer and use it in GitHub Desktop.
Example for "Sigfox Shield for Arduino (UnaShield V2S)" with SORACOM Harvest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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