Skip to main content

12 posts tagged with "AWS"

AWS

View All Tags

Smart Cat Feeder – Part 1

· 3 min read
Chiwai Chan
Tinkerer

If you are forgetful when it comes to feeding your fur babies like me, and you often only realise you need to put some dry food into the bowl when you are at work then you should read these series of blogs. Over time, I'll be designing and building a smart cat feeder over time using a combination of components such as Arduino micro controllers, motors, sensors and IoT devices and Cloud services. I'll publish the steps taken in these series of blogs, also, I'll publish any designs and source code as I figure things out and make decisions on aspects of the design.

In this part 1 of the series, I will do a walkthrough on setting up an AWS IoT 1-Click device to trigger a Lambda Function. I got myself one of these Seeed IoT buttons for $20; I also bought a NCR18650B battery which I realised later on is only required if I wanted to run the device without it being powered by a USB type-C cable (used for charging the power as well).

seeed iot button for aws

Firstly, make sure you have an AWS account. Then install the AWS IoT1-Click app onto your phone and log in using your AWS account. With these we will be able to link IoT devices up to our AWS account.

aws iot app login

Claim the IoT device with Device ID

aws iot app claim

Scan the barcode on the back of the device; you can scan multiple devices in bulk.

aws iot app scan aws iot app added aws iot app complete claim aws iot app claim wait for click

Next, I'll set up the Wifi on the device so that it can reach the internet internet from home. Can't see why I can't set it up to my phone's AP for feeding on the go, I'll try it out some other time.

aws iot app wifi

Now we'll create a project and add the IoT device to a placement group in the AWS Console. Give a name and description for the project.

aws iot new project

Next define a template, this is where we create a Lambda function; all the plumbing between the IoT device and Lambda will be handled for us.

aws iot project template

Next we create a placement for the Iot device.

aws iot project placement

aws iot project new placement

aws iot project placement created

Since I have no Arduino micro-controllers (have yet to buy one), I will get the Lambda to log a message.

aws iot lambda

Push the button on the Iot device, wait for the event LED status to turn green after flashing white then check the logs CloudWatch Logs.

aws iot lambda logs

At some point I have to code the Lambda to perform a real action as each event comes through, which will be demonstrated in a following blog in the series instead of just logging to CloudWatch logs.

Within the app on your phone you can see status of each IoT device such as the remaining battery life percentage.

aws iot app devices

As well as a history of the button's events.

aws iot app device events

In the next blog, I'll configure the Lambda to push the event to a Topic for AWS IoT Core to subscribe to, which in turns will trigger an event to an ESP32 ( I've yet to decide on a specific version of the micro-controller) using the IoT MQTT protocol.

Storing Electricity Price Data on AWS

· 2 min read
Chiwai Chan
Tinkerer

For a personal project of mine, I like to be able to analyse the pattern of New Zealand's electricity Spot Prices; to identify the cheapest hours during the day to pull power from the grid, as well as, the best time of the day to sell back to the grid.

I will be creating a series of blogs as I build out the fragments of my project. Over time, I will integrate the individual fragments into a bigger overall solution. One of the drivers for analysing the New Zealand Spot Prices: is the aim in reducing the payback period of my Solar and Tesla Powerwall purchase. I have had the 2 systems for over a year at the time when this blog was published.

In this blog, I will explain how I will be collecting Spot Prices from electricityinfo.co.nz using one of their APIs; each Spot Price data reading will then be stored as a JSON file in an S3 bucket where it will be query-able using SQL. Using the same pattern, I will also track the actual cost per unit of power I am paying for from pulling power from the grid, my electricity provider is Flick Electric and I will also leverage their APIs to retrieve the pricing data.

power price reporting

An architecture diagram of the solution. The orchestration of retrieval and storage of the data using AWS serverless components.

query-athena

Querying price data stored as JSON file in an S3 bucket using SQL in Athena.

The source code for this AWS SAM project can be found in my Github repository: https://github.com/chiwaichan/athena-spot-prices

In order for this solution to work you must have a set of credentials for Flick Electric, otherwise you can modify the SAM template to disable the Lambda Function's scheduler that triggers the Lambda to retrieve data. This Lambda function retrieves the credentials from AWS Secrets Manager, so you will need to create a Secret before deploying this solution as demonstrated in the AWS CLI shown in the screenshot below.

create secrets manager value

In a follow up blog, I will demonstrate the use of these Athena tables using a reporting service called QuickSight.