Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
send receive TEXT Virtuino6 VirtuinoCN
#1
Hello, I am doing a project with Arduino Mega2560 and Virtuino6 (version 6.0.34) communication via Bluetooth. I use Serial1 and the VirtuinoCN library.
I am interested in passing text strings from Virtuino6 to the Arduino, and from the Arduino to the Virtuino6.
Is it not supported?
I can't find any example.
Can someone show me an example?
Thank you.
Reply
#2
Hi, this is an example for the Ethernet connection.
The only you have to do is to change the connection type lines.
https://virtuino.com/downloads/examples/...e_text.zip

On the top of the code declare two Strings:
String T0="";
String T1="";

On the void loop do something with the strings:
if (T0=="ENABLE PIN 5") digitalWrite(5,HIGH);
  else if (T0=="DISABLE PIN 5") digitalWrite(5,LOW);
 
  T1= "Hello Virtuino "+String(random(100));


Make these changes to the onReceived and onRequested methods 
Code:
void onReceived(char variableType, uint8_t variableIndex, String valueAsText){     
    if (variableType=='V'){
        float value = valueAsText.toFloat();        // convert the value to float. The valueAsText have to be numerical
        if (variableIndex<V_memory_count) V[variableIndex]=value;              // copy the received value to arduino V memory array
    }
    else  if (variableType=='T'){
      if (variableIndex==0) T0=valueAsText;          // Store the text to the text variable T0
      else if (variableIndex==1) T1=valueAsText;     // Store the text to the text variable T1
     //else if (variableIndex==2) T2=valueAsText;     // Store the text to the text variable T2
     //else if (variableIndex==3) T3=valueAsText;     // Store the text to the text variable T3
     
    }
}

String onRequested(char variableType, uint8_t variableIndex){    
Code:
    if (variableType=='V') {
Code:
    if (variableIndex<V_memory_count) return  String(V[variableIndex]);   // return the value of the arduino V memory array
Code:
  }
Code:
  else if (variableType=='T') {
Code:
   if (variableIndex==0) return T0; 
Code:
   else if (variableIndex==1) return T1;  
Code:
   //else if (variableIndex==2) return T2;  
Code:
   //else if (variableIndex==3) return T3;  
Code:
   }
Code:
  
Code:
  return "";
Code:
}
Reply
#3
Good evening Ilias, thank you for your prompt response.
I have already built a program with your comments but in the Virtuino6 APP, when selecting the memory in the "Test value display" field, the "T" option does not appear.
I attach screenshots of the mobile.
As I said, I use the Virtuino6 Pro 6.0.34 version.
Thanks for the help.
Xavier.


Attached Files Thumbnail(s)
               
Reply
#4
Exclamation 
(01-29-2024, 10:00 PM)xmilav Wrote: Good evening Ilias, thank you for your prompt response.
I have already built a program with your comments but in the Virtuino6 APP, when selecting the memory in the "Test value display" field, the "T" option does not appear.
I attach screenshots of the mobile.
As I said, I use the Virtuino6 Pro 6.0.34 version.
Thanks for the help.
Xavier.
Can someone help me understand why I don't see the "T" variable option in the Virtuino6 app?
Reply
#5
Hi, I sorry for the previous answer.
The T variable has been deprecated by Virtuino.
You can use the V variable for the text.
Please check this conversation:
https://virtuino.com/forum/showthread.php?tid=1197
Reply
#6
Heart 
(02-03-2024, 06:17 PM)iliaslamprou Wrote: Hi, I sorry for the previous answer.
The T variable has been deprecated by Virtuino.
You can use the V variable for the text.
Please check this conversation:
https://virtuino.com/forum/showthread.php?tid=1197
Perfect Ilias, it has worked for me both to send text from the Arduino to the Virtuino and the other way around.

Thank you so much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)