自製IOT紅外線額溫槍

因為小孩學校要求天天要量兩次體溫, 額溫槍目前應該完全買不到, 所以就自己動手做, 還可以有wifi direct功能, 可以透過手機連上用Browser查詢過去10次量測的溫度紀錄, 具有IOT功能, 材料費約500元, 不過近期內MCU90615紅外線人體Sensor價格天天在上漲, 很多供應商也一直缺貨中, 一料難求, 所以目前製作成本會筆我當初買的時候更高.

 

 

BOM

1. 萬孔板
2. 無段開關
3. 100K電阻
4. 排針母座 1*16P 2個
5. 90度排針母座 1*4P 2個
6. MCU90615
7. 0.96吋 I2C OLED
8. NodeMCU 開發板 ESP8266 WiFi ESP-12E cp2102

電路

Schematic_esptsm_ESP8266_20200311012836

Arduino程式碼 https://github.com/ChenKaiJung/esptsm


#include 
#include 
#include 
#include
#include 
#include "SSD1306Wire.h"
#include "images.h"

/* Set these to your desired credentials. */
const char *ssid = "ESPTSMOLED";
const char *password = "12345678";

ESP8266WebServer server(80);
SoftwareSerial sSerial(2, 0);
SSD1306Wire display(0x3c, SDA, SCL);

float temperture[10] = {NAN,NAN,NAN,NAN,NAN,NAN,NAN,NAN,NAN,NAN};
unsigned int tp = 0;
float envTemperture[10] = {NAN,NAN,NAN,NAN,NAN,NAN,NAN,NAN,NAN,NAN};
unsigned int ep = 0;
unsigned char output[37];
unsigned char to[2];
unsigned char ta[2];
char buff[1024];
char dispbuf[128];

void handleRoot() {

char temp[256];
unsigned int pf=0;
int ttp=tp;

//Serial.println();
//Serial.print("ttp:");
//Serial.print(ttp);
if(ttp!=0) {
for( int i=ttp-1;i>=0;i--){
sprintf(temp, "
<h1><font size="7">Temperture is: %.2f</font></h1>
", temperture[i]);
strncpy(&amp;buff[pf],temp,strlen(temp));
pf=pf+strlen(temp);
Serial.println();
Serial.print("temperture:");
Serial.print(temperture[i]);
Serial.println();
Serial.print("i:");
Serial.print(i);
}
}
//Serial.println();
//Serial.print("ttp:");
//Serial.print(ttp);

if(ttp!=9) {
for( int i=9;i&gt;=ttp;i--){
sprintf(temp, "
<h1><font size="7">Temperture is: %.2f</font></h1>
", temperture[i]);
strncpy(&amp;buff[pf],temp,strlen(temp));
pf=pf+strlen(temp);
//Serial.println();
//Serial.print("temperture:");
//Serial.print(temperture[i]);

// Serial.println();
//Serial.print("i:");
//Serial.print(i);
}
}
server.send(200, "text/html", buff);
}

unsigned char checksum(unsigned char* buffer) {
unsigned char *buf = (unsigned char *)buffer;
unsigned int seed;
seed = buffer[0] + buffer[1] + buffer[2] + buffer[3] + buffer[4] + buffer[5] + buffer[6] + buffer[7];
unsigned char result = (unsigned char)seed &amp; 0xff;
return result;
}

void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid, password);

IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);

server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");

sSerial.begin(115200);
//sSerial.write(0xA5);
//sSerial.write(0x45);
//sSerial.write(0xEA);

display.init();
//display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);

pinMode(16, INPUT);
}
void loop() {
server.handleClient();

int keyin=digitalRead(16);
//Serial.println();
//Serial.print(keyin);
if(keyin==1) {
sSerial.write(0xA5);
sSerial.write(0x15);
sSerial.write(0xBA);
}

if (sSerial.available() == false) {
return;
}

display.clear();
display.drawXbm(15, 0, da_width, da_height, da_bits);
Serial.println();
Serial.print("Taking Readings:");
for (int counter = 0; counter &lt;= 36; counter++) {
output[counter] = (unsigned char)sSerial.read();
Serial.print(output[counter], HEX);;
}

for (int obj = 0; obj &lt;= 36; obj++) {

if (output[obj] != 0x5A
|| output[obj + 2] != 0x45
|| output[obj + 3] != 0x04
|| output[obj + 8] != checksum(&amp;output[obj])) {
delay(100);
continue;
}
to[0] = output[obj + 4];
to[1] = output[obj + 5];
unsigned int total = to[0] &lt;9) {
tp=0;
}

ta[0] = output[obj + 6];
ta[1] = output[obj + 7];

total = ta[0] &lt;9) {
ep=0;
}
}

delay(100);
}

One thought on “自製IOT紅外線額溫槍”

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com 標誌

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Google photo

您的留言將使用 Google 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 /  變更 )

連結到 %s