Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By martinayotte
#30721 Here is the version used in my last tests yesterday, the differences are mainly that my LED is on GPIO16 :

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
extern "C" {
#include "user_interface.h"
}
#define WIFI_MODE_AP

/* Set these to your desired credentials. */
const char *ssid = "MyESPAP";
const char *password = "MyPassword";
//Reference station counter as "devices"
unsigned char devices;
// boolean ledState = false;
int alreadyBlinked = 0;
unsigned int prevMillis = 0;

ESP8266WebServer server(80);

void handleRoot() {

}

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  pinMode(16, OUTPUT);
  digitalWrite(16, LOW);
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);
  server.begin();
 
 
   }

void loop() {
  if ((millis() - prevMillis) > 1000) {
    prevMillis = millis();
    struct station_info *stat_info = wifi_softap_get_station_info();
    devices = 0;
    while (stat_info != NULL) {
      stat_info = STAILQ_NEXT(stat_info, next);
      devices++;
    }
    if (alreadyBlinked > 0) {
      digitalWrite(16, LOW);
      prevMillis = millis();
      Serial.println("Led turned LOW");
      Serial.print("devcount=");
      Serial.println(devices);
    }
  }
  if (devices == 0) {
    alreadyBlinked = 0;
  }
  else if (alreadyBlinked == 0) {           
    digitalWrite(16, HIGH);
    Serial.println("Led turned HIGH");
    prevMillis = millis();
    alreadyBlinked = 1;
  }
  server.handleClient();
}
User avatar
By derek bernsen
#30728 It's still not working even with that code. Is your GPIO0 & CH_PD connected to high? And is your GPIO16 AKA RST pin connected to the LED then ground, OR to VCC? Maybe it's a baud rate issue when I first upload the code. I'm using 11520 baud, DIO, 40MHz, CPU 80MHz, flash size 512K (64k Spiffs).
User avatar
By martinayotte
#30734
derek bernsen wrote:Is your GPIO0 & CH_PD connected to high?

Of course, this is mandatory ...
derek bernsen wrote:And is your GPIO16 AKA RST pin connected to the LED then ground, OR to VCC?

My LED is thru GND since GPIO16 doesn't the issue of been a Boot mode input like GPIO2, therefore the sketch is issuing normal positive logic states, HIGH being ON and LOW being OFF.
derek bernsen wrote:Maybe it's a baud rate issue when I first upload the code.

For that, as I suggested earlier, you may try to upload a simple Blink sketch to prove that you setup is Ok.
User avatar
By derek bernsen
#30791 Blink sketch works fine, but with the other code it just keeps the LED lit at all times flickering slightly with the AP on.
I've tried with 2 different ESP-01 modules, one from Ebay.com, and the other from http://www.banggood.com/Banggood. Same issues. I'm using a brown-black-yellow-gold (100 ohm?) resistor. and a blue LED. Same issue when tried without any resistor. I tried using the serial to USB adapter itself as the power supply, and also I tried using a 3.6v 500mAh LiPO.