Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By joshbg2k
#62368 I am really confused about behavior I'm observing with my application. I am trying to control 10 cameras through USB serial on a NodeMCU board. I am new to ESP8266 (this is my first project beyond simple examples), but accustomed to the Arduino platform, and I'm not an electrical engineer, so bear with me. We want to try to stick to the NodeMCU board because of all the advantages it has over Arduino.

The application works as expected if I power on the device and then hook up the cameras. If I power on the device with the cameras plugged in, the device appears to shut down. I think this is true because some of the inputs I use are associated with the onboard LEDs, and when I power it on in this manner, the LEDs go down and I can't talk to the cameras anymore. I haven't experienced these kinds of issues on proper Arduino boards, so I am hoping that it's an issue with my code setup.

I've paired down my code to just one IO pin set up, and the application behaves the same way. Here is that code:

Code: Select all#define TOTAL_CAMERAS 1
#define CAMERA_0 0    //D3

int cameras[TOTAL_CAMERAS] = {
  CAMERA_0
};

char val; //the incoming serial byte

void setup() {
  Serial.begin(115200);
  pinMode(CAMERA_0, FUNCTION_0);
  pinMode(CAMERA_0, OUTPUT);
  delay(10);
}
 
void loop() {
  while (Serial.available()) {
    val = Serial.read();
    int camera = val - '0';
    if (camera >= 0 && camera < TOTAL_CAMERAS) {
      fireCamera(cameras[camera]);
      Serial.println("fire single camera");
    }
  }
  delay(10);
}

void fireCamera(int camera) {
  digitalWrite(camera, HIGH);
  delay(SHUTTER_DELAY);
  digitalWrite(camera, LOW);
}


Can you see anything obviously wrong in that code that would cause my app to behave this way> I've gone over my circuit fairly thoroughly, and I think it's OK, but if it's not I can get more in depth with information about that. Thanks very much!
User avatar
By rudy
#62374 On power up some of the I/O lines are used to determine the boot mode. D0 and D2 must be high and D15 must be low in order to run the code to run your code. After the initial start they are available for use.

When loading your code D0 has to be low, D2 high, and D10 has to be low at reset.
User avatar
By joshbg2k
#62376 Thanks, that explains a lot. I knew something like that had to be going on, I just didn't know where to track down that documentation.

So would I simply set those values in the setup function? And would my pin function settings on any of those pins prevent this from working? Thanks again.