0

I'm using an ESP8266 with the following pin configuration and it doesn't connect to my WiFi. The blue light on the ESP module is on and my LED is on. That's it.

  • VCC - 3.3v
  • GND - GND
  • CH_PD - 3.3v
  • GPIO 0 - GND
  • GPIO2 - LED

I'm using a 1,000 mah 3.7 LiPo battery for this. Here's my Arduino code. I'm following a tutorial from nyl.io.

#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

const char* ssid     = "sukkaa";  
const char* password = "123456789123";
const char* host     = "www.sukkzzesp.tk"; // Your domain  
String path          = "esp\light.json";  
const int pin        = 2;

void setup() {
  pinMode(pin, OUTPUT);
  pinMode(pin, HIGH);
  Serial.begin(115200);
  delay(10);
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  int wifi_ctr = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");
  Serial.println("IP address: " + WiFi.localIP());
}

void loop() {
  Serial.print("connecting to ");
  Serial.println(host);
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  client.print(String("GET ") + path + " HTTP/1.1\r\n" +
    "Host: " + host + "\r\n" +
    "Connection: keep-alive\r\n\r\n");
  delay(500); // wait for server to respond
  // read response
  String section="header";
  while(client.available()) {
    String line = client.readStringUntil('\r');
    // we’ll parse the HTML body here
    if (section=="header") { // headers..
      Serial.print(".");
      if (line=="\n") { // skips the empty space at the beginning 
        section="json";
      }
    } else if (section=="json") { // print the good stuff
      section="ignore";
      String result = line.substring(1);
      // Parse JSON
      int size = result.length() + 1;
      char json[size];
      result.toCharArray(json, size);
      StaticJsonBuffer<200> jsonBuffer;
      JsonObject& json_parsed = jsonBuffer.parseObject(json);
      if (!json_parsed.success()) {
        Serial.println("parseObject() failed");
        return;
      }
      // Make the decision to turn off or on the LED
      if (strcmp(json_parsed["light"], "on") == 0) {
        digitalWrite(pin, HIGH); 
        Serial.println("LED ON");
      } else {
        digitalWrite(pin, LOW);
        Serial.println("led off");
      }
    }
  }
  Serial.print("closing connection. ");
}

Pls help me with this error. Thanks.

  • with io 0 LOW esp8266 goes into bootloader mode – Juraj Apr 7 '18 at 6:36
  • Hi Juraj I removed GPIO 0 from GND and still the same results. Not connecting and theres a small hum coming from the esp chip – Suvin Nimnaka Sukka Apr 7 '18 at 7:16
  • you power it with 3.7 V? – Juraj Apr 7 '18 at 10:24

Your Answer

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

Browse other questions tagged or ask your own question.