This is a binary for AT&T IoT StarterKit that allows the kit to send sensor data to M2X and/or UDP endpoint in Flow.
You will need StarterKit and microSD card where you will put the configuration file.
Collected sensor data are temperature (in °C), humidity and 3-axis accelerometer.
- format microSD card to FAT32 filesystem.
- create
config.ini
file and put it in the root directory of microSD card - assemble the kit, insert microSD card into NXP FRDM-K64F board power it up and connnect to the computer
- put
StarterKit_M2X_UDP_K64F.bin
into root directory of yourMBED
USB drive - after 10 seconds the green LED next to USB port on NXP board will stop blinking, press
RESET
button - if everything is properly configured the RGB led on NXP board should turn red first then blink yellow and after a moment turn green
- the RGB led will blink green whenever data are being sent to M2X
All configuration parameters are in config.ini file in format option=value
one configuration option per line.
Configuration options are case sensitive. No quotes around text values. These are the supported configuration options:
- Enable_M2X = enables sending data to M2X. 1=enabled, 0=disabled
- Device_ID = M2X device ID
- M2X_Key = M2X API key, could be either device's primary API key or master API key
- M2X_Commands = periodicaly checks M2X for pending device commands, see API reference for more information on commands. 1=enabled, 0=disabled
- Enable_UDP = enables sending data to Flow over UDP. The endpoint can be any UDP listener, not just Flow. 1=enabled, 0=disabled
- UDP_Host = UDP endpoint hostname
- UDP_Port = UDP endpoint port number
- IMEI = StarterKit's IMEI. 16 digits. It is part of UDP packet.
- Latitude
- Longitude = StarterKit's location. It is part of UDP packet. Latitude has to be in range -90 to 90 and Longitude in range -180 to 180.
- Comand_Wait = This determines how many seconds should StarterKit wait between polling for comands
- Command_Polls = This determines how many times should StarteKit poll M2X for pending commands between sending values
The wait time between sending values to M2X and/or UDP endpoint is a product of Command_Wait and Command_Polls: wait time = Command_Polls * Command_Wait
. This formula is used even if M2X and commands are not enabled so make sure to always set Command_Wait and Command_Polls to reasonable values.
For instance, if you want the values to be sent every minute you can set Command_Wait=10 and Command_Polls=6: 10 * 6 = 60 seconds.
Sample config.ini is in the repo.
In order to send data to M2X the device and streams have to be already created. The code expects following stream names to be present on the device:
Stream ID | Meaning |
---|---|
temp | temperature |
humidity | humidity |
accelX | X-axis accelerometer value |
accelY | Y-axis accelerometer value |
accelZ | Z-axis accelerometer value |
UDP packet payload is single line string and contains following comma separated values:
IMEI,temperature,humidity,X-acelerometer,Y-accelerometer,Z-accelerometer,latitude,longitude
IMEI, latitude and longitude are taken from the configuration file. IMEI is enclosed in single quotes.
Source code is available in MBED repository: https://os.mbed.com/users/korycanjan/code/StarterKit_M2X_UDP/