Virtuino Forum
Synchronize text T[] with ESP32 - Printable Version

+- Virtuino Forum (https://virtuino.com/forum)
+-- Forum: Virtuino (https://virtuino.com/forum/forumdisplay.php?fid=1)
+--- Forum: Virtuino 6 (https://virtuino.com/forum/forumdisplay.php?fid=3)
+--- Thread: Synchronize text T[] with ESP32 (/showthread.php?tid=1283)



Synchronize text T[] with ESP32 - Dionysos - 05-02-2023

Hi,

Ilias, I would like your opinion on my approach 

I want to use the ESP32 in AP mode to initialize STA mode. So I synchronize text variables (conversions of char SSID and char password).

As Virtuino 6 allows to declare text variables T[], to synchronyse them i have declared an array of String :
String T[10];  // array for 10 text values

This allows  enums, easy to use in the code than V40, V41... as text : 
enum ePinsAP {
eButtonValid = 0,  // Virtuino virtual V Memory V[0]
eSsidNetwork = 1, // Virtuino virtual T Memory T[1]
ePwNetWork = 2,
};


... Setup ...
V[eButtonValid] = 0;  // Valid SSID_STA
T[eSsidNetwork] = "";
T[ePwNetWork] = "";



So I added an "if (variableType == 'T')" test in the onReceived and onRequested functions : 

void onReceived(char variableType, uint8_t variableIndex, String valueAsText) {
if (variableType == 'V') {
// Modified to take case of text values
// float value = valueAsText.toFloat();                          // convert the value to float. The valueAsText have to be numerical
if (variableIndex < V_memory_count) {
float value = valueAsText.toFloat();  // convert the value to float. The valueAsText have to be numerical
V[variableIndex] = value;            // copy the received value to arduino V memory array
}
// else if (variableIndex == 40) V40 = valueAsText;
//  ..
}
if (variableType == 'T') {
T[variableIndex] = valueAsText;
}
}

String onRequested(char variableType, uint8_t variableIndex) {
if (variableType == 'V') {
if (variableIndex < V_memory_count) return String(V[variableIndex]);  // return the value of the arduino V memory array

// else if (variableIndex == 40) return V40;  // return the value of the V0 variable
//..
}
if (variableType == 'T') {
return T[variableIndex];
}

return "";
}


It works well. But I read that you don't recommend using T[] variables.
Will you remove them in future versions of virtuino 6 ?
For this use, i would be disappointed.

Thanks for your opinion.

Denis


RE: Synchronize text T[] with ESP32 - iliaslamprou - 05-02-2023

Hi,
this option has already deprecated from the app. 
Which is your app version?
I don't intend to make other changes to the variables. 
I am amazed that it still works!


RE: Synchronize text T[] with ESP32 - Dionysos - 05-06-2023

(05-02-2023, 10:29 PM)iliaslamprou Wrote: Hi,
this option has already deprecated from the app. 
Which is your app version?
I don't intend to make other changes to the variables. 
I am amazed that it still works!

Thanks,

Virtuino 6 version 6.0.32

Don't change anything, I'm fine with T[] variable text Wink


RE: Synchronize text T[] with ESP32 - Dr. Mario - 05-07-2023

Hello!
Where can I find sample code for Arduino IDE ESP8266 with text messaging between the controller and Virtuino 6 CM, and the Virtuino6 project itself?
I installed the VirtuinoCM library, so far I managed to control the GPIO.
I can't figure out how to receive and send text from ESP to Virtuino6 project.


RE: Synchronize text T[] with ESP32 - Dionysos - 05-07-2023

(05-07-2023, 02:30 PM)Dr. Mario Wrote: Hello!
Where can I find sample code for Arduino IDE ESP8266 with text messaging between the controller and Virtuino 6 CM, and the Virtuino6 project itself?
I installed the VirtuinoCM library, so far I managed to control the GPIO.
I can't figure out how to receive and send text from ESP to Virtuino6 project.
I think it is better to control GPIO with variables  V[] values.

If you only want to send and receive text values, you can:

1 - use the example sketch (for esp8266 and ESP32 with VirtuinoCM): Wemos_NodeMCU_ESP8266_Vmemory_text.ino
This example adds the "if" condition to handle the each case of text variables V0, V1..: if (variableIndex==0) V0 = valueAsText;

2 - proceed as I explained above. This example:
- declare a text array: String T[10]; // array for 10 text values.
- initialize T[1]="", T[2] = "", ...
  or T[eSsidNetwork] = ""; if you want to use enum
- then as I wrote, add if conditions to process the text array:
if (variableType == 'T') {T[variableIndex] = valueAsText;}


RE: Synchronize text T[] with ESP32 - Dr. Mario - 05-07-2023

I can't figure out how and in which widget you can select Virtuino pin T0.
In the widget settings, there are only Digital pin, Analog pin, PWM pin ~, V-memory, M memory.
I have the latest version of Virtuino 6.0.31 - Pro.
After careful study, I finally understood. Virtuino pin T flush type selection is not supported.


RE: Synchronize text T[] with ESP32 - Dionysos - 05-08-2023

Virtuino 6 pro / Level 2/ Text value display / Memory / Text memory T

Text memory T is supported with the appropriate instructions, as explained above.


RE: Synchronize text T[] with ESP32 - iliaslamprou - 05-08-2023

Hi,
I think the T memory is supported because the project is updated from an older version to a newer.
Using the latest version there are no difference between text and number. 
The app uses the V memory to transfer number or text.
By default the arduino code examples are configured to support 32 float values not text. 
The code needs some changes if you want to support both text and numbers.

There are examples on how to do it in this post:
https://virtuino.com/forum/showthread.php?tid=1197 

This is the library example on how to transfer text:
https://virtuino.com/downloads/examples/virtuinoCM/Wemos_NodeMCU_ESP8266_Vmemory_text.zip 
On this example the code supports 32 float values and some text variables.