Problems on ESP8266 programming based on Arduino IDE for ESP8266

I decided to use Arduino IDE for ESP8266 to program on my ESP8266, targeting to read data(bytes array from TTL Camera). As we know that ESP8266-01(8Mbits Flash ROM) has 8 pins and I decided to use GPIO16(TXD) and GPIO2(RXD) as SoftwareSerial pins to achieve it. But the ESP8266 printed exception info and I am not sure what happened to it. So I have a few question on this crash.

  1. I want to know whether I can run SoftwareSerial on ESP8266(ESP8266 have 2 UARTs,Serial0 for Serial print and we could not send datas through Serial1), so I decided to use SoftwareSerial.
  2. I don’t know what the exception info means for I can’t understand assemble language.
  3. I read documents on Github for Arduino IDE for ESP8266, but I don’t understand well about the pin definitions on ESP8266 when programming by Arduino IDE(For example, when using GPIO16(TXD) and GPIO2(RXD) as SoftwareSerial, we might use Constructor “SoftwareSerial Camera(int Pin1, int Pin2)”, I want to know what is the corresponding Pin1 and Pin2 for GPIO2 and GPIO16), the document really confused me.

Here is my key code.

#include <Arduino.h>
#include "camera_VC0706.h"
#include <SoftwareSerial.h>
HTTPClient httpClient;
//define camera and bytes array, I am not sure whether the pins are correct or not
int rxPin=2;
int txPin=16;
SoftwareSerial cameraSerial(rxPin,txPin); //RX,TX
camera_VC0706 Camera = camera_VC0706(&cameraSerial);
//take photo
bool takePhoto(){
  byte time=0;
  writeRawSerial(F("<STATUS>WAITING</STATUS>"),true);
  while(!Camera.begin(115200)){
    if(+time<=5){//try 5 times
      writeRawSerial(F("."),false);
    }
    else{
      writeRawSerial("",true);
      writeSerial(F("<STATUS>NO_CAMERA</STATUS>"));
      return false;
    }
  }
  writeRawSerial(F("<STATUS>CAMERA_ON</STATUS>"),false);
  writeRawSerial(F("<VERSION>"),false);
  writeRawSerial(Camera.getVersion(),false);
  writeSerial(F("</VERSION>"));
  Camera.setImageSize(VC0706_320x240);
  if (!Camera.takePicture()){
    writeSerial(F("<STATUS>TAKE_PHOTO_FAIL</STATUS>"));
    return false;
  }
  else{
    byte imgSize = Camera.frameLength();
    writeSerial(F("<STATUS>TAKE_PHOTO_SUCCESS</STATUS>"));
    writeRawSerial(F("<IMAGE_SIZE>"),false);
    writeRawSerial(String(imgSize,DEC),false);
    writeSerial(F("</IMAGE_SIZE>"));
    freeHeap();//It was defined, but not key function, only for showing free heap of esp8266
    imgBuffer=Camera.readPicture(imgSize);
    freeHeap();
    Camera.resumeVideo();
    writeSerial(F("<STATUS>SAVE_PHOTO_SUCCESS</STATUS>"));
    return true;
  }
}

Thank you for your reading of my questions.

a thread about SoftwareSerial on esp8266

Juraj:
https://github.com/me-no-dev/EspExceptionDecoder

Well the question I most wanted to know is that whether SoftwareSerial is available on ESP8266 or not.

Also posted at:

If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

pert:
Also posted at:
Problems on ESP8266 programming based on Arduino IDE for ESP8266 - Stack Overflow
If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

Haha......I didn't have habit to do so, I think that you gave me a good suggestion:)

liangyugz:
Well the question I most wanted to know is that whether SoftwareSerial is available on ESP8266 or not.

did you see the edit of my comment?

Juraj:
did you see the edit of my comment?

Yee I got it, I followed the guidance but crashes are still happening, the exception decoder told me that crash happens when it comes to opening softwareSerial. I am not sure whether Pins are limited while using them to start softwareSerial or not, could you tell me about that?

it is in the thread I linked

bool SoftwareSerial::isValidGPIOpin(int pin) {
   // Some GPIO pins are reserved by the system
   return (pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 15);
}

Juraj:
it is in the thread I linked

bool SoftwareSerial::isValidGPIOpin(int pin) {

// Some GPIO pins are reserved by the system
  return (pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 15);
}

I had got this information, but when I use GPIO0 and GPIO2 as SoftwareSerial pins, the crashes are still happening, so I don’t know if GPIO0 is unavailable in ESP8266-01 ,or…not? There are many types of models of ESP8266 with different quantities of GPIO pins, but the thread didn’t give out explicit description about this.

liangyugz:
I had got this information, but when I use GPIO0 and GPIO2 as SoftwareSerial pins, the crashes are still happening, so I don't know if GPIO0 is unavailable in ESP8266-01 ,or...not? There are many types of models of ESP8266 with different quantities of GPIO pins, but the thread didn't give out explicit description about this.

http://www.forward.com.au/pfod/ESP8266/GPIOpins/ESP8266_01_pin_magic.html

.

on esp8266-01 only RX (io1), TX (io3), TX1 (io2) and io 0 are accessible. io 0 has pull-up resistor for the required boot state (because LOW enters bootloader mode).

use hw serial

Juraj:
on esp8266-01 only RX (io1), TX (io3), TX1 (io2) and io 0 are accessible. io 0 has pull-up resistor for the required boot state (because LOW enters bootloader mode).

use hw serial

Let me make it clear...So you mean that besides using RX,TX without setting anything, I can only use TX1 and GPIO0 as another hardware serial, but not software serial(Serial1 in Arduino), right?
but I read a thread about the GPIO of ESP8266, it said that we can only use Serial1 to transfer data without receiving data, but I need both TX and RX, so how should I set io2 and io0 by Arduino Language and the hardware itself?

Sorry, I meant the main HW serial RX and TX. You can use TX1 for debug prints over USB with adapter. I never used software serial with esp8266. I read that it doesn't work reliably. I think the interrupts to handle WiFi disturb it. And I think with the two gpio pins of 01 where one has a pullup and the other must not be low it is impossible.

Juraj:
Sorry, I meant the main HW serial RX and TX. You can use TX1 for debug prints over USB with adapter. I never used software serial with esp8266. I read that it doesn't work reliably. I think the interrupts to handle WiFi disturb it. And I think with the two gpio pins of 01 where one has a pullup and the other must not be low it is impossible.

In fact, I use ESP8266 with special requirements, the structure of my project is "ESP8266+Arduino Nano+TTL camera". because of the low SRAM of Arduino Nano and the limitation of physical space, I want to drive the camera directly on ESP8266.

and what will the Nano do?

Juraj:
Sorry, I meant the main HW serial RX and TX. You can use TX1 for debug prints over USB with adapter. I never used software serial with esp8266. I read that it doesn't work reliably. I think the interrupts to handle WiFi disturb it. And I think with the two gpio pins of 01 where one has a pullup and the other must not be low it is impossible.

But I also need Arduino Nano the control ESP8266 through self-defined words and get returning message by serial port , so the usable pins for me is GPIO0 and GPIO2. I want to find an approach to solve this problem.

Juraj:
and what will the Nano do?

Every business such as taking photos, accessing server and connecting to WIFI was written as functions in ESP8266, Arduino just send instructions and WIFI info got from Android APP through HC-05 Bluetooth Chip to ESP8266, Arduino also justify the delay of uploading sensors data from the returning message of ESP8266.

then you need a breakout board with esp8266 or buy an ESP32 dev board. it has WiFi, bluetooth and many pins

Juraj:
then you need a breakout board with esp8266 or buy an ESP32 dev board. it has WiFi, bluetooth and many pins

I don't know the SRAM of ESP32 is enough or not, for large photo transferring, it need a large space to create a byte array containing at least 2000 bytes for one time, if the array buffer is smaller than 2000 bytes maybe it will cost a long time to create and send a photo, it might be unacceptable.

maybe the esp8266 break board is not a good advice, because of the unsteady performance of software serial on esp

the ESP32 is a more capable successor of esp8266