The BG95 belongs to a series of LTE Cat M1/Cat NB2/EGPRS modules and the BG96 is an LTE Cat M1/Cat NB1/EGPRS module, both of which support a wide set of internet protocols and industry-standard interfaces like USB/UART/I2C that make them suitable for a large number of IoT applications.
In this tutorial, we will show the steps and AT commands list needed to send data to Ubidots using BG95/BG96 modules.
Note: Before starting, make sure you can send AT commands to the device and receive the response. To make a simple test, try sending the ATI command and verify the product information is successfully received as the response. e.g.:
An active Ubidots account.
A BG95/BG96-based device.
APN configuration information from your mobile network provider.
Understanding how to send data through our HTTP(S) data API.
Table of contents
1. Save the certificate
In order to keep your data safe and private, HTTPS will be used to send data to Ubidots, and to be a little bit safer, the device will verify that in effect it is connecting to Ubidots. To achieve that, the Ubidots root PEM certificate will be saved in the device's non-volatile storage. This is a one-time step and can be done at the production stage.
First, download the root certificate and save it into a know location, then send the file with the AT command:
CONNECT as a response, transfer the raw file. You should receive an
OK if the transfer succeeds.
2. Setup mobile connection
Before an HTTPS request can be done, mobile data connection must be set up. For this, APN configuration information from your mobile network provider is needed. You must provide the following:
Access point name (APN)
Username if required
Password if required
3: PAP or CHAP
With the information above, build the following AT command replacing the corresponding values:
authentication use the corresponding number listed above. If
password is not required, leave its corresponding field empty. e.g.:
Wait for the
OK response, then activate the connection by sending:
This may take a while and if successful,
OK is received as a response. After that, you can check the IP address with the AT command:
3. Setup HTTP(S) parameters
Send the following AT commands to configure HTTP(S) connection to Ubidots server:
Remember to wait for the
OK response after each command before sending the next.
4. Send data
Build the URL according to our data API. e.g:
Remember to replace
<device_label accordingly and get the final URL length.
Setup the URL for the request with the following AT command:
CONNECT response send the URL, then wait for
OK to be received.
Build the HTTP(S) request data as follows:
POST /api/v1.6/devices/<device_label>/ HTTP/1.1
Replace the fields marked with
<> accordingly and get the final length of the request data. Take into account that line endings for an HTTP(S) request are CRLF.
Send request data:
Wait for the
CONNECT response and then send the request data. After receiving
OK you can get the server response with:
POST /api/v1.6/devices/bg96/ HTTP/1.1
5. Feedback and suggestions
Feel free to post questions or suggestions in our community portal, or drop us a line at firstname.lastname@example.org.