# Chapter 1: Upload Data to ThingSpeak
ThingSpeak is IoT platform for user to gather real-time data; for instance, climate information, location data and other device data. In different channels in ThingSpeak, you can summarize information and visualize data online in charts and analyze useful information.
ThingSpeak can integrate IoT:bit (micro:bit) and other software/ hardware platforms. Through IoT:bit, you can upload sensors data to ThingSpeak (e.g. temperature, humidity, light intensity, noise, motion, raindrop, distance and other device information).

## Thingspeak Configuration
Go to [https://thingspeak.com/](https://thingspeak.com/), register an account and login to the platform

Step 2
Choose Channels -> My Channels -> New Channel

Step 3
Input Channel name, Field1 , then click “Save Channel”
* Channel name: smart-house * Field 1: Temperature 
Step 4
You will see a chat for data field1

Step 5
Open your web browser, go to https://thingspeak.com , select your channel > “API Keys” ,copy the API key as follows:

## Coding (Makecode)
Before we do the thingspeak uploading part, we already know how to connect to the WiFi on the first chapter.

Step 2
On every 15 seconds, if the WiFi is connected, it will send data to ThingSpeak.
* Use `if-statement` inside the `forever` loop to check `WiFi connected?` status
* Snap the `Send Thingspeak key.....` block inside the `if-statement`
* Fill in the `api key` from Thingspeak and the `temperature` values
* Snap `pause` to the loop to wait 15 second

Step 3
If you want to show the thingspeak status, you can use the on Thingspeak Uploaded handler to get the variable for status and error code. You may use the OLED to display the status and error code.
* Go to OLED Tab
* Snap `initialize OLED with width 128 height 64` to `on start`
* Snap the `show string` inside the `On Thingspeak Uploaded`
* Draw the variable from `On Thingspeak Uploaded` to the `show string` block placeholder.

Full Solution
MakeCode: [https://makecode.microbit.org/S50897-87530-58227-65452](https://makecode.microbit.org/S50897-87530-58227-65452)
You could also download the program from the following website:
## Result
When the Upload is finish, it will shown the status `OK` and Error Code `0`.
If the thingspeak cannot be uploaded successfully, the status will return `FAIL` with `error code`.
The charts in your channel in ThingSpeak will be updated.

After Connected to Internet, the program start upload the data to Thingspeak.

For the error 400, the user inputted the wrong API Key. For the error code -28674, there is no internet connection.
