问题
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.
回答1:
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
.
To use the Arduino as an FTDI:
- 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
Now you need to setup Arduino IDE so it can program an 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 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.
- connect a push-button between GND and the ESP8266 GPIO_0 pin
- connect a push-button between GND and the ESP8266 RESET pin
- add a 10K-ohm pull-up resistor between 3.3V and ESP8266 pin (defaults the reset pin to HIGH)
When you are ready to upload a sketch to the ESP8266, use those buttons like this:
- press both buttons
- release RESET button
- release GPIO_0 button
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.
Here's an overview of the project:
. 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!
来源:https://stackoverflow.com/questions/45999417/send-data-sensor-from-arduino-to-esp8266-who-send-it-to-the-cloud-using-ssl