Project tutorial
Arduino MKR1000 & Favoriot

Arduino MKR1000 & Favoriot © GPL3+

A simple IoT experiment, using an Arduino MKR1000 board to monitor a potentiometer and DHT11 sensor via Favoriot IoT platform.

  • 515 views
  • 0 comments
  • 3 respects

Components and supplies

Apps and online services

About this project

Favoriot offers a platform specifically designed for any Internet of Things (IoT) project. The platform is developed to support the integration of data from sensors and actuators on the internet. Collecting and storing data from IoT devices have become much easier. Moreover, the platform also helps developers in building vertical applications without worry about the hosting.

This article will present a step by step example of how to upload analog value of a potentiometer and DHT11 temperature/humidity sensor's value from an Arduino MKR1000 to the Favoriot IoT platform.

Watch the video below for a demo, and then follow these instructions to start building your project with Arduino MKR1000 and Favoriot.

Arduino MKR1000 & Favoriot

1. What You Need 🎁

To build this project, you will need the following items:

  • 1 Arduino MKR1000 board
  • 1 breadboard
  • 1 potentiometer
  • 1 DHT11 temperature and humidity sensor
  • Some jumper wires

2. Schematics πŸ”§πŸ”¨

Gather your parts then follow the schematics below.

3. Favoriot Setup πŸ’œ

  • Device Developer IDSignup & login to Favoriot. If you are registered in Favoriot, you have a default device already created for you. Go to right platform on https://platform.favoriot.com and see the device panel to see the devices that are present. Basically you need the device_developer_id that might be something like defaultDevice@myusername. But if you want, you can create a new device and use it in this example.
  • API KeyNow, go to your Favoriot Account Setting which is available on the top right corner in the dropdown and check your API key. You need this API key to complete this example. It's a big alphanumeric token like:
'986673a6377ef1fde2357ebdcb0da582lintang150b00cabcd5a0d83045425407ab4'

4. Arduino Sketch πŸ“‹

First you need to install Arduino MKR1000 platform on Arduino IDE, follow these instructions: click here. Install Adafruit DHT11 and WiFi101 library, then copy sketch below to your Arduino IDE. Make sure you have chosen the right option for Board and Port under Tools menu, then upload to your Arduino MKR1000 board.

5. Have Fun! 😎

Now you can monitor your potentiometer and DHT11 sensor every five seconds on Favoriot data stream menu, and create data visualization on graph section. For more information about Favoriot, read its full documentation here.

My other tutorials on Favoriot:

Lintang Wisesa πŸ’Œ lintangwisesa@ymail.co m

Facebook | Twitter | Google+ | Youtube | GitHub | Hackster

Code

Arduino MKR1000 & FavoriotC/C++
#define _DISABLE_TLS_
#include <SPI.h>
#include <WiFi101.h>
#include "DHT.h" 

#define DHTPIN 6
#define DHTTYPE DHT11
DHT dht(DHTPIN,DHTTYPE);

char ssid[] = "your_network_SSID";                        // change it!
char pass[] = "your_network_password";                    // change it!
const String yourDevice = "deviceDefault@your_Username";  // change it!
int status = WL_IDLE_STATUS;
char server[] = "api.favoriot.com";
WiFiClient client;

void setup() {
  Serial.begin(115200);
  WiFi.disconnect();
  Serial.println("Mulai menghubungkan");
  WiFi.begin(ssid,pass);
  while((!(WiFi.status() == WL_CONNECTED))){
    delay(300);
    Serial.print("...");
  }
  Serial.println(WiFi.status());
  Serial.println("Terhubung!");
  Serial.println("");
}

void loop() {
  String pot = String(map(analogRead(A0), 0, 1023, 0, 100));
  String temp = String(dht.readTemperature());
  String humid = String(dht.readHumidity());
  String json = "{\"device_developer_id\":\""+yourDevice+"\",\"data\":{\"Potentio\":\""+pot+"\",\"Temperature\":\""+temp+"\",\"Humidity\":\""+humid+"\"}}";
  Serial.println(json);
  if (client.connect(server, 80)) {
    
    client.println("POST /v1/streams HTTP/1.1");
    client.println("Host: api.favoriot.com");
    client.println(F("apikey: your_API_key"));          // change it!
    client.println("Content-Type: application/json");
    client.println("cache-control: no-cache");
    client.print("Content-Length: ");
    int thisLength = json.length();
    client.println(thisLength);
    client.println("Connection: close");

    client.println();
    client.println(json);
  }
  delay(5000);
}

Comments

Similar projects you might like

Arduino MKR1000 & Blynk

Project tutorial by Lintang Wisesa

  • 1,164 views
  • 0 comments
  • 3 respects

Arduino MKR1000 & Thinger

Project tutorial by Lintang Wisesa

  • 413 views
  • 0 comments
  • 3 respects

Home Automation with Arduino MKR1000 and Windows 10

Project tutorial by Ioannis Kydonis

  • 10,284 views
  • 1 comment
  • 33 respects

Send MKR1000 Data to Google Sheets

Project tutorial by Stephen Borsay

  • 14,001 views
  • 29 comments
  • 38 respects

MKR1000 Christmas IoTree with Cayenne Project Builder

Project tutorial by Benny Estes

  • 3,097 views
  • 3 comments
  • 9 respects

Water Quality Monitoring Using MKR1000 and ARTIK Cloud

Project tutorial by Team Animo!

  • 10,528 views
  • 13 comments
  • 35 respects
Add projectSign up / Login