Yun Bridge

I have been using the Yun via WiFi to control a scrolling LED message display. The idea is that a user receives as web page (arduino.local/sd) asking for a message to be typed in to the web page panel. This is in turn shown on the moving display. All this has in the past worked OK, but now on reset (power up) the web page appears to accept the message, but it does not get shown. When working OK, the web page posts a msg to the user “Sent OK” when the message is sent and displayed. Now this does not happen and only once in a while on say 2 resets out of 10 does it work properly. To me its a timing issue on power up but I have tried various delays. It displays “Open from 1030 to 1630” by default on power up. Code for the AR9331 is:

/*  A WiFi controlled NeoPixel shield using the Arduino Yun. Controlled by a standard
 *  browser, it will display browser generated messages in one of eight colours as
 *  selected by the user.
 *  The Yun requires either a micro SD card or USB stick to handle the simple web server
 *  which uses zepto to serve the client. The micro SD must have a folder named "arduino"
 *  in the SD root which in turn contains a folder named "www".
 *  This coding is based on the Adafruit_NeoMatrix example for a single NeoPixel Shield as
 *  written by Phillip Burgess. (The "Howdy" sketch)
 *  Displays messages across the matrix in a portrait (vertical) orientation in
 * one of eight colours selected.
 * The colour key letter (lower case) is put at the beginning of the message. If no key
 * letter is entered, the display will show the message in the last colour used.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

#ifndef PSTR
 #define PSTR // Make Arduino Due happy

#define PIN 6

YunServer server;
String msg;
String msg1;
String speedstring;

// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

// Example for NeoPixel Shield.  In this application we'd like to use it
// as a 5x8 tall matrix, with the USB port positioned at the top of the
// Arduino.  When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order.  The shield uses
// 800 KHz (v2) pixels that expect GRB color data.

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 8, 4, 1, PIN,
  NEO_GRB            + NEO_KHZ800);

// Set the colours available with the NeoPixel shield

const int Blank = matrix.Color(0,0,0);
const int Blue = matrix.Color(0,0,255); 
const int Green = matrix.Color(0,255,0);
const int Red = matrix.Color(255,0,0); // default colour when reset
const int White = matrix.Color(225,255,255);
const int Yellow = matrix.Color(255,255,0);
const int Mauve = matrix.Color(255,0,255);
const int Pink = matrix.Color(255,120,120);
const int Orange = matrix.Color(170,100,20);

const uint16_t colors[] = {

void setup() {

  msg = "Open from 1030-1630";


int x    = matrix.width();
int pass = 0;
int key;

void loop() {

  // Collect the incoming message via the bridge into the String variable "msg"

  YunClient client = server.accept();              //check new msgs from browser client
  if(client.connected()) {
    String command = client.readStringUntil('/');  //read the incoming data
    if (command == "msg") {
       msg = client.readStringUntil('/');          // read the incoming data

/* Check if the user wants to change the matrix colour. If not, play msg out
 *  in the last colour used.
// Check first if the user wishes to increase or decrease to display speed
// Start with a default of 50

    int speed = 50;
    if (msg.startsWith("!")){
      speedstring = (msg.substring(1));
      speed = speedstring.toInt();

// Now start looking for the built in message flags to display selected message
    else if (msg.startsWith("1")){
      msg = "WE ARE CLOSED";
    else if (msg.startsWith("2")){
      msg = "I'm at Lunch: Back 1.30pm";
    else if (msg.startsWith("3")){
      msg = "Back on Tuesday";
    else if (msg.startsWith("4")){
      msg = "Back on Wednesday";
    else if (msg.startsWith("5")){
      msg = "Back on Thursday";
    else if (msg.startsWith("6")){
      msg = "Back on Friday";
    else if (msg.startsWith("7")){
      msg = "Back on Saturday";
    else if (msg.startsWith("8")){
      msg = "On Holiday";
    else if (msg.startsWith("9")){
      msg = "I'm around call my Cellphone";
    else if (msg.startsWith("0")){
      msg = "For access call URSULA";

// Now start looking for free formed msg inputs and which colour they should be
    else if (msg.startsWith("r")){   
    key = 0;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("g")){
    key = 1;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("b")){
    key = 2;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("w")){
    key = 3;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("y")){
    key = 4;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("m")){
    key = 5;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("p")){
    key = 6;
    msg1 = (msg.substring(1));}
    else if (msg.startsWith("o")){
    key = 7;
    msg1 = (msg.substring(1));}
    // If there is not a leading colour letter, then leave the message as it is
    // and do not trim the first colour key character off.
    else msg1 = msg;

  matrix.setCursor(x, 0);
  int count = msg1.length();

  if(--x < -count*6) {
    x = matrix.width();

// Post the message out at the selected scan speed

@ianwj, please do not use generic subject title when posting. This is likely why you have not gotten any reply yet.

In reading your description of your issue (which was not suggested in the subject line), I could not find the description of what happens When not working OK.

FWIW: here are some better subject lines on your issue:

  • Yun Bridge appears not to work with LED display
  • Webpage input fails with Yun Bridge sometimes
  • Sometimes, webpage to bridge to LED display does not work.


ianwj: only once in a while on say 2 resets out of 10 does it work properly.

Define "reset": do you mean resetting the sketch (32U4 RST) or the Linux system (YUN RST) or cycling the power?

To me its a timing issue on power up

If "reset" means power up, as implied by this line, I agree: you have a power up timing issue. This is your initial startup code:

void setup() {

Those are the first two lines executed. Serial.begin() will be fast, and then you can Bridge.begin() which will immediately start sending characters to the Linux side to start the Bridge process under Linux. But after applying power, at this point Linux has barely started to boot. There are two points in the Linux boot up process where typing any key can stop the boot process. Since Bridge.begin() is trying to start the Bridge process, it is sending characters and can easily interrupt booting. This could easily be your problem.

Read this for more information: How to improve reboot/reset stability