├── Arduino + Ethernet Shield ├── Demo Code v.1.1 └── Readme.md ├── ESP32 ├── Demo Code v.1.1 ├── Old versions │ └── Demo Code v.1.0 └── Readme.md ├── ESP8266 ├── Demo Code v.1 └── Readme.md ├── PrivacyPolicy └── README.md /Arduino + Ethernet Shield/Demo Code v.1.1: -------------------------------------------------------------------------------- 1 | // Sketch : Arduino [static IP: 192.168.1.111] 2 | // Connection through Ethernet (ENET) 3 | // Label Node > Displays the value readed from a potentiometer 4 | // Button Node > Blinks a LED 5 | // Switch Node > Toggles the state of a LED 6 | // TextField Node > Set a PWM value to the LED 7 | 8 | // Libraries 9 | #include 10 | #include 11 | 12 | // STATIC IP DETAILS 13 | // mac : unique MAC address 14 | byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 15 | // local : unique IP on the local network 16 | byte local[] = {192, 168, 1, 111}; 17 | // to know how to configure the rest, in your iPhone go to: 18 | // (the iPhone must be connected to the same network) 19 | // Preferences > Wi-Fi > (i) on the WiFi network 20 | // Router -> gateway 21 | // Subnet Mask -> subnet 22 | byte gateway[] = {192, 168, 1, 1}; 23 | byte subnet[] = {255, 255, 255, 0}; 24 | 25 | // Server instance 26 | EthernetServer server(80); 27 | 28 | // Server variables 29 | String readString; 30 | 31 | // Arduino pins 32 | const int ledPin = 5; 33 | const int potPin = 2; 34 | 35 | // Sketch variables 36 | bool isLedOn = false; 37 | 38 | void setup() { 39 | // Serial initialization 40 | Serial.begin(9600); 41 | delay(2000); 42 | 43 | // Configures Ethernet connection 44 | Ethernet.begin(mac, local, gateway, subnet); 45 | server.begin(); 46 | Serial.print("Server connected at: "); 47 | Serial.println(Ethernet.localIP()); 48 | 49 | // LED & Pot pinModes 50 | pinMode(ledPin, OUTPUT); 51 | pinMode(potPin, INPUT); 52 | } 53 | 54 | void loop() { 55 | // Looks for client requests 56 | EthernetClient client = server.available(); 57 | if (client) { 58 | while (client.connected()) { 59 | if (client.available()) { 60 | char c = client.read(); 61 | readString += c; 62 | 63 | if (c == '\n') { 64 | // Request ended 65 | Serial.println(readString); 66 | 67 | // Server respond header 68 | client.println("HTTP/1.1 200 OK"); 69 | client.println("Content-Type: text/html"); 70 | client.println("Connection: close"); 71 | client.println(""); 72 | 73 | // Create a IF statement for each node 74 | // Check Label Node Request 75 | if (readString.indexOf("/potValue") > 0) { 76 | int potValue = analogRead(potPin); 77 | client.println(potValue); 78 | Serial.println(potValue); 79 | 80 | // Check Switch Node Request 81 | } else if (readString.indexOf("/toggleLed") > 0) { 82 | if (readString.indexOf("?value") > 0) { 83 | isLedOn = (getValue(readString) == "1") ? true : false; 84 | digitalWrite(ledPin, isLedOn); 85 | } 86 | client.println(isLedOn ? "1" : "0"); 87 | Serial.println(isLedOn); 88 | 89 | // Check Button Node Request 90 | } else if (readString.indexOf("/blinkLed") > 0) { 91 | digitalWrite(ledPin, !isLedOn); 92 | delay(200); 93 | digitalWrite(ledPin, isLedOn); 94 | Serial.println("Blink!"); 95 | 96 | // Check Text Field Node Request 97 | } else if (readString.indexOf("/pwmValue") > 0) { 98 | analogWrite(ledPin, getValue(readString).toInt()); 99 | Serial.print("PWM: "); 100 | Serial.println(getValue(readString)); 101 | } 102 | 103 | delay(5); 104 | client.stop(); 105 | 106 | readString = ""; 107 | } 108 | } 109 | } 110 | } 111 | } 112 | 113 | // Process input data from HTTP Request 114 | // input "GET http://192.168.1.111/toggleLed?value=1 HTTP/1.1" 115 | // return "1" 116 | String getValue(String input) { 117 | int startIndex = (input.indexOf("=") + 1); 118 | int endIndex = input.indexOf(" ", startIndex); 119 | return input.substring(startIndex, endIndex); 120 | } 121 | -------------------------------------------------------------------------------- /Arduino + Ethernet Shield/Readme.md: -------------------------------------------------------------------------------- 1 | ## How it works 2 | - Download the app from the [App Store](https://apps.apple.com/es/developer/david-brana-campos/id1047286431) 3 | 4 | - Copy the code from this [GitHub page](https://github.com/ios-dbrancam/ArduinoCmd/blob/master/Arduino%20%2B%20Ethernet%20Shield/Demo%20Code%20v.1.1) to a new Arduino Sketch 5 | 6 | - You need to modify some things of the sketch 7 | - Change lines *22 .. 23* to your IP Address values. If you don't know this values, connect your iPhone to the same network as the Arduino and go to **Preferences > Wi-Fi > (i)** on the WiFi network and there you will find the values. *Router -> gateway; Subnet Mask -> subnet* 8 | - `byte gateway[] = {192, 168, 1, 1};` 9 | - `byte subnet[] = {255, 255, 255, 0};` 10 | 11 | - Upload the sketch 12 | 13 | - Follow the schematic to connect a LED and a Potentiometer to the Arduino + Ethernet Shield 14 | 15 | ![Sch_Arduino](https://user-images.githubusercontent.com/53085860/63844897-4f523180-c989-11e9-8dfa-7fba6e71babb.png) 16 | 17 | - Open **ArduinoCmd**, you will find four *nodes* on the Main Screen. The first one displays the value read from the potentiometer (slide down to update the value). The other ones control the LED, you will be able to blink the LED by pressing the button, toggling the state with the switch or using PWM with the TextField. *If the Main Screen is empty it's possible to restart the tutorial from the Preferences View.* 18 | 19 | ![MainView](https://user-images.githubusercontent.com/53085860/63841557-4f4f3300-c983-11e9-9d08-94ab39a06335.png) 20 | -------------------------------------------------------------------------------- /ESP32/Demo Code v.1.1: -------------------------------------------------------------------------------- 1 | // Sketch : ESP32 [static IP: 192.168.1.111] 2 | // Connection through WiFi 3 | // Label Node > Displays the value readed from a potentiometer 4 | // Button Node > Blinks a LED 5 | // Switch Node > Toggles the state of a LED 6 | // TextField Node > Set a PWM value to the LED* 7 | 8 | // Libraries 9 | // To download WebServer.h >> github.com/espressif/arduino-esp32/tree/master/libraries/WebServer 10 | #include 11 | #include 12 | 13 | // Your Network Name (SSID) & Password 14 | // Change them to your network name and password 15 | const char* ssid = "YOUR_NETWORK_NAME"; 16 | const char* password = "YOUR_NETWORK_PASSWORD"; 17 | 18 | // STATIC IP DETAILS 19 | // local must be a unique IP on the local network 20 | IPAddress local(192, 168, 1, 111); 21 | // to know how to configure the rest of the IPAddresses go in your iPhone to: 22 | // (the iPhone must be connected to the same networks as the ESP32) 23 | // Preferences > Wi-Fi > (i) on the WiFi network 24 | // Router -> gateway 25 | // Subnet Mask -> subnet 26 | // DNS -> primaryDNS & secondaryDNS 27 | IPAddress gateway(192, 168, 1, 1); 28 | IPAddress subnet(255, 255, 255, 0); 29 | IPAddress primaryDNS(80, 58, 62, 250); 30 | IPAddress secondaryDNS(80, 58, 62, 254); 31 | 32 | // WebServer instance 33 | WebServer server(80); 34 | 35 | // ESP32 Pins 36 | const int ledPin = 15; 37 | // const int ledChannel = 0; 38 | const int potPin = 34; 39 | 40 | // Sketch variables 41 | bool isLedOn = false; 42 | 43 | void setup() { 44 | // Serial initialization 45 | Serial.begin(115200); 46 | delay(2000); 47 | 48 | // Configures WiFi connection 49 | if (!WiFi.config(local, gateway, subnet, primaryDNS, secondaryDNS)) { 50 | Serial.println("Failed to config"); 51 | } 52 | WiFi.begin(ssid, password); 53 | while (WiFi.status() != WL_CONNECTED) { 54 | delay(1000); 55 | Serial.println("Connecting to WiFi..."); 56 | } 57 | Serial.print("Connected to the WiFi network // IP: "); 58 | Serial.println(WiFi.localIP()); 59 | 60 | // Initialize server 61 | server.begin(); 62 | 63 | // Add here the 'code' of the nodes 64 | // .on(nodeCode, arduinoFunction) 65 | server.on("/potValue", handlePotValue); 66 | server.on("/toggleLed", handleToggle); 67 | server.on("/blinkLed", handleBlink); 68 | server.on("/pwmValue", handlePWM); 69 | 70 | // LED & Pot pinModes 71 | pinMode(ledPin, OUTPUT); 72 | // ledcSetup(ledChannel, 5000, 8); 73 | // ledcAttachPin(ledPin, ledChannel); 74 | pinMode(potPin, INPUT); 75 | } 76 | 77 | void loop() { 78 | server.handleClient(); 79 | } 80 | 81 | // Reads the value of the potentiometer and sends it 82 | void handlePotValue() { 83 | int potValue = analogRead(potPin); 84 | server.send(200, "text/html", String(potValue)); 85 | Serial.println(potValue); 86 | } 87 | 88 | // Toggles the state of a LED 89 | void handleToggle() { 90 | if (server.args()) { 91 | isLedOn = server.arg("value") == "1" ? true : false; 92 | digitalWrite(ledPin, isLedOn); 93 | } 94 | server.send(200, "text/html", isLedOn ? "1" : "0"); 95 | Serial.println(isLedOn); 96 | } 97 | 98 | // Blinks the LED 99 | void handleBlink() { 100 | digitalWrite(ledPin, !isLedOn); 101 | delay(200); 102 | digitalWrite(ledPin, isLedOn); 103 | server.send(200, "text/html", "OK"); 104 | Serial.println("Blink!"); 105 | } 106 | 107 | // Sets a PWM value on the LED 108 | // digitalWrite & ledcWrite can't be 109 | // used simultaneously, so it only prints it 110 | void handlePWM() { 111 | int pwmValue = server.arg("value").toInt(); 112 | // ledcWrite(ledChannel, pwmValue); 113 | server.send(200, "text/html", "OK"); 114 | Serial.println(pwmValue); 115 | } 116 | -------------------------------------------------------------------------------- /ESP32/Old versions/Demo Code v.1.0: -------------------------------------------------------------------------------- 1 | // Sketch ESP32 [static IP: 192.168.1.111] 2 | // Read potentiometer value and display it as a Label Node 3 | // Toggle the state of a LED with a Button Node 4 | // Connection through WiFi 5 | 6 | // Libraries 7 | // To download WebServer.h >> github.com/espressif/arduino-esp32/tree/master/libraries/WebServer 8 | #include 9 | #include 10 | 11 | // Your Network Name (SSID) & Password 12 | // Change them to your network name and password 13 | const char* ssid = "YOUR_NETWORK_NAME"; 14 | const char* password = "YOUR_NETWORK_PASSWORD"; 15 | 16 | // STATIC IP DETAILS 17 | // local must be a unique IP on the local network 18 | IPAddress local(192,168,1,111); 19 | // to know how to configure the rest of the IPAddresses go in your iPhone to: 20 | // (the iPhone must be connected to the same networks as the ESP32) 21 | // Preferences > Wi-Fi > (i) on the WiFi network 22 | // Router -> gateway 23 | // Subnet Mask -> subnet 24 | // DNS -> primaryDNS & secondaryDNS 25 | IPAddress gateway(192,168,1,1); 26 | IPAddress subnet(255, 255, 255, 0); 27 | IPAddress primaryDNS(80, 58, 62, 250); 28 | IPAddress secondaryDNS(80, 58, 62, 254); 29 | 30 | // WebServer instance 31 | WebServer server(80); 32 | 33 | // ESP32 Pins 34 | const int ledPin = 22; 35 | const int potPin = 34; 36 | 37 | // Variables 38 | bool isLedOn = false; 39 | int potValue = 0; 40 | 41 | void setup() { 42 | // Serial initialization 43 | Serial.begin(115200); 44 | delay(2000); 45 | 46 | // Configures WiFi connection 47 | if(!WiFi.config(local, gateway, subnet, primaryDNS, secondaryDNS)) { 48 | Serial.println("Failed to config"); 49 | } 50 | 51 | WiFi.begin(ssid, password); 52 | 53 | while(WiFi.status() != WL_CONNECTED) { 54 | delay(1000); 55 | Serial.println("Connecting to WiFi..."); 56 | } 57 | 58 | Serial.print("Connected to the WiFi network // IP: "); 59 | Serial.println(WiFi.localIP()); 60 | 61 | // Initialize server 62 | server.begin(); 63 | // Add here the 'code' of the nodes 64 | // .on(nodeCode, arduinoFunction) 65 | server.on("/toggleLed", handleToggle); 66 | server.on("/potValue", handlePotValue); 67 | 68 | // LED & Pot pinModes 69 | pinMode(ledPin, OUTPUT); 70 | pinMode(potPin, INPUT); 71 | } 72 | 73 | void loop() { 74 | server.handleClient(); 75 | } 76 | 77 | // When server calls it the LED state is toggled 78 | void handleToggle() { 79 | if(isLedOn) { 80 | digitalWrite(ledPin, LOW); 81 | Serial.println("LED: OFF"); 82 | } else { 83 | digitalWrite(ledPin, HIGH); 84 | Serial.println("LED: ON"); 85 | } 86 | isLedOn = !isLedOn; 87 | server.send(200, "text/html", "done"); 88 | } 89 | 90 | // When server calls it, reads the value of the pot and sends it 91 | void handlePotValue() { 92 | potValue = analogRead(potPin); 93 | Serial.println(potValue); 94 | server.send(200, "text/html", String(potValue)); 95 | } 96 | -------------------------------------------------------------------------------- /ESP32/Readme.md: -------------------------------------------------------------------------------- 1 | ## How it works 2 | - Download the app from the [App Store](https://apps.apple.com/es/developer/david-brana-campos/id1047286431) 3 | 4 | - Download and install the [WebServer Library](https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer) 5 | 6 | - Copy the code from this [GitHub page](https://github.com/ios-dbrancam/ArduinoCmd/blob/master/ESP32/Demo%20Code%20v.1.1) to a new Arduino Sketch 7 | 8 | - You need to modify some things of the sketch 9 | - Change lines *15 .. 16* to your current WiFi network name and password 10 | - `const char* ssid = "YOUR_NETWORK_NAME";` 11 | - `const char* password = "YOUR_NETWORK_PASSWORD"` 12 | - Change lines *27 .. 30* to your IP Address values. If you don't know this value, connect your iPhone to the same network as the ESP32 and go to **Preferences > Wi-Fi > (i)** on the WiFi network and there you will find the values. *Router -> gateway; Subnet Mask -> subnet; DNS -> primaryDNS and secondaryDNS.* 13 | - `IPAddress gateway(192,168,1,1);` 14 | - `IPAddress subnet(255, 255, 255, 0);` 15 | - `IPAddress primaryDNS(80, 58, 62, 250);` 16 | - `IPAddress secondaryDNS(80, 58, 62, 254);` 17 | 18 | - Upload the sketch 19 | 20 | - Follow the schematic to connect a LED and a Potentiometer to the ESP32 21 | 22 | ![Sch_ESP32](https://user-images.githubusercontent.com/53085860/63844898-4f523180-c989-11e9-8ca7-e453b8fd9486.png) 23 | 24 | - Open **ArduinoCmd**, you will find four *nodes* on the Main Screen. The first one displays the value read from the potentiometer (slide down to update the value). The second and third one control the LED, you will be able to blink the LED by pressing the button or toggling the state with the switch. *It's not possible to use PWM and digitalWrite on the ESP32 at the same time so the fourth node is disabled on the Sketch. If the Main Screen is empty it's possible to restart the tutorial from the Preferences View.* 25 | 26 | ![MainView](https://user-images.githubusercontent.com/53085860/63841557-4f4f3300-c983-11e9-9d08-94ab39a06335.png) 27 | 28 | 29 | 30 | ### Quick Reference 31 | 32 | ![Diagram](https://user-images.githubusercontent.com/53085860/62040503-0d9f6100-b1fa-11e9-8252-637cf517f245.jpg) 33 | -------------------------------------------------------------------------------- /ESP8266/Demo Code v.1: -------------------------------------------------------------------------------- 1 | // Sketch : ESP8266 [static IP: 192.168.1.111] 2 | // Connection through WiFi 3 | // Label Node > Displays the value readed from a potentiometer 4 | // Button Node > Blinks a LED 5 | // Switch Node > Toggles the state of a LED 6 | // TextField Node > Set a PWM value to the LED 7 | 8 | // Libraries 9 | #include 10 | #include 11 | #include 12 | 13 | // Your Network Name (SSID) & Password 14 | // Change them to your network name and password 15 | const char* ssid = "YOUR_NETWORK_NAME"; 16 | const char* password = "YOUR_NETWORK_PASSWORD"; 17 | 18 | // STATIC IP DETAILS 19 | // local must be a unique IP on the local network 20 | IPAddress local(192, 168, 1, 111); 21 | // to know how to configure the rest of the IPAddresses go in your iPhone to: 22 | // (the iPhone must be connected to the same networks as the ESP32) 23 | // Preferences > Wi-Fi > (i) on the WiFi network 24 | // Router -> gateway 25 | // Subnet Mask -> subnet 26 | // DNS -> primaryDNS & secondaryDNS 27 | IPAddress gateway(192, 168, 1, 1); 28 | IPAddress subnet(255, 255, 255, 0); 29 | IPAddress primaryDNS(80, 58, 62, 250); 30 | IPAddress secondaryDNS(80, 58, 62, 254); 31 | 32 | // WebServer instance 33 | ESP8266WebServer server(80); 34 | 35 | // ESP8266 Pins 36 | // 4 => GPIO4 ~ D2 37 | const int ledPin = 4; 38 | // A0 => ADC0 39 | const int potPin = A0; 40 | 41 | // Sketch variables 42 | bool isLedOn = false; 43 | 44 | void setup() { 45 | // Serial initialization 46 | Serial.begin(115200); 47 | delay(2000); 48 | 49 | // Configures WiFi connection 50 | if (!WiFi.config(local, gateway, subnet, primaryDNS, secondaryDNS)) { 51 | Serial.println("Failed to config"); 52 | } 53 | WiFi.begin(ssid, password); 54 | while (WiFi.status() != WL_CONNECTED) { 55 | delay(1000); 56 | Serial.println("Connecting to WiFi..."); 57 | } 58 | Serial.print("Connected to the WiFi network // IP: "); 59 | Serial.println(WiFi.localIP()); 60 | 61 | // Initialize server 62 | server.begin(); 63 | 64 | // Add here the 'code' of the nodes 65 | // .on(nodeCode, arduinoFunction) 66 | server.on("/potValue", handlePotValue); 67 | server.on("/toggleLed", handleToggle); 68 | server.on("/blinkLed", handleBlink); 69 | server.on("/pwmValue", handlePWM); 70 | 71 | // LED & Pot pinModes 72 | pinMode(ledPin, OUTPUT); 73 | pinMode(potPin, INPUT); 74 | } 75 | 76 | void loop() { 77 | server.handleClient(); 78 | } 79 | 80 | // Reads the value of the potentiometer and sends it 81 | void handlePotValue() { 82 | int potValue = analogRead(potPin); 83 | server.send(200, "text/html", String(potValue)); 84 | Serial.println(potValue); 85 | } 86 | 87 | // Toggles the state of a LED 88 | void handleToggle() { 89 | if (server.args()) { 90 | isLedOn = server.arg("value") == "1" ? true : false; 91 | digitalWrite(ledPin, isLedOn); 92 | } 93 | server.send(200, "text/html", isLedOn ? "1" : "0"); 94 | Serial.println(isLedOn); 95 | } 96 | 97 | // Blinks the LED 98 | void handleBlink() { 99 | digitalWrite(ledPin, !isLedOn); 100 | delay(200); 101 | digitalWrite(ledPin, isLedOn); 102 | server.send(200, "text/html", "OK"); 103 | Serial.println("Blink!"); 104 | } 105 | 106 | // Sets a PWM value on the LED 107 | void handlePWM() { 108 | int pwmValue = server.arg("value").toInt(); 109 | analogWrite(ledPin, pwmValue); 110 | server.send(200, "text/html", "OK"); 111 | Serial.println(pwmValue); 112 | } 113 | -------------------------------------------------------------------------------- /ESP8266/Readme.md: -------------------------------------------------------------------------------- 1 | ## How it works 2 | - Download the app from the [App Store](https://apps.apple.com/es/developer/david-brana-campos/id1047286431) 3 | 4 | - Copy the code from this [GitHub page](https://github.com/ios-dbrancam/ArduinoCmd/blob/master/ESP8266/Demo%20Code%20v.1) to a new Arduino Sketch 5 | 6 | - You need to modify some things of the sketch 7 | - Change lines *15 .. 16* to your current WiFi network name and password 8 | - `const char* ssid = "YOUR_NETWORK_NAME";` 9 | - `const char* password = "YOUR_NETWORK_PASSWORD"` 10 | - Change lines *27 .. 30* to your IP Address values. If you don't know this value, connect your iPhone to the same network as the ESP32 and go to **Preferences > Wi-Fi > (i)** on the WiFi network and there you will find the values. *Router -> gateway; Subnet Mask -> subnet; DNS -> primaryDNS and secondaryDNS.* 11 | - `IPAddress gateway(192,168,1,1);` 12 | - `IPAddress subnet(255, 255, 255, 0);` 13 | - `IPAddress primaryDNS(80, 58, 62, 250);` 14 | - `IPAddress secondaryDNS(80, 58, 62, 254);` 15 | 16 | - Upload the sketch 17 | 18 | - Follow the schematic to connect a LED and a Potentiometer to the ESP8266 19 | 20 | ![Sch_ESP32](https://user-images.githubusercontent.com/53085860/63844898-4f523180-c989-11e9-8ca7-e453b8fd9486.png) 21 | 22 | - Open **ArduinoCmd**, you will find four *nodes* on the Main Screen. The first one displays the value read from the potentiometer (slide down to update the value). The second and third one control the LED, you will be able to blink the LED by pressing the button or toggling the state with the switch. *It's not possible to use PWM and digitalWrite on the ESP32 at the same time so the fourth node is disabled on the Sketch. If the Main Screen is empty it's possible to restart the tutorial from the Preferences View.* 23 | 24 | ![MainView](https://user-images.githubusercontent.com/53085860/63841557-4f4f3300-c983-11e9-9d08-94ab39a06335.png) 25 | 26 | 27 | 28 | ### Quick Reference 29 | 30 | ![Diagram](https://user-images.githubusercontent.com/53085860/62040503-0d9f6100-b1fa-11e9-8252-637cf517f245.jpg) 31 | -------------------------------------------------------------------------------- /PrivacyPolicy: -------------------------------------------------------------------------------- 1 | No data is collected or stored from the user. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino Commands 2 | *Arduino Commands is an iOS App that allows you to easily control all your Arduino based projects throught WiFi/Ethernet using HTTP Requests.* [App Store](https://apps.apple.com/us/app/arduino-commands/id1474614825) 3 | 4 | [![Schematic-_JPG](https://user-images.githubusercontent.com/53085860/61950423-0f74e480-afae-11e9-9aba-a4c44ea940bc.jpg)](https://apps.apple.com/us/app/arduino-commands/id1474614825) 5 | 6 | You'll start with an empty canvas that you can fill with different kind of **Nodes** to interact with the Arduino: 7 | - **Label**: to display data from the Arduino 8 | - **Button**: to do some action on the Arduino 9 | - **Switch**: to toggle between two states 10 | - **TextField**: to send data as a String to the Arduino 11 | 12 | ![MainView](https://user-images.githubusercontent.com/53085860/63841557-4f4f3300-c983-11e9-9d08-94ab39a06335.png) 13 | --------------------------------------------------------------------------------