This page describes the low-level serial APIs used to manage UbiBot devices such as WS1 and WS1 Pro model. There are currently two ways to access the APIs:
The following APIs read information from the connected device.
This returns details of the firmware version, channel ID, user ID and serial number of the device.
Request:
{"command":"ReadProduct"}
Response:
{"ProductID":"ubibot-ws1-cn","SeriesNumber":"XXXXXX","Host":"api.ubibot.com","CHANNEL_ID":"XX","USER_ID":"XXX-XXXX","USAGE":"0%","firmware":"ws1_v1.6_17_10_18","backup_ip":"xxx.xxx.xxx.xxx"}
This returns the SSID and password of the Wi-Fi access point the device is configured to use.
Request:
{"command":"ReadWifi"}
Response:
{"SSID":"XXXXXX","password":"XXXXXX","type":"WPA"}
This returns the SSID and password of the Wi-Fi access point the device is configured to use.
Request:
{"command":"ReadMetaData"}
Response:
{"fn_th":120,"fn_light":60,"fn_mag":86400,"fn_mag_int":2,"fn_acc_tap1":0,"fn_acc_tap2":0,"fn_acc_act":0,"fn_acc_min":90,"fn_bt":300,"fn_ext":600,"fn_battery":36 00,"fn_dp":600,"cg_data_led":1}
This returns the sensor data that is stored on the device. The WS1 can hold over 300,000 sensor readings.
Request:{"command":"ReadData"}
Response:
{"created_at":"2015-12-17T18:16:22Z","field1":0}……
Request:
{"command":"GetLastError"}
This returns the sensor data that is stored on the device. The WS1 can hold over 300,000 sensor readings.
Request:
{"command":"ScanWifiList"}
Response:
{"WiFi_List_Sum":%d }\n\r {"SSID":"%s","rssi":%d,"type":%d}\n\r
This command triggers the device to read all the sensors and return the results.
Request:
{"command":"CheckSensors"}
Response:
{"created_at":"2017-05-12T04:41:10Z","temp_val":32.132446,"humi_val":17,"light_val":767.359985,"power_vol_val":4.524133,"ssid":"m_work-GN","rssi":-37,"acce_xval":0,"acce_yval":0,"acce_zval":0,"mag_val":1,"ext_temp_val":65535}
The following commands are used to change the device settings. Please make sure you have backed up or synced all data before running these commands.
This command deletes the data stored internally on the device. It can take up to 30 seconds to run.
NB the data is deleted permanently.
Request:
{"command":"ClearData"}
This command is used to change the sensor metadata.
NB the new metadata sent with the request must be supplied in JSON format as show in the example.
Request:
{"command":"SetMetaData","metadata":"{\"fn_th\":60,\"fn_light\":60,\"fn_mag\":120,\"fn_mag_int\":2,\"fn_acc_tap1\":0,\"fn_acc_tap2\":0,\"fn_acc_act\":0,\"fn_acc_min\":5,\"fn_bt\":120,\"fn_ext_t\":1480041854,\"fn_battery\":120,\"fn_dp\":120,\"cg_data_led\":\"on\"}"}
Response (if successful):
{\"status\":0,\"code\": 0x00}
This command updates the Wi-Fi configuration of the device. It takes the following parameters:
SSID: SSID of the new Wi-Fi access point
Password: The password for the access point (plain text)
Type: WPA, WEP or OPEN
Backup IP: IP address to use if DNS isn’t working
Request:{"command":"SetupWifi","SSID":"XXXXX","password": "XXXXX","backup_ip":"101.201.30.5","type":"wpa"}
Response if successful:
{\"status\":0,\"code\": 0x00}
If you’re interested in configuring UbiBot devices to connect to your own private server or platform, please join the UbiBot Developer program. Membership includes the following benefits and resources: