[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


How to connect Arduino Uno WiFi to ThingSpeak

Published on
11,917 Points
8 Endorsements
Last Modified:
Shaun Vermaak
My name is Shaun Vermaak and I have always been fascinated with technology and how we use it to enhance our lives and business.
I took on this little project as a proof of concept for IoT devices. My main goals were to find the easiest, cheapest way to stream data to the cloud. This article describes how to stream telemetry data to ThingSpeak via REST API. This can also be done with Azure IoT hub with a local gateway.

1) What you need

DHT22 - Temperature/Humidity Sensor

MH-RD - Snow/Raindrop Detection Sensor

YL-69 - Soil Moisture Sensor

Arduino UNO WiFi connected to WiFI with internet access 

Resistor 10k Ohm

Battery Pack

ThingSpeak Account with a channel configured

Arduino IDE

Any waterproof enclosure big enough to fit components

2) Fritzing Diagram

3) Sketch

a) After connecting all the sensors and cables as per the diagram above, open the Arduino IDE and copy and paste this into a new sketch.

#include <Wire.h>
#include <DHT.h>
#include <UnoWiFiDevEd.h>

#define CONNECTOR     "rest"
#define SERVER_ADDR   "api.thingspeak.com"
#define APIKEY_THINGSPEAK  "****************" //Insert your API Key

void setup() {

void loop() {
  DHT dht;

  String uri = "/update?api_key=";
  uri += "&field1=";
  uri += String(dht.getHumidity());
  uri += "&field2=";
  uri += String(dht.getTemperature());
  uri += "&field3=";
  uri += String(analogRead(A0));
  uri += "&field4=";
  uri += String(analogRead(A1));

  Ciao.println("Sending data on ThingSpeak Channel");
  CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

  if (!data.isEmpty()){
    Ciao.println( "State: " + String (data.get(1)) );
    Ciao.println( "Response: " + String (data.get(2)) );
    Ciao.println("Write Error");

b) Change the ThingSpeak API to you channel API

c) Plug in Arduino Uno and hit CTRL+U to upload sketch to device

4) End Result

As data is streamed to ThingSpeak the online dashboard will populate these values to the graphs, here's mine http://thingspeak.com/channels/265283

Screenshot of ThingSpeak dashboard

Enclosure and soil moisture sensor

Closeup of enclosure

Closeup of soil moisture sensor

Please do not forget to press the "Thumb's Up" button if this article was helpful and valuable for EE members.
It also provides me with positive feedback. Thank you!

1 Comment

Expert Comment

by:Fahad Syed Karim
Hey man, I'm working with an Arduino UNO WiFi board, and am getting errors such as "ciao was not declared in this scope". Could you shed some light on this, and also how to set up the framework for basic ThingSpeak connectivity with the UNO WiFi?

Featured Post

Challenges in Government Cyber Security

Has cyber security been a challenge in your government organization? Are you looking to improve your government's network security? Learn more about how to improve your government organization's security by viewing our on-demand webinar!

Join & Write a Comment

Wrapper-1-Query. Use an Excel function to calculate a column for an Access query. Part 1. Shows a query in Access that has a calculated column with the results of an Excel worksheet function. See how to call a wrapper function from a query, and …
Watch this simple and effective video tutorial to extract attachments from Outlook 2007 and try this easy method by yourself. No need to go anywhere, just watch the video and export attachments from Outlook in few simple steps. To know more, click h…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month