Arduino Yun Webserver

Hello Arduino Forum,

I recently purchased an Arduino Yun and I am attempting this the arduino temperature webserver tutorial. (http://arduino.cc/en/Tutorial/TemperatureWebPanel). I created a folder named arduino on the sd card and then in that a subfolder called www, just as the tutorial says. When I put the SD card back into the Yun and uploaded the provided code everything seems to run well until you go to the site. The website says that to access the data one can go to arduino.local/sd/temperatureWebPanel. I did this, obviously replacing the arduino with the name of my yun. When the site finally loads I get this: Not Found: The requested URL /sd/TemperatureWebPanel was not found on this server.
Please help in any way you can.
Thanks,
ma7730

TemperatureWebPanel example uses additional files: and webpage and some javascript. For these additional files to get uploaded to the yun, you need to upload via wifi, not USB

I added the html file just as they said and uploaded the code via wifi but it still does not work. =(

Can you paste the URL you're using? What's the name of your yun?

My yun's name is ma7730, so I use ma7730.local/sd/temperatureWebPanel. I found out how to that I had to include a zepto file, not just the HTML and I put that in the www folder. Now when I go to that link I get a page saying: Waiting for Arduino...
If I reload it it still says that. I don't know what to do.
Thanks,
ma7730

I have posted similar question here: Tutorial TemperatureWebPanel, sample HTML page? - Arduino Yún - Arduino Forum but without answer...

ma7730:
My yun's name is ma7730, so I use ma7730.local/sd/temperatureWebPanel. I found out how to that I had to include a zepto file, not just the HTML and I put that in the www folder. Now when I go to that link I get a page saying: Waiting for Arduino...
If I reload it it still says that. I don't know what to do.

Waiting for arduino? Are you sure you typed the url above? (BTW the "t" in "temperatureWebPanel" should be Upper Case)

I don't have the example code handy, so I'm working from memory...

If I recall correctly, the HTML in the web page starts out by displaying "Waiting for Arduino" then makes the JavaScript call to fetch the temperature from the Yun. When the temperature is received, the JavaScript replaces the initial waiting text with the received value.

So I would look for something that is preventing the Arduino script from running (is it waiting for the serial port to open?) or otherwise interfering with the REST call (did the bridge start properly?)

I am not very experienced with the yun, just beginning..

anyway: you can check if zepto is correctly loaded going into the browser and open the inspector. chrome shortcut is: command+i. by this inspector you can see if the javascript gets some error. you can also check the page html to see if the page is the right one.

to see if bridge is started properly you have to ssh as root to the yun, and prompt the command ps. ps stay for Process Status ( http://en.wikipedia.org/wiki/Ps_(Unix) ). If bridge is correctly opened you will see something like python -u bridge.py. For shortness you can also Unix Pipe and prompt ps | grep bridge.

hope it helps!

Thanks. I don't know what it is. I am not so well versed in the various Javascript extensions and don't know how to work zepto.js. How do you install it into the correct place?

it is really like a simplified query.. in the main website there is almost everything.. have you tried with inspector? do you receive any errors?
just open the js console in the browser and type the character $ to see if the library is correctly loaded..

ma7730 have you double checked the url? You pasted ma7730.local/sd/temperatureWebPanel while correct url is ma7730.local/sd/TemperatureWebPanel (the "t" in temperature is upper case)

ma7730:
How do you install it into the correct place?

You don't need to install it. If these three conditions are met

  • your sketch has a "www" folder
  • your yun has an SD card properly set up
  • you upload via wifi
    the Arduino IDE will upload the contents of that "www" folder to the yun and make them available at url http://arduino.local/sd/NAME_OF_YOUR_SKETCH_HERE/

I'm a newbie but have a number of sketches working fine and now migrating to a Yun. I have good I/O control success and now trying to implement web interface...

Couldn't get the example TemperatureWebPanel web page to work...
(https://www.arduino.cc/en/Tutorial/TemperatureWebPanel)

Narrowing in on cause of above problem, It tried working on another one at
http://scuola.arduino.cc/lesson/zzdeJ3m/YunServer_Sensor_values_to_HTML_page
I have given the board a name "OMANYUN".
It's wifi IP address is "172.16.0.41"
The only URL that I can get to work is "http://172.16.0.41/sd/index.html"
And the response is "Waiting for Arduino..." (from the index.html file)
("http://OMANYUN/sd/index.html" and "http://OMANYUN.local/sd/index.html" do not work)

But that's as far as it goes...
So I think maybe the problem is that I have the REST password required. So go into the Yun configuration page and set the REST to OPEN, download/configure... At that point, the IP address disappears from the network and does not come back. Trying to download a sketch (via wifi) comes up with many error messages saying port not found.

Pressing the RST WLAN button for a while seems to return the REST setting back to password, communications is restored and I can again download and use sketches. It does not seem to restore the other configuration settings to default.

So that's where I'm at. I still am unable to make either of the two temperature / web display sketches work.

Several days into this now. Becoming very frustrated!!! Can anyone help??? Thanks!!!

JohnOman:
("http://OMANYUN/sd/index.html"

Correct, that shouldn't work, it never will.

and "http://OMANYUN.local/sd/index.html" do not work)

That should work, if you are in a Mac or an iOS device. It won't work on Windows unless you gave installed Apple's Bonjour or another zeroconf utility (Bonjour is automatically installed if you installed iTunes or QuickTime.) It may work from a Linux computer if you have Avahi installed. It will never work from Android.

Using the IP address should always work.

So go into the Yun configuration page and set the REST to OPEN, download/configure... At that point, the IP address disappears from the network and does not come back. Trying to download a sketch (via wifi) comes up with many error messages saying port not found.

Sounds like something is not right - what do you mean by "download/configure"? To change the REST API password, I believe you just have to click on the radio button - it takes effect immediately nothing to do to save the new setting.

What sketch do you have loaded while doing this? If the sketch is sending things via the Bridge or with Serial1 while the Linux side is booting, that can cause the Linux boot process to fail. The safe bet is to load an Emory sketch or something simple like the Blink example.

Pressing the RST WLAN button for a while seems to return the REST setting back to password, communications is restored and I can again download and use sketches. It does not seem to restore the other configuration settings to default.

It's not well documented, but the Yun must be completely booted up and running normally before the RST WLAN button has any effect. It will not work while powering up, while still booting, or if the Yun fails to boot.

Thank you ShapeShifter! That cleared some of the fog in my brain. But still not getting data from the board.

Here's the sketch named "temperature"...

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

YunServer server;

void setup() {
// put your setup code here, to run once:
Bridge.begin();
server.listenOnLocalhost();
server.begin();
}

void loop() {
// put your main code here, to run repeatedly:
YunClient client = server.accept();

if (client) {
String command = client.readString();
Console.println(command);
command.trim();
if (command == "temperature") {
int val = analogRead(A1);
client.print(val);
Console.println(val);
}
client.stop();
}
delay(50);
//Toggle pin 13 LED
if(digitalRead(13)==HIGH)
{
digitalWrite(13, LOW);
}
else
{
digitalWrite(13, HIGH);
}
}

Here's index.html...

OmanYun/Arduino/www - waiting for board...

The "REST API ACCESS" "OPEN" radio box is selected...

The SD's /android/www directory contains the following files:
index.html
zepto.min.js
zepto.js

The zepto files were downloaded from:
http://zeptojs.com/zepto.min.js and http://zeptojs.com/zepto.js respectively, was cut/copied from the browser and pasted into Notepad and saved to the SD's android/www directory.

When the board is powered up, the LED13 begins to blink, erratically for maybe 15 seconds or so, and then at the programmed rate (at about the same time the white WLAN LED comes on).

Entering the URL in a browser:
http://172.16.0.41/sd/index.html

Returns the page
"OmanYun/Arduino/www - waiting for board..."

So, obviously arduino, Yun and the webserver are running...
But nothing else follows...????
Any ideas???

Thanks!

Update... I don't have the above example working (and don't know why). I believe that there is an error in the index.html code that doesn't correctly send the request (or return the result) to/from the arduino. I have another application working that does not use any files on the SD (the arduino prints the entire web page). But for more complex pages, I need to get the Yun/SD based pages working with dynamic data only supplied by the arduino. Thanks!

Please use CODE tags when posting code, it makes things much easier to read: hit the </> button to insert the tags, and paste your code between them.

JohnOman:
function refresh() {
$('#content').load('/OmanYun/temperature');

What do you expect this line to do? Where did you come up with that URL?

In the example, the URL is '/arduino/temperature' and the only thing you should change is the 'temperature' part of it if you want to access a different REST node in your sketch. The 'arduino' part should not change - this is not the name of your arduino, it is an essential part of the URL that tells the Yun's web server to route the rest of the request to the YunServer/YunClient in your sketch.

The load() function gets the node name from the root of the URL on the page it is currently running, you don't have to include that part in the load() call.

I'm sure this is the root of your problem.

The SD's /android/www directory contains the following files:

That should be /arduino/www, but since you say the index.html page is getting loaded, I'm guessing the android substitution is perhaps an overly aggressive autocorrect function (and you posted this from an Android device)?

The zepto files were downloaded from:
http://zeptojs.com/zepto.min.js and http://zeptojs.com/zepto.js respectively, was cut/copied from the browser and pasted into Notepad and saved to the SD's android/www directory.

Again, arduino, not android. You could also have found the files in the www subfolder of the TemeperatureWebPanel example. In fact, if you upload the sketch over the network, and if you have an SD card mounted that has an /arduino folder in the SD card's root, then the contents of the www folder within the sketch's folder on your computer will automatically be copied to the /arduino/www folder on the SD card.