×

使用M5Stack Core2 ESP32的公共空间安全激励器

消耗积分:0 | 格式:zip | 大小:0.03 MB | 2022-11-04

李秀珍

分享资料个

描述

我们知道,世界正在经历大流行浪潮。一旦锁定打开下一波周期性的到来。口罩,社会距离,消毒,疫苗接种这些是解决这个问题的主要解决方案。一旦解锁国家,人们将走出去满足他们无法停止的需求。人们会去公共办公室满足他们的需要。人们必须去商店购买。甚至他们也必须使用自己办公楼的厕所。人们会逐渐减少预防措施。即使消毒剂在他们面前,他们也会跳过手部消毒。

现有的解决方案是采取预防措施的海报和标牌。每个人都知道,为了防止covid传播,口罩、消毒、社交距离是解决方案。但随着时间的推移,人们会减少预防措施。他们不会正确戴上口罩,他们会犹豫消毒即使消毒剂在前面。造成这种情况的主要原因是人们只会认为(即使他们知道这是错误的)我不会被感染,电晕已经消失,就像那样。解决方案是每次都向他们展示真实数据,我提出了一种设备,它可以像现有自动化系统的附加组件一样。设备将提供有关特定空间以及国家和地方 covid 更新的信息,实时数据将鼓励人们采取预防措施而不会失败。

用于 aws IoT EduKit 的 core2 将用于制作一个设备,该设备将成为其他设备网络的一部分,并将显示实时数据,例如 1. 在新人进入“您是今天使用此设施的第 XXX 个人。请保持手部消毒并戴上你的面具”可以从另一个连接的计数设备/门传感器等中获取计数 2.设备将显示国家/地区的 covid 统计数据(每日病例、病例总数、死亡人数等),这将鼓励访客认真采取预防措施. 3.如果设备在商店店主可以设置自定义消息和显示除了covid更新4.设备将报警如果任何高温人员进入设施。数据将来自连接的人员温度监视器入口。

访客体温读数模块

这个模块/设备将帮助商店/建筑物/空间监测访客的温度。现在我已经使用粒子光子和温度传感器完成了这项工作。

为此,我们需要开发一个代码来读取温度并将警报消息发送到 aws iot core mqtt 主题,该主题将由我们的 m5 堆栈核心 2 订阅。

#include 


#include 


//#include "ArduinoJson.h"      //Library for parsing JSON object

// This #include statement was automatically added by the Particle IDE.
//#include 

//SYSTEM_THREAD(DISABLED);


void callback(char* topic, byte* payload, unsigned int length);
void BlinkLed(int LedPin, int BlinkTimes, int BlinkPeriod);    //A func to blink LED
String FormMQTTPayload(int reading1, double reading2);         //A func to create JSON object

#define AMAZON_IOT_ROOT_CA_PEM                                          \
"-----BEGIN CERTIFICATE-----\r\n"  \
"MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\r\n"  \
"ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\r\n"  \
"b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\r\n"  \
"MAkGA1UEBhMCVsVMxDzANBgNVwrwrBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\r\n"  \
"b3QgQ0EgMTCCASIwDQYJKoZwrgwerggvwIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\r\n"  \
"ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\r\n"  \
"9O6II8c+6zf1tRn4SWitgikugiuguigwwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\r\n"  \
"A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\r\n"  \
"U5PMCCjjmCXPI6T53iHTfvIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\r\n"  \
"N+gDS63pYaACbvXy8MWy7Vu33PfffqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\r\n"  \
"o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XzV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\r\n"  \
"5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\r\n"  \
"rqXRfboQnoZsG4q5WTP468SQvvG5\r\n"  \
"-----END CERTIFICATE-----"
const char amazonIoTRootCaPem[] = AMAZON_IOT_ROOT_CA_PEM;

