Amazon FreeRTOS Workshop

Logo

Amazon Freertos workshop using the M5 StickC

View the Project on GitHub onsankawai/amazon-freertos-m5stickc-workshop

31 October 2019 by teuteuguy

Lab 2 - Interract with the Thing

It’s the summer, and its hot outside. Lets play around with remove controlled Air Conditioning units.

For this lab, our M5StickC will act as our Air Conditioning unit.

You can turn the AirCon ON or OFF remotely as well as set a target temperature.

  • If the AirCon is OFF, the temperature will rise to a stable 40 deg celcius.
  • If the AirCon is ON, the temperature will decrease to reach your chosen temperature

Thing

Configuration

In order to configure the code and your M5StickC for Lab2, you must change the following lines of code:

In file: ./amazon-freertos/vendors/espressif/boards/m5stickc/aws_demos/application_code/m5stickc_lab_config.h

Change the LAB define to: M5CONFIG_LAB2_SHADOW

Replace:
#define M5CONFIG_LAB0_DEEP_SLEEP_BUTTON_WAKEUP

With:
#define M5CONFIG_LAB2_SHADOW

Rebuild Code

cd ./amazon-freertos/vendors/espressif/boards/m5stickc/aws_demos
make all -j4

Flash Code

Please follow the procedure form the following Setup guide.

Result

Log into your AWS IoT Management console, and open up your Thing.

Click on Shadow.

  1. The device should have reported it’s first state at this point and your shadow document should look something like:
{
	"reported": {
		"powerOn": 0,
		"temperature": 40
	}
}
  1. Edit this shadow document, on the page with the following:
{
	"desired": {
		"powerOn": 1,
		"temperature": 22
	}
}

This should instantly result in a compiled shadow document looking something like:

{
	"desired": {
		"powerOn": 1,
		"temperature": 22
	},
	"reported": {
		"powerOn": 0,
		"temperature": 40
	},
	"delta": {
		"powerOn": 1,
		"temperature": 22
	}
}

Whatch how now that you have turned on your Air Con, the temperature will slowly decrease to your set value.

Note: Be carefull when setting the temperature value. The code only supports positive integer values. Do not use a floating point value.

categories: lab tags: iot-core - shadow