ESP8266 not connecting to wifi

I am following this tutorial here to try and connect arduino to firebase via ESP8266. I've gotten it to work following the tutorial a couple times (albeit requiring trying a couple times sometimes) and it does connect to the wifi, however when I was trying to upload and connect to wifi, nothing is printing in serial--even the wifi debug output.

Uploading code works when I wire the Esp8266 module as specified in the tutorial, and previously, after the code is uploaded I would unplug TX, remove the connection between ESP8266's IO0 pin and ground, and then replug TX, at which point things would start printing in serial port (the tutorial says unplug/replug the "serial cable" and it seemed to work with TX). But, today I could only get serial output if I unplugged the ground of Arduino/ground of ESP8266/reset on the breadboard and then replugged them.

At this point, the TX light on Arduino would begin to flash (it hadn't previously) and the debug output for the wifi module would start printing. However, even after waiting, it could never actually establish connection with the wifi. The debug output is below (it keeps printing the same thing):

......scandone
state: 0 -> 2 (b0)
..state: 2 -> 0 (2)
reconnect
.....scandone
state: 0 -> 2 (b0)
..state: 2 -> 0 (2)
reconnect
......scandone
state: 0 -> 2 (b0)
..state: 2 -> 0 (2)
reconnect
......scandone

So, the question is, why does it not connect to the wifi (when everything worked perfectly fine yesterday) and am I doing anything wrong here? Could my ESP8266 be broken since I didn't use a voltage divider (this doesn't seem likely though--I was able to upload code and the blue light flashed)? My code is below

#include <Firebase.h>
#include <FirebaseArduino.h>
#include <FirebaseCloudMessaging.h>
#include <FirebaseError.h>
#include <FirebaseHttpClient.h>
#include <FirebaseObject.h>
#include <dummy.h>

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <SPI.h>  
#include <Wire.h> 
#include <DHT.h>  
#include <Adafruit_BMP085.h>

//sensitive info removed, but they're all there in the actual code
#define FIREBASE_HOST ""
#define FIREBASE_AUTH ""

#define WIFI_SSID ""
#define WIFI_PASSWORD ""

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.setDebugOutput(true);
  
  //connect to Wifi
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

  //define pin
  pinMode(MQ138, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  // set value
  Firebase.setFloat("PPM", n);
  //error catching
  if (Firebase.failed()) {
    Serial.print("setting /number failed:");
    Serial.println(Firebase.error());
    return;
  }
  delay(1000);
  // appending a new value to /logs, CHANGE INT
  String name = Firebase.pushInt("logs", n++);
  //handle error
  if (Firebase.failed()) {
    Serial.print("pushing /logs failed: ");
    Serial.println(Firebase.error());
    return;
  }
  Serial.print("pushed: /logs/");
  Serial.println(name);
  delay(1000);

  if (Firebase.failed()) {
    return;
  }
  
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.