OV7670 no fifo esp32

Hi!
I've tried this code from bitluni: GitHub - bitluni/ESP32CameraI2S

My camera is OV7670.

The fact is that my board is a TTGO LoRa32 (without OLED, this won´t be something remarkable, I think), which I'll attach in the post. And the issue I have is that when I upload the code, the Serial Output remains in:

Waiting for VSYNC...

This text was set as DEBUG_PRINT(), or something like that. What I had done was changing that for Serial.println(), only to see failures in the code. (If you upload as it is, it won't appear). The point is that it doesn't move forward "Waiting for VSYNC".

Here´s my board. Its micro is ESP32-D0WDQ6. Thanks for all!

Here's the code from the main code (the headers are in github):

#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>
#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 = 5;
const int TFT_CS = 2;

#define ssid1        "oppo"
#define password1    "sofiaaaa"

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()
{
  WiFiClient 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);
  Serial.println("Connecting Wifi...");
  if(wifiMulti.run() == WL_CONNECTED) {
      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);
}
1 Like

You appear to also be a newbie on the forum, so here's some high-level advice.

the fact something came out on the serial port means probably everything will come out when code runs,
it is very simple and hard to break unless you mess with the serial port.

so some code is running. The place to start digging into the actual software would be the wifi thing.

You may find a specific match to another forum user who can answer it,
but a broader internet audience would have more.

I'm really just answering a randomly selected question to prove that J-M-L is tracking and trolling me.

1 Like

okayy. The code is running, but maybe any register or sth in the code is wrong. For example, you tell the board to activate the pin which is +1 than yours. This is sth really stupid but you will understand. Anyway, I'll take a look at wifi, thanks!!!
:joy: :joy: :joy: and yes, I'm a newbie totally, what's J-M-L??

@shockedolddad this is not appropriate. This topic is a place to assist @antonio_00. If a comment isn't intended to further that then it doesn't belong here. Don't drag your unrelated quarrels in.

If you encounter behavior you think is abusive, then raise a flag and let the moderators deal with it:

https://meta.discourse.org/t/flag-a-post-for-moderator-attention/3278

The Arduino Forum is a place for learning and teaching knowledge about embedded systems. Focus on that and minimize the drama.

2 Likes

Look inside the file named Log.h, flip the comment block around and you'll see all the debug info..
vsync is an output from the cam..
you got built in LoRa32??
Looks like your using some lora pins, wondering if you can do that??

good luck.. ~q

1 Like

I've tried this pins in a ESP32:

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 = 19;

const int D2 = 18;

const int D3 = 15;

const int D4 = 14;

const int D5 = 13;

const int D6 = 12;

const int D7 = 4;

And this is the result:
image

So, well, now I have to enhance the image, but at least it works!! Thanks so much my friend!! For sure it had to be sth related to the pins

1 Like

That looks like noise!

yeah, it's not good, but at least the cam sends sth, making progress...

@antonio_00

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.