Skip to content

Instantly share code, notes, and snippets.

@Kaniiisek
Created March 9, 2017 09:07
Show Gist options
  • Save Kaniiisek/0532b08603f0a6c205f0a1ee4d2f8ab1 to your computer and use it in GitHub Desktop.
Save Kaniiisek/0532b08603f0a6c205f0a1ee4d2f8ab1 to your computer and use it in GitHub Desktop.
SEND value
/* Akeru.h - sendSingleValues.ino
*
* Copyleft Snootlab 2016
*
* How to send a single analog value on the Sigfox network
*/
#include <Akeru.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// TD1208 Sigfox module IO definition
/* Snootlab device | TX | RX
Akeru | D4 | D5
Akene | D5 | D4
Breakout | your pick */
#define TX 2
#define RX 3
#define ONE_WIRE_BUS 7
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Sigfox instance management
Akeru akeru(RX, TX);
int TempInC;
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Serial.println("Starting...");
// Check TD1208 communication
if (!akeru.begin())
{
Serial.println("TD1208 KO");
while(1);
}
//akeru.echoOn(); // uncomment this line to see AT commands
}
void loop()
{
sensors.requestTemperatures();
sensors.getTempCByIndex(0);
TempInC = sensors.getTempCByIndex(0);
float temperatureInCelsius = sensors.getTempCByIndex(0);
//int sensorValue = analogRead(A0);
// Trace on serial console
Serial.print(temperatureInCelsius, 2);
// convert to hexadecimal before sending
String data = akeru.toHex(temperatureInCelsius);
// Send in the mighty internet!
// akeru.sendPayload() returns 0 if message failed.
if (akeru.sendPayload(data))
{
Serial.println("Message sent !");
}
// Wait for 10 minutes.
// Note that delay(600000) will block the Arduino (bug in delay()?)
for (int second = 0; second < 600; second++)
{
delay(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment