Problem while sending data to the server

Hello Everyone, I am stuck in a problem . The Blynk is not sending the data to the server. Here are few observations…

  1. The first time it goes into the sendd function, It wait for 5-10 sencond and then it comes out without sending data to server Although it prints the last line also.
  2. It goes one time in the Loop ,and then it always runs in the camCB class.
  3. It was working fine a few days ago.
  4. It is importent to use the camCB class for my furthur project. so can somone please help me to resolve the issue.
  5. It also prints Login Timeout after some time in my serial moniter

#include <Camera.h>
int take_picture_count =0;
int reference_height  = 0; 
int Height=0;
float ACY=0;
int count=0;
#define BLYNK_TEMPLATE_ID "xxxxxxxxx"
#define BLYNK_TEMPLATE_NAME "xxxxxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxx"
#define BLYNK_PRINT Serial
#define ESP8266_BAUD 115200
//
#include <ESP8266_Lib.h>
#include <ezButton.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(20,21);
//
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "xxxxxxxx";
char pass[] = "12345678";

ESP8266 wifi(&EspSerial);
BlynkTimer timer;
void printError(enum CamErr err)
{
  Serial.print("Error: ");
  switch (err)
    {
      case CAM_ERR_NO_DEVICE:
        Serial.println("No Device");
        break;
      case CAM_ERR_ILLEGAL_DEVERR:
        Serial.println("Illegal device error");
        break;
      case CAM_ERR_ALREADY_INITIALIZED:
        Serial.println("Already initialized");
        break;
      case CAM_ERR_NOT_INITIALIZED:
        Serial.println("Not initialized");
        break;
      case CAM_ERR_NOT_STILL_INITIALIZED:
        Serial.println("Still picture not initialized");
        break;
      case CAM_ERR_CANT_CREATE_THREAD:
        Serial.println("Failed to create thread");
        break;
      case CAM_ERR_INVALID_PARAM:
        Serial.println("Invalid parameter");
        break;
      case CAM_ERR_NO_MEMORY:
        Serial.println("No memory");
        break;
      case CAM_ERR_USR_INUSED:
        Serial.println("Buffer already in use");
        break;
      case CAM_ERR_NOT_PERMITTED:
        Serial.println("Operation not permitted");
        break;
      default:
        break;
    }
}

/**
 * Callback from Camera library when video frame is captured.
 */

void CamCB(CamImage img)
{
Blynk.run();
  timer.run(); 

 take_picture_count++;
 count++;
 delay(2000);
 Serial.println("In the camcb");
  delay(500);

  ACY++;
  
  /* Check the img instance is available or not. */

  if (img.isAvailable())
    {

      /* If you want RGB565 data, convert image data format to RGB565 */

      img.convertPixFormat(CAM_IMAGE_PIX_FMT_RGB565);

      /* You can use image data directly by using getImgSize() and getImgBuff().
       * for displaying image to a display, etc. */
    }
  else
    {
      Serial.println("Failed to get video stream image");
    }
}

void setup() {
    Serial.begin(115200);
  EspSerial.begin(ESP8266_BAUD);///////////////
  Blynk.begin(auth, wifi, ssid, pass);
  timer.setInterval(5000,sendd);
  delay(300);
   
 CamErr err;
   Serial.println("Prepare camera");
  err = theCamera.begin();
  if (err != CAM_ERR_SUCCESS)
    {
      printError(err);
    }

  /* Start video stream.
   * If received video stream data from camera device,
   *  camera library call CamCB.
   */

  Serial.println("Start streaming");
  err = theCamera.startStreaming(true, CamCB);
  if (err != CAM_ERR_SUCCESS)
    {
      printError(err);
    }

  /* Auto white balance configuration */

  Serial.println("Set Auto white balance parameter");
//  err = theCamera.setAutoWhiteBalanceMode(CAM_WHITE_BALANCE_AUTO);
//  if (err != CAM_ERR_SUCCESS)
//    {
//      printError(err);
//    }

  // put your setup code here, to run once:

}

void sendd(){
  delay(500);
  Serial.println("yoy have called sednd data");
  Blynk.virtualWrite(V13, ACY);
  delay(500);
  Blynk.virtualWrite(V17, take_picture_count);
  delay(500);
  Blynk.virtualWrite(V18, count);
  delay(500);
  Blynk.virtualWrite(V19, count);
  
  Serial.println("sent");
  
}

void loop() {
  Blynk.run();
  timer.run(); 

  Serial.println("In the loop");
  delay(500);
  
  // put your main code here, to run repeatedly:

}

