In the pandemic situation aged people facing many problems, through this project I am going to share one of the problems solving, that is temperature monitoring with AWS IoT EduKit. More over that we can connect puls-oxymeter, heart rate sensor, so we will get all required data of a patient to monitor.
One of the symptoms of covid-19 is fever. So they have to check the temperature continuously. This project will help them to indicate the temperature and also upload the values in the AWS cloud. When the temperature is greater than the normal temperature it will indicate the Red otherwise it indicates the green.
This project is a sample model of temperature monitoring with AWS cloud. The project uses AWS IoT EduKit, LM35 and AWS server. The lm35 sensor may not be accurate.
First, we have to install AWS CLI and a programming IDE (like vscode, arduino). After installing AWS CLI open the terminal(i am using ubuntu
), and configure the AWS by
aws configure
then, it will show like this and give appropriate data
AWS Access Key ID [None]: EXAMPLEKEYIDEXAMPLE
AWS Secret Access Key [None]: EXAMPLEtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json
to get the endpoint date use the command below
aws iot describe-endpoint --endpoint-type iot:Data-ATS
then, use the credential in your device
ConfigureTo configure the AWS IoT EduKit, open the ide( I am using platform io
extension in visual studio code
), open new window and new platform io terminal, then open the aws registration folder and register by using this command( on pio-terminal)
python3 registration_helper.py -p <<DEVICE_PORT>>
Now, we have to configure the AWS IoT EduKit,
pio run --environment core2foraws --target menuconfig
Then select Component config–>Amazon Web Services IoT Platform and open AWS IoT Endpoint Hostname
, type your endpoint address and save, Now we have to setup wifi AWS IoT EduKit Configuration
from the menu. Set your WiFi SSID
and WiFi Password
, give appropriate data and save.
Then we have to enable AWS IoT EduKit I/O port. component config -> Core 2 for AWS Hardware enable
and enable the Expansion port A, B, C
To read the sensor, add this line
Core2ForAWS_Port_PinMode(PORT_B_ADC_PIN, ADC);
in this function
void app_main()
{
Core2ForAWS_Init();
Core2ForAWS_Display_SetBrightness(80);
Core2ForAWS_Port_PinMode(PORT_B_ADC_PIN, ADC);
ui_init();
initialise_wifi();
}
Reading the analog value
float sensor = Core2ForAWS_Port_B_ADC_ReadMilliVolts();
int temperature = sensor / 10;
in this function
static void publisher(AWS_IoT_Client *client, char *base_topic, uint16_t base_topic_len){
char cPayload[100];
int32_t i = 0;
IoT_Publish_Message_Params paramsQOS0;
IoT_Publish_Message_Params paramsQOS1;
paramsQOS0.qos = QOS0;
paramsQOS0.payload = (void *) cPayload;
paramsQOS0.isRetained = 0;
//temperature sensor
float sensor = Core2ForAWS_Port_B_ADC_ReadMilliVolts();
int temperature = sensor / 10;
if(temperature > 37){
Core2ForAWS_Sk6812_SetSideColor(SK6812_SIDE_LEFT, 0xff0000);
Core2ForAWS_Sk6812_SetSideColor(SK6812_SIDE_RIGHT, 0xff0000);
Core2ForAWS_Sk6812_Show();
}else{
Core2ForAWS_Sk6812_SetSideColor(SK6812_SIDE_LEFT, 0x00ff00);
Core2ForAWS_Sk6812_SetSideColor(SK6812_SIDE_RIGHT, 0x00ff00);
Core2ForAWS_Sk6812_Show();
}
cJSON *payload = cJSON_CreateObject();
cJSON *Temp_level = cJSON_CreateNumber(temperature);
cJSON_AddItemToObject(payload, "T-value C",Temp_level);
const char *JSONPayload = cJSON_Print(payload);
paramsQOS0.payload = (void *) JSONPayload;
paramsQOS0.payloadLen = strlen(JSONPayload);
// Publish and ignore if "ack" was received or from AWS IoT Core
sprintf(cPayload, "%s : %d ", "Hello from AWS IoT EduKit (QOS0)", i++);
paramsQOS0.payloadLen = strlen(cPayload);
IoT_Error_t rc = aws_iot_mqtt_publish(client, base_topic, base_topic_len, ¶msQOS0);
if (rc != SUCCESS){
ESP_LOGE(TAG, "Publish QOS0 error %i", rc);
rc = SUCCESS;
}
ui_textarea_add("%s", (char *)JSONPayload, paramsQOS0.payloadLen);
cJSON_Delete(payload);
paramsQOS1.qos = QOS1;
paramsQOS1.payload = (void *) cPayload;
paramsQOS1.isRetained = 0;
// Publish and check if "ack" was sent from AWS IoT Core
sprintf(cPayload, "%s : %d ", "Hello from AWS IoT EduKit (QOS1)", i++);
//sprintf(cPayload, Temp_level);
paramsQOS1.payloadLen = strlen(cPayload);
rc = aws_iot_mqtt_publish(client, base_topic, base_topic_len, ¶msQOS1);
if (rc == MQTT_REQUEST_TIMEOUT_ERROR) {
ESP_LOGW(TAG, "QOS1 publish ack not received.");
rc = SUCCESS;
}
}
so, we will get the temperature value. Now we can upload our code to the AWS IoT EduKit
UploadTo compile the firmware use this command on platform io terminal
pio run --environment core2foraws
To upload the firmware
pio run --environment core2foraws --target upload
Now ready to connect the Temperature sensor.
ConnectionThe AWS IoT EduKit has ADC pin, We are using the Port B.
connect the sensor in it.
Open the AWS IoT MQTT client
> Test
> MQTT
test client, then subscribe
using client id
. Then you can see the data send by the AWS IoT EduKit
We can add more sensors and monitor the patient's health status through the cloud. So we can take early precaution. This is the basic project, So I didn't add the graph plot on AWS cloud.
Comments