Go Down

Topic: ESP8266 (Read 91588 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



}

Akorede

Hi guys
I'm currently working on a project that involves sending and receiving text via wifi. I'm using esp8266 01 for this. I've done my basic settings, everything seems cool with AT commands. I even used it as a webserver. But the problem lies in getting http get response. Whenever I receive anything with space and some characters, mt response will have + sign and some %c ....characters. I know they are the ascii equivalent of the sent characters. PLease guys, how may I remove those unwanted characters? I tried to use esp8266Wifi library, but installing it has never been successful, getting all sort of errors (like functional.h, queue.h, etc). Please guy assist me. Thanks

mistergreen

#126
Feb 09, 2018, 03:01 am Last Edit: Feb 09, 2018, 03:01 am by mistergreen
http response is usually url encoded. You need to url decode. Use this
https://github.com/zenmanenergy/ESP8266-Arduino-Examples/blob/master/helloWorld_urlencoded/urlencode.ino


JonMiles

Hi All,

I am having real problems access the AT commands.

I have the following set up between a nano and the ESP-8266:

GND------->GND
VCC-------->+3.3v
CH_PD---->+3.3v
TX--------->RX
RX--------->tx

I am using the flowing code as a serial through:
Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial softSerial(2, 3); // RX, TX

void setup()
{
  uint32_t baud = 9600;
  Serial.begin(baud);
  softSerial.begin(baud);
  Serial.print("SETUP!! @");
  Serial.println(baud);
}

void loop()
{
    while(softSerial.available() > 0)
    {
      char a = softSerial.read();
      if(a == '\0')
        continue;
      if(a != '\r' && a != '\n' && (a < 32))
        continue;
      Serial.print(a);
    }
   
    while(Serial.available() > 0)
    {
      char a = Serial.read();
      Serial.write(a);
      softSerial.write(a);
    }
}


When i send AT the blue led flashes once very quickly on the ESP-8266 but i get no response back.

I have tried various baud rates but to no avail.

I have been searching for day on the web, but to no avail, anyone see what I am missing?

thanks in advance

ieee488

Hi All,

I am having real problems access the AT commands.

I have the following set up between a nano and the ESP-8266:

GND------->GND
VCC-------->+3.3v
CH_PD---->+3.3v
TX--------->RX
RX--------->tx

I am using the flowing code as a serial through:
Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial softSerial(2, 3); // RX, TX

void setup()
{
  uint32_t baud = 9600;
  Serial.begin(baud);
  softSerial.begin(baud);
  Serial.print("SETUP!! @");
  Serial.println(baud);
}

void loop()
{
    while(softSerial.available() > 0)
    {
      char a = softSerial.read();
      if(a == '\0')
        continue;
      if(a != '\r' && a != '\n' && (a < 32))
        continue;
      Serial.print(a);
    }
   
    while(Serial.available() > 0)
    {
      char a = Serial.read();
      Serial.write(a);
      softSerial.write(a);
    }
}


When i send AT the blue led flashes once very quickly on the ESP-8266 but i get no response back.

I have tried various baud rates but to no avail.

I have been searching for day on the web, but to no avail, anyone see what I am missing?

thanks in advance
Start your own thread so that your problem will get the attention it needs.

You shouldn't hijack someone else's thread.




JonMiles

I thought this was a thread all about the esp8266. It even says that in the first post.......

ieee488

I thought this was a thread all about the esp8266. It even says that in the first post.......
You'll notice that the other topics have nothing to do with your problem.

If you want your post to be noticed, create your own thread.

If you don't care, then that is fine too.


rbright

For AT Commands don't assume the logical approach of UNO TX to ESP RX... Try TX to TX and RX to RX.

Also understand contents of the following link: https://arduino.stackexchange.com/questions/18575/send-at-commands-to-esp8266-from-arduino-uno-via-a-softwareserial-port

Enjoy... 

JonMiles

I have tried both TX to TX and TX to RX.

With TX to TX there is no blue led flash on the ESP8266.  Also i am using softwareserial so not using the same tx and rx pins as the usb connection

zoomx

Try 115200 baud instead of 9600.

JonMiles

Have tried that too. I have tried each of the baud rates at least once on the off chance.

Go Up