#define CELINT_KEY_CRT_PEM                                              \
"-----BEGIN CERTIFICATE-----\r\n"  \
"MIIDWjCCAkKgAwIBAgIVAIFV6RQ25r0k13o+nTThox0khQ1tMA0GCSqGSIb3DQEB\r\n"  \
"CwUAME0xSzBJBgNVBAsMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29t\r\n"  \
"IEluYy4gTD1TZWF0dGxlIFNUPVdhc2hpbmd0b24gQz1VUzAeFw0yMTA5MDgxMTAx\r\n"  \
"MjBaFw00OTEyMzEyMzU5NTlaMB34xHDAaBgNVBAMME0FXUyBJb1QgQ2VydGlmaWNh\r\n"  \
"dGUwggEiMA0GCSqGSIbw3DQEBAQUAA4IBDwAwggEKAoIBAQDJIEcvn8CKMXynu2GL\r\n"  \
"sQ4KHcn5yyNOBJcNToj6KV+iEXvzqnOwtOEw2FbQh6123TNoKcoIXr+srstUGWoPV\r\n"  \
"VrVlZ7JkZqNO7dwxsS0RETq7MrZdTMblKO18WAVXW8jiGBPjvt58DNawYxkhi/vMfk\r\n"  \
"VthZnQXNrzVdyF8DgsL1QeBMupWMEVkGLBA3M7Xlzwedu3OWrJR4pX+l7XLvvbFn\r\n"  \
"ioami/GMZg6RsjTbWhdPbLWLM9aHWRDJcOYefL4JrG1wEcJgrxsBZsDGZNUQbZp4\r\n"  \
"ZR/jTrD8YmZ3a8TmmS2WBWjx/f66DHXVoD5F2OjsRdMdhPDWGUwhD5O4DPxKgvQ46\r\n"  \
"xNkhAgMBAAGjYDBeMB8GA1UdIwQYMBaAFJlO/vDfND/PFXZ6RlK7CEIGuzyHMB0G\r\n"  \
"A1UdDgQWBBTfbtSBke3mZ20EpO0E+K6se85NSBTAMBgNVHRMBAf8EAjAAMA4GA1Ud\r\n"  \
"DwEB/wQEAwIHgDANBgksqhkiG9w0BAQsFAAOCAQEAoPWUDCIqL/bi+Nd4rWX/6ar5\r\n"  \
"IZnYC+BKWiD5PjZzfOssshfx9gqa1XqCl8/6x5vqilwQoMN8phvjdy1GQvUGjOe6\r\n"  \
"MIQjwJ+SuOQ1B2rCdPT7w8EZsMTVgfUeWsdfhL5U9GVnPipkqt3OIgAU/Mw/7Jz0XAJd\r\n"  \
"QCCojsASLbK8WkCjXBPHmIAzwwa9VBi0rjWJIgckgmz9RuRRzLt5p/F0pTy6epPB\r\n"  \
"bblBCoo9yxlwWPXY2AFmHs2is7HcqSB1puK0qrzy3MTBmDxsPWY1wrRngmxipMSPL\r\n"  \
"Ebtq8U8V3JpIF7dEuiAAXMnXjsE8UM93ZBGHwwApCH719g43UKZh3tfHimUgjg==\r\n"  \
"-----END CERTIFICATE-----" 
const char clientKeyCrtPem[] = CELINT_KEY_CRT_PEM;

#define CELINT_KEY_PEM                                                  \
"-----BEGIN RSA PRIVATE KEY-----\r\n"  \
"MIIEowIBAAKCAQEA5osqGO8Ah0LEIlnnxvnzJk1x1YbfuC7Ma4nVNQu4wJWeU01W\r\n"  \
"0nUvRVotuWSmftvxqPzSeBzc6eq4g0XqkYpxTe6DtmrrboxRqFWrh7LAkQ9Bp+tW\r\n"  \
"lsX0DtrjUZjCSAdGEgNsOiFK+IPHRx2x2OTVpyAN1wZMy+o3uJ3o17XciRbWMobc\r\n"  \
"jCaRc024GiMcJCyjvdkKioiTwsfrtwcM1gMofA6UhN+WhQD1yxlAE63uiKCavcfsJ/Ed\r\n"  \
"T4GMDmShYpA/8vh5cECIhgHYHyToYCuutO+3Ogahv5I+zzruhKZ4p5+DRi6BaI3L\r\n"  \
"JLePjCyyPlDUN0kipZm+TuZ9533rrwAnYWO5ZMWsoQIDAQABAoIBAQC4aknaeBSsHjRW\r\n"  \
"ZiSJfheKZBjS/XioFIdg3ni2XhIDu6tSZ2M0JpkRmPlKe8DTaYz96H9TpYLxetjt\r\n"  \
"6Veh5GSOOmUR3qVFYOlRBnaXrd1sLBARCqfRI7f+yglclB2VEHx0nFhOh6M49/DI\r\n"  \
"anCBV0uw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X\r\n"  \
"2TEJqYVTNeK6Lx2Chp7mn4bdMA0ZFzFT7ITCGyzo9jQK7rL5vKCqdXuj/P/odj84\r\n"  \
"lrLDoz0qZFO9IR2s6swtceT/tQwO53Qkp8FBDMREd5MQhUIJe1bw\r\n"  \
"-----END RSA PRIVATE KEY-----"
const char clientKeyPem[] = CELINT_KEY_PEM;

/**
 * if want to use IP address,
 * byte server[] = { XXX,XXX,XXX,XXX };
 * MQTT client(server, 1883, callback);
 * want to use domain name,
 * MQTT client("www.sample.com", 1883, callback);
 **/
