How can i get the analog and sensor values from arduino in Iviewer? (Super NoobMan)

137 views
Skip to first unread message

Wendell Mendes

unread,
Mar 16, 2015, 1:25:16 PM3/16/15
to comman...@googlegroups.com
Hello people!

How can i get the value from the sensors in arduino to the Iviewer App?

With my current project, i can make the digital outputs turning ON and OFF, normally, through the LAN, but i want to improve the app capacity and incorporate the values of the sensors connected to the Arduino, on my tablet screen. How should i proceed?

To help those who are helping me (Haha):
The way I trigger outputs is by the command "GET / 100 HTTP / 1.1 \ x0d \ x0AHOST: 192.168.0.120 \ x0d \ x0A \ x0d \ x0A" in
iViewer, where "100" is the value that I use as argument in my function "Switch Case", in the Arduino, which causes the digital ports, stay on or turn off.

Is there any way to do something like that? I tried to use the "return", in Arduino, but it still fails. Thank you very much!

Jarrod Bell

unread,
Mar 16, 2015, 6:56:19 PM3/16/15
to comman...@googlegroups.com
Unless the Arduino is setup to push data over a raw TCP or UDP socket, you will have to poll the unit for the sensor values.
If you are limited to using HTTP, I would suggest you learn JavaScript. The documentation is here:
http://commandfusion.com/docs/scripting/

Then you would use CF.request to make the HTTP request, and process the response data however you need.
Use CF.setJoin to update the UI in iViewer using the returned data.

http://commandfusion.com/docs/scripting/net.html#cF.request
http://commandfusion.com/docs/scripting/gui.html#cF.setJoin

Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Barry Gordon

unread,
Mar 17, 2015, 11:59:20 AM3/17/15
to comman...@googlegroups.com

I strongly second Jarrod's "learn javascript" comment. Once you do that the world of automation changes (for the better). I am not familiar with the Arduino, having chosen to use the Raspberry Pi. On the Pi you can either use Node Javascript or Python, either of which would suffice for communications over TCP to iViewer.

 

In my home I have multiple wall mounted iPads plus an iPhone 5S that I carry around with me.  They run the same guiDesigner/iViewer system with some code sections specifically checking if running on an iPad or iPhone e.g. resume from sleep). When I am programming other controllers for communications with iViewer I have chosen UDP whenever possible for communications of asynchronous events from the controller (Homeseer, Autelis Pool control, etc.) to iViewer. The UDP message protocol includes a message sequence number and each message is sent "n" times (n is currently2 in my house) with the same sequence number. The iViewer code discards messages with the same sequence numbers (repeats). This gives reliable communications over UDP even though not guaranteed delivery.

 

For messages from iViewer to the controller/device I use TCP but establish and destroy sessions as I need them. If a device is busy when an iPad tries to send it a message (establishing a session by first connecting) it retries after a short delay. A message session my contain multiple queued messages.

Wendell Mendes

unread,
Mar 19, 2015, 1:48:28 PM3/19/15
to comman...@googlegroups.com
Thank You. I'll goto study more.
But, in arduino, how can i answer the request? A function like this will works?:


ANSWER() {
    return Info_needed;
};


Thank you. You both are amazing!

Steve

unread,
Mar 19, 2015, 4:00:01 PM3/19/15
to comman...@googlegroups.com
I have not actually done this but have thought about it.

You would need an ethernet shield on your Arduino and then create an EthernetServer class using the Ethernet library. When you receive a request from Command Fusion cF.request you check the sensors connected to the Arduino and respond.

Should be relatively easy.

If you want to do it wirelessly, you should be able to use a WIFI shield with the WIFI library. From what I can see the WIFIServer class is much the same as the EthernetServer class.

Of course, once you add up the cost of an Arduino and an ethernet or WIFI shield you may as well get a RaspBerry Pi 2. It all depends on whether you need battery operation or not.

In my situation I use battery operated Moteino's (http://lowpowerlab.com/moteino/) which can be had for less than $20. These talk to a Moteino USB which talks to my iMac. CF talks to my iMac via Apache/PHP which grabs the data from a MySQL Database that is populated with data from the Moteino's. Each wireless Moteino has temperature, humidity and light sensors attached and wake up every six minutes, take readings and send that data to the iMac. Three AA batteries last about a year or so this way.

Wendell Mendes

unread,
Mar 20, 2015, 10:22:39 AM3/20/15
to comman...@googlegroups.com
Very Nice, man!

In my situation, i have a Webserver with the ethernet shield. Actually, i can turn ON and OFF my serial ports, using the command "GET /100 HTTP/1.1\x0D\xAHOST: 192.168.25.100\x0D\x0A\x0D\x0A\" , when the "/100" is the ID that i use in my Switch Case, in arduino code. Like this:

case 100:
     turnOnMyLight();
     break;
   
Can i use the CF.request() to get the answer from the Arduino just like i turn ON a lamp?

How can i use CF.request() and arduino return? Can i use "client.println("value")" - From ETHERNET library - to send a text to CF.request?

i know that when i use CF.request() i can get the page that the arduino uses to theirs users can navigate, but my server don't works like that. Look how i did in the arduino code:

