Giter VIP home page Giter VIP logo

esp8266_favoriot's Introduction

favoriot

ESP8266 & Favoriot

Favoriot offers an IOT platform specifically designed for any Internet of Things (IoT) projects. The platform is developed to support the integration of data from sensors and actuators on the internet. Collecting and storing data from IOT devices 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 how to upload analog value of a potentiometer from ESP8266 NodeMCU to Favoriot IoT platform. Watch video below (or click here) for its demonstration, then follow these instructions to start building your project with ESP8266 & Favoriot.

Video ESP8266 & Favoriot

1. What You Need ๐ŸŽ

To build this project, you need the following items:

  • 1 ESP8266 board (I'm using NodeMCU)
  • 1 breadboard
  • 1 potentiometer
  • some jumper wires
  • Arduino IDE (download here)

2. Schematics ๐Ÿ”ง๐Ÿ”จ

Gather your parts then follow the schematics below.

ESP8266 Favoriot

3. Favoriot Setup ๐Ÿ’œ

  • Device Developer ID

    Signup & 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 Key

    Now, 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 ESP8266 platform on Arduino IDE, follow these instructions: click here. 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 board.

#include <SPI.h>
#include <ESP8266WiFi.h>

char ssid[] = "your_network_SSID";      // change it!
char pass[] = "your_network_PASSWORD";  // change it!
const String myDevice = "myDeviceDefault@your_Username"; // change it!
char server[] = "api.favoriot.com";

int status = WL_IDLE_STATUS;
WiFiClient client;

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

void loop() {
  String myData = String(analogRead(A0));
  String json = "{\"myDevice_developer_id\":\""+myDevice+"\",\"data\":{\"My Data\":\""+myData+"\"}}";
  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);
  }
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }
  if (!client.connected()) {
    client.stop();
  }
  delay(5000);
}

To upload multiple values, use this:

String json = "{\"device_developer_id\":\"deviceDefault@User\",
\"data\":{ \"Sensor_1\":\""+sensor1+"\",
           \"Sensor_2\":\""+sensor2+"\",
           \"Sensor_3\":\""+sensor3+"\" }
}";

5. Have Fun! ๐Ÿ˜‚

Now you can monitor your potentiometer value every 5 seconds on Favoriot dashboard. For more information about Favoriot, read its full documentation: click here.

My other tutorials on Favoriot:

Lintang Wisesa ๐Ÿ’Œ [email protected]

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

esp8266_favoriot's People

Contributors

lintangwisesa avatar

Watchers

James Cloos avatar Hariyawan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.