All Collections
Connect your Devices
Connect Quectel FC41D Module to Ubidots
Connect Quectel FC41D Module to Ubidots

Learn how to send data from your FC41D WI-Fi-Bluetooth devices to Ubidots.

David Sepúlveda avatar
Written by David Sepúlveda
Updated over a week ago

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: This guide uses a FC41D based evaluation board, however, this configuration steps work also on the standalone chip, you only need to take care of connecting everything properly.

Requirements

  • An active Ubidots account.

  • A FC41D based device.

  • WI-Fi with internet access as well as its credentials (network SSID and Password).

  • Understanding how to send data through our HTTP(S) data API.

  • Any serial terminal. This guide used Arduino's serial terminal utility, however, you can choose any that you feel comfortable with.

Table of contents

1. Setup Serial Connection

Start by connecting the evaluation board to the PC using a USB cable. This will allow serial communication with the module, then, open your terminal serial utility. In case you are using Arduino's serial terminal, start by selecting the serial device to which you are going to communicate: head over to "Tools" ---> "Port" and select your device.

It should be labeled something like "/dev/ttyUSB0" if you are using Linux.

After selecting the serial port that you are going to use, proceed to open the "Serial Monitor" from "Tools". Everything that was said here is depicted in the following image:

After clicking on "Serial Monitor" the following GUI will be displayed, there be sure to set the baud rate at 115200 as well as setting the "Both NL & CR" option from the bottom of the window as depicted below:

Now you should check if there is communication between the PC and the FC41D module. To do so, type in the text field the following command and hit the "Send" button:

AT+QVERSION

Then the device shall respond with something like:

FC41D_VERSION:FC41DAAR03A03.bin_202202211819
OK

Now that the communication with the FC41D module is established, let's configure the WI-Fi settings for sending data.

2. 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 the next start up.

AT+QSTAAPINFODEF=ssid,password

Just as you did in the previous section, send the command above by typing it into the text field and then hit the "Send" button. Also, replace ssid and password with your network credentials. After doing so, the device shall respond an "OK" message.

3. 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.

Send the following command in order to put the device in a mode for loading Ubidots root PEM certificate to its storage media:

AT+QSSLCERT="CA",2,3139

The device will respond a "CONNECT" message, wait for it and then copy and paste the following text as if it were any of the commands that you have sent before:

-----BEGIN CERTIFICATE----- MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4 WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn OlFuhjuefXK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8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ -----END CERTIFICATE-----

The following two images depict the process:

If the transfer succeeded you should get a response like:

OK

Then, send the following AT commands to configure HTTPS connection to Ubidots server, taking into account that after sending each single command, you should wait for its "OK" response before sending the next one:

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

4. Send data

Suppose that you have a FC41D based temperature sensor for which you want to ingest data, then according to our API docs, you can do it by making an HTTP(S) request as follows:

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

Being aware to change "<device_label>" for your device's label. Take into account that if there is no device with the provided label, Ubidots will create one for you with that label.

Let's send data to a device labeled "fc41d-temperature-sensor", type the following command alongside with the URL according to our API, this will setup the URL for sending future request:

AT+QHTTPCFG="url","https://industrial.api.ubidots.com/api/v1.6/devices/fc41d-temperature-sensor/"

Add request headers by sending the following AT commands, replacing <Ubidots token> with your token.

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

Take a look this link if you forgot where to find your Token.

According to Ubidots JSON compatible format , in order to send data to a variable named "temperature", the JSON body must to be as follows:

{"temperature":198}

In order to send this message through the correspoding AT command, the message's length needs to be established, so you should always count the number of characters that you want to send. In the above case, the message's length is 19 characters long.

In order to start data transmission, send the following AT command, replacing <data_length> with the message's length that you want to send.

AT+QHTTPPOST=<data_length>,60,60

Since in this guide's example, the string {"temperature":198} was used, then <data_length> is replaced by 19.

After sending the above command, wait for the CONNECT response and then send the request data as a raw message just like you did when sending the root PEM certificate.

After receiving OK you can read the server response with:

AT+QHTTPREAD=60

Example:

AT+QHTTPPOST=19,60,60
CONNECT
{"temperature":198}
OK
+QHTTPPOST: 0,200
AT+QHTTPREAD=60
CONNECT
{"temperature":[{"status_code":201}]}
OK
+QHTTPREAD: 0

Other users also looked at:

Did this answer your question?