当前位置: 首页 > news >正文

坪山网站建设渠道技术好的手机网站建设

坪山网站建设渠道,技术好的手机网站建设,做网站站长,WordPress图片关闭永久链接最近在做一个有趣的小场景功能,其实已经有成熟产品,但是考虑到没法实现场景扩展,所以自己开始动手做。 场景描述:玄关人体感应,有人进门,致欢迎词,有人离开,致欢送词。 硬件设备&a…

最近在做一个有趣的小场景功能,其实已经有成熟产品,但是考虑到没法实现场景扩展,所以自己开始动手做。

场景描述:玄关人体感应,有人进门,致欢迎词,有人离开,致欢送词。

硬件设备:WeMOS D1 + PIR 【HC-SR501 】 + Android手机

数据流:

从WeMOS D1开始

关于WeMos D1的参考链接:

Arduino文档阅读笔记-WeMos D1 ESP8266 WIFI开发板入门_wemos d1手册-CSDN博客

ArduiNo(WeMos D1)基础(一)_arduino d1-CSDN博客

ESP8266之WiFiClient库学习-CSDN博客

WeMos D1主要是是作为TCPClient,将接收到的PIR信息推送给android系统,并接收反馈信息

/*This sketch establishes a TCP connection to a "quote of the day" service.It sends a "hello" message, and then prints received data.
*/#include <ESP8266WiFi.h>#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endifconst char* ssid = STASSID;
const char* password = STAPSK;const char* host = "djxmmx.net";
const uint16_t port = 17;void setup() {Serial.begin(115200);// We start by connecting to a WiFi networkSerial.println();Serial.println();Serial.print("Connecting to ");Serial.println(ssid);/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,would try to act as both a client and an access-point and could causenetwork-issues with your other WiFi-devices on your WiFi-network. */WiFi.mode(WIFI_STA);WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {delay(500);Serial.print(".");}Serial.println("");Serial.println("WiFi connected");Serial.println("IP address: ");Serial.println(WiFi.localIP());
}void loop() {static bool wait = false;Serial.print("connecting to ");Serial.print(host);Serial.print(':');Serial.println(port);// Use WiFiClient class to create TCP connectionsWiFiClient client;if (!client.connect(host, port)) {Serial.println("connection failed");delay(5000);return;}// This will send a string to the serverSerial.println("sending data to server");if (client.connected()) { client.println("hello from ESP8266"); }// wait for data to be availableunsigned long timeout = millis();while (client.available() == 0) {if (millis() - timeout > 5000) {Serial.println(">>> Client Timeout !");client.stop();delay(60000);return;}}// Read all the lines of the reply from server and print them to SerialSerial.println("receiving from remote server");// not testing 'client.connected()' since we do not need to send data herewhile (client.available()) {char ch = static_cast<char>(client.read());Serial.print(ch);}// Close the connectionSerial.println();Serial.println("closing connection");client.stop();if (wait) {delay(300000);  // execute once every 5 minutes, don't flood remote service}wait = true;
}

PIR功能的开发测试链接:

在 Arduino 上使用 HC-SR501 人体热释电(PIR)传感器 – Arduino 实验室 (nxez.com)

其中的有些代码还是要调整的:

int pirPin = D5;  // PIR传感器连接的引脚void setup() {pinMode(pirPin, INPUT);  // 将PIR传感器引脚设置为输入模式pinMode(LED_BUILTIN, OUTPUT);Serial.begin(115200);      // 初始化串口通信
}void loop() {int pirValue = digitalRead(pirPin); // 读取PIR传感器的值if (pirValue == HIGH) { // 如果检测到运动digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)delay(1000);                       // wait for a seconddigitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOWdelay(1000);  Serial.println("Motion detected!"); // 在串口打印消息delay(1000); // 延迟1秒} else {digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOWdelay(1000);}
}

通过Android系统,搭建TCPServer接收 WeMos发送的PIR的测试信息.

Android功能待更新...

http://www.dtcms.com/a/475498.html

相关文章:

  • Lorax_linux构建软件
  • 网站建设管理维护责任书好看的团队官网源码
  • 不利于优化网站的因素wordpress做微信支付
  • wordpress快速加载企业网站seo优帮云
  • 马尾网站建设相册制作
  • 类和对象(类的默认6个成员函数以及操作符重载,日期类的实现)
  • Speedtest by Ookla:网速测速工具
  • 网站建设借鉴wordpress 教育主题
  • 百度怎么注册自己的网站湘潭企业网站建设 磐石网络
  • 基于加密技术的RFID标签数据安全保护方案
  • 培训心得网站建设互联网平台运营是做什么的
  • 辛集建设局网站优化方案英语
  • 网站建设采购项目王野天个人简历
  • 【微知】Mellanox mft工具的shell工具 mft-shell的基础用法(fw info、port info)
  • 集团网站网页模板腾讯云域名注册入口
  • wap网站建设公司互联网推广属于什么经营范围
  • 个人网站是什么意思一个人的免费高清影院
  • Go语言技术与应用(六):命令行工具开发基础
  • 网站建设通ipv6地址可以做网站吗
  • 北京网站设计工资多少西宁网站制作多少钱
  • 做张家界旅游网站多少钱苏州市市政建设管理处网站
  • 【图像处理基石】遥感图像地物识别从0到1:流程、实战与避坑指南
  • 西安集团网站建设趣丁号友情链接
  • sql优化之部分索引(Using index condition简称ICP)
  • 网站建设西安wordpress微交易
  • 滴滴出行网站建设Python爬取wordpress
  • 容器运维管理技能完全指南
  • 网站定位包括哪些内容电商是做什么的?
  • 网站开发的系统设计怎么写wordpress下载验证码
  • 前端开发者对AI的思考