Send JS variable from web server to the Arduino sketch

Hi,

I spent hours trying to understand this, but I must be missing the thing:
How to send a Javascript variable from a webpage (hosted on an Arduino Yun) to the running Arduino sketch.

I have a simple webpage with a text input on it, and I want to send its value (Javascript String) to the Arduino sketch, to control a servo motor. I've tried many things with REST, /arduino and /data to use key and values, but nothing worked.

The problem might possibly come from the webpage. How to send Javascript variables to the Arduino sketch?
I couldn't find any answer in the forum, nor on the Arduino Yun official pages.

Can someone a bit more advanced give me a hint?

Thank you so much in advance :slight_smile:

It may sound trivial, but I'm really stuck on this.

Phil01:
It may sound trivial, but I'm really stuck on this.

You can contact the sketch by means of "the bridge". On side of the sketch, you would have to include bridge.h and make appropriate calls to the bridge methods in order to receive those variable(s). I know that there are bridge libraries for Python and Lua, which by default are available on the Linino side, you would have to find the equivalent for your JavaScript code or IWCS, push the data down by calling a Python or Lua script with the variable as parameter....

Ralf

Thanks!

Yes I thought about something like this, but I can't find any documentation.

IS the arduino on the network ?

using html5 and MQTT this would be pretty easy

--Matt

Yes the Arduino is connected to a wifi network. Actually the web page is hosted ON the Arduino Yun.

I've just read about MQTT, sounds like a way to go but still a bit abstract to me.

Arduino Yun Bridge and Javascipt example:

http://forum.arduino.cc/index.php?topic=217756.msg1591479#msg1591479

Thank you so much Sonnyyu! That's what I was looking for.

The Javascript part - how to send the data - was really not clear. Now this example should make things easier:
http://www.fabiobiondi.com/blog/2014/02/html5-arduino-yun-and-angularjs-build-a-mobile-servo-controller/