Introduction
Welcome to the Termite API! You can use our API to get and set hardware information and settings on various sensors, network settings, network.
There are examples in various flavours: Serial Console, C++ , C , C# , and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
Sense, Create + Control :)
Installing the software
The default firmware streams data from its onboard sensors continously and allows you to make calls to the Termite over serial interface to change settings.
Serial Console
UART Settings
Parameter | Value |
---|---|
Serial Port | /dev/tty.SLAB_USBtoUART |
Baud Rate | 115200 |
Data Bits | 8 |
Parity | none |
Stop Bits | 1 |
Flow Control | false |
Open your serial console and connect to the Termite with the correct BaudRate (115200)
. You should see lots of data flowing from the Termite in human readable format in the following order:
Version 1.0 Senses
X,Y,Z,Temperature,Light,Humidity,Proximity,Pressure,Altitude,DewPoint
Variable | Sensor | Description |
---|---|---|
X | Accelerometer | X axis acceleration |
Y | Accelerometer | Y axis acceleration |
Z | Accelerometer | Z axis acceleration |
Temperature | Environmental | Temperature from Environmental sensor in Celcius. |
Light | Optical | Ambient light levels measured in Lux |
Humidity | Environmental | Percentage of water vapor present in the air. |
Proximity | Optical | Distance measured between 1cm and 13cm. |
Pressure | Environmental | Atmospheric pressure |
Additional sensor readings for hardware v1.1
X,Y,Z,Temperature,Light,Humidity,Proximity,Pressure,Altitude,DewPoint,Red,Green,Blue
Variable | Sensor | Description |
---|---|---|
Red | Optical | Red spectrum measurement |
Green | Optical | Green spectrum measurement |
Blue | Optical | Blue spectrum measurement |
Additional sensor readings for hardware v2.0
X,Y,Z,Temperature,Light,Humidity,Proximity,Pressure,Altitude,DewPoint,wq,qx,qy,qz,temperaturelsm
Variable | Sensor | Description |
---|---|---|
QW | Gyroscope | Quaternion W component |
QX | Gyroscope | Quaternion X component |
QY | Gyroscope | Quaternion Y component |
QZ | Gyroscope | Quaternion Z component |
Temperature LSM | Environmental | Temperature from Environmental sensor in Celcius. |
Serial Commands
> TMT
Asks device if it is a Termite, returns the hardware version if true as the follwing:
Response: +Termite VERSION:1.0
> CMD
Puts the Termite into 'command mode' allowing you to enter additional commands.
Response: +Termite CMD Mode Active
Response: +OK
The following commands only work once you have entered 'Command Mode' (CMD):
The Termite will only respond to the following two commands when outside of 'Command Mode'
Command | Result |
---|---|
TMT | Ask device if Termite? Returns hardware version if true. |
CMD | Enters you into command mode. From here you may run additional commands below. |
The following commands are only available once user has entered *'Command Mode'** (CMD)
*
Control Commands
> INFO
The above command returns JSON structured like this:
+INFO:
{
"chipid":00000000,
"flashchipid":0000000,
"flashchipsize":4096,
"mac":"00:00:00:00:00:00",
"sname":"DEVICE NAME",
"stype":"SENSOR TYPE",
"prj":"PROJECT NAME",
"user":"USER/OWNER NAME",
"deepsleep":"false",
"interval":"600",
"accelint":"false",
"pirint":"false",
"wifi":"YOUR NETWORK",
"wifipass":"YOUR PASSWORD",
"wifiauto":"true",
"UDP":"127.0.0.1",
"UDPPort":"19992",
"UDPAuto":"true",
"MQTT":"some.mqqt.server.com",
"MQTTPort":"8883",
"MQTTLogin":"YOUR LOGIN",
"MQTTPass":"YOUR PASSWORD",
"lat":"0",
"lon":"0",
"geoaccuracy":"0"
}
These commands are for querying and controlling the Termite.
Command | Result |
---|---|
EXT | Exits command mode |
RST | Resets the device |
INFO | Returns a JSON array of Termites settings |
HELP | Prints out a list of possible commands |
Checksum
In order to maintain data integrity the default firmware makes use of CRC32 for error checking. When activated a checksum will be added to the beginning of all outputs.
Command | Result |
---|---|
CRCON | Enables Checksum |
CRCOFF | Disables Checksum |
Data Format Command
> CSV
Changes the output to the follwing format
-5.83, 0.82, -8.03, 25.33, 217.25, 27.64, 11.45, 101599.55, -0.25, 5.32, 339.24, 37.99, 352.20, 22.19
> TAB
Changes the output to the follwing format
X = -6.01 Y = 0.83 Z = -7.93 Temp = 25.12 Light = 223.00 Humidity = 28.93 Proximity = 11.74 Pressure = 101599.63 Altitude = -0.25 DewPoint = 5.80 Yaw = 340.07 Pitch = 39.66 Roll = 352.37 tempLSM = 21.94
> JSON
Changes the output to the follwing format
{
"X":"-5.81",
"Y":"0.81",
"Z":"-8.10",
"temperature":"26.26",
"light":"222.75",
"humidity":"26.00",
"proximity":"11.74",
"pressure":"101602.96",
"altitude":"-0.25",
"dewpoint":"5.23",
"yaw":"339.60",
"pitch":"35.79",
"roll":"352.71",
"tempLSM":"23.11"
}
These commands change the output format from the device. Please note that these settings are not saved and return to the default TAB format when the device is reset.
Command | Returns | Description |
---|---|---|
CSV | +CSV Output | Comma Seperated Format |
TAB | +TAB Output | Tabulated Keyed Format |
JSON | +JSON Output | JSON Format |
Device Settings
Settings Command
> SETTINGS{"INSERT_JSON_CONTENT_HERE"}END
Here is an example of settings to change your WIFI settings:
{
"sname":"Termite Name",
"UDP":"127.0.0.1",
"UDPPort":"19992",
"UDPAuto":"true",
"wifi":"YOUR NETWORK",
"wifipass":"YOUR PASSWORD",
"wifiauto":"true"
}
The device has an onboard memory (eeprom) that allows us to write and save settings that will be retained even after reboot or a power cycle.
Command | Result |
---|---|
SETTINGS{} | Device saves settings and exits CMD mode. |
Example:
SETTINGS{"sname":"Termite Name","UDP":"18.111.26.196","UDPPort":"19992","UDPAuto":"true","wifi":"YOUR NETWORK","wifipass":"YOUR PASSWORD","wifiauto":"true"}END
Make sure to include SETTINGS before your JSON packet and END afterwards.
Settings Info
The device stores settings in its onboard memory (EEPROM). One must not write to settings unless you absolutely must change the settings. There is a maximum of 100,000 write cycles.
You may read the SPIFFS File system as much as you want. But the best practice is to read this information once when the device starts up and store this information in variables.
The default firmware allows the user to read stored settings. The response is a JSON file. See INFO command
+INFO:{"chipid":00000000,"flashchipid":0000000,"flashchipsize":4096,"mac":"00:00:00:00:00:00","sname":"DEVICE NAME","stype":"SENSOR TYPE","prj":"PROJECT NAME","user":"USER/OWNER NAME","deepsleep":"false","interval":"600","accelint":"false","pirint":"false","wifi":"YOUR NETWORK","wifipass":"YOUR PASSWORD","wifiauto":"true","UDP":"127.0.0.1","UDPPort":"19992","UDPAuto":"true","MQTT":"some.mqqt.server.com","MQTTPort":"8883","MQTTLogin":"YOUR LOGIN","MQTTPass":"YOUR PASSWORD","lat":"0","lon":"0","geoaccuracy":"0"}
Setting Parameters
Parameter | Example | State | Default Value |
---|---|---|---|
chipid | 00000000 | get | NA |
flashchipid | 0000000 | get | NA |
flashchipsize | 4096 | get | NA |
mac | "00:00:00:00:00:00" | get | NA |
sname | "DEVICE NAME" | get/set | "Device Name" |
stype | "SENSOR TYPE" | get/set | "Sensor Type" |
prj | "PROJECT NAME" | get/set | "Project Name" |
user | "USER/OWNER NAME" | get/set | "User Name" |
deepsleep | "false" | get/set | "false" |
interval | "600" | get/set | "600" |
accelint | "false" | get/set | "false" |
pirint | "false" | get/set | "false" |
wifi | "YOUR NETWORK" | get/set | "Wifi_Network" |
wifipass | "YOUR PASSWORD" | get/set | "Wifi_Password" |
wifiauto | "false" | get/set | "false" |
UDP | "127.0.0.1" | get/set | "127.0.0.1" |
UDPPort | "19992" | get/set | "19992" |
UDPAuto | "false" | get/set | "false" |
MQTT | "some.mqqt.server.com" | get/set | "some.mqtt.server.com" |
MQTTPort | "8883" | get/set | "8883" |
MQTTLogin | "YOUR LOGIN" | get/set | "" |
MQTTPass | "YOUR PASSWORD" | get/set | "" |
lat | "0" | get/set | "0" |
lon | "0" | get/set | "0" |
geoaccuracy | "0" | get/set | "0" |
Sensor Values
Senses | Range |
---|---|
Pressure | 300...1100 hPa |
Humidity | 0…100% |
Temperature | -40…85°C |
Sensor Accuracy
Hardware v1:
± 3 % relative humidity - Response time for accurate reading = 1 s
Hardware v2:
± 3 % relative humidity - Response time for accurate reading = 8 s
+/- 15% +/- 15 VOC Gases
Average Current
Hardware Version | Awake + Wifi | Deep Sleep |
---|---|---|
Version 1 | Average = 78mA | 40uA to 51.2uA |
Version 2 | Average = 78mA | 160uA to 190uA |
Firmware
Firmware files allow us to create different applications from the Termite.
It is important to note that Core firmware is required in order for the Termite to function with the commands in this API and the "Termite Connect" app.
Core firmware file will be titled: Termite_Core_v0.00.bin
Escaping DeepSleep
If the Termite cannot be programmed or is not responding it is possible that the Termite is in Deep Sleep mode
ROS
ROS Termites wrapper was created and maintained by: Yago Lizarribar
Robot Operating System (ROS) is a flexible framework for writing robot software.
This package gets the data sent from Termites and sends it to the ROS system.
How to run the node
You will have to install the serial library for Python:
bash
user@machine:~$ sudo pip install pyserial
Create a catkin workspace and paste the folder:
bash
user@machine:~$ mkdir -p catkin_ws/src && cd catkin_ws/src
user@machine:~/catkin_ws/src$ git clone https://github.com/yagoliz/Termites_ros.git
user@machine:~/catkin_ws/src$ cd .. && catkin_make
If it compiles without errors, open a terminal and start a roscore:
user@machine:~$ roscore
On another terminal run:
user@machine:~$ rosrun Termites_ros termite_control.py
To check if it's working, you can open a third terminal and run:
user@machine:~$ rostopic echo /termite
How to set udev rules for Termites
Hardware/Udev rules are a great tool to organize your peripherals, since they allow you to give them unique symbolic names.
In the case of the Termites, while in this folder, open a terminal and run:
bash
user@machine:~$ chmod +x setRule.sh
user@machine:~$ ./setRule.sh
Once this is done, you can chech that the udev rule was properly loaded by typing in the terminal:
bash
user@machine:~$ ls /dev/termite
/dev/termite (in blue color)