小试牛刀 WiFi 远控 + wendu
废话 少说 直接上代码
DH11三根线 信号线 接2
WiFi 模块 r-------t
t--------r
en&vcc------3.3v
剩下的
共地的啦
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
} //摄氏温度度转化为华氏温度
double Kelvin(double celsius)
{
return celsius + 273.15;
} //摄氏温度转化为开氏温度
// 露点(点在此温度时,空气饱和并产生露珠)
// 参考: [url=http://wahiduddin.net/calc/density_algorithms.htm]http://wahiduddin.net/calc/density_algorithms.htm[/url]
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}
// 快速计算露点,速度是5倍dewPoint()
// 参考: [url=http://en.wikipedia.org/wiki/Dew_point]http://en.wikipedia.org/wiki/Dew_point[/url]
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}
#include <Gizwits.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 2
SoftwareSerial mySerial(A2, A3); // A2 -> RX, A3 -> TX
Gizwits myGizwits;
#define KEY1 6
#define KEY2 7
#define KEY1_SHORT_PRESS 1
#define KEY1_LONG_PRESS 2
#define KEY2_SHORT_PRESS 4
#define KEY2_LONG_PRESS 8
#define NO_KEY 0
#define KEY_LONG_TIMER 3
unsigned long Last_KeyTime = 0;
unsigned long gokit_time_s(void)
{
return millis() / 1000;
}
char gokit_key1down(void)
{
unsigned long keep_time = 0;
if (digitalRead(KEY1) == LOW)
{
delay(100);
if (digitalRead(KEY1) == LOW)
{
keep_time = gokit_time_s();
while (digitalRead(KEY1) == LOW)
{
if ((gokit_time_s() - keep_time) > KEY_LONG_TIMER)
{
Last_KeyTime = gokit_time_s();
return KEY1_LONG_PRESS;
}
} //until open the key
if ((gokit_time_s() - Last_KeyTime) > KEY_LONG_TIMER)
{
return KEY1_SHORT_PRESS;
}
return 0;
}
return 0;
}
return 0;
}
char gokit_key2down(void)
{
unsigned long keep_time = 0;
if (digitalRead(KEY2) == LOW)
{
delay(100);
if (digitalRead(KEY2) == LOW)
{
keep_time = gokit_time_s();
while (digitalRead(KEY2) == LOW) //until open the key
{
if ((gokit_time_s() - keep_time) > KEY_LONG_TIMER)
{
Last_KeyTime = gokit_time_s();
return KEY2_LONG_PRESS;
}
}
if ((gokit_time_s() - Last_KeyTime) > KEY_LONG_TIMER)
{
return KEY2_SHORT_PRESS;
}
return 0;
}
return 0;
}
return 0;
}
char gokit_keydown(void)
{
char ret = 0;
ret |= gokit_key2down();
ret |= gokit_key1down();
return ret;
}
/**
* KEY_Handle
* @param none
* @return none
*/
void KEY_Handle(void)
{
/* Press for over than 3 second is Long Press */
switch (gokit_keydown())
{
case KEY1_SHORT_PRESS:
mySerial.println(F("KEY1_SHORT_PRESS , Production Test Mode "));
myGizwits.setBindMode(WIFI_PRODUCTION_TEST);
break;
case KEY1_LONG_PRESS:
mySerial.println(F("KEY1_LONG_PRESS ,Wifi Reset"));
myGizwits.setBindMode(WIFI_RESET_MODE);
break;
case KEY2_SHORT_PRESS:
mySerial.println(F("KEY2_SHORT_PRESS Soft AP mode"));
myGizwits.setBindMode(WIFI_SOFTAP_MODE);
//Soft AP mode
break;
case KEY2_LONG_PRESS:
mySerial.println(F("KEY2_LONG_PRESS ,AirLink mode"));
myGizwits.setBindMode(WIFI_AIRLINK_MODE);
//AirLink mode
break;
default:
break;
}
}
/**
* Serial Init , Gizwits Init
* @param none
* @return none
*/
void setup() {
// put your setup code here, to run once:
mySerial.begin(115200);
pinMode(9,OUTPUT);//接继电器
pinMode(KEY1, INPUT_PULLUP);
pinMode(KEY2, INPUT_PULLUP);
myGizwits.begin();
mySerial.println("GoKit init OK \n");
}
/**
* Wifi status printf
* @param none
* @return none
*/
void wifiStatusHandle()
{
if(myGizwits.wifiHasBeenSet(WIFI_SOFTAP))
{
mySerial.println(F("WIFI_SOFTAP!"));
}
if(myGizwits.wifiHasBeenSet(WIFI_AIRLINK))
{
mySerial.println(F("WIFI_AIRLINK!"));
}
if(myGizwits.wifiHasBeenSet(WIFI_STATION))
{
mySerial.println(F("WIFI_STATION!"));
}
if(myGizwits.wifiHasBeenSet(WIFI_CON_ROUTER))
{
mySerial.println(F("WIFI_CON_ROUTER!"));
}
if(myGizwits.wifiHasBeenSet(WIFI_DISCON_ROUTER))
{
mySerial.println(F("WIFI_DISCON_ROUTER!"));
}
if(myGizwits.wifiHasBeenSet(WIFI_CON_M2M))
{
mySerial.println(F("WIFI_CON_M2M!"));
}
if(myGizwits.wifiHasBeenSet(WIFI_DISCON_M2M))
{
mySerial.println(F("WIFI_DISCON_M2M!"));
}
}
/**
* Arduino loop
* @param none
* @return none
*/
void loop() {
KEY_Handle();//key handle , network configure
wifiStatusHandle();//WIFI Status Handle
int chk = DHT11.read(DHT11PIN);
Serial.print("Read sensor: ");
switch (chk)
{
case DHTLIB_OK:
Serial.println("OK");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.println("Checksum error");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.println("Time out error");
break;
default:
Serial.println("Unknown error");
break;
}
unsigned long varW_wendu =(float)DHT11.temperature ;//Add Sensor Data Collection
myGizwits.write(VALUE_wendu, varW_wendu);
unsigned long varW_shidu = (float)DHT11.humidity;//Add Sensor Data Collection
myGizwits.write(VALUE_shidu, varW_shidu);
bool varR_deng = 0;
if(myGizwits.hasBeenSet(EVENT_deng))
{
myGizwits.read(EVENT_deng,&varR_deng);//Address for storing data
if(varR_deng==1)
{
digitalWrite(9,LOW);
}
else
digitalWrite(9,HIGH);
mySerial.println(F("EVENT_deng"));
mySerial.println(varR_deng,DEC);
}
myGizwits.process();
}
机智云 就是好
小试牛刀 WiFi 远控 + wendu的更多相关文章
- [Micropython]TPYBoard v202 智能WIFI远控小车
转载请注明文章来源,更多教程可自助参考docs.tpyboard.com,QQ技术交流群:157816561,公众号:MicroPython玩家汇 前言---------------------- 之 ...
- Python3实现ICMP远控后门(上)
这几天一直在研究远控木马的一些通信协议,比如TCP,UDP,ICMP,DNS,HTTP等等,对于TCP,UDP这两种就不讲解了,因为太常见了. 大家可能对采用ICMP,DNS的木马不是很熟悉,其实这两 ...
- Python3实现ICMP远控后门(上)_补充篇
ICMP后门(上)补充篇 前言 在上一篇文章Python3实现ICMP远控后门(上)中,我简要讲解了ICMP协议,以及实现了一个简单的ping功能,在文章发表之后,后台很多朋友留言,说对校验和的计算不 ...
- Python3实现ICMP远控后门(中)之“嗅探”黑科技
ICMP后门 前言 第一篇:Python3实现ICMP远控后门(上) 第二篇:Python3实现ICMP远控后门(上)_补充篇 在上两篇文章中,详细讲解了ICMP协议,同时实现了一个具备完整功能的pi ...
- Python3实现ICMP远控后门(下)之“Boss”出场
ICMP后门 前言 第一篇:Python3实现ICMP远控后门(上) 第二篇:Python3实现ICMP远控后门(上)_补充篇 第三篇:Python3实现ICMP远控后门(中)之"嗅探&qu ...
- 【原创】利用Office宏实现powershell payload远控
本文将演示使用Veil-Evasion生成远控所需要的payload以及监听器,然后使用MacroShop生成payload 相关的VBA代码,最后演示将VBA代码写入.doc文本文档的宏中. 环境: ...
- [jk]服务器远控卡及kvm切换器
远控卡的需求 经常我们有这么一个需求,那就是某一台器服务器突然宕机,不能启动,而机房却在外地.解决这个问题的方法有两种,一是联系机房人员,二是通过idrac卡远程连接.我们必须根据事情的轻重缓急,来选 ...
- python破解网吧收费系统,远控网吧电脑设备!
我今天呢 , 我就没事跟着朋友喝酒喝酒啊.喝了很多啊.晚上到旁边的酒店开了一个房间,到了酒店才十点! 感觉没啥事情干的,那就去网吧走走看把,看到是一个嘟嘟牛的,和上次是一样的.还是照常用MS170 ...
- 为GHOST远控添加ROOTKIT功能
原版的ghost远控似乎有一个SSDT HOOK功能的模块,当然已经没有什么用处了.这里在GHOST的基础上添加一些ROOTKIT功能.而且随着x64下主动防御技术的发展,这里不打算使用传统的HOOK ...
随机推荐
- LoRa无线技术介绍
什么是LoRa LoRa是semtech公司创建的低功耗局域网无线标准,低功耗一般很难覆盖远距离,远距离一般功耗高,要想马儿不吃草还要跑得远,好像难以办到.LoRa的名字就是远距离无线电(Long R ...
- Java线程池—ThreadPool简介
一.Java线程池类/接口关系图及作用 Executor接口:只有一个方法execute(Runnable command),用来执行用户的任务线程. ExecutorService接口:继承自Exe ...
- Oracle使用
Oracle数据库首先必须在服务器端安装,安装完成后在DBCA中创建数据库,然后在Net Configuration Assistant中配置监听程序和本地Net服务名.然后安装本地Oracle客户端 ...
- istio路由配置
istio路由配置 istio的代理配置参考文档: 中文文档: https://istio.io/zh/docs/reference/config/istio.networking.v1alpha ...
- C++函数指针与指针函数干货
C++要是不常用,相信过四天你的指针函数与函数指针的概念就该忘个精光. 其实只要记住谁在后面谁就是哪个本质. 先了解下指针数组与数组指针吧 数组指针 就是指向数组的指针,它表示的是一个指针,它指向的是 ...
- 在ibatis中时间段查询完整代码
ibatis.xml文件中的代码如下: <typeAlias alias="ServInvokeTest" type="com.entity.ServInvokeT ...
- PAT 1132 Cut Integer
1132 Cut Integer (20 分) Cutting an integer means to cut a K digits lone integer Z into two integer ...
- vue1.0配置路由
1,//创建 router 实例 var router = new VueRouter() 2,//components下新建home.vue组件,并在app.vue中引入模块: import hom ...
- bootstrap-editable实现bootstrap-table行内编辑
bootstrap-editable行内编辑效果如下: 需要引入插件 列初始化代码,为可编辑的列添加editable属性: columns = [ { title: '文件名', field: 'Na ...
- python小游戏,石头/剪子/布
#从控制台输入石头(1)/剪子(2)/布(3) player=int(input("玩家出拳 石头(1)/剪子(2)/布(3)")) #电脑随机出拳 computer comput ...