Look at this: data
https://blog.csdn.net/gsh_hello_world/article/details/56277182
https://blog.csdn.net/gsh_hello_world/article/details/81335955
Overall program
Witty use cloud platform to develop, create data points on wit cloud platform, then the secondary development of its MCU code and the code APP. APP is possible to ultimately obtain the temperature and humidity of smart home, smart home and can remotely control the fans and humidifiers.
Link connection relationship
TP-LINK router through a network cable network, WIFI module is connected to this router: Arduino account, password 12345678.
Phone is connected to this network router / other wireless network / traffic use, open the APP can control the smart home. (Later LAN consists of direct control, no uploading data to wit cloud, so the phone can only be connected to a network router arduino controlled)
Note: The relay module and the module temperature and humidity are alone electric power on the USB-to-TTL 5V supply, and this may affect the normal operation of WIFI.
Note: If the module is connected to the computer WIFI wireless network points out, there will be instability, APP will often get less data. (To be verified)
Hardwired instructions
WIFI module
WIFI module the RX - the TX Arduino
WIFI module the TX - Arduino the RX
WIFI module the VCC - 3.3V Arduino
WIFI module the GND - the GND Arduino
KEY1 - Arduino PIN6 of (subsequently removed, the direct mode is set by a program SOFTAP)
KEY2-- arduino PIN7 (subsequently removed, the direct mode is set by a program SOFTAP)
(Note: KEY2 short press WIFI_SOFTAP_MODE mode, this time can be controlled by smart home LAN; long press WIFI_AIRLINK_MODE mode, this time can be controlled by the cloud server wit)
Temperature and humidity sensors DHT11
DHT11 VCC——arduino 5V
DHT11 GND——arduino GND
DHT11 DATA——arduino PIN2
Fan control relay module (active-low)
RELAY VCC——USB转TTL5V
RELAY GND——arduino GND
RELAY IN——arduino PIN12
Humidifier control relay module (low level triggered)
RELAY VCC——USB转TTL 5V
RELAY GND——arduino GND
RELAY IN——arduino PIN13
Development steps
Step overall reference links:
http://club.gizwits.com/thread-6728-1-1.html
http://docs.gizwits.com/zh-cn/quickstart/UseMCU.html
1, first of ESP8266-12F WIFI module programmed firmware cloud wit, built in accordance with the circuit diagram below WIFI module peripheral circuits, of course, can buy a good build WIFI module (note that this case GPIO0 ground).
http://club.gizwits.com/thread-3551-1-1.html
http://docs.gizwits.com/zh-cn/deviceDev/ESP8266 serial programming instructions .html
2, the vacant GPIO0, WIFI module, a relay module, and the temperature and humidity sensors connected in the connection arduino instructions.
3, in the cloud wit and APP download MCU code.
Cloud APP generates wit: http://docs.gizwits.com/zh-cn/UserManual/devApp.html
. 4, the steps according to the overall development of the secondary reference links MCU code arduino 1.8.5.
5, secondary development of APP Android studio, which changed APP related to the icon reference links: https://blog.csdn.net/tichimi3375/article/details/80621362
Replace icon.png icon, launch icon and about_logo.png icon.
6、下载好arduino程序后,首先短按KEY2,使系统在局域网工作,如果一切正常的话,长按KEY2,此时系统通过WIFI模块与机智云联网。(后来不用进行这一步)
7、APP配置界面,首先短按KEY2键,配置WIFI模块为WIFI_SOFTAP_MODE模式,连接到路由器;然后长按KEY2键,配置WIFI模块为WIFI_AIRLINK_MODE模式,连接到机智云服务器(手机也连接到路由器网络):(后来不用进行这一步,打开APP直接点击“一键配置”即可)
ESP8266-12F:https://item.taobao.com/item.htm?spm=a1z09.2.0.0.362b2e8dBdXzad&id=533821727074&_u=k10kp0pjd785
注意事项
1、下载arduino程序时最好将所有接在板子上的线拔掉,防止下载失败。特别是接在arduino TX和RX上的引线,必须拔掉,因为下载程序是通过这个串口下载的。
2、不能在WIFI模块连着某个无线的情况下,配置其连接另外一个无线,此时配置不成功。
3、供电采用方口(下载口),用圆口供电的话APP控制不正常(好像是电压小)。
4、配置引脚输出时:
首先定义引脚:int myWaterPin = 5;
然后设置为输出模式:pinMode(myWaterPin, OUTPUT);
最后根据逻辑进行高低输出:
if(varR_Water_OnOff == 0)
{
digitalWrite(myWaterPin, LOW);
}
else
{
digitalWrite(myWaterPin, HIGH);
}
5、MCU和APP代码的目录中最好不要有中文,可能会编译失败。
6.目录说明
Arduino代码位置:
Arduino连接机智云\MCU_ArduinoUNOR3_source\Gizwits\examples\simpleTry
APP代码位置:
Arduino连接机智云\App_Android_source\AndroidStudio
实物图
运行记录(后来没有用)
联系方式
QQ:1447491726,技术交流,共同进步!