ArduinoLED Code
Demonstrating connection of smartphone to silple SSL server on Arduino
Brought to you by:
nrovinskiy
File | Date | Author | Commit |
---|---|---|---|
.idea | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
app | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
gradle | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
ssl_server | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
.gitignore | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
README.md | 2023-03-18 |
![]() |
[6b1f27] Test |
build.gradle | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
gradle.properties | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
gradlew | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
gradlew.bat | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
settings.gradle | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
ssl.conf | 2023-03-18 |
![]() |
[923f0e] Commit code for ArduinoLED |
This project demonstrates how Arduino (WeMos D1 board) can be used from the smartphone application through HTTPS protocol. In this example we will generate the Certificate Authority and sign certificates. These certificates will be used to secure connection with Arduino.
# First generate the certificate authority key.
openssl genrsa -out ca_key.pem 2048
# Generate the CA certificate.
openssl req -x509 -key rsa:4096 -key arduino_ca_key.pem -out arduino_ca_csr.pem -sha256 -days 100500
# Generate server key
openssl genrsa -out server_key.pem 2048
# Create a signing request server_req.csr
openssl req -out server_req.csr -key server_key.pem -new -config ssl.conf
# Sign certificate with authority
openssl x509 -req -in server_req.csr -out server_cer.pem -sha256 -CAcreateserial -CA arduino_ca_csr.pem -CAkey arduino_ca_key.pem -days 100500 -extensions req_ext -extfile ssl.conf
# Key
openssl genrsa -out client1_key.pem 2048
# Signing request
openssl req -out client1_req.csr -key client1_key.pem -new -config ssl.conf
# Generate certificate
openssl x509 -req -in client1_req.csr -out client1_cer.pem -sha256 -CAcreateserial -days 4000 -CA arduino_ca_csr.pem -CAkey arduino_ca_key.pem -extensions req_ext -extfile ssl.conf
arduino_ca_csr.pem
, server_key.pem
and server_cer.pem
to the Secrets folder on the SD card.auth.json
file which will contain the authentication information as follows:{
"ssid": "ssid_of_your_router",
"password": "password to router",
"arduino_ap_ssid": "desired_ssid_of_arduino_ap",
"arduino_ap_password": "password to arduino access point"
}
ssl_server.ino
in the ssl_server
folder and launch the server.# Get the red, green and blue components of the RGB LED in JSON format
curl --cacert /home/User/workspace/IOT/keys/arduino_ca_csr.pem https://ARDUINO.IP.ADDRESS
# Light LED with red color
curl --cacert /home/User/workspace/IOT/keys/arduino_ca_csr.pem https://ARDUINO.IP.ADDRESS --data "red=100" --data "green=0" --data "blue=0"
arduino_ca_csr.pem
to app/src/main/res/raw
folder and compile the android application.