1

I tried to modify the Temperature Web Panel example (found in arduino-1.5.6-rw/libraries/Bridge/examples/TemperatureWebPanel) for a light sensor. Unfortunately it seems even the simplest receive and transmit result over wifi doesn't work! I even commented out the working part to just send back some text to the browser as you can see, but I still see nothing in the browser:

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

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server;
String startString;
long hits = 0;

void setup() {
  Serial.begin(9600);

  // For debugging, wait until the serial console is connected.
  /*delay(4000);
  while(!Serial);
  Bridge.begin();
*/
  // Bridge startup
  pinMode(13, OUTPUT);
  Bridge.begin();
  digitalWrite(13, HIGH);

  pinMode(A0, INPUT);


  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  server.listenOnLocalhost();
  server.begin();

  // get the time that this sketch started:
  Process startTime;
  startTime.runShellCommand("date");
  while (startTime.available()) {
    char c = startTime.read();
    startString += c;
  }

  Serial.println("yeah\n");
  Serial.println(startTime);
}

void loop() {
  // Get clients coming from server
  Serial.println("a\n");
  YunClient client = server.accept();

  // There is a new client?
  if (client) {
    Serial.println("Client!\n");
    // read the command
    String command = client.readString();
    client.print('(This should definitely be sent over bridge)');
    /*command.trim();        //kill whitespace
    Serial.println(command);
    // is "temperature" command?
    if (command == "temperature") {

      // get the time from the server:
      Process time;
      time.runShellCommand("date");
      String timeString = "";
      while (time.available()) {
        char c = time.read();
        timeString += c;
      }
      Serial.println(timeString);
      int sensorValue = analogRead(A0);
      // convert the reading to millivolts:
      client.print("Current time on the Yún: ");
      client.println(timeString);
      client.print("<br>Current value: ");
      client.print(sensorValue);
      client.print("<br>This sketch has been running since ");
      client.print(startString);
      client.print("<br>Hits so far: ");
      client.print(hits);
    }*/

    // Close connection and free resources.
    client.stop();
    hits++;
  }

  delay(50); // Poll every 50ms
}

I see the "a" multiple times in the serial monitor, but never see anything in the arduino.local/arduino/temperature url, just a blank response.

Furthurmore, after awhile it seems the Yun was disconnecting from the network, not accessible over http or ssh. How does one debug an issue like this, considering ssh is the main way to communicate with this computer?

NoBugs
  • 9,310
  • 13
  • 80
  • 146
  • `while(!Serial);` waits for the serial port to be ready, it's a good idea to leave that in. I don't know what the real problem is though. – monty0 Jul 08 '14 at 16:58
  • @monty0 Doesn't that just wait for you to open the Arduino IDE's serial console? – NoBugs Jul 09 '14 at 01:17
  • yeah, but I don't know what might happen if you try to write to the serial port before it is ready – monty0 Jul 14 '14 at 18:12

4 Answers4

1

After debugging step by step on my own configuration, I found that the code never advanced past Bridge.begin().

Upon further investigation, I found that the default Bridge baud rate of 250000 no longer matched the kernel baud rate of 115200.

Changing to: Bridge.begin(115200) ... fixed the issue for me.

To determine your kernel speed, run cat /proc/cmdline from a terminal into your Yun

See this link for more info: https://groups.google.com/forum/#!msg/linino/-rSmpjX4UOM/Cnjv-uzrlfgJ

If this isn't your issue, consider adding debug information (ie.. Serial.print()) in the actual source files for Bridge.cpp, etc. Unfortunately, it appears that Arduino/Linino devs often make breaking changes and do not have the resources to update documentation, examples, etc.

0

If you are on Windows, don't use 'arduino.local', because Windows has problems to resolve this host. Have you tried with the IP address ? You must televerse your script through wifi, and not through serial (in arduino Ide you must change the port) Have you created the path 'arduino/www/'

You need a micro SD card plugged in to your Yún with a folder named “arduino” at the root. Inside the “arduino” folder, there must be a directory called “www”. You need to upload the sketch via WiFi to transfer the contents of the local “www” folder. You cannot transfer files via USB. Once uploaded, you can open your favorite browser and go to http://arduino.local/sd/TemperatureWebPanel.

you must open http://YUNS_IP/sd/TemperatureWebPanel

FaDa
  • 86
  • 6
0

if you are using the Yun Shield u need to comment out the Serial commands or remove all references to serial as the Bridge and the Serial port all share the same hardware serial. I faced the same problem there was no connection.

mumbasa
  • 632
  • 7
  • 11
-1

Replace serial.begin(115...) by Bridge.begin().

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Fred
  • 1
  • Recommend expanding on this. Explain why doing this will help the questioner otherwise this is a glorified comment. – user4581301 Oct 23 '15 at 01:10