Go Down

Topic: ESP8266 (Read 76466 times) previous topic - next topic

mateusguedes17


Hello I'm doing a project to recognize ssid of the model 5 esp8266, inside it has a menu with some bus lines would like to make a third button to call the string ssid cuff can help me

#include <Wire.h>
#include <LiquidCrystal_I2C.h>


//**entrada dos pinos Digital Pwm**

#define butUp 10  //Pino
#define butDown 9    //Pino
#define butSetar  8 

int id ;

void changeMenu();
void dispMenu();

String SSAID ;
 

void SalvLiCent();
void CletCent();
void VillCamIICent();
void BenBentCentJaci();
void EusGCent();

// *** Variáveis Globais ***

String ssid [5];

ssid
  • = "{b2@U}"

ssid [1] = "{ac@U}"
ssid [2] = "{h82c0U}"
ssid [3] = "{B1AU0}"
ssid [4] = "{]02@U}"


char menu = 0x01;
char seta = 0x00;
boolean t_butUp, t_butDown, t_butSetar;

// --- Hardware do LCD ---
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

// *** Configurações Iniciais ***

void setup() {
  lcd.begin(16, 2);

  for (char i = 9; i < 13; i++) pinMode(i, INPUT_PULLUP);

  t_butUp   = 0x00;
  t_butDown = 0x00;

}

// ** Loop Infinito ***
void loop() {


  changeMenu();
  dispMenu();

 

}

void espset {

  while (true){
 
  if (ESP.available()){
  Serial.write(ESP.read());
  }
 
  if (Serial.available()){
  ESP.write(Serial.read());
  }
}

// *** Desenvolvimento das Funções Auxiliares ***

void changeMenu()
{

  if (!digitalRead(butUp))   t_butUp   = 0x01;        //Botão up pressionado seta flag
  if (!digitalRead(butDown)) t_butDown = 0x01;        //Botão down pressionado seta flag

  if (digitalRead(butUp) && t_butUp)                  //Botão up solto e flag setada
  {
    t_butUp = 0x00;                                   //Limpa flag

    lcd.clear();                                      //Limpa display
    menu++;                                           //Incrementa menu

    if (menu > 0x05) menu = 0x01;                     //Se menu maior que 3, volta a ser 1

  }

  if (digitalRead(butDown) && t_butDown)              //Botão Down solto e flag setada
  { //Sim...
    t_butDown = 0x00;                                //Limpa flag

    lcd.clear();                                     //Limpa display
    menu--;                                          //Decrementa menu

    if (menu < 0x01) menu = 0x05;                    //Se menu menor que 1, volta a ser 3 (PODE ADD MAIS PAGINAS)


    changeMenu();
    dispMenu();

  }

}

void dispMenu() //Mostra o menu atual
{

  switch (menu)
  {
    case 0x01:
      SalvLiCent();
      break;

    case 0x02:
      CletCent();
      break;

    case 0x03:
      VillCamIICent();
      break;

    case 0x04:
      BenBentCentJaci();
      break;

    case 0x05:
      EusGCent();
      break;

  }

  SSAID = ssid [id];
  pinMode(RST, OUTPUT);
  digitalWrite(RST, LOW);
  delay(300);
  digitalWrite(RST, HIGH);
 
  }

}

void SalvLiCent()  //Linha Ponta verdade (menu1)
{
  id = 0;
  lcd.setCursor(0, 1);
  lcd.print("SALVADOR LIRA/CENTRO");
  lcd.scrollDisplayLeft();
  delay(150);

}

void  CletCent()  //Linhda Cruz das almas (menu2)
{
  id = 1;
  lcd.setCursor(0, 1);
  lcd.print("CLETO MARQUES LUZ/CENTRO");
  lcd.scrollDisplayLeft();
  delay(150);

}


void VillCamIICent()   //Linhda Centro (menu3)
{
  id = 2;
  lcd.setCursor(0, 1);
  lcd.print("VILLAGE CAMPESTRE II / CENTRO");
  lcd.scrollDisplayLeft();
  delay(150);

}

void  BenBentCentJaci() {
  id = 3;
  lcd.setCursor(0, 1);
  lcd.print("B. BENTES/CENTRO/JACINTINHO");
  lcd.scrollDisplayLeft();
  delay(150);

}

void EusGCent() {
  id = 4;
  lcd.setCursor(0, 1);
  lcd.print("EUSTAQUIO GOMES/CENTRO");
  lcd.scrollDisplayLeft();
  delay(150);

}

void butSetar (){

  if (!digitalRead (butSetar)) t_butSetar = 0x01;

  if(digitalRead (butSetar) && t_butSetar){

    t_butSetar = 0x00

    seta ++;

    if (seta > 2) sete = 0x01;

    switch (seta){

      case 0x01:
      digitalWrite( SSAID [id], HIGH)
      break;
    }
  }
   
}

mohitz27

Kindly follow the steps as given in the blog post..!
Hope it helps you..

http://hackshaders.blogspot.in/2017/05/how-to-blink-led-using-esp8266-arduino.html

LMI1

Do you know a 8266 based module for linking two controllers via a serial bus? Wireless serial cable.

I am testing two ESP-01 modules but linking is difficult with them. What I know a web server and suitable request are needed. Something simpler for raw data would be enough.

Abhijeet8919

Hello Guyz, I am working on ESP01 wifi project with Arduino IDE 1.8.2. but whenever i tried to work on ESP8266.h it gives me error like

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

Ive already install ESP8266 Generic Board.

Please give me advice. Thank you.

alisystem

there are some codes available on "github.com/esp8266/Arduino/" . I made the code work by modifying it a little but the main problem is that it Exchange data only once ,the server closes the connection when a one data exchanged .i want a continues TCP socket connection (send/receive )

this is my code :

#include <ESP8266WiFi.h>

   const char *ssid = "ESPaliAP";
   const char *password = "12345678hamed";

   WiFiServer server(21);


   char incomingPacket[255];
   char  replyPacekt[] = "Hi there! Got the message :-)";



// the setup function runs once when you press reset or power the board
void setup() {
   pinMode(2, OUTPUT);
     digitalWrite(2, 1);
        delay(1000);
    Serial.begin(115200);
    Serial.println();
    Serial.print("Configuring access point...");
  WiFi.disconnect();
  delay(100);
 WiFi.mode(WIFI_STA);
    // You can remove the password parameter if you want the AP to be open.
    WiFi.softAP(ssid, password);

    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);

// Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
}





void loop()

 {


   // Check if a client has connected
 WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String req = client.readStringUntil('\r');
  Serial.println(req);
 client.flush();

  // Match the request
  int val;
  if (req.indexOf("/gpio/0") != -1)
    val = 1;
  else if (req.indexOf("/gpio/1") != -1)
    val = 0;
  else {
    Serial.println("invalid request");
    client.stop();
    return;
  }

  // Set GPIO2 according to the request
  digitalWrite(2, val);

  client.flush();

  // Prepare the response
  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
  s += (val)?"high":"low";
  s += "</html>\n";

  // Send the response to the client
  client.print(s);
  delay(1);
  Serial.println("Client disonnected");

  // The client will actually be disconnected
// when the function returns and 'client' object is detroyed



}

Go Up