pdf-icon

TimerCAM/Unit CAM - UIFlow

Feature Description

Use M5CORE devices to connect to TimerCAM/Unit CAM through the GROVE interface, enabling control over the camera to transmit images via UART for preview on the M5CORE screen, or to configure timed shooting for cloud upload (returning a fixed HTTP API).

Firmware Flashing

The default firmware of TimerCAM is not compatible with this application, so it is necessary to flash the camera with firmware that matches UIFlow before use. Note: The default firmware of UnitCAM is compatible with UIFlow and does not require re-flashing. For firmware flashing instructions, click here to view the tutorial and follow the image below to flash the firmware for your device .

UIFlow Block Usage Instructions

UIFlow supports configuring the camera to switch between UART and Wi-Fi modes. Wi-Fi mode supports timed shooting and automatic upload of images to the M5 cloud, returning the image call interface (URL). In UART mode, users can obtain image frames through UART communication with other control devices and modify image parameters. The CORE controller will be used as an example below, connecting to UnitCAM and retrieving image data.

UIFlow Block Function Description

Cloud Mode Functions:

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

  • Configure the interval for camera image upload to the cloud Set-unitcam-cloud-mode-upload-interval

  • Get camera Token Get-unitcam-cloud-token

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

UART Mode Functions:

  • In UART mode, start the thread for displaying images on the screen, with the default display coordinates at 0,0 Set-unitcam-image-show-in-screen

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

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

  • Command:

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

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

UIFlow Example Usage

Before using, click the add button in the bottom left corner to add the corresponding camera extension.
Example operation instructions:
Press button A to enable WiFi connection mode, connect to specified WiFi, the camera takes pictures every 5s and uploads them to the M5 cloud. Press button B to get the camera Token, and use this Token to generate a cloud image URL QR code.
Press button C to enable UART connection mode, configure the image size to 320*240, and start the image display thread to continuously refresh images on the screen.

Operation Video

Micropython API


import unit

# Create a 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)

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

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

# Get camera Token
unitcam_token = unitcam0.get_token()

# Concatenate fixed domain fields to get camera cloud image URL
unicam_image_url = 'camera.m5stack.com/timer-cam/image?tok=' + unitcam0.get_token()

# In UART mode, start the thread for displaying images on the screen, with the default display coordinates at 0,0
unitcam0.set_show(True)

# Set the camera return 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 the brightness of the Unit CAM onboard LED, value: 0~100
unitcam0.set_led_brightness(0)
On This Page