wifi 模块
#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 模块的更多相关文章
- 智能家居常用WiFi模块
WiFi模块 WiFi模块就是整个系统的控制中心,控制很简单,就是输出一个开关信号控制继电器,而这个模块的核心是WiFi的连接,手机连接WiFi时需要扫描,输入密码,而这类本身没有屏幕和键盘的硬件设备 ...
- Beaglebone Black– 智能家居控制系统 LAS - 刷 WiFi 模块 ESP8266 Firmware 和 ESP8266 直接收发 GPIO 信号
用 Windows 来刷 ESP8266 固件有很多中文教程,来试试直接用 BBB 刷吧.目标是 NodeMCU,ESP-01 可用,就是我买的那个. 接线方式在上一篇.当 echo ‘BB-UART ...
- 天嵌E9平台下进行USB Wifi模块RT3070驱动的移植
因为项目工作须要,要在天嵌E9平台下实现wifi的点对点,点对多点的传输. Wifi 模块芯片:雷凌3070芯片 嵌入式平台:E9(ARM) 交叉编译环境:arm-none-linux-gnueabi ...
- 移植 wifi模块
本文以realtek 8192CU WiFi模块为例,介绍USB wifi在Jelly Bean 4.1的调试笔记. 1.WIFI打不开现象概述 WiFi打不开是指您在UI的settings下选中Wi ...
- 有人WIFI模块使用详解
补充 模块在连接路由器时如果希望模块固定IP 不过发现固定IP之后好像连接路由器的等待时间增加了 用的这一款 看一下现在可能用到了引脚 这个模块也有三种模式AP,STA,AP+STA 先说一下模块在A ...
- 第一次 刷 WiFi 模块esp8266 感谢创客阿正
在正哥指导下 第一次 刷 WiFi 模块 少走了 不少弯路 套件里的 两块 机智云 ==== 我的电脑 需要单独供电 先 对应 接好 ic0要记得接gnd 等待上电时要断电重启 等 用助手 返回 ...
- RealTek WiFi 模块 RTL8710AF RTL8711AF RTL8711AM RTL8195AM
瑞昱 8710 是一个完整且自成体系的 WiFi 网络解决方案, 能够独立运行,也可以作为从机搭载于其他主机 MCU 运行. 瑞昱 8710 在搭载应用并作为设备中唯⼀的应⽤处理器时,能够直接从外接闪 ...
- 5-(基础入门篇)学会刷Wi-Fi模块固件(刷LUA版本固件)
http://www.cnblogs.com/yangfengwu/p/9065559.html 基础教程源码链接请在淘宝介绍中下载,由于链接很容易失效,如果失效请联系卖家,谢谢 https://it ...
- 带WIFI模块布局布线要点。
带WIFI模块布局布线要求: 1: RF底部不能铺铜要挖空不能有GND否则RF信号会被耦合掉从而无法发送出去. 2:WIFI模块下方不能打孔尽量不走线不打孔避开其他信号穿过下方,要整体的铺铜 3:连接 ...
随机推荐
- 冒泡排序最佳情况的时间复杂度,为什么是O(n)
冒泡排序最佳情况的时间复杂度,为什么是O(n) 我在许多书本上看到冒泡排序的最佳时间复杂度是O(n),即是在序列本来就是正序的情况下. 但我一直不明白这是怎么算出来的,因此通过阅读<算法导论-第 ...
- exit与_exit
一.main函数: 先从程序的执行开始谈起,C程序总是从main函数开始执行,当内核执行C程序时(使用了一个exec函数),在调用main函数前先调用一个特殊的启动例程.可执行程序 文件将此启动例程指 ...
- Coursera台大机器学习基础课程1
Coursera台大机器学习基础课程学习笔记 -- 1 最近在跟台大的这个课程,觉得不错,想把学习笔记发出来跟大家分享下,有错误希望大家指正. 一 机器学习是什么? 感觉和 Tom M. Mitche ...
- VS2012 Unit Test
VS2012 Unit Test 个人学习汇总(含目录) 首先,给出MSDN相关地址:http://msdn.microsoft.com/en-us/library/Microsoft.VisualS ...
- Mobile页面项目总结
项目过去个把月了,一直没有写些东西总结下,这次借着年后的空隙,将当时记录下来的几个点回顾一下. 今明的布局:position技巧 每当看到类似横向并排布局的时候,总是想起定宽浮动,和下面讲到的列表并排 ...
- asp.net缓存(转载)
由于工作的需要,最近对.net缓存做了相关了解和学习.做以下分类: 客户端缓存 第三方的缓存 服务器缓存 客户端缓存 客户端缓存主要是指浏览器帮我们缓存一些页面组件包括脚本,样式,图片等等,由于客户端 ...
- jquery选择器之层级过滤选择器
$("ancestor descendant"):选取parent元素后所有的child元素 $("parent > child"):选取parent元素 ...
- 关于Update语句的锁
关于Update语句的锁 环境:MSSQL2005,在Read Committed级别 语句A:begin tranUpdate Table Set f1='xxx' where f2='ttt' ...
- SVM学习资料
SVM学习资料 2013-06-21 17:29 by 夜与周公, 227 阅读, 0 评论, 收藏, 编辑 SVM(support vector machine),被认为是“off-the-shel ...
- mosquitto awareness when before it's being compiling, and you do settings and testing
Mostly, this clearify the usage of ' mosquitto.conf ' in easy-understanding language. 1. compile ...