...

       // Create a client connection
      EthernetClient client = server.available();
      if (client) {
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();

            //read char by char HTTP request
            if (readString.length() < 100) {

              //store characters to string
              readString += c;
               }
           
               //if HTTP request has ended
            if (c == '\n') {

              inString = readString.substring(5,8);        
            
              Strng = (inString.toInt());

              Serial.println(readString); //print to serial monitor for debuging
              Serial.println(inString); //print to serial monitor for debuging
              Serial.println(Strng); //print to serial monitor for debuging  
              Serial.println(readString.substring(5,6)); //print to serial monitor for debuging  
            

          
         if((Strng == 30)  && (digitalRead(7) == HIGH))
              {
                digitalWrite(7, LOW);    // set pin 7 high
               }
             
         if((Strng == 31) && (digitalRead(7) == LOW))
                {
                  digitalWrite(7, HIGH);    // set pin 7 low
                }

         if((Strng == 40) && (digitalRead(8) == HIGH))
              {
                digitalWrite(8, LOW);
              }
    
        if((Strng == 41) && (digitalRead(8) == LOW))
                {
                  digitalWrite(8, HIGH);
                }
    

    if (readString.substring(5,6) == "1")
    {
       digitalWrite(IRCPin_2, LOW);
       digitalWrite(IRCPin_1, HIGH);
       Serial.println("IR 1");  
       delay(50);
    }
    if (readString.substring(5,6) == "2")
    {
       digitalWrite(IRCPin_1, LOW);
       digitalWrite(IRCPin_2, HIGH); 
       Serial.println("IR 2");     
       delay(50);
    }


        switch (Strng)
        {
        
          case 100: //REBEMBER the "/100"? here he will be used
             LgBdAudio(); 
             Serial.println("LG BD Audio");
             break;        


Can you help me? I'll do whatever needed

Barry Gordon

unread,
Mar 20, 2015, 1:53:35 PM3/20/15
to comman...@googlegroups.com

I will start off by saying I know zero about the Arduino, I use R Pi's. In iViewer I tend to use CF.send and monitor the feedback for communications to "servers" I construct. I open the connection of iViewer and once the connection is established (I generally use always on as the system mode and control connectivity through the enable property of the system properties.)

 

If the Arduino can do HTTP it must be able to do TCP. By watching for feedback on the IP:port the Arduino is using you can send messages (CF.send) and receive anything that the Arduino sends, be it a reply to a message you sent or an asynchronous transmission of a status change. This eliminates the HTTP overhead and I believe is much simpler easier. I use both TCP and UDP in this manner.

 

 

 

From: comman...@googlegroups.com [mailto:comman...@googlegroups.com] On Behalf Of Wendell Mendes
Sent: Friday, March 20, 2015 10:23 AM
To: comman...@googlegroups.com
Subject: Re: How can i get the analog and sensor values from arduino in Iviewer? (Super NoobMan)

 

Very Nice, man!



Can you help me. I'll do whatever needed




Em quinta-feira, 19 de março de 2015 17:00:01 UTC-3, Steve escreveu:

I have not actually done this but have thought about it.

You would need an ethernet shield on your Arduino and then create an EthernetServer class using the Ethernet library. When you receive a request from Command Fusion cF.request you check the sensors connected to the Arduino and respond.

Should be relatively easy.

If you want to do it wirelessly, you should be able to use a WIFI shield with the WIFI library. From what I can see the WIFIServer class is much the same as the EthernetServer class.

Of course, once you add up the cost of an Arduino and an ethernet or WIFI shield you may as well get a RaspBerry Pi 2. It all depends on whether you need battery operation or not.

In my situation I use battery operated Moteino's (http://lowpowerlab.com/moteino/) which can be had for less than $20. These talk to a Moteino USB which talks to my iMac. CF talks to my iMac via Apache/PHP which grabs the data from a MySQL Database that is populated with data from the Moteino's. Each wireless Moteino has temperature, humidity and light sensors attached and wake up every six minutes, take readings and send that data to the iMac. Three AA batteries last about a year or so this way.

On Monday, March 16, 2015 at 1:25:16 PM UTC-4, Wendell Mendes wrote:

Hello people!

How can i get the value from the sensors in arduino to the Iviewer App?

With my current project, i can make the digital outputs turning ON and OFF, normally, through the LAN, but i want to improve the app capacity and incorporate the values of the sensors connected to the Arduino, on my tablet screen. How should i proceed?

To help those who are helping me (Haha):
The way I trigger outputs is by the command "GET / 100 HTTP / 1.1 \ x0d \ x0AHOST: 192.168.0.120 \ x0d \ x0A \ x0d \ x0A" in
iViewer, where "100" is the value that I use as argument in my function "Switch Case", in the Arduino, which causes the digital ports, stay on or turn off.

Is there any way to do something like that? I tried to use the "return", in Arduino, but it still fails. Thank you very much!

--

Steve

unread,
Mar 20, 2015, 4:13:46 PM3/20/15
to comman...@googlegroups.com
So, as I said, I have not done it with an ethernet shield.

Just looking at the ethernet library it kinda looks like you are on the right track. Do you have a EthernetServer instance. if so you would just use server.write(data) to send something back to CF.

In fact, why not just use the example at http://arduino.cc/en/Reference/EthernetServer to send some data using cf.Request or cF.send and see if it comes back? (That's all that example does - write back what it received).

From the code that you provided you could add a server.write("Hello"); to the case 100 code.

Jarrod Bell

unread,
Mar 20, 2015, 5:50:02 PM3/20/15
to comman...@googlegroups.com
Definitely agree with Barry here. Use raw TCP sockets if you can, much easier to handle two way communications this way. HTTP is not designed for this and should only really be used if you have no other choice.


Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


Reply all
Reply to author
Forward
0 new messages