TANK TANK

Showing posts with label Arduino UNO ESP8266 interfacing. Show all posts
Showing posts with label Arduino UNO ESP8266 interfacing. Show all posts

Saturday, June 23, 2018

Connecting Arduino UNO with ESP8266 and to ThingSpeak

Today I found a great article about how to configure ESP8266 to connect to Arduino UNO in super simple steps and then connect them all to ThingSpeak website.



This article is a real treasure to anyone who wants to get started with ESP8266 and doesn't know where to start from.

What I liked the most about this article and what makes it so special

  1.  The author also clarifies the difference between ESP32 as the newer ESP module and the ESP8266 WIFI Module with basic function.
  2. Another thing I liked about the article is a new trial the author has made and succeeded in doing it. This trial is by accessing ESP8266 WiFi Module directly but using Arduino UNO as a bridge. I've seen many other programmers and makers who used USB-to-TTL converters and made the task of configuring the module seem so hard. But this author has clarified the steps making it so simple and straightforward.
  3. Another useful thing I've learned from this article is ThingSpeak. The IoT website that you can use to connect your application and then analyze your data using Matlab tools and all for free.
Signup tsp ml image
So let's get started.

Testing the ESP8266 Directly

Connection
Esp8266 | Arduino 
-----------------
     RX | RX 
     TX | TX 
    GND | GND
    VCC | 5v 
  CH_PD | 5v 
 GPIO 0 | None 
 GPIO 2 | None
Arduino | Arduino
-----------------
  Reset | GND




 

Accessing ESP8266 from Arduino Uno code

Esp8266 | Arduino 
 — — — — — — — — -
     RX | 11 
     TX | 10 
    GND | GND (same)
    VCC | 5v (same) 
  CH_PD | 5v (same) 
 GPIO 0 | None (same) 
 GPIO 2 | None (same)



Code

#include <SoftwareSerial.h>
#define RX 10
#define TX 11
String AP = "WIFI_NAME";       // CHANGE ME
String PASS = "WIFI_PASSWORD"; // CHANGE ME
String API = "YOUR_API_KEY";   // CHANGE ME
String HOST = "api.thingspeak.com";
String PORT = "80";
String field = "field1";
int countTrueCommand;
int countTimeCommand; 
boolean found = false; 
int valSensor = 1;
SoftwareSerial esp8266(RX,TX); 
 
  
void setup() {
  Serial.begin(9600);
  esp8266.begin(115200);
  sendCommand("AT",5,"OK");
  sendCommand("AT+CWMODE=1",5,"OK");
  sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}
void loop() {
 valSensor = getSensorData();
 String getData = "GET /update?api_key="+ API +"&"+ field +"="+String(valSensor);
sendCommand("AT+CIPMUX=1",5,"OK");
 sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
 sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
 esp8266.println(getData);delay(1500);countTrueCommand++;
 sendCommand("AT+CIPCLOSE=0",5,"OK");
}
int getSensorData(){
  return random(1000); // Replace with 
}
void sendCommand(String command, int maxTime, char readReplay[]) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => ");
  Serial.print(command);
  Serial.print(" ");
  while(countTimeCommand < (maxTime*1))
  {
    esp8266.println(command);//at+cipsend
    if(esp8266.find(readReplay))//ok
    {
      found = true;
      break;
    }
  
    countTimeCommand++;
  }
  
  if(found == true)
  {
    Serial.println("OYI");
    countTrueCommand++;
    countTimeCommand = 0;
  }
  
  if(found == false)
  {
    Serial.println("Fail");
    countTrueCommand = 0;
    countTimeCommand = 0;
  }
  
  found = false;
 }


Source : Medium

Wednesday, April 18, 2018

How to easily Firmware Update the AI Thinker ESP8266

This is not just another post of how to connect Arduino UNO to ESP8266 board.


Image result for ai thinker esp8266


Yes there is how to connect it and how to configure it in details. Also, in this post you can find the detailed steps of how to firmware update of the ESP8266 board.



This firmware update is essential for some boards to have the function of AT commands.



Why

ESP8266 is a smart solution for many IoT projects indeed. It's so cheap and powerful that you can start prototyping and making your own products quickly.

ESP8266 is based on the ARM processor and Arduino compatible. It also has its own Wifi transceiver.

So you can use it as a stand alone Arduino board with Wifi capability and you can also use it as an Arduino Wifi Shield.

The problem is when you get the AI-Cloud inside version of ESP8266 you need to Firmware Update it before using the AT commands.

This means that you can use it only as a standalone Arduino board before the update.

But to be able to use it as an Arduino Wifi Shield with AT command you have to update the firmware.

Got it ?








Components


Arduino
ESP8266



How







Connections



ESP8266 -- Arduino
VCC 3.3V
CH_PD 3.3V
GPIO2 3.3V
GND GND
GPIO0 GND
TX TX
RX RX






Circuit

Source: Arduino Website
























Tuesday, April 17, 2018

How to configure ESP8266 with Arduino - Arduino WiFi Shield

Yesterday we knew how to add the ESP8266 board to Arduino IDE.




Today, we are examining how to configure it using Arduino UNO board.

ESP8266 is low cost Arduino compatible development board. It can act as a standalone board that runs Arduino code just as any Arduino compatible board.

It can also be thought of as an Arduino Wi-Fi shield. In this concept, you can configure it and then use it as Wi-Fi shield that serially connects to Arduino.

In the previous post, we learned how to configure connect and program the ESP8266 using USB to TTL converter that has 3.3v selector switch (FOCA).

We can also configure the ESP8266 using Arduino UNO board as we’ll see in this post.

Components 

Arduino UNO
ESP8266

Connection




Code


You can find a list of AT commands used to configure ESP8266 here.















Source: Arduino Website






















Sunday, April 15, 2018

Arduino UNO ESP8266 interfacing - How to connect Arduino UNO to ESP8266

ESP8266 is a popular board developed and introduced in 2014. It’s an Arduino compatible board that has WiFi connectivity.

In this post we’ll learn how to connect Arduino UNO to ESP8266.

First, we’ll learn how to configure and upload code into ESP8266.

Then, we connect it to Arduino UNO to act like a serial WiFi shield.

Components


Arduino UNO

ESP8266

Logic Level Converter Circuit



Connection 







Circuit

Code

https://github.com/Circuito-io/ESP8266_SoftwareSerial/commit/f5591181490751700dc01c32155d7543d0c04f49










Source: Arduino Website