FC41D is a standalone Wi-Fi 802.11b/g/n and Bluetooth 5.2 module with built-in resources for Wi-Fi and Bluetooth applications. It supports Wi-Fi AP and STA modes along with low-power Bluetooth.


This tutorial will show the steps and AT commands list needed to send data to Ubidots using FC41D Wi-Fi 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 AT+QVERSION command and verify the firmware version is successfully received as the response. e.g.:

AT+QVERSION
FC41D_VERSION:FC41DAAR03A03.bin_202202211819
OK

Requirements

Table of contents

  1. Setup Wi-Fi connection

  2. Setup HTTP(S) parameters

  3. Send data

1. Setup Wi-Fi connection

Before an HTTPS request can be done, the module must be connected to a Wi-Fi network. The following AT command achieves that and saves the credentials so the device connects automatically at start up.

AT+QSTAAPINFODEF=<ssid>,<password>

Replace <ssid> and <password> with corresponding values.

2. Setup HTTP(S) parameters

In order to keep your data safe and private, HTTPS will be used to send data to Ubidots and 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 on the device's volatile storage. This can be done at a device start-up.
First, download the root certificate and save it into a know location, then send the file with the AT command:

AT+QSSLCERT="CA",2,3139

After receiving CONNECT as a response, transfer the raw file. You should receive an OK if the transfer succeeds. Then, send the following AT commands to configure HTTPS connection to Ubidots server:

AT+QSSLCFG="version",0,3
AT+QSSLCFG="ciphersuite",0,0xFFFF
AT+QSSLCFG="verify",0,0
AT+QHTTPCFG="sslctxid",0

Remember to wait for the OK response after each command before sending the next.

3. Send data

Build the URL according to our data API. e.g:

https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/

Remember to replace <device_label accordingly, then setup the URL for the request with the following AT command:

AT+QHTTPCFG="url","https://industrial.api.ubidots.com/api/v1.6/devices/<device_label>/"

Add request headers replacing <Ubidots token> with your token:

AT+QHTTPCFG="header","Content-Type","application/json"
AT+QHTTPCFG="header","X-Auth-Token","<Ubidots token>"

Build the data to send and calculate its length, then make the request:

AT+QHTTPPOST=<data_length>,60,60

Wait for the CONNECT response and then send the request data. After receiving OK you can get the server response with:

AT+QHTTPREAD=60

Example:

AT+QHTTPPOST=12,60,60
CONNECT
{"my-var":1}
OK
+QHTTPPOST: 0,200
AT+QHTTPREAD=60
CONNECT
{"my-var":[{"status_code":201}]}
OK
+QHTTPREAD: 0

Other users also looked at:

Did this answer your question?