Skip to content

begin(baud) might not work #25

Open
@MrBryonMiller

Description

@MrBryonMiller

begin(baud) does not work for a baud value other than 38400. (This is assuming you haven't done anything to change the camera's Flash or E2PROM values.)

The begin function sets the serial communication rate to the baud argument. It then issues a reset command over the serial interface.

There are two problems with this :

  1. if the baud argument does not match the rate the camera is currently set at then there can be no communication and the reset command will not be seen by the camera.

  2. Even if the baud argument does match the camera's current setting the 'reset' will change the camera to its default value of 38400 ensuring a mismatch between the serial interface and the camera thus preventing any further commands from working.

I ran into these problems when I had a sketch that did a begin() and later did a setBaud115200(). If I let the sketch run following a power-up it worked fine. But if I did a MCU reset (by pressing the MCU's reset button or simply by uploading a new sketch) the begin() failed. This is because when the sketch started to rerun the camera knew nothing about the reset hence it was still set at 115200 and the begin() command could not talk to the camera. If I changed the begin() to begin(115200) it could communicate and reset the camera, but as explained in 2), it was then mismatched after a complete power-up.

I solved my problem by 'searching' for the camera's baud setting by first trying a begin() and if not successful trying begin(115200). Once I had a successful begin() I knew the camera was at 38400 so I could set the serial rate also to 38400 and then could manually set my desired communication rate :

cam.setBaud115200();
Serial1.end(); // not sure this is needed
Serial1.begin(115200);

I wonder if the begin function should either not be used to set the baud rate or perhaps do something like I did...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions