How to Send tweets from Arduino MKR1000: Arduino tutorial

This Arduino tutorial describes how to send tweets from Arduino MKR1000. This is an interesting Internet of things project where there is MKR1000 that uses cloud services to send tweets. As a cloud platform, this Arduino tutorial uses Temboo that provides a set of interesting services.

Send Tweets from Arduino MRK1000: Arduino tutorial Project Overview

Before digging into the Arduino tutorial project details and how to invoke a cloud service from Arduino MKR1000, it is useful to have a project overview :
in this project Arduino MKR1000 is connected to two different sensors:

  • DHT11 to measure the temperature and humidity
  • BMP180 to measure the pressure

The figure below shows the schematics describing the connections between MKR1000 and the two sensors. The image below shows the dev boards with the connections.
Arduino tutorial

Moreover, this project uses Temboo IoT platform and Twitter so if you want to test it you have to create two free accounts.

send tweets from arduino mkr1000

Arduino/Genuino MKR1000

As you may already know Arduino/Genuino MKR1000 is the last dev board specifically made for IoT projects. It is designed to offer a practical solution for makers that want to build IoT projects. This dev board has WIFI built-in. Arduino/Genuino MKR1000 uses Atmel ATSAMW25 SoC. This SoC is specifically designed for IoT projects. The main features of this SoC are:

  • 32-bit
  • 48 MHz
  • ARM core
  • 3.3 V

It is important to note that this dev board uses 3.3V instead of 5V as Arduino Uno. It is important to remember it because the I/O pin voltage must be lower than 3.3V otherwise there is the risk to damage it. MKR1000 has a built-in WIFI module so it is very simple to connect it to the network without using shield.

Read Temperature Humidity Pressure using MKR1000

You should already know how to read temperature and humidity using MKR1000. Otherwise, remember to import DHT11 library to simplify the work. To read temperature, humidity and pressure the sketch uses this piece of code:

#include "DHT.h"
#include <Adafruit_BMP085.h>

#define DHTPIN 2
#define DHTTYPE DHT11

Adafruit_BMP085 bmp;
void setup() {

void loop() {

   float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  float presPa = bmp.readPressure();
  float presMb = presPa * 1013.25 / 101325;

In this sketch, the DHT11 sensor is connected to the PIN 2, while BMP180 has 4 connection: GROUND, VCC(3.3V), SDA and CLOCK. The connection with MKR1000 is easy.

Create Twitter app

To send tweets from Arduino MKR1000, it is fundamental to create a twitter app. To create an app, it is just necessary to provide a few information. This information are useful to get the keys to authenticate our Arduino MKR1000.

The first step is creating the twitter app:
twitter create app

the next step is creating the keys to use later in Temboo:

twitter access token

twitter token

Ok..remember the code above because you have to use it in your Temboo configuration.

Tweets from Arduino MKR1000: Sketch

Now it is time to go to the Arduino code and implement send tweets from Arduino MKR1000. As a first step, it is necessary to provide information to Temboo choreo. This process is simple you have just to copy and paste the values

configure tempo and MKR1000

To establish a WIFI connection is very simple:

#include <SPI.h>
#include <WiFi101.h>
char ssid[] = "xxxxx";     //  your network SSID (name)
char pass[] = "pppp";  // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

WiFiClient client;

void setup() {
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:

This code is the same used in the Arduino MKR1000 examples. Now everything is ready to import the choreo code:

void loop() {
   String msgText = "Temp is" + String(t,2) + "C and humidity " + String(h,2) + " Press is " +     String(presMb,2) + ". Have fun!";

   Serial.println("Msg ["+msgText+"]");
   TembooChoreo SendDirectMessageChoreo(client);

    // Invoke the Temboo client

    // Set Temboo account credentials

    // Set Choreo inputs
    String AccessTokenValue = "......";
    SendDirectMessageChoreo.addInput("AccessToken", AccessTokenValue);
    String ConsumerKeyValue = ".......";
    SendDirectMessageChoreo.addInput("ConsumerKey", ConsumerKeyValue);
    String ConsumerSecretValue = "......";
    SendDirectMessageChoreo.addInput("ConsumerSecret", ConsumerSecretValue);
    String ScreenNameValue = "survivingwithan";
    SendDirectMessageChoreo.addInput("ScreenName", ScreenNameValue);
    String TextValue = "test";
    SendDirectMessageChoreo.addInput("Text", msgText);
    String AccessTokenSecretValue = "....";
    SendDirectMessageChoreo.addInput("AccessTokenSecret", AccessTokenSecretValue);

    // Identify the Choreo to run

    // Run the Choreo; when results are available, print them to serial;

    while(SendDirectMessageChoreo.available()) {
      char c =;


Running the sketch on Arduino MKR1000 the result is shown below:
mrk1000 tweet message


tweet from mkr1000

At the end of this Arduino tutorial, hopefully, you know how to send tweets from Arduino MKR1000 and how to invoke a remote service from Arduino. There are other applications of this project, like sending alarms or other kinds of information.