ESP32 web sayfasına bağlanmıyor

Başlatan bbs2006, 28 Ağustos 2019, 17:45:26

bbs2006

merhaba
esp32 nodemcu web sayfasına bağlanmıyor. resimdeki hatayı veriyor.


serial monitor çıktısı ise



bbs2006

ESp32 s Nodemcu yazılımı

#include "OV7670.h"

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library

#include <WiFi.h>
//#include <WiFiMulti.h>
//#include <WiFiClient.h>
WiFiClient client;
#include "BMP.h"

const int SIOD = 21; //SDA
const int SIOC = 22; //SCL

const int VSYNC = 34;
const int HREF = 35;

const int XCLK = 32;
const int PCLK = 33;

const int D0 = 27;
const int D1 = 17;
const int D2 = 16;
const int D3 = 15;
const int D4 = 14;
const int D5 = 13;
const int D6 = 12;
const int D7 = 4;

const int TFT_DC = 2;
const int TFT_CS = 5;
//DIN <- MOSI 23
//CLK <- SCK 18

#define ssid1        "TurkTelekom_TC140"
#define password1    "Uqan4gxv"
//#define ssid2        ""
//#define password2    ""

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, 0/*no reset*/);
OV7670 *camera;

//WiFiMulti wifiMulti;
WiFiServer server(80);

unsigned char bmpHeader[BMP::headerSize];

void serve()
{
   client = server.available();
  if (client) 
  {
    //Serial.println("New Client.");
    String currentLine = "";
    while (client.connected()) 
    {
      if (client.available()) 
      {
        char c = client.read();
        //Serial.write(c);
        if (c == '\n') 
        {
          if (currentLine.length() == 0) 
          {
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();
            client.print(
              "<style>body{margin: 0}\nimg{height: 100%; width: auto}</style>"
              "<img id='a' src='/camera' onload='this.style.display=\"initial\"; var b = document.getElementById(\"b\"); b.style.display=\"none\"; b.src=\"camera?\"+Date.now(); '>"
              "<img id='b' style='display: none' src='/camera' onload='this.style.display=\"initial\"; var a = document.getElementById(\"a\"); a.style.display=\"none\"; a.src=\"camera?\"+Date.now(); '>");
            client.println();
            break;
          } 
          else 
          {
            currentLine = "";
          }
        } 
        else if (c != '\r') 
        {
          currentLine += c;
        }
        
        if(currentLine.endsWith("GET /camera"))
        {
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:image/bmp");
            client.println();
            
            client.write(bmpHeader, BMP::headerSize);
            client.write(camera->frame, camera->xres * camera->yres * 2);
        }
      }
    }
    // close the connection:
    client.stop();
    //Serial.println("Client Disconnected.");
  }  
}

void setup() 
{
  Serial.begin(115200);

  //wifiMulti.addAP(ssid1, password1);
  //wifiMulti.addAP(ssid2, password2);
  WiFi.begin(ssid1, password1);
  Serial.println("Connecting Wifi...");
  while(WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.println("");
      Serial.println("WiFi connected");
      Serial.println("IP address: ");
      Serial.println(WiFi.localIP());
  }
  
  camera = new OV7670(OV7670::Mode::QQVGA_RGB565, SIOD, SIOC, VSYNC, HREF, XCLK, PCLK, D0, D1, D2, D3, D4, D5, D6, D7);
  BMP::construct16BitHeader(bmpHeader, camera->xres, camera->yres);
  
  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(0);
  server.begin();
}

void displayY8(unsigned char * frame, int xres, int yres)
{
  tft.setAddrWindow(0, 0, yres - 1, xres - 1);
  int i = 0;
  for(int x = 0; x < xres; x++)
    for(int y = 0; y < yres; y++)
    {
      i = y * xres + x;
      unsigned char c = frame[i];
      unsigned short r = c >> 3;
      unsigned short g = c >> 2;
      unsigned short b = c >> 3;
      tft.pushColor(r << 11 | g << 5 | b);
    }  
}

void displayRGB565(unsigned char * frame, int xres, int yres)
{
  tft.setAddrWindow(0, 0, yres - 1, xres - 1);
  int i = 0;
  for(int x = 0; x < xres; x++)
    for(int y = 0; y < yres; y++)
    {
      i = (y * xres + x) << 1;
      tft.pushColor((frame[i] | (frame[i+1] << 8)));
    }  
}

void loop()
{
  camera->oneFrame();
  serve();
  displayRGB565(camera->frame, camera->xres, camera->yres);
}

SpeedyX

#2
Merhaba,

Kullandığın kütüphane kodlarını yorum yapıp test et, eğer düzgün çalışırsa ilgili kısma odaklanırsın.

Kodun içinde ledc_channel_config adında bir fonksiyon çağırılıyor olmalı. İşte orada biryerde problem var. ;)

taydin

"Connection refused" hatasının anlamı, 80 numaralı portta dinleme yapan bir TCP server yok. Belki de kullandığın kütüphane web sunucusunu farklı bir portta çalıştırıyor (8080?). Veya bir şekilde server'a 80 numaralı portta dinleme yapmasını söylemen gerekiyor (Kullandığın kütüphane ile ilgili tecrübem yok, bunları genel bilgi olarak al).
Timur Aydın (mekatronik.org)