--
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.
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.
// 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;
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!
--