Chat freely about anything...

User avatar
By mmohamed2
#85601 Hi,
i was trying for days to fix that problem without success

can anybody help please

here's a part of my code

Code: Select all#include <LCD5110_Graph.h>
#include <Adafruit_MLX90614.h>

#define DEVICE_ID "Monitor1"

#define DEBUG true
#define REQ_CODE_ACK 1
#define REQ_CODE_VALUES 2

//84w * 48h
LCD5110 myGLCD(8,9,10,12,11);
extern uint8_t SmallFont[];   //8h * 6w font

Adafruit_MLX90614 mlx = Adafruit_MLX90614();
int pinLM35 = A0;         //Pin A0 is for LM35
int fsrAnalogPin = A2;    //Pin A2 is for force sensor
int blinkPin = 13;        // Pin 13 is the on-board LED

String mSSID = "LibyaADSL-9a86";    //initial ssid and password
String mPASS = "BYRTPCRJAHPWQ";

//http request code
int service_code;       


//wifi listen variables
String wifiBuf = "";       
char character;
int connectionId = 0 ;

//sensor values
float sensor_mlx, sensor_heart, sensor_lm35;
int sensor_force;

void setup() {
  //init LCD 
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
  randomSeed(analogRead(7));

  //init MLX90614
  mlx.begin();

  //init serial
  Serial.begin(115200);           //Arduino-PC
  Serial3.begin(115200);          //Arduino-ESP8266\

  //init esp8266
  init8266();

  pinMode(blinkPin,OUTPUT);         // pin that will blink to your heartbeat!
   
  delay(200);
}

//init esp8266
void init8266()
{   
    Serial.println("Init ESP...");
   
    sendCommand("AT+RST\r\n",2000,DEBUG);       // reset module
    sendCommand("AT+CWMODE=1\r\n",1000,DEBUG);  // configure as access point   غيرت 1 لي 3
    sendCommand("AT+CWDHCP=1,1\r\n",1000,DEBUG);  // HI اني ضفته
    delay(1000);
    sendCommand("AT+CWQAP\r\n",1000,DEBUG);     // quit the AP   
    delay(1000); 
    sendCommand("AT+CWJAP=\""+ mSSID +"\",\""+ mPASS +"\"",20,"OK");
    delay(10000);
    sendCommand("AT+CIFSR\r\n",1000,DEBUG);     // get ip address   
///
    sendCommand("AT+CIPMUX=1\r\n",1000,DEBUG);  // configure for multiple connections
    sendCommand("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80   
}



/*
* Name: sendCommand
* Description: Function used to send data to ESP8266.
* Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no)
* Returns: The response from the esp8266 (if there is a reponse)
*/
String sendCommand(String command, const int timeout, boolean debug)
{
    String response = "";
           
    Serial3.print(command); // send the read character to the esp8266
   
    long int time = millis();
   
    while( (time+timeout) > millis())
    {
      while(Serial3.available())
      {       
        // The esp has data so display its output to the serial window
        char c = Serial3.read(); // read the next character.
        response+=c;
      } 
    }
   
    if(debug)
    {
      Serial.print(response);
    }
   
    return response;
}

//Process wifi request
void procWifiRequest(String content)
{
    int indexEnd;
   int dataSize = content.length();
    char data[dataSize];
    content.toCharArray(data,dataSize);
    Serial.println("-------------------- Received Request --------------------");
    Serial.write(data, dataSize);
    int index = content.indexOf("+IPD,");   
    connectionId = content.charAt(index+5) - 48;

    index = content.indexOf("action=");
    service_code = content.charAt(index+7) - 48;

    Serial.println("Service code = " + service_code);
       
    if(service_code == REQ_CODE_VALUES)
    {
        responseSensors();
    }
    else
    {
         String response;
         response = "result=ACK";           
         response += "&id=";
         response += DEVICE_ID;             
         sendHTTPResponse(connectionId,response);
    }
}


i got

Image

Appreciate any help!