//MQTT client("Your AWS IoT Thing ReST API Endpoint", 8883, callback); //set ReST API endpoint

//Set keep-alive timeout as 60sec. Default is 15sec. 
MQTT client("a1pk8vviACFAScasldsscsafacblpi-ats.iot.ap-south-1.amazonaws.com", 8883, 60, callback); //set ReST API endpoint 
const int thermistor_output = A0;
//#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)
//unsigned long lastSync = millis();
float celcius1, celcius2, celcius3, celcius4;
int high_temperture_alert = 0;   //DummyData used here. Revise this for your own need. 
int LedIndicator_Publish = D7;   //set LED D7 as publishing indicator
int LedIndicator_CommLow = D6;   //set LED connected on D6 as indicator for command “turnlowâ€
int LedIndicator_CommMid = D5;   //set LED connected on D6 as indicator for command “turnmidâ€
int LedIndicator_CommHigh = D4;  //set LED connected on D6 as indicator for command “turnhighâ€

void setup() {Serial.begin(9600);
    // enable tls. set Root CA pem, private key file.
    client.enableTls(amazonIoTRootCaPem, sizeof(amazonIoTRootCaPem),
                     clientKeyCrtPem, sizeof(clientKeyCrtPem),
                     clientKeyPem, sizeof(clientKeyPem));
				 
Serial.println("tls enable");

// connect to the server
client.connect("sparkclient");

// publish/subscribe
if (client.isConnected()) {
    Serial.println("client connected");
    client.publish("alert", "hello world!");
    client.subscribe("myfirstthing/intest");
}
}

void loop() { int thermistor_adc_val = analogRead(thermistor_output);
     int Vo = thermistor_adc_val;
                                    Vo=4095-Vo;
                                    float R2 = (10000 * (4095.0 / (float)Vo - 1.0));
                                    float logR2 = log(R2);
                                    float T = (1.0 / ((1.039292445e-03) + (2.512639704e-04)*logR2 + (0.006364887727e-07)*logR2*logR2*logR2));
                                    celcius4 = (T - 273.15);
                                 
    if (client.isConnected()) {
        client.loop();
        if (celcius4>37.6){
         client.publish("alert", "alert");
         digitalWrite(D7,HIGH);}
    }
    delay(200);
}
//The func to form a JSON formatted payload
String FormMQTTPayload(int reading1, double reading2=0.0) 
{
  String retnstring = "{";
  retnstring += "\"Sensor1\":";
  retnstring += "\""+String(reading1)+"\",";
  retnstring += "\"Sensor2\":";
  retnstring += "\""+String(reading2)+"\",";
  //retnstring += "\"Sensor3\":";
  //retnstring += "\""+String(reading3)+"\","; 
  retnstring += "}";

  return retnstring;
}

// callback func to process/resp recieved commands sent from AWS IoT
void callback(char* topic, byte* payload, unsigned int length) {
    char p[length + 1];
    memcpy(p, payload, length);
    p[length] = NULL;
    String message(p);
}


//A func to blink a LED for BlinkTimes
void BlinkLed(int LedPin, int BlinkTimes, int BlinkPeriod) 
{
  for (int k=0; k
      digitalWrite(LedPin, HIGH);
      delay(BlinkPeriod);
      digitalWrite(LedPin, LOW);
      delay(BlinkPeriod);
  }    
}

如果任何高温人员进入太空,该设备将发送警报 AWS iot core mqtt。m5stack 将通过声音和灯光显示该信息。

 
 
 
pYYBAGNkfiWAYKLiAAKRq8lSxd0628.jpg
 
1 / 2
 
poYBAGNkfimATS8qAAHExEyDoBg628.jpg
 
 
 
 
poYBAGNkfi6AVVIDAAO1luR2dwA412.jpg
 
1 / 2
 
pYYBAGNkfjKAR-xjAASdzvaGG2I111.jpg
 

M5堆栈设备

这里我使用 m5 堆栈作为连接到 aws iot core mqtt 的显示单元。对于基本代码,我修改了 sdk 中的闪烁代码。

首先,我们必须为 LED 动画和声音警报创建一些任务。一旦在警报主题收到任何消息,这将触发。警报消息来自我们基于粒子光子的温带监测设备。

poYBAGNkfjeAajAFAAUbBEoULN8004.jpg
 
pYYBAGNkfjyAJC3iAAN58DhM3Mo197.jpg
 

经理可以通过 aws iot mqtt 测试客户端发送他的消息。他可以使用此接口向客户端提供信息,

 

poYBAGNkfj6AFEMbAAFgYaqmZ1U149.png
 

每小时屏幕将显示在印度传播的冠状病毒的静态状态。这将激励人们戴口罩和使用消毒剂。

 

屏幕将循环显示covid意识消息。


声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !