To provide low cost thermal image solution with Panasonic's 8x8 IR Grid-Eye detector, ESP32 , AWS IOT and serverless infrastructure.
Use case scenario
- Wild Fire alert
- Security with object detection
- Object maintenance monitoring
- Health temperature screening
- ESP32 SOC
- Panasonic's 8x8 IR Grid-Eye
- Sensor connectivity
- Software Development
- Arduino platform
- Library dependency
- AWS Cert
2. AWS Service
- AWS IOT
- Create thing
- Create policy
- Create certificate
- Configure IoT rules engine
- Create IoT rules role
- Create SNS Topic
- AWS Lambda
- Create Lambda execution role policy
- Perform Image processing
- Persist thermal image to S3
- Save sensor data to DynamoDB
- AWS Storage
- Setup new S3 bucket
- Setup DynamoDB table
Leverage on the WIFI capability of ESP32, this board will first make the connectivity to the AWS IOT network with 3 certificates issued during AWS thing registration
- A certificate for this thing
- A private key
- A root CA for AWS IoT
All 3 certs can be defined in a single certs.h file and imported into core Arduino program for MQTT client to initiate the connection with AWS IOT endpoint.
Once the connectivity is established, I will be calling Adafruit_AMG88xx readPixels() api to retrieve the reading of IR Infrared 8*8 Array(refer to data key below) from the sensor.
I also utilize ArduinoJson library to help us on Json serialization. The sensor key is set to name of sensor and batch key is set to current unix timestamp. The combination of both will be the key for DynamoDB record.
"data": ['21.2', '21.0', '21.0', '21.8', '21.5', '21.0', '21.5', '20.5',
'21.8', '21.8', '22.0', '21.5', '21.5', '21.8', '21.5', '21.8',
'21.8', '22.0', '21.5', '22.0', '21.8', '21.8', '21.5', '21.5',
'21.2', '21.8', '21.8', '21.8', '22.2', '21.8', '21.8', '22.0',
'21.5', '22.0', '22.0', '22.2', '22.2', '22.0', '21.8', '21.0',
'21.5', '22.0', '22.2', '22.5', '21.5', '21.5', '21.8', '21.5',
'21.8', '21.8', '22.2', '22.0', '22.0', '21.2', '21.8', '21.2',
'22.0', '21.8', '23.2', '22.2', '21.8', '22.0', '22.0', '21.0']
A local counter is also defined in the program so that we can control the frequency to publish MQTT topic.
AWS IoT rule is setup listening to the MQTT topic of IOT endpoint. Every message received in the topic will trigger to push SNS notification.
We setup our lambda to subscribe the SNS topic.
Lambda logic is written with Python 3.8.
I built a heatmap function to first construct a colour gradient range from 0(Blue) to 1023(Red) and map to the 8*8 matrix received from sensor.
The next step I use cubic interpolation to help us to convert from original low resolution 8*8 pixels into 32*32 pixels .
Finally to use the Python Image Library (PIL) to resize with anti-aliasing and flip the image before saving into S3 bucket.
Once the image data is successfully process, the thermal image is persisted into s3 bucket as JPEG and each of the sensor record is also saved into the DynamoDB.