Arduino - HTTPS Request

Arduino can play a role as a web client to make HTTPS to a web server. Web Server can be a website, Web API or REST API, Web service ...

HTTP vs HTTPS

From a web client point of view, HTTPS are the same as HTTP, except that HTTPS encrypt data between client end server. This makes HTTPS secure.

Therefore, to learn about HTTPS, We just need to learn about HTTP first, and then lean how to encrypt data.

Learn about HTTP

Learn how to encrypt data in HTTPS

Fortunately, It is easy to modify HTTP code to make HTTPS code. It just needs to modify one line of code, depending on the board/shield. In HTTP code, find the code lines specified in the table below, replace by the corresponding HTTPS code.

Board/Shield HTTP Code HTTPS Code
Arduino UNO R4 WiFi WiFiClient client; WiFiSSLClient client;
Arduino UNO WIFI Rev2 client.connect(server, 80) client.connectSSL(server, 443)
ARDUINO NANO 33 IOT client.connect(server, 80) client.connectSSL(server, 443)
ARDUINO MKR WIFI 1010 client.connect(server, 80) client.connectSSL(server, 443)
ARDUINO MKR1000 WIFI client.connect(server, 80) client.connectSSL(server, 443)
Arduino MKR VIDOR 4000 WiFi client.connect(server, 80) client.connectSSL(server, 443)

※ NOTE THAT:

  • In some board/shield, if the library supports WiFiSSLClient class, we have one more way to modify HTTP code to make HTTPS code. It just needs to replace WiFiClient by WiFiSSLClient and port 80 to 443.
  • Arduino Ethernet Shield 2 does not support HTTPS.
  • In this tutorial, we do not show any code. That is because you just need to get HTTP code from Arduino - HTTP request, and then modify it based on the above instruction. By modifing HTTP code, you can make HTTPS POST/GET or send data from Arduino via HTTPS POST/GET to a web server.

The Best Arduino Starter Kit

※ OUR MESSAGES