#include"STC12C5A.H"
#include <string.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define Wifi_Buffer_Length 10
sbit LED=P2^; int ceshi=;
uchar temp;
uchar RX_Count=;
uchar Wifi_Buffer[Wifi_Buffer_Length];
bit flag;
void delay_15s() //@11.0592MHz
{
unsigned char i, j, k; _nop_();
_nop_();
i = ;
j = ;
k = ;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
} //延时函数
void delay_ms(uint c)
{
unsigned char i, j; _nop_();
_nop_();
_nop_();
i = ;
j = ;
while(c--)
{
do
{
while (--j);
} while (--i);
}
}
//波特率发生器
void UartInit(void) //115200bps@11.0592MHz
{
PCON &= 0x7F; //波特率不倍速
SCON = 0x50; //8位数据,可变波特率
AUXR |= 0x04; //独立波特率发生器时钟为Fosc,即1T
BRT = 0xFD; //设定独立波特率发生器重装值
AUXR |= 0x01; //串口1选择独立波特率发生器为波特率发生器
AUXR |= 0x10; //启动独立波特率发生器
ES=;
EA=;//需要打开总中断
}
//串口发送函数
void Send_Uart(uchar value)
{
ES=;//发送数据之前关闭中断
SBUF=value;
while(!TI);//等待发送完毕
TI=; //发送结束 软件置0
ES=;
}
//wifi模块设置函数
void ESP8266_Set(uchar *s)
{
while(*s!='\0')
{
Send_Uart(*s);
s++;
}
delay_ms();
}
void Send_String(uchar *s)
{
while(*s!='\0')
{
Send_Uart(*s);
s++;
}
delay_ms();
}
void wifi_send()
{
/* ESP8266_Set("AT+CWMODE=1");
ESP8266_Set("AT+RST");
ESP8266_Set("AT+CWJAP=\"qwe\",\"123456789\"");
ESP8266_Set("AT+CIPSTART=\"TCP\",\"10.25.97.164\",8001");
ESP8266_Set("AT+CIPMODE=1");
ESP8266_Set("AT+CIPSEND"); */ Send_String("AT+CIPSTART=\"TCP\",\"api.yeelink.net\",80\r\n");
Send_String("AT+CIPSEND=250\r\n");
Send_String("POST /v1.0/device/351905/sensor/396141/datapoints HTTP/1.1\r\n");
Send_String("Host: api.yeelink.net\r\n");
Send_String("Accept: */*\r\n") ;
Send_String("U-ApiKey: 71c27d52c090e00b65998a2d4dba73e8\r\n");
Send_String("Content-Length: 14\r\n");
Send_String("Content-Type: application/x-www-form-urlencoded\r\n");
Send_String("Connection: close\r\n");
Send_String("\r\n");
// display("{\"value\":");
// Send_Uart(temp/10);
//Send_Uart(temp%10) ;
Send_String("{\"value\":");
Send_Uart(0x30+ceshi/);
Send_Uart(0x30+ceshi%);
Send_String(" }\r\n");
Send_String("\r\n");
Send_String("\r\n");
ceshi++;
if(ceshi==)
ceshi=;
}
void wifi_accept()
{
Send_String("AT+CIPSTART=\"TCP\",\"api.yeelink.net\",80\r\n");
Send_String("AT+CIPSEND=250\r\n");
Send_String("GET /v1.0/device/351905/sensor/396173/datapoints HTTP/1.1\r\n");
Send_String("Host: api.yeelink.net\r\n");
Send_String("Accept: */*\r\n");
Send_String("U-ApiKey: 71c27d52c090e00b65998a2d4dba73e8\r\n");
Send_String("Content-Length: 0\r\n");
Send_String("Connection: close\r\n");
Send_String("\r\n");
Send_String("print get done.\r\n");
Send_String("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\r\n");
}
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0xff ;
P2M1 = 0x00;
P3M0 = 0xff;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
UartInit();
ESP8266_Set("AT+CWJAP=\"qwe\",\"123456789\"\r\n");
ESP8266_Set("AT+CWJAP=\"qwe\",\"123456789\"\r\n");
ESP8266_Set("AT+CWJAP=\"qwe\",\"123456789\"\r\n"); while()
{
wifi_send();
delay_15s();
wifi_accept();
delay_15s();
}
}
void ser() interrupt using
{
ES=;
temp=SBUF;
RI=;
if(temp=='l')
{
RX_Count=;
}
if(RX_Count<)
{
Wifi_Buffer[RX_Count++]=temp;
}
else if(Wifi_Buffer[]=='l'&&Wifi_Buffer[]=='u'&&Wifi_Buffer[]=='"')
{
Wifi_Buffer[RX_Count++]=temp;
if(temp=='\n')
{
if(Wifi_Buffer[]=='')
{
LED=;
}
else if(Wifi_Buffer[]=='')
{
LED=;
}
memset(Wifi_Buffer,,Wifi_Buffer_Length);//清空数组的数据
}
}
ES=; }

今天实验成功了,有点小兴奋

wifi 模块的更多相关文章

  1. 智能家居常用WiFi模块

    WiFi模块 WiFi模块就是整个系统的控制中心,控制很简单,就是输出一个开关信号控制继电器,而这个模块的核心是WiFi的连接,手机连接WiFi时需要扫描,输入密码,而这类本身没有屏幕和键盘的硬件设备 ...

  2. Beaglebone Black– 智能家居控制系统 LAS - 刷 WiFi 模块 ESP8266 Firmware 和 ESP8266 直接收发 GPIO 信号

    用 Windows 来刷 ESP8266 固件有很多中文教程,来试试直接用 BBB 刷吧.目标是 NodeMCU,ESP-01 可用,就是我买的那个. 接线方式在上一篇.当 echo ‘BB-UART ...

  3. 天嵌E9平台下进行USB Wifi模块RT3070驱动的移植

    因为项目工作须要,要在天嵌E9平台下实现wifi的点对点,点对多点的传输. Wifi 模块芯片:雷凌3070芯片 嵌入式平台:E9(ARM) 交叉编译环境:arm-none-linux-gnueabi ...

  4. 移植 wifi模块

    本文以realtek 8192CU WiFi模块为例,介绍USB wifi在Jelly Bean 4.1的调试笔记. 1.WIFI打不开现象概述 WiFi打不开是指您在UI的settings下选中Wi ...

  5. 有人WIFI模块使用详解

    补充 模块在连接路由器时如果希望模块固定IP 不过发现固定IP之后好像连接路由器的等待时间增加了 用的这一款 看一下现在可能用到了引脚 这个模块也有三种模式AP,STA,AP+STA 先说一下模块在A ...

  6. 第一次 刷 WiFi 模块esp8266 感谢创客阿正

    在正哥指导下 第一次 刷 WiFi 模块  少走了 不少弯路 套件里的 两块 机智云  ==== 我的电脑 需要单独供电 先 对应 接好 ic0要记得接gnd 等待上电时要断电重启 等  用助手 返回 ...

  7. RealTek WiFi 模块 RTL8710AF RTL8711AF RTL8711AM RTL8195AM

    瑞昱 8710 是一个完整且自成体系的 WiFi 网络解决方案, 能够独立运行,也可以作为从机搭载于其他主机 MCU 运行. 瑞昱 8710 在搭载应用并作为设备中唯⼀的应⽤处理器时,能够直接从外接闪 ...

  8. 5-(基础入门篇)学会刷Wi-Fi模块固件(刷LUA版本固件)

    http://www.cnblogs.com/yangfengwu/p/9065559.html 基础教程源码链接请在淘宝介绍中下载,由于链接很容易失效,如果失效请联系卖家,谢谢 https://it ...

  9. 带WIFI模块布局布线要点。

    带WIFI模块布局布线要求: 1: RF底部不能铺铜要挖空不能有GND否则RF信号会被耦合掉从而无法发送出去. 2:WIFI模块下方不能打孔尽量不走线不打孔避开其他信号穿过下方,要整体的铺铜 3:连接 ...

随机推荐

  1. linux $ 类型变量 及Makefile 中 $ 类型变量的含义

    Shell 命令中: $$: shell pid $!: pid of the last process running in shell $?: shell command return code ...

  2. Castle.DynamicProxy Part 1: ClassProxy

    1.Castle中代理对象的分类 总的来说,代理对象大概可以分为2大类: 1.继承类型的代理对象 一类是继承类型的代理类.即:有一个类A,它的代理类是B.B是继承自A的.调用代理类B中的方法时,可以通 ...

  3. IL代码完结篇

    读懂IL代码就这么简单(三)完结篇   一 前言 写了两篇关于IL指令相关的文章,分别把值类型与引用类型在 堆与栈上的操作区别详细的写了一遍这第三篇也是最后一篇,之所以到第三篇就结束了,是因为以我现在 ...

  4. Leetcode::JumpGame

    Description: Given an array of non-negative integers, you are initially positioned at the first inde ...

  5. [转]ARM/Thumb/Thumb-2

    ref:http://kmittal82.wordpress.com/2012/02/17/armthumbthumb-2/ A few months ago I gave a presentatio ...

  6. Nvelocity模板引擎开发网页

    在ASP.NET网站开发中,我们要做许多的网页,如果多个网页的内容框架有些重复使用,我们用NVelocity模板引擎,就可以把相同的部分html代码单独放在一个文件中就行了,当要使用的时候,只需使用# ...

  7. C#计算两个文件的相对目录算法

    C#计算两个文件的相对目录算法 楼主大菜鸟一只,第一次写技术博客,如果有概念错误或代码不规范的地方,还请各位多多批评指正.话不多说,来看题: 前一阵子开发了一个用户控件,里面调用了很多css,js等资 ...

  8. 在Visual Studio 2012中使用VMSDK开发领域特定语言1

    在Visual Studio 2012中使用VMSDK开发领域特定语言(一)   前言 本专题主要介绍在Visual Studio 2012中使用Visualization & Modelin ...

  9. easyui 个人使用心得之下拉列表

    下拉框: 第一种:从数据库获取<input id="FlowType" name="FlowType" style="width: 245px; ...

  10. 结构-行为-样式-Angularjs-ngSanitize

    简单点,上代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...