TimerCAM/Unit CAM - UIFlow

Function description

Use M5CORE type equipment to connect TimerCAM/Unit CAM through GROVE interface, realize command control camera UART to transmit images and preview on M5CORE screen, or configure timed shooting upload cloud function (return to fixed HTTP API).

Firmware burning

The default factory firmware of TimerCAM is not suitable for the application, so you need to burn the firmware matching UIFlow for the camera before use. Note: The factory firmware of UnitCAM is compatible with UIFlow by default, so there is no need to burn again. If you need to re-flash the firmware, you can click here to view the flashing tutorial, and flash the firmware matching the device used according to the figure below .

UIFlow Block Instructions

UIFlow supports the configuration of the camera to switch between UART and Wi-Fi working modes. WiFi mode supports timed shooting and automatically uploads pictures to the M5 cloud and returns to the picture calling interface (URL). Under UART mode, users can use other master devices to obtain picture frames through UART communication and modify picture parameters. The following will use the main control CORE as a case to connect to UnitCAM and obtain image data.

UIFlow Block function description

Cloud Mode Functions:

  • Configure the camera to connect to the designated WiFi Set-unitcam-connect-wifi-ssid

  • Configure the upload interval of camera pictures to the cloud Set-unitcam-cloud-mode-upload-interval

  • Get camera Token Get-unitcam-cloud-token

  • Get the URL of the camera cloud image Get-unitcam-cloud-image-url

UART Mode Functions:

  • In UART mode, start the screen display image thread, the default display coordinates are 0,0 `Set-unitcam-image-show-in-screen

  • Set the camera to return the image size Set-unitcam-image-size

  • Set the image display position Set-unitcam-image-position-x-y

Command:

  • Switch UART/CLOUD mode Switch-unitcam-mode-to-UART/CLOUD

  • Set the brightness of the onboard LED of the camera Set-unitcam, led-brightness

UIFlow Use Case

Before use, you need to click the add button in the lower left corner to add the corresponding camera extension.
Case operation instructions:
Key A to enable WiFi connection mode, connect to the designated WiFi, the camera will take pictures at 5s intervals and upload them to the M5 cloud, and key B will get the camera Token, and use the cloud image URL generated by the Token to create a two-dimensional code.
Press C to enable UART connection mode, configure the picture size to be 320*240, and start the picture display thread to continuously refresh the picture to the screen.

Video

Micropython API


import unit

#Create unitcam instance
unitcam0 = unit.get(unit.UNITCAM, unit.PORTB)

#UART Mode: unitcam0.UART_MODE
#WIFI mode: unitcam0.CLOUD_MODE
unitcam0.set_mode(unitcam0.UART_MODE)

#WiFi mode, configure the camera to connect to the specified WiFi
unitcam0.set_wifi('','')

#WiFi mode, configure the camera image upload cloud interval
unitcam0.set_upload_time(5)

#Get camera token
unitcam_token = unitcam0.get_token()

#Stitching a fixed domain name field to get the URL of the camera cloud image
unicam_image_url ='camera.m5stack.com/timer-cam/image?tok=' + unitcam0.get_token()

#UART mode, start the screen display image thread, the default display coordinates are 0,0
unitcam0.set_show(True)

#Set the camera to return the image size
#unitcam0.SIZE_800_600
#unitcam0.SIZE_640_480
#unitcam0.SIZE_320_240
#unitcam0.SIZE_240_240
#unitcam0.SIZE_160_120
unitcam0.set_image_size(unitcam0.SIZE_320_240)


#Set Unit CAM onboard LED brightness value: 0~100
unitcam0.set_led_brightness(0)
On This Page