Monitoring Amazon Blink Cameras with AWS IoT Core, Lambda and Grafana Dashboard

Mustafa Kachwala
5 min readJun 24, 2021

This blog post describes a ‘hobby project’ showcasing capture of Amazon Blink camera sensor attributes like temperature, battery voltage, Wi-fi and low-frequency signal strengths, and visualizing them in a real-time dashboard for monitoring and alerts, leveraging AWS IoT core and compute services.

Amazon Blink Security Cameras

Amazon Blink cameras are wireless, smart home security cameras that provide cloud-based video storage. They can be remotely controlled by mobile app and provide host of features like configurable motion sensitivity, motion detection zones, two-way audio and infrared night vision.

‘Blink App’ uses (un-documented) APIs with JSON payloads to control, trigger, store and stream videos from cameras via a ‘command hub’.

We can leverage these APIs to fetch and monitor camera sensor attributes like ‘temperature’, battery voltage, Wi-Fi and low-frequency signal strengths which are not displayed on its mobile App.

AWS IoT Core

AWS IoT Core lets you connect IoT devices to the AWS cloud without the need to provision or manage servers.

Create AWS IoT ‘Thing’. Configure ‘IoT endpoint’ & MQTT Topic for publishing messages. Associate it with IoT Policy and download IoT ‘Thing’ IoT certificate, Public Key and Private key files.

Note: Amazon Root certificate will be downloaded by AWS IoT Python SDK

Fetch and publish sensor attributes to AWS IoT endpoint

Since Blink cameras cannot be programmed to run scripts, we use a custom python script along with ‘AWS IoT Python SDK’ running on a Laptop (or EC2 compute Instance) to substitute as ‘Edge Compute’.

The python script calls (un-official) Blink Camera APIs to:

  1. Authenticate using two-factor authentication

2. Share ‘Auth-token’ to identify authenticated client

3. Fetch camera sensor attributes by parsing result JSON payload

The python script also leverages downloaded IoT certificate, Public key, private key & root certificate to publish camera sensor attributes to IoT endpoint using MQTT protocol on port 8883

We can verify the messages are received at configured IoT end-point and their MQTT Topic ‘iot/camera/backyard’ using out-of-box AWS MQTT Test client

AWS IoT rule to insert camera sensor data in AWS Dynamo DB

Once messages are received at IoT endpoint, IoT rule engine evaluates inbound messages, transforms and delivers them to a cloud service, based on business rules defined. The IoT Rule query is as follows:

SELECT timestamp() AS timestamp, temperature, battery, wifi, lfr FROM ‘iot/camera/backyard’

In above example, AWS IoT rule engine uses ‘query statement’ to map JSON payload attributes to Dynamo DB columns and insert in Dynamo DB Table ‘device/backyard’. A timestamp attribute is also inserted which is the ‘partition key’ for the Dynamo DB table.

AWS IoT rule to log errors in CloudWatch Logs

IoT ‘Error action’ allows us to log all parsing, transformation or insertion related errors in CloudWatch Log group.

Visualize camera sensor attributes using CloudWatch Log Insights

AWS IoT rule engine can be used with ‘query statement’ to send JSON payload to CloudWatch. CloudWatch Log insights can parse JSON log data in-flight and discover fields which can be visualized in real-time dashboard.

Query for logs:

fields temperature, battery, wifi, lfr | sort @timestamp desc | limit 100

Query for dashboard:

stats avg(temperature), avg(battery), avg(wifi), avg(lfr) by bin(30s)

Insert camera sensor attributes in time series database (TSDB) using Lambda function

We can insert sensor attributes to a time series database like ‘Influx DB’ running on a EC2 t2.micro instance. To enable this, IoT rule engine can send messages to Lambda function. The Lambda function needs to be configured to have node.js modules and InfluxDB client libraries to perform DB Insert operations. InfluxDB config parameters like hostname, DB username, DB password and port can be configured as Lambda environment variables.

Visualize camera sensor attributes in Grafana dashboard

We can visualize and monitor ‘camera sensor’ attributes like Temperature, Battery Voltage, Wi-fi and Low-frequency signal strengths on ‘Grafana dashboard’ running on same EC2 t2.micro instance. We can add various widgets to query, visualize and alert on thresholds for each sensor attribute using its ‘last-received’ or ‘moving-average’ values.

AWS IoT architecture diagram

Above is a high-level architecture diagram showing various components and cloud services used in this example.

--

--