Things used in this project

Hardware components:
D1 mini
Everything ESP Wemos D1 Mini
×1
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Ide web
Arduino Arduino IDE
dweet.io
freeboard.io

Code

dweet that thangArduino
:) main code for dweeting , still in construction but working flawless
//coded for my wemos esp8266 pro mini, dweet.io posting
//Javier Muñoz Sáez 05/07/2017, javimusama@gmail.com
//////////////////wifi dweeting.io
// Import required libraries
#include "ESP8266WiFi.h"

// WiFi parameters
                    const char* ssid = "your wifi ssid";
                    const char* password = "password";
                    
  String thingName="TYPICALSENSORTHING"; 

const char* host = "dweet.io";


  String arrayVariableNames[]={"UNO","DOS","TRES","CUATRO","CINCO","SEIS","SIETE","OCHO"};//THIS WAY WE REFER TO EACH VARIABLE AS AN INDEX IN THIS GLOBAL ARRAY. arrayVariableNames[0]="UNO"
  int   arrayVariableValues[]={1,2,3,4,5,6,7,8};  
int numberVariables=sizeof(arrayVariableValues)/sizeof(arrayVariableValues[0]);//tells the number of arguments inside each array
//////////////////////////////

void setup() {
  Serial.begin(9600);
///////////wifi things
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  //initialice and connect to wifi lan
  WiFi.begin(ssid, password);  
  int retries = 0;
  while ((WiFi.status() != WL_CONNECTED) && (retries < 15)) {
    retries++;
    delay(500);
    Serial.print(".");
  }
  if(retries>14){
        Serial.println(F("WiFi conection FAILED"));
  }
  if (WiFi.status() == WL_CONNECTED) {
  Serial.println(F("WiFi connected"));
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println(F("======================================================")); 
  }
  
   Serial.println(F("Setup ready")); 


}

void loop() { 

arrayVariableValues[0]=25;//this is how you change values of the variables
arrayVariableValues[1]=42;
arrayVariableValues[2]=9;

arrayVariableNames[0]="veinticinco";//this is how you change the name of the variable( veinticinco=25)
dweetdata();//upload it
}

void dweetdata(){//connects TCP,sends dweet,drops connection, prints the server response on the console 
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }

    client.print(GetDweetStringHttpBuilder());

  delay(10);//slow doown ...stability stuff
  
  // Read all the lines of the reply from dweet server and print them to Serial
  while(client.available()){
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }
  //just display ending conection on the serial port
  Serial.println();
  Serial.println("closing connection");
   
}

String GetDweetStringHttpBuilder() {
  int i=0;
  int numberVariables=sizeof(arrayVariableValues)/sizeof(arrayVariableValues[0]);//tells the number of arguments inside each array
  String dweetHttpGet="GET /dweet/for/";//initial empty get request
  dweetHttpGet=dweetHttpGet+String(thingName)+"?";//start concatenating the thing name (dweet.io)
  
  for(i=0;i<(numberVariables);i++){//concatenate all the variable names and values
   if(i==numberVariables-1){
    dweetHttpGet=dweetHttpGet + String(arrayVariableNames[i]) + "="+ String( arrayVariableValues[i]);//the lastone doesnt have a "&" at the end

   }
   else
    dweetHttpGet=dweetHttpGet + String(arrayVariableNames[i]) + "="+ String( arrayVariableValues[i]) + "&";  
  }
 dweetHttpGet=dweetHttpGet+" HTTP/1.1\r\n"+
                  "Host: " + 
                    host + 
                  "\r\n" + 
                  "Connection: close\r\n\r\n";
                  
  return dweetHttpGet;//this is our freshly made http string request
}

Credits

Ltcqjr9usazbcjumiyay
javier muñoz sáez

Electronic engineer, musician and mad scientist

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

AWS IoT Environment for Home Assistant
Intermediate
  • 903
  • 8

Work in progress

Home Assistant is an automation platform that can track and control all kinds of devices and automate actions, which fits well with AWS IoT.

Home Automation Using IoT
Intermediate
  • 117
  • 2

Work in progress

Connecting home appliances to the internet and controlling them from anywhere in the world.

Doorbell (Working Captive Portal Use Case)
Intermediate
  • 50
  • 0

Wi-Fi Example of dynamical switching between SoftAp & STA: makes a wireless Arduino device configurable via a web page (SoftAP mode).

Autonomous Plant (ESP8266 - Arduino)
Intermediate
  • 538
  • 4

Full instructions

Want to build system that takes care of a plant? Here's my first attempt. Using ESP8266, soil moisture and Sonoff grow light

Add Email Notifications to Any Robotic Vacuum Cleaning Robot
Intermediate
  • 56
  • 0

Full instructions

Dear friends, welcome to another tutorial! This is Nick and today we are going modify this Roomba robotic vacuum cleaner.

Smart Health Kit
Intermediate
  • 413
  • 2

Creating E-health care system that allows easier, better, and faster communications between patients, doctors, and hospitals.

Smart Health Kit

Team Akatsuki

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login