I am programming the Edge board through the Arduino IDE and been working on two sketches that now I need to combine. Unfortunately, the sketches require different BSPs as stated in the subject.
The sketches are:
i) BLE sketch requiring 2.0.5.
Using 1.2.1, this sketch throws the error already when using
#include <ArduinoBLE.h>
C:\Users\jante\Documents\Arduino\libraries\ArduinoBLE\src/BLETypedCharacteristics.h:60:61: error: ‘word’ was not declared in this scope class BLEWordCharacteristic : public BLETypedCharacteristic { ^~~~ C:\Users\jante\Documents\Arduino\libraries\ArduinoBLE\src/BLETypedCharacteristics.h:60:65: error: template argument 1 is invalid class BLEWordCharacteristic : public BLETypedCharacteristic {
I guess I got too excited too fast. Indeed, the sketch Paul provided (as well as the original sketch) do compile and upload onto the Edge using Pauls modified HM01B0 lib and BSP 2.0.6.
However, inspecting the serial output or running the python script in the console, reveals that the camera does not start properly.
The output reads:
waiting for first frame b’\x00’ b’Turned on camera regulator\r\nCamera.begin() failed with code: 1\nCalibrating Auto Exposure…\r\n’
The error code is “1”, i.e. HM01B0_ERR throws the error. Looking at the cpp file in the library:
status = hm01b0_get_modelid(&cfg, &ui16ModelId); if( ui16ModelId != (uint16_t)HM01B0_MODEL_ID ){ status = HM01B0_ERR; }
It seems that there is a mismatch for the model ID. Paul, as you kindly provided the modified lib, does this give you any leads as to what causes the error?
As indicated before I do not have this camera, but just ordered one to play around with it. I looked at the code and there is some difference. Tthe error might happen earlier than you indicate as hm01b0_mclk_enable() does not return status in the new code. Put some Serial. print after each of the calls to when it fails.
Okay, thanks for the hint. I need to see how to debug the library, i.e. how to send Serial Prints out of the c++ file that I can see.
hm01b0_c.h (old lib) and hm01b0.h (new lib) are the files that contain the hm01b0_mclk_enable function and others. Comparing them, I notice that in the new lib, the body of the function is not there. I might be misunderstanding something entirely, but if not there, then where in the new lib is the body of these functions specified?
I got my camera and connected it. A number of issues:
Many double definitions and different definitions of structures while they have the same name in V1 and V2. Have cut down the original V1 library and use the code and definitions included in V2.0.6.
Power-on the camera with AM_BSP_GPIO_CAMERA_HM01B0_DVDDEN did not work. It is defined as D10 (GPIO10), but this is not defined as a Pinname in V2.06 ( only D1, D36, D38 and D3) Hence it failed. Would need a change in the Target PinNames.h and then a recompile of the MBED-OS library. Now replaced with other calls to set as output and high with different calls without the need to recompile the library.
It now starts and produces output. Have tried the Python interface and get some pictures, but they are not stable and do not make sense yet to me. But sharing the code for now so you can work on it as well. The code is still work in progress more work to be done.
finally… got it running BUT it needs a change in MBED-OS pre-compiled library. The reason is that V2.0.6 is getting regular interrupts to do “something” else . As a result on critical moments where every microsecond counts, the processor is interrupted and you lose the characters (pixel information) that are streamed from the camera. The picture is getting out of sync. By disabling interrupts on the critical moment you capture all the data. I have not tested this in combination with BLE etc.
I can follow the steps and the program also runs as you desrcibe it, also the Python script still runs and outputs a single image now.
However, it seems that the new libmbed-os does not seem to be compatible with BLE. Including only:
#include <ArduinoBLE.h>
leads to an error (attached). From the error message it seems that something in the mbed files in the BSP are not correct/sth is missing.