Thingspeak connection with Miicroblocks

databot, ThingSpeak, and MicroBlocks


We continue to connect databot to IOT services. Today we will connect to the well-known Thingspeak platform. This service allows you to collect information from a databot and publish it to the Thingspeak cloud service.  From there it can be seen from anywhere on Earth if you have an Internet connection. IOT projects like this can be very useful for monitoring all kinds of things including environmental conditions, especially if you have the suite of environmental sensors built in to databot.

How Does It work?

databot sensors collect information and connect to the Thingspeak site via wi-fi and send the data to the Thingspeak server in the cloud. The data from databot is displayed on the Thingspeak platform in graphs as shown below.

Data in the system can be displayed in real time and can be set to private or public access. Users have the ability to share information with others through this method. You can display up to eight graphs on the screen simultaneously and remote users can easily download the data sets for closer analysis.

Thingspeak provides a great free option for individual use, the project shown here is using the free version. It has some limitations with respect to the amount of data you can share and how quickly things can update. However, for advanced features a paid version with additional capabilities is available.

Thingspeak architecture diagram

In the free version, the number of queries is limited to eight thousand per day, with a mandatory interval of 15 seconds between queries. This is more than sufficient for our demonstration environmental monitoring project.

Example of a graph

Getting Started

The materials for this project are simple, all you will need is a computer with the Arduino IDE for coding databot, an Internet connected browser, a databot, and of course you will set up a free account with Thingspeak.

1. Go to  This is the service that allows you to turn your databot into an IoT device.
2. In the upper right corner select the icon with the image of a person.
3. In the opened window select “No account? Create one!”
4. You just need to fill in your data and click the “Continue” button.
5. A confirmation e-mail will be sent to your e-mail. Check it and confirm.

That’s it, you are set up and ready to begin.

screen capture of the User Interface for setting up a free Thingspeak account.
Create a channel on Thingspeak

After registration create your own channel where data from databot will be published.

In the main menu: select:

  1. Channels
  2. MyChannels
  3. New Channels

Now you can fill in your channel information.

  • Channel Name: Enter a unique name for the ThingSpeak channel.

  • Description: Enter a description of the ThingSpeak channel.

  • Field#: Check the box to enable the field, and enter a field name. Each ThingSpeak channel can have up to 8 fields.

  • Metadata: Enter information about channel data, including JSON, XML, or CSV data.

  • Tags: Enter keywords that identify the channel. Separate tags with commas.

  • Link to External Site: If you have a website that contains information about your ThingSpeak channel, specify the URL.

  • Show Channel Location:

    • Latitude: Specify the latitude position in decimal degrees. For example, the latitude of the city of London is 51.5072.

    • Longitude: Specify the longitude position in decimal degrees. For example, the longitude of the city of London is -0.1275.

    • Elevation: Specify the elevation position meters. For example, the elevation of the city of London is 35.052.

  • Video URL: If you have a YouTube™ or Vimeo® video that displays your channel information, specify the full path of the video URL.

  • Link to GitHub: If you store your ThingSpeak code on GitHub®, specify the GitHub repository URL.

Don’t forget to click “Save Channel” at the bottom to create it.

Creating a new channel

Now the new channel will be visible in the list of channels.
In this example we will create a project where we will check the local environment for six sensor values shown to the right and display them on a Thingspeak dashboard in the cloud.  This will enable us to see the data from anywhere on Earth that has an Internet connection!

  • CO2
  • VOC
  • Ambient Light
  • Humidity
  • Temperature
  • Air Pressure
My channel

Before we move on to writing the databot program, we need to take the API Key data from the Thingspeak website.
It is this key that will tell Thingspeak that we are transmitting data to our channel.
To find the key we need to select: our channel, go to the API Key tab and copy the key.

How connect to Microblock

MicroBlocks is a drag and drop coding environment optimized for physical computing with microcontrollers. It makes working with databot sensors, lights, sound, and networking capabilities a snap!
If you have not worked in it before – you can follow this link and learn how to connect and use this environment to develop your projects.

How to work with microblock

Here we will step-by-step divide each line of code that will need to be loaded to the microcontroller for proper operation.

Thingspeak connection with Miicroblocks
  1. – First of all, we need to get the API Key from the Thingspeak website. This key is needed to connect the databot to your channel. Write it in the “Set API Key to” block and specify the key number.
  2.  You need to enter your wifi network name and password to allow you to connect to the internet.
  3. The most important block is the block with the POST Request. It is during this request that we transmit all important information to the site. Your task is only to choose which graph to send the information to (in my example the information will be sent to the 5th field) and you can choose which sensor to send the information from (in my example the temperature sensor).
Post website request

4- Free version allows to send requests not more than once in 15 seconds, so we put a waiting block.

The code is ready, the only thing left is to upload it to the databot and turn it into a smart IOT device

Download sample code

We have also prepared a complete working code of the air analyzer on microblock. You only need to enter api key and information of your wifi network.

Download the code of the air analyzer

We also have many other projects on our site. Come, look and realize