Ways of getting Arduino Yun communicate

Hi,I'm new to Arduino, what I'm saying here is very likely to be wrong. :smiley:
Just want to share some notes,
Do correct me if my understanding is wrong .

The first thing I wanted to do when I have an Arduino Yun was to make it connected with the web, the internet of things.

So far I have found several ways that allow Arduino Yun to connect with the world.

  1. Build API with Yun's native Bridge library YunServer and YunClient

This simple code basically builds up a server on Arduino provides a set of APIs. Other devices on the same internal network can call these API to access the features on Arduino.

It's suitable for getting a few data from Yun, but not for more complex data processing.

And you also need to make Yun accessible from the web, if you really want run the Arduino standalone.

  1. Use Yun's native Bridge HttpClient get method

Libraryhttp://arduino.cc/en/Tutorial/HttpClient

the HttpClient get method allows you to call a GET api.

However, for some reason, it doesn't include a POST method.

But I found out you can use http POST by using Bridge's linux CURL command.

  1. Follow Arduino instructions, use Temboo

Maybe I missed something, it seems only give you a limited number of features.

  1. Use serialport / Johnny-Five packages

They are cool, and I'm sure they can do more, but the concept of these packages is essentially to establish a port connection with Arduino, without further tweaking, with another computer, which seems against the concept of Arduino Yun ( to be something standalone ).

I haven't come this far, but could it establish the connection remotely, ideally one server to multiple devices ?

  1. Build a Nodejs server on Arduino Yun

Here is a good article.

http://www.tigoe.com/pcomp/code/arduinowiring/1216/

I haven't really tried, just a bit worried about Arduino's capacity.

After reviewed all these solutions, I'm relatively in favour of the 2nd method- Use Yun's native Bridge HttpClient get method. I was wondering, why not just simply make http calls from Yun ?

The rationale is:

  1. Arduino Yun can stand alone, all you need is a power supply.

  2. You don't need to expose Yun to the internet by building a server on it.

  3. Arduino language is low-level, all it needs to do is to make http calls and deal with what it's born to do.

  4. You can have a nodejs server, in the cloud which deal with more complex processing, i.e. exchange data with the database.

  5. It's cross-platform.

So I made this simple experiment,

it's constitute by three parts:

  • an Arduino client ( makes http GET/POST calls, and deal with the electronic part.)

  • a Nodejs server ( provides API )

  • a web/mobile client by angularjs

a demo: - YouTube

Make http GET call:

client.get("http://192.168.1.70:3000/getSignal");

here my internal ip for the nodejs server was 192.168.1.70, but it could be anything like example.com.

Make http POST call:

shell.runShellCommand("curl --data"number="+String(pitch*100)+""http://192.168.1.70:3000/postSignal");

Get response:

while (client.available()) {
String command = client.readStringUntil('/');
Serial.println( command.toFloat()(sensorValue/1000));
tone(toner, command.toInt()
(sensorValue/1000), speed);
}

A noticeable point is you can use stream class methods to read the stream which GET/POST method come back with.

One of the drawbacks here is clearly this program makes too many GET calls.

This is my idea so far.

Again, I'm not experienced in Arduino at all. I don't know which way is more efficient and useful.

I've used the first method and I think its quite easy, eventhough just for basic commands and few data, not large stream data. You dont have to expose the yun to the internet if your network isnt connected (I connected my tablet to yun as accespoint).

yoyu777:
Hi,I'm new to Arduino, what I'm saying here is very likely to be wrong. :smiley:
Just want to share some notes,
Do correct me if my understanding is wrong .

::::

youyu777,
there is nothing "wrong" with your understanding. However, there is another method, alluded to, but not really seen. There other method that might be worth considering is to have the "client" run on the Linux side of the Yun (and not the Arduino side).

Jesse

mart256:
I've used the first method and I think its quite easy, eventhough just for basic commands and few data, not large stream data. You dont have to expose the yun to the internet if your network isnt connected (I connected my tablet to yun as accespoint).

Hi Mart, the thing is I really want to connect it through the internet, not internal network.

jessemonroy650:
youyu777,
there is nothing "wrong" with your understanding. However, there is another method, alluded to, but not really seen. There other method that might be worth considering is to have the "client" run on the Linux side of the Yun (and not the Arduino side).

Jesse

You mean to run a shell command that run programs based on C ?

yoyu777:
You mean to run a shell command that run programs based on C ?

yoyu777,
you could run a shell command, but you could also use the "bridge" mailbox or run a daemon on the linux side.

However, this speculation is a bit too much. From what I can see, the process can be as simple or as complex as you need.

So, rather than dabble in "for instance this idea, or that idea", please let us know what you goal is. Please tell us what you are trying to accomplish. Is this a hobby idea? Is this a learning project? Do you plan on using this for more than gathering data?

You said at one point:

It's suitable for getting a few data from Yun, but not for more complex data processing.

What does that mean? It would help to have a concrete idea of what this is, and not vague descriptions.

TIA
Jesse

jessemonroy650:
yoyu777,
you could run a shell command, but you could also use the "bridge" mailbox or run a daemon on the linux side.

However, this speculation is a bit too much. From what I can see, the process can be as simple or as complex as you need.

So, rather than dabble in "for instance this idea, or that idea", please let us know what you goal is. Please tell us what you are trying to accomplish. Is this a hobby idea? Is this a learning project? Do you plan on using this for more than gathering data?

You said at one point:

It's suitable for getting a few data from Yun, but not for more complex data processing.

What does that mean? It would help to have a concrete idea of what this is, and not vague descriptions.

TIA
Jesse

Thanks for your reply Jesse,
What I want to do is a communication tool, so I have to allow it to run across the cloud.
And it needs to work across different platforms, so I would like to process the data on the server side, so i don't need to repeat on every platform.

I agree with you. But when i posted this, i really wanted to ask a generic question, as a beginner :slight_smile:

yoyu777:
Thanks for your reply Jesse,
What I want to do is a communication tool, so I have to allow it to run across the cloud.
And it needs to work across different platforms, so I would like to process the data on the server side, so i don't need to repeat on every platform.

I agree with you. But when i posted this, i really wanted to ask a generic question, as a beginner :slight_smile:

I understand.

  • Getting data to the "cloud" is not an issue, you have wireless and ethernet. In worst case, you would have to by a bridge to get the data to the internet.

  • Processing data on the is limited. You have the equivalent of a Pentium II (2) AND not much RAM - 64 MB (and much of it is used by the OS.) You will not have to use any software tricks, but you will have to becareful depending on what data you are collecting.

  • The data you collect is the key. If you are collecting pictures, each picture could be 1Mb. If you are sampling room temperature, then you could collect every minute of every day of weeks before you need upload.

Is this helping?

Jesse