[RTFM] Akeru library documentation [EN]

Forum de support et d'échange sur la carte Akeru (carte compatible Arduino développée par Snootlab et intégrant la technologie Sigfox) et du shield Akene pour Arduino (shield pour Arduino développée par Snootlab et intégrant la technologie Sigfox)

[RTFM] Akeru library documentation [EN]

Message non lude Laetitia » Jeu 28 Juil 2016 10:58

Akeru - Arduino library for TD1208

Empower your Arduino with IoT !

Note : this document is valid from version 4 of the Akeru library.

- Changelog -

Important changes compared to version 3 of the library, valid for every sketch including v4 :
  • No need to include SoftwareSerial library in your sketch
  • RX/TX definition happens in the sketch instead of the .cpp file (that way it's easier to adapt the code for an Akene or a TD1208 breakout)
  • The payload is a String object instead of a structure struct
  • Data must be converted in hexadecimal prior to sending, with toHex()
  • No need to insert delays or call isReady() to manage the timing between two messages, sendPayload() already does it.
The Akeru library enables Sigfox connectivity for your Arduino. It allows you to define the RX/TX pins directly in your sketch, fetch data from the modem (temperature, revision numbers...), send and receive messages on the Sigfox network.

Akeru.h : Header file to be included in your sketch
Akeru.cpp : Definition of the global object Akeru and its associated methods
/examples : Folder containing examples of use
- DemoTest : complete demonstration of the library, requests every available parameter and sends a message on the network
- downlinkDemo : how to receive data from the network
- sendMultipleValues : how to send multiple variables in a single message
- sendSingleValues : how to send values from a single sensor

- Initialization -

To use the Akeru library, you need to include it in your sketch :

Code: Tout sélectionner
#include <Akeru.h>

Then declare the Akeru object from which you'll call the methods you need. For example :

Code: Tout sélectionner
Akeru akeru (RX, TX);

The RX/TX values depend on the device you're using :
  • Akeru : RX=D5 ; TX=D4
  • Akene : RX=D4 ; TX=D5
  • Breakout TD1208 : up to your wiring.
Then, initialize the board with a begin() :

Code: Tout sélectionner
void setup()

- Available methods -

Note : every function described here, except toHex(), echoOn() and echoOff() returns 1 if everything went alright, 0 otherwise.

Prints AT commands and TD1208's answers on the serial monitor. Inactive by default.

Disables AT commands & answers echo. Active by default.

To be used in the setup() of your sketch.

Indicates if the modem is ready to send a new message (more precisely if enough time passed between 2 messages, so you don't send too many). Its use may be redundant since this function is called each time a message or a downlink request is sent.

Sends a simple AT command.

sendPayload(const String payload)
Sends data on the Sigfox network. Prior to sending, data must be formatted in hexadecimal with toHex().

getTemperature(int *temperature)
Gets the modem temperature.

getID(String *id)
Gets the modem's ID (equal to the ID on the modem's sticker)

getVoltage(float *voltage)
Gets the modem's power supply voltage.

getHardware(String *hardware)
Get the modem's hardware revision number.

getFirmware(String *firmware)
Get the modem's firmware revision number.

getPower(int *power)
Gets the modem's power level (in dBm).

setPower(int power)
Sets the modem's power level (in dBm).

toHex(int i) | toHex(unsigned int ui) | toHex(long l) | toHex(unsigned long ul) | toHex(float f) | toHex(double d) | toHex(char c)
Converts a variable in hexadecimal. Returns a String containing the data to be sent.

toHex(char *c, int length)
Converts a string in hexadecimal. The array's size must be known (use sizeof). Returns a String containing the data to be sent.

receive(String *data)
Enables downlink, waits for an answer from the network. Received data is hexadecimal.

- Sending multiple values -

When you need to send several values on the Sigfox network in a single message, you need to put all the data in the same payload. You can do this easily with the concatenation operators from the String library :

Code: Tout sélectionner
int integer = 42;
float floating = 3.141592;

String i = akeru.toHex(integer);
String f = akeru.toHex(floating);

String msg = i + f;

"If it's itchy, scratch it !" - "DIY or die"

RTFM (À lire avant de poster) - ANDb (Arduino Noob Database)
Avatar de l’utilisateur
Messages: 286
Inscription: Mar 7 Aoû 2012 15:07
Localisation: Toulouse

Retourner vers Akeru et Akene

Qui est en ligne

Utilisateurs parcourant ce forum: Bing [Bot] et 1 invité