0@0 0@0 175 0@0 169 383 0@-120 root output globalVariable 2 bdeff322-e2d0-453c-a0fe-50d8e0c45478 0@-312 4 470@150 490@150 corner: 633.0d@190 470@150 corner: 653.0d@190 495.0d@164.5d Index 1 470@180 490@180 464.0d@183.5d Virtuino_SE_read in d0676182-94e9-4f82-96a6-f7fa7ed60e2f e0412fad-e9c9-4da2-b2d4-f54b062414e6 d074b8c7-908b-42b6-9dc4-4598c55c8e30 caee7d17-717b-4a2a-86fc-4cc043acd2e0 8cbbf72c-9ad9-49e1-ae6b-a0c9f9862f25 Virtuino_SE_ read //--- How to read a variable from Virtuino SE if (in!=V_memory[index]) { // Read the V0 memory. On Virtuino panel add a regulator to virtual memory V0 in=V_memory[index]; } 208 470@170 corner: 490@190 3 760@170 780@170 corner: 824.0d@190 760@170 corner: 844.0d@190 784@184.0d 760@170 corner: 780@190 760@180 ыход 1 GPIO4 D4,D14/SDA 178586408 36.0d 8.0d 780@180 653.0d@180 corner: 653.0d@180 in 10.0d 633.0d@180 653.0d@180 8de48cc3-5c22-4140-89fa-17931ae36b1a 201848c2-1add-44f2-af97-6799c38274c2 9dc8aabb-469c-4809-817b-9df4724e7695 //--- How to read a variable from Virtuino SE if (in!=V_memory[Index]) { // Read the V0 memory. On Virtuino panel add a regulator to virtual memory V0 in =V_memory[Index]; } 210 633.0d@170 corner: 653.0d@190 Virtuino_SE_read_rabotaet 4ba8d867-09c7-4104-b46b-0309de7fc604 Virtuino_SE_ read_rabotaet 143.0d 6 370@410 390@410 corner: 529.0d@430 370@410 corner: 549.0d@430 394@423.5d 370@420 390@420 370@410 corner: 390@430 7 620@410 640@410 corner: 780.0d@470 620@410 corner: 800.0d@470 645.0d@424.5d 620@430 corner: 640@450 Index_vhod 620@460 640@460 612.0d@463.5d Отправить V (float) Вход V (float) in d6426b76-faa8-4b6e-8e46-35239356b49d d76fe00f-37d3-451c-9faf-0fc074579211 9bd5db24-bf75-434d-afca-c3d7ab5ce539 Вход V (float) memoryIndex 0 100 149e963d-f45f-493e-8e7c-2337794649d6 3a810b69-9f93-4ad8-a999-8711e4e9229d virtuino.vMemoryWrite(memoryIndex,in); 38 Index 55a592d4-f7e3-4350-8551-a19f1d7bc6c9 74537b29-6c6c-4643-a4d0-fe50e03271dd 0f30f465-d4c3-4d9a-a394-a7beb141a290 Отправить V (float) Отправить переменную V в Virtuino 33 virtuino.vMemoryWrite(Index,in); 32 620@450 corner: 640@470 620@440 620@460 Отправить_в_Virtuino_ Se in_vhod 7b1f2498-e6e3-43d4-97ee-ffa422ffadd9 Отправить_в_Virtuino_ Se //--- How to send to Virtuino SE sensor values if (millis()-timeStrored>5000) { // read sensor value every 5 seconds. Avoid to use delay on your code V_memory[ Index_vhod ]= in_vhod ; // copy the sensor value to V2 timeStrored=millis(); // On Virtuino panel add value displays or instrument to virtual memories V2,V3,V4 } 372 140.0d 640@440 549.0d@420 corner: 549.0d@440 0.0d 529.0d@420 549.0d@420 529.0d@410 corner: 549.0d@430 отттправляем на андроид 22 131.0d 7.0d 9 250@40 270@40 corner: 366.0d@60 250@40 corner: 386.0d@60 275.0d@54.5d Virtuino_SE_Json f57240bc-fd3d-423c-a2df-b05cecd74d24 Virtuino_SE_ Json WIFI NETWORK Vladlink_99C4BA cb0a0bf5-7021-4ebd-9b60-2afc0f78a28c 72613bb6-59f1-4d1a-8e55-54740ca87c69 PASSWORD 43345911 7fed998f-eea4-4338-9bc8-6aa2295e6069 b2e94ec7-01de-4155-864f-d929f25d5b65 virtuinoRun(); //Necessary function to communicate with Virtuino. Client handler 91 if (debug) { Serial.begin(9600); while (!Serial) continue; } //initAccessPoint(); //enable this line to use the esp board as AP connectToWiFiNetwork(); //enable this line to connect the module to your wifi network wifiServer.begin(); 276 #ifdef ESP8266 #include <ESP8266WiFi.h> The name of your WiFi network (SSID) ssid = "WIFI NETWORK"; #else #include <WiFi.h> #endif const char* WIFI network PASSWORD password = "PASSWORD"; const char* Virtuino default Server port: 8000 wifiServer (8000); WiFiServer Access point network SSID ssid_AP = "Virtuino network"; const char* Access point network PASSWORD password_AP = "1234567890"; const char* Virtuino KEY, only the requests that include this key will be acceptable. // disable the line if you don't want to use a key #define VIRTUINO_KEY "1234" the size of V memory. You can change it to a number <256 #define V_memory_count 255 This array is synchronized with Virtuino SE V memory V_memory [V_memory_count]; float set this variable to false on the finale code to decrease the request duration debug = true; boolean variable1 = 0; float variable2 = 0; float timeStrored =0; unsigned long #define WRONG_KEY_MESSAGE "Wrong Key" #define WELLCOME_MESSAGE "Hello Virtuino" Serial.println("Connecting to "+String(ssid)); // If you don't want to config IP manually disable the next four lines IPAddress ip(192, 168, 1, 150); // where 150 is the desired IP Address IPAddress gateway(192, 168, 1, 1); // set gateway to match your network IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network WiFi.config(ip, gateway, subnet); // If you don't want to config IP manually disable this line WiFi.mode(WIFI_STA); // Configure the module as station only. WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println(WiFi.localIP()); 788 void connectToWiFiNetwork Serial.print("Setting soft-AP ... "); // Default IP: 192.168.4.1 WiFi.mode(WIFI_AP); // Config module as Access point only. Set WiFi.mode(WIFI_AP_STA); to config module as Acces point and station boolean result = WiFi.softAP(ssid_AP,password_AP); // set the Access point SSID and password if(result == true) { Serial.println("Server Ready"); Serial.println(WiFi.softAPIP()); } else Serial.println("Failed!"); 492 void initAccessPoint String valueAsText = getJsonValue(valueAsJson,"value"); // read the value from the received Json string if (debug) Serial.println("New value received: V"+String(variableIndex)+" value="+valueAsText); if (valueAsText=="?") return String(V_memory[variableIndex]); // return the value of the arduino V memory array else { float value = valueAsText.toFloat(); // convert the value to float. The valueAsText have to be numerical V_memory[variableIndex]=value; // copy the received value to arduino V memory array } return ""; 568 String onCommandReceived int variableIndex String valueAsJson WiFiClient client = wifiServer.available(); if (client) { if (debug) Serial.println("Client connected"); while(!client.available())delay(1); // Wait until the client sends some data String data=""; while (client.connected()) { while (client.available()>0) { char c = client.read(); data+=c; if (debug) Serial.write(c); } client.flush(); if (debug) Serial.println("\nReceived data: "+data); String response= getResponseAsJson(data); client.print(response); if (debug) Serial.println("Response : "+response); client.stop(); } if (debug) Serial.println("Client disconnected"); } 680 void virtuinoRun //---check the KEY #ifdef VIRTUINO_KEY String key = getJsonValue(data, "key"); if (debug) Serial.println("Key="+key); if (!key.equals(VIRTUINO_KEY)) return "{\"status\":\"-1\",\"message\":\""+String(WRONG_KEY_MESSAGE)+"\"}"; #endif //---check connection status String statusInfo = getJsonValue(data, "status"); if (debug) Serial.println("statusInfo="+statusInfo); if (statusInfo.equals("0")) return "{\"status\":\"2\",\"message\":\""+String(WELLCOME_MESSAGE)+"\"}"; String response="{\"status\":\"1\""; for (byte i=0;i<V_memory_count;i++){ // easy way to read a Json object without installing extra json libraries String jsonTag="V"+String(i)+"_"; int pos = data.indexOf(jsonTag); if (pos>0) { int startPos= data.indexOf("{",pos+1); if (startPos>pos) { int endPos= data.indexOf("}", startPos+2); if (endPos>startPos) { String variableAsJson = data.substring(startPos,endPos+1); String variableValue=onCommandReceived(i,variableAsJson); if (variableValue.length()>0) response+=",\""+jsonTag+"\":{\"value\":\""+urlencode(&variableValue)+"\"}"; } } } } //for response+="}"; return response; 1271 String getResponseAsJson String data int pos = jsonAsText.indexOf(jsonTag); if (pos>0) { int startPos=jsonAsText.indexOf(":\"",pos); int lastPos = jsonAsText.indexOf("\"",startPos+2); String value=jsonAsText.substring(startPos+2,lastPos); value=urldecode(&value); if (lastPos>startPos) return value; } return ""; 318 String getJsonValue String jsonAsText String jsonTag String encodedString=""; char c; char code0; char code1; for (int i =0; i < str->length(); i++){ c=str->charAt(i); if (c == '+'){ encodedString+=' '; }else if (c == '%') { i++; code0=str->charAt(i); i++; code1=str->charAt(i); c = (h2int(code0) << 4) | h2int(code1); encodedString+=c; } else{ encodedString+=c; } yield(); } return encodedString; 479 String urldecode String* str String encodedString=""; char c; char code0; char code1; char code2; for (int i =0; i < str->length(); i++){ c=str->charAt(i); if (c == ' '){ encodedString+= '+'; } else if (isalnum(c)){ encodedString+=c; } else{ code1=(c & 0xf)+'0'; if ((c & 0xf) >9){ code1=(c & 0xf) - 10 + 'A'; } c=(c>>4)&0xf; code0=c+'0'; if (c > 9){ code0=c - 10 + 'A'; } code2='\0'; encodedString+='%'; encodedString+=code0; encodedString+=code1; //encodedString+=code2; } yield(); } return encodedString; 678 String urlencode String* str if (c >= '0' && c <='9'){ return((unsigned char)c - '0'); } if (c >= 'a' && c <='f'){ return((unsigned char)c - 'a' + 10); } if (c >= 'A' && c <='F'){ return((unsigned char)c - 'A' + 10); } return(0); 248 unsigned char h2int char c 96.0d 560 (0 to: 560) отправляем на андроид pizda 9600 arduinoIDE 134 4096 238630949 WeMos D1 R1 21466046