问题描述
我有一个从传感器收集数据的arduino Uno,我想使用支持WifiClientSecure库的SSL的wifi esp8266将此数据发送到云,还有一种替代方法,可以将arduino的数据发送到esp卡和esp8266此数据并将其发送到云后,我可以使用mqtt,但我想知道是否有一种方法可以在arduino uno和esp8266之间建立直接连接而无需第三方,任何帮助都将是感激不尽.
I have an arduino Uno which collect data from sensor, i want to send this data to the cloud using wifi esp8266 who support SSL using the library WifiClientSecure, is there an alternative to send data from arduino to the esp card and esp8266 read this data and send it after that to the cloud, i'm able to work with mqtt but i want to know if there is a way to have a directly connection between the arduino uno and esp8266 without having a third part, any help will be gratefull.
推荐答案
根据我的研究,ESP8266 AT Command API不支持SSL.这意味着您将需要使用Arduino(作为FTDI转换器)来使用自定义固件对ESP8266进行编程.这将使您能够使用WiFiClientSecure
和pubsubclient
.
According to my research, the ESP8266 AT Command API does not support SSL. This means you will need to use the Arduino (as an FTDI converter) to program the ESP8266 with custom firmware. This will enable you to use WiFiClientSecure
and pubsubclient
.
要将Arduino用作FTDI:
To use the Arduino as an FTDI:
- 加载不使用
Serial
的草图,例如眨眼"示例 - 将Arduino的TX引脚连接到ESP8266 RX引脚
- 将Arduino的RX引脚连接到ESP8266 TX引脚
- load a sketch that does not use
Serial
, such as the "Blink" example - connect the Arduino's TX pin to the ESP8266 RX pin
- connect the Arduino's RX pin to the ESP8266 TX pin
现在您需要设置Arduino IDE,以便可以对ESP8266进行编程
Now you need to setup Arduino IDE so it can program an ESP8266
- 在Arduino IDE->文件->首选项中,将其粘贴到附加板管理器URL中: http://arduino.esp8266.com/stable/package_esp8266com_index.json (只需复制链接而不是单击即可)
- 转到工具"->董事会"->董事会经理".在主板列表中找到"esp8266",然后单击安装"
- 在工具->开发板上将开发板设置为通用ESP8266模块"
- In Arduino IDE -> File -> Preferences, paste this into the Additional Boards Manager URLs: http://arduino.esp8266.com/stable/package_esp8266com_index.json (just copy the link as it is instead of clicking)
- go to Tools -> Boards -> Boards Manager. Find "esp8266" in the list of boards and click "Install"
- Set your board to "Generic ESP8266 Module" in Tools -> Boards
Arduino IDE准备好了!但是在使用ESP8266编程之前,您需要将一个重置按钮和一个程序按钮连接到ESP8266.
Arduino IDE is ready! But before you caan program an ESP8266 with it you need to connect a reset button and a program button to the ESP8266.
- 在GND和ESP8266 GPIO_0引脚之间连接一个按钮
- 在GND和ESP8266 RESET引脚之间连接一个按钮
- 在3.3V和ESP8266引脚之间添加一个10K欧姆上拉电阻(默认复位引脚为HIGH)
准备将草图上传到ESP8266时,请使用以下按钮:
When you are ready to upload a sketch to the ESP8266, use those buttons like this:
- 同时按下两个按钮
- 释放RESET按钮
- 释放GPIO_0按钮
这会使ESP8266进入程序模式!现在,您应该能够在Arduino IDE中单击上传"按钮.我建议使用提供的ESP826a6示例草图之一(例如此人)来测试所有内容.
This puts the ESP8266 in program mode! You should now be able to click the "Upload" button in Arduino IDE. I would suggest using one of the provided ESP826a6 example sketches (like this one) to test everything out.
这是项目的概述:
. Arduino Uno草图:读取传感器数据,通过Serial
发送到ESP8266. ESP8266草图:连接到WiFi网络,从Serial
接收传感器数据,通过WiFiClientSecure
发送到云端.
. Arduino Uno sketch: read sensor data, send via Serial
to ESP8266. ESP8266 sketch: connect to WiFi network, receive sensor data from Serial
, send via WiFiClientSecure
to the cloud.
我将把这两个程序的实际代码留给您,但是如果您遇到困难,请发表评论.希望这会有所帮助!
I will leave the actual code of these two programs up to you, but if you get stuck just leave a comment. Hope this helps!
这篇关于将数据传感器从arduino发送到esp8266,后者使用SSL将其发送到云的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!