at 指令可以被单片机usb转串口发送出去,esp8266 直接发 at 指令也可以发出去,esp8266(01s) 连上单片机(89c52rc)后就发不出去,表现为, 下面是测试代码与接线,我主要感觉接线不对
#include <REGX52.H>
#include "stdio.H"
#include "intrins.h"
#include "Delay.h"
void UartTnit(void) //修改波特率9600@11.0592
{
SCON=0x50;
TH2=0xFF;
TL2=0xFD;
RCAP2H=0xFF;
RCAP2L=0xFD;
/*****************/
TCLK=1;
RCLK=1;
C_T2=0;
EXEN2=0;
/*****************/
TR2=1 ;
TI = 1;
EA=1;
ES=1;
}
void Sendchar(unsigned char Char)
{SBUF=Char;
while(!TI);
TI=0;
}
/*
**重写printf调用的putchar函数,重定向到串口输出
**需要引入头文件<stdio.h>
*****/
char putchar(char c){
//输出重定向到串口
Sendchar(c);
return c; //返回给函数的调用者printf
}
void main(){
UartTnit();
while(1){Delay(1000);
printf("AT+CWJAP=\"meizu20\",\"1368424228\"\r\n");//不加/号会被认为引号前后自动配对,
/*Delay(5000);
printf("AT+MQTTUSERCFG=0,1,\"NULL\",\"ESP8266DUAN&a1cxPjP9UIP\",\"a6694b57ad9f0638be348c5e7e113a7ac9e0fda7faf5609259617324390d2ef1\",0,0,\"\"\r\n");
Delay(1000);
printf("AT+MQTTCLIENTID=0,\"a1cxPjP9UIP.ESP8266DUAN|securemode=2\\,signmethod=hmacsha256\\,timestamp=1713930839062|\"\r\n");
Delay(1000);
printf("AT+MQTTCONN=0,\"a1cxPjP9UIP.iot-as-mqtt.cn-shanghai.aliyuncs.com\",1883,1\r\n");
Delay(3000);
printf("AT+MQTTSUB=0,\"/sys/a1cxPjP9UIP/${deviceName}/thing/event/property/post_reply\",1\r\n");
Delay(1000);
printf("AT+MQTTPUB=0,\"/a1cxPjP9UIP/ESP8266DUAN/user/ESP8266DUAN\",\"{\\\"LightSwitch\\\":1}\",1,0\r\n");
Delay(1000);
printf("AT+MQTTPUB=0,\"/a1cxPjP9UIP/ESP8266DUAN/user/ESP8266DUAN\",\"{\\\"LightSwitch\\\":0}\",1,0\r\n");
Delay(1000);*/
}
}