0

I am trying to set up my Arduino Uno to receive information from the internet, but I am having a very hard time finding proper guides online. I am using an Arduino Uno and ESP8266-01. I am trying to use the "WebClientRepeating" example from this library: https://github.com/bportaluri/WiFiEsp

Here is the code I am running (updated the SSID and password):

/*
 WiFiEsp example: WebClientRepeating

 This sketch connects to a web server and makes an HTTP request
 using an Arduino ESP8266 module.
 It repeats the HTTP call each 10 seconds.

 For more details see: http://yaab-arduino.blogspot.com/p/wifiesp.html
*/

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6,7); // RX, TX
#endif

char ssid[] = "MY-SSID";            // your network SSID (name)
char pass[] = "MY-PASSWORD";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "arduino.cc";

unsigned long lastConnectionTime = 0;         // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10000L; // delay between updates, in milliseconds

// Initialize the Ethernet client object
WiFiEspClient client;

void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // 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: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");

  printWifiStatus();
}

void loop()
{
  // if there's incoming data from the net connection send it out the serial port
  // this is for debugging purposes only
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if 10 seconds have passed since your last connection,
  // then connect again and send data
  if (millis() - lastConnectionTime > postingInterval) {
    httpRequest();
  }
}

// this method makes a HTTP connection to the server
void httpRequest()
{
  Serial.println();

  // close any connection before send a new request
  // this will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection
  if (client.connect(server, 80)) {
    Serial.println("Connecting...");

    // send the HTTP PUT request
    client.println(F("GET /asciilogo.txt HTTP/1.1"));
    client.println(F("Host: arduino.cc"));
    client.println("Connection: close");
    client.println();

    // note the time that the connection was made
    lastConnectionTime = millis();
  }
  else {
    // if you couldn't make a connection
    Serial.println("Connection failed");
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

My wiring is as follows:

  • ESP8266 RX - Uno Pin 7
  • ESP8266 TX - Uno Pin 6
  • ESP8266 VCC - 3.3V power source (not from Uno)
  • ESP8266 GND - Uno GND
  • ESP8266 CH_PD - 3.3V power source (not from Uno)

I also connected the GND of the 3.3V power source to the other GNDs.

When I go to run the WebClientRepeating example, my Serial output says:

11:05:04.764 -> [WiFiEsp] Initializing ESP module
11:05:05.760 -> [WiFiEsp] >>> TIMEOUT >>>
11:05:07.785 -> [WiFiEsp] >>> TIMEOUT >>>
11:05:09.758 -> [WiFiEsp] >>> TIMEOUT >>>
11:05:11.780 -> [WiFiEsp] >>> TIMEOUT >>>
11:05:13.803 -> [WiFiEsp] >>> TIMEOUT >>>
11:05:14.794 -> [WiFiEsp] Cannot initialize ESP module
11:05:20.794 -> [WiFiEsp] >>> TIMEOUT >>>
11:05:20.794 -> [WiFiEsp] No tag found
11:05:20.830 -> WiFi shield not present

The tutorial specifies that it uses a "ESP WiFi shield" but I am using a ESP8266 card only - could that be part of the problem? If that is a problem, are there any simple guides out there for how to connect the Arduino Uno to the internet to read information? I am frustrated with the lack of good documentation, and would really appreciate some help.

6
  • That's not a tutorial. That's a library. What code are you actually running? And how exactly have you wired your ESP-01? – Majenko Aug 4 '19 at 15:13
  • Thank you, I updated the posting to include this information – garson Aug 4 '19 at 15:27
  • So... you wired the ESP-01 to pins 0 and 1, not to pins 6 and 7 as specified in your sketch? – Majenko Aug 4 '19 at 15:32
  • Oh sorry no that was wrong, I did wire to 6 and 7 – garson Aug 4 '19 at 15:33
  • There are a number of different AT firmware versions for the ESP-01. And they all use different baud rates. It may well be that you have one with 115200 baud, not 9600 baud. 115200 baud doesn't work well with SoftwareSerial, so you will have to change the baud rate on the ESP-01 to 9600 - however, how you do that depends on the firmware version, and some versions are known to commit suicide when you try changing the baud rate. You should confirm the baud rate by connecting the ESP-01 direct to the computer with a USB to UART adaptor. – Majenko Aug 4 '19 at 15:48
1

It means that your ESP8266 is not detected

Because of you connect RX and TX (6 and 7) to secondary pin. Use your standart RX TX pin to solve the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.