This sample demonstrates capturing a JPEG picture using ArduCAM mini 2MP PLUS SPI camera on Azure Sphere OS and upload the picture to Azure Blob service using libcurl to initiate Put Blob REST API with SAS authorization.
- To run this demo you need have a storage account and create a blob container
- Download Azure Storage Explorer and login with your Azure AD
- In Storage Explorer, navigate to your container icon and right click to Get Shared Access Signature, create a Ad-hoc Service SAS with at least Create and Write permission. Copy Query String to code
-
Ensure that your Azure Sphere device is connected to your PC, and your PC is connected to the internet.
-
Even if you've performed this set up previously, ensure that you have Azure Sphere SDK version 20.04 or above. In an Azure Sphere Developer Command Prompt, run azsphere show-version to check. Download and install the latest SDK as needed.
-
Open Azure Sphere Developer Command Prompt and issue the following command:
azsphere dev edv
-
The demo is tested on RDB, Starter Kit Rev1 and Starter Kit Rev2 boards. Connect camera as shown below. Detailed connections are:
ArduCAM mini 2MP Plus RDB Avnet SK Rev1/Rev2 SCL H2-7 Click 1: Header 2: Pin 5 SDA H2-1 Click 1: Header 2: Pin 6 VCC H3-3 Click 1: Header 1: Pin 7 GND H3-2 Click 1: Header 1: Pin 8 SCK H4-7 Click 1: Header 1: Pin 4 MISO H4-5 Click 1: Header 1: Pin 5 MOSI H4-11 Click 1: Header 1: Pin 6 CS H1-10 Click 1: Header 2: Pin 1
-
Start Visual Studio.
-
Open the CMakeLists.txt file
-
In main.c file, replace storageURL string with your stroage account name, SASToken string with the Query String your created, and pathFileName with your blob container name.
-
In app_manifest.json file, fill your own stroage account name in AllowedConnections capability.
-
Press F5 to build and debug the application
-
In Device Output window, you will observe below logs:
Remote debugging from host 192.168.35.1, port 55935 Exmaple to capture a JPEG image from ArduCAM mini 2MP Plus and send to Azure Blob ArduCAM mini 2MP Plus is found len = 8200 * Trying 52.239.223.132:443... * Connected to <your-storage-account>.blob.core.windows.net (52.239.223.132) port 443 (#0) * ALPN, offering http/1.1 * ALPN, server did not agree to a protocol * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 > PUT /auduino-pictures/img/b21ff595-2dba-469a-a37f-beb68757b12d.jpg<YourSharedAccessSignature> HTTP/1.1 Host: <your-storage-account>.blob.core.windows.net Accept: */* x-ms-blob-type:BlockBlob Content-Length: 8046 Expect: 100-continue * Mark bundle as not supporting multiuse < HTTP/1.1 100 Continue * We are completely uploaded and fine * Mark bundle as not supporting multiuse < HTTP/1.1 201 Created < Content-Length: 0 < Content-MD5: gb+b3lQnVLIIG/YPmA3Sgw== < Last-Modified: Tue, 17 Nov 2020 18:33:18 GMT < ETag: "0x8D88B27414D9FC0" < Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 < x-ms-request-id: 60898629-601e-003c-0910-bd5470000000 < x-ms-version: 2019-02-02 < x-ms-content-crc64: 4goS2PiDO4c= < x-ms-request-server-encrypted: true < Date: Tue, 17 Nov 2020 18:33:18 GMT < * Connection #0 to host <your-storage-account>.blob.core.windows.net left intact App Exit Child exited with status 0 unt>.blob.core.windows.net left intact
-
Go to Azure Storage Explorer and double click your container, a (Random GUID).jpg* will be listed. Double click the file to open and inspect the image.