You need to start by removing all the delay() commands from your code.
I would also help your debugging if you made your serial print commands more sensible, by adding-in the values of the variables that you’re sending to Blynk.

Is your device online?
How have you configured your datastreams?
What hardware are you using?

Pete.

Thank you for your reply.

  1. I have removed all the delay. except one in camCB class of 500ms.
  2. No, It getting offline .
  3. I am using a Spresense Main board and Extension Board connect with ESP8266.
    Here is the Serialprint report
11:13:09.820 -> [33670] Ready (ping: 11ms).
11:13:10.659 -> Prepare camera
11:13:11.515 -> Start streaming
11:13:11.751 -> Set Auto white balance parameter
11:13:11.751 -> In the loop
11:13:11.751 -> In the loop
11:13:11.751 -> In the loop
11:13:11.799 -> In the loop
11:13:11.799 -> In the camcb
11:13:11.988 -> In the loop
11:13:11.988 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.084 -> In the loop
11:13:12.084 -> In the loop
11:13:12.084 -> In the camcb
11:13:12.275 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.370 -> In the loop
11:13:12.370 -> In the loop
11:13:12.370 -> In the loop
11:13:12.370 -> In the camcb

This thing get repeated for 5 second untill My first send data call is made.(Device is online untill this).


Observed this Strange behaviour of not going in loop, And then It got disconnected .
Thanks in Advance

You need to remove this from your CamCB() function.

When you paste serial output please copy and paste the text and use triple backticks at the beginning and end, the same was you do when posting code.
Please don’t post screenshots of your serial output.

Pete.

I have removed the timer.run(); function but the error is still the same.
I am attaching the full Serial output

11:12:59.226 -> [23050] Connected to WiFi
11:13:09.820 -> [33670] Ready (ping: 11ms).
11:13:10.659 -> Prepare camera
11:13:11.515 -> Start streaming
11:13:11.751 -> Set Auto white balance parameter
11:13:11.751 -> In the loop
11:13:11.751 -> In the loop
11:13:11.751 -> In the loop
11:13:11.799 -> In the loop
11:13:11.799 -> In the camcb
11:13:11.988 -> In the loop
11:13:11.988 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.035 -> In the loop
11:13:12.084 -> In the loop
11:13:12.084 -> In the loop
11:13:12.084 -> In the camcb
11:13:12.275 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.323 -> In the loop
11:13:12.370 -> In the loop
11:13:12.370 -> In the loop
11:13:12.370 -> In the loop
11:13:12.370 -> In the camcb
11:13:12.608 -> In the loop
11:13:12.608 -> In the loop
11:13:12.608 -> In the loop
11:13:12.608 -> In the loop
11:13:12.608 -> In the loop
11:13:12.654 -> In the loop
11:13:12.654 -> In the loop
11:13:12.654 -> In the loop
11:13:12.654 -> In the loop
11:13:12.702 -> In the camcb
11:13:12.891 -> In the loop
11:13:12.891 -> In the loop
11:13:12.891 -> In the loop
11:13:12.938 -> In the loop
11:13:12.938 -> In the loop
11:13:12.938 -> In the loop
11:13:12.938 -> In the loop
11:13:12.938 -> In the loop
11:13:12.986 -> In the loop
11:13:12.986 -> In the camcb
11:13:13.174 -> In the loop
11:13:13.174 -> In the loop
11:13:13.222 -> In the loop
11:13:13.222 -> In the loop
11:13:13.222 -> In the loop
11:13:13.222 -> In the loop
11:13:13.222 -> In the loop
11:13:13.269 -> In the loop
11:13:13.269 -> In the loop
11:13:13.269 -> In the camcb
11:13:13.507 -> In the loop
11:13:13.507 -> In the loop
11:13:13.507 -> In the loop
11:13:13.507 -> In the loop
11:13:13.507 -> In the loop
11:13:13.507 -> In the loop
11:13:13.552 -> In the loop
11:13:13.552 -> In the loop
11:13:13.552 -> In the loop
11:13:13.598 -> In the camcb
11:13:13.786 -> In the loop
11:13:13.786 -> In the loop
11:13:13.786 -> In the loop
11:13:13.786 -> In the loop
11:13:13.834 -> In the loop
11:13:13.834 -> In the loop
11:13:13.834 -> In the loop
11:13:13.834 -> In the loop
11:13:13.834 -> In the loop
11:13:13.881 -> In the camcb
11:13:14.070 -> In the loop
11:13:14.070 -> In the loop
11:13:14.117 -> In the loop
11:13:14.117 -> In the loop
11:13:14.117 -> In the loop
11:13:14.117 -> In the loop
11:13:14.117 -> In the loop
11:13:14.164 -> In the loop
11:13:14.164 -> In the loop
11:13:14.164 -> In the camcb
11:13:14.352 -> In the loop
11:13:14.399 -> In the loop
11:13:14.399 -> In the loop
11:13:14.399 -> In the loop
11:13:14.399 -> In the loop
11:13:14.399 -> In the loop
11:13:14.446 -> In the loop
11:13:14.446 -> In the loop
11:13:14.446 -> In the loop
11:13:14.446 -> In the camcb
11:13:14.683 -> In the loop
11:13:14.683 -> In the loop
11:13:14.683 -> In the loop
11:13:14.683 -> In the loop
11:13:14.730 -> In the loop
11:13:14.730 -> In the loop
11:13:14.730 -> In the loop
11:13:14.730 -> In the loop
11:13:14.730 -> In the loop
11:13:14.777 -> In the camcb
11:13:14.966 -> In the loop
11:13:14.966 -> In the loop
11:13:14.966 -> In the loop
11:13:15.013 -> In the loop
11:13:15.013 -> In the loop
11:13:15.013 -> In the loop
11:13:15.013 -> In the loop
11:13:15.013 -> In the loop
11:13:15.060 -> In the loop
11:13:15.060 -> In the camcb
11:13:15.249 -> In the loop
11:13:15.249 -> In the loop
11:13:15.296 -> In the loop
11:13:15.296 -> In the loop
11:13:15.296 -> In the loop
11:13:15.296 -> In the loop
11:13:15.344 -> In the loop
11:13:15.344 -> In the loop
11:13:15.344 -> In the loop
11:13:15.344 -> In the camcb
11:13:15.579 -> In the loop
11:13:15.579 -> In the loop
11:13:15.579 -> In the loop
11:13:15.579 -> In the loop
11:13:15.579 -> In the loop
11:13:15.627 -> In the loop
11:13:15.627 -> In the loop
11:13:15.627 -> In the loop
11:13:15.627 -> In the loop
11:13:15.667 -> In the camcb
11:13:15.856 -> yoy have called sednd data
11:13:16.092 -> In the camcb
11:13:16.374 -> In the camcb
11:13:16.657 -> In the camcb
11:13:16.988 -> In the camcb
11:13:17.272 -> In the camcb
11:13:17.555 -> In the camcb
11:13:17.885 -> In the camcb
11:13:18.167 -> In the camcb
11:13:18.452 -> In the camcb
11:13:18.738 -> In the camcb
11:13:19.069 -> In the camcb
11:13:19.352 -> In the camcb
11:13:19.636 -> In the camcb
11:13:19.919 -> In the camcb
11:13:20.249 -> In the camcb
11:13:20.533 -> In the camcb
11:13:20.817 -> yoy have called sednd data
11:13:30.883 -> Take_picture_count: 
11:13:30.883 -> 30
11:13:30.883 -> sent
11:13:30.883 -> In the camcb
11:13:51.513 -> yoy have called sednd data
11:13:51.513 -> Take_picture_count: 
11:13:51.513 -> 31
11:13:51.513 -> sent
11:13:51.513 -> In the camcb
11:13:51.701 -> Take_picture_count: 
11:13:51.701 -> 32
11:13:51.701 -> sent
11:13:51.701 -> In the loop
11:14:12.186 -> yoy have called sednd data
11:14:12.186 -> Take_picture_count: 
11:14:12.186 -> 32
11:14:12.186 -> sent
11:14:12.186 -> In the camcb
11:14:27.667 -> yoy have called sednd data
11:14:27.667 -> Take_picture_count: 
11:14:27.667 -> 33
11:14:27.667 -> sent
11:14:27.667 -> In the camcb
11:14:27.855 -> In the loop
11:14:48.239 -> yoy have called sednd data
11:14:48.239 -> Take_picture_count: 
11:14:48.239 -> 34
11:14:48.239 -> sent
11:14:48.239 -> In the camcb
11:15:03.799 -> yoy have called sednd data
11:15:03.799 -> Take_picture_count: 
11:15:03.799 -> 35
11:15:03.799 -> sent
11:15:03.799 -> In the camcb
11:15:04.019 -> In the loop
11:15:24.464 -> yoy have called sednd data
11:15:24.464 -> Take_picture_count: 
11:15:24.464 -> 36
11:15:24.464 -> sent
11:15:24.464 -> In the camcb

Thanks

Please post your current code, and more details of your hardware and how your devices are connected.

A link to the Camera.h library and the version of that library you have installed would also be useful.

Pete.

Thank You for your reply,Here is the Code

#include <Camera.h>
int take_picture_count =0;
int reference_height  = 0; 
int Height=0;
float ACY=0;
int count=0;
#define BLYNK_TEMPLATE_ID "xxxxxxxxxxxxxx"
#define BLYNK_TEMPLATE_NAME "x xxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxx"
#define BLYNK_PRINT Serial
#define ESP8266_BAUD 115200
//
#include <ESP8266_Lib.h>

#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(20,21);
//
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "x";
char pass[] = "xxxxxx";

ESP8266 wifi(&EspSerial);
BlynkTimer timer;
void printError(enum CamErr err)
{
  Serial.print("Error: ");
  switch (err)
    {
      case CAM_ERR_NO_DEVICE:
        Serial.println("No Device");
        break;
      case CAM_ERR_ILLEGAL_DEVERR:
        Serial.println("Illegal device error");
        break;
      case CAM_ERR_ALREADY_INITIALIZED:
        Serial.println("Already initialized");
        break;
      case CAM_ERR_NOT_INITIALIZED:
        Serial.println("Not initialized");
        break;
      case CAM_ERR_NOT_STILL_INITIALIZED:
        Serial.println("Still picture not initialized");
        break;
      case CAM_ERR_CANT_CREATE_THREAD:
        Serial.println("Failed to create thread");
        break;
      case CAM_ERR_INVALID_PARAM:
        Serial.println("Invalid parameter");
        break;
      case CAM_ERR_NO_MEMORY:
        Serial.println("No memory");
        break;
      case CAM_ERR_USR_INUSED:
        Serial.println("Buffer already in use");
        break;
      case CAM_ERR_NOT_PERMITTED:
        Serial.println("Operation not permitted");
        break;
      default:
        break;
    }
}

/**
 * Callback from Camera library when video frame is captured.
 */

void CamCB(CamImage img)
{
Blynk.run();


 take_picture_count++;
 count++;

 Serial.println("In the camcb");

  delay(500);

  ACY++;
  
  /* Check the img instance is available or not. */

  if (img.isAvailable())
    {

      /* If you want RGB565 data, convert image data format to RGB565 */

      img.convertPixFormat(CAM_IMAGE_PIX_FMT_RGB565);

      /* You can use image data directly by using getImgSize() and getImgBuff().
       * for displaying image to a display, etc. */
    }
  else
    {
      Serial.println("Failed to get video stream image");
    }
}

void setup() {
    Serial.begin(115200);
  EspSerial.begin(ESP8266_BAUD);///////////////
  Blynk.begin(auth, wifi, ssid, pass);
  timer.setInterval(5000,sendd);

   
 CamErr err;
   Serial.println("Prepare camera");
  err = theCamera.begin();
  if (err != CAM_ERR_SUCCESS)
    {
      printError(err);
    }

  /* Start video stream.
   * If received video stream data from camera device,
   *  camera library call CamCB.
   */

  Serial.println("Start streaming");
  err = theCamera.startStreaming(true, CamCB);
  if (err != CAM_ERR_SUCCESS)
    {
      printError(err);
    }


}
//
void sendd(){
//  delay(500);
  Serial.println("yoy have called sednd data");
  Blynk.virtualWrite(V13, ACY);
//  delay(500);
  Blynk.virtualWrite(V17, take_picture_count);
//  delay(500);
  Blynk.virtualWrite(V18, count);
//  delay(500);
  Blynk.virtualWrite(V19, count);
  Serial.println("Take_picture_count: ");
  Serial.println(take_picture_count);
  Serial.println("sent");
  
}

void loop() {
  Blynk.run();
  timer.run();

  Serial.println("In the loop");


}

I am using a Spresense Main board with Extension board(can be ignored), Main board is connected to ESP8266 via Serial connection.
Here is the link to Camera.h file that I am using

Where?

That’s pretty-much the same Information you provided before. Why are you reluctant to provide details?

Pete.

@FNSPH your code is posted without the necessary triple backticks at the beginning and end, so it doesn’t display correctly.
In addition, you’ve hijacked a post about an unrelated topic rather than creating a new post and providing all of the necessary background information.

As a result, I’ve deleted your post.

Please create a new “Need help with my project” topic and carefully read the guidance information that appears when you do this, and provide the requested information, and follow the example about how to post code correctly.

Pete.

Sorry in advance for my mistake when posting, but can you give me an example of an error in my program code?