Jump to content
pine

To stop drolling in front of those Arduino Yun web pages...

Recommended Posts

.. finally made the switch and flashed OpenWrt to a TP-Link WR703N router, added a 16G memory flash stick, and connected to my first F5529 LaunchPad. Here is a picture of the setup.

 

post-286-0-69776900-1391932004_thumb.jpg

 

The version of OpenWrt is 12.09. To connect with the MSP Launchpad, need to install the acm driver by

opkg install kmod-usb-acm

And also installed "screen" for serial client by

opkg install screen

Apart from the missing bridge library that come with the Yun, i'm quite satisfied with this setup, especailly the tiny form factor of the whole package.

 

The LaunchPad seems to enjoy running with her new Internet companion!

 

 

post-286-0-69776900-1391932004_thumb.jpg

Share this post


Link to post
Share on other sites

Yes, I am glad to share. As far as I understand about the Arduino Yun:

  • Is a marriage of the ATmega32u4 and a Atheros AR9331 400MHz processor with WiFi.
  • It is all on a standard UNO form factor.
  • The Atheros part runs a linux distribution called Linino
  • Linino handles the USB host, SD card, ETH, and WiFi
  • Linino communicates with the ATmega through an underlying serial bridge
  • A customized library built in for program on the ATmega to communicate with Linino, so that Arduino hobbyist / developers alike can instantly enjoy the features available on the Atheros.

In my setup it is impossible to make it as compact as the Yun, but all the key features like WiFi, physical ethernet, and USB port (with many supported devices like web cam from OpenWrt) are present.

 

The line up - TP-Link WR703N, 4-port USB hub, SanDisk 16G flash drive, and mini USB converter for the F5529 LaunchPad.

post-286-0-24607700-1392044910_thumb.jpg

 

The wireless router in my setting is a TP-Link WR703N. It sports a similar processor in the Yun, but with a lot less memory. It is a popular router among OpenWrt enthusiasts. Installing it is very simple:

  1. Buy the router. Please note, do not get the WR-702N for this purpose. It looks exactly the same except missing the USB port. OpenWrt will not work in 702N.
  2. Check the version on the router. There are a few of them owing to year of manufacture. Most of the time the AA version will work. Just to be sure.
  3. Download the appropriate binary image from OpenWrt according to the router version, and also pick either JFFS2 or squashFS image. I picked JFFS2 as it looks like complete recovery (factory restore) is easier. Actually I did that twice already, one for 100% disk utilization and another for having enough test drive and reset for a fresh install.
  4. Plug in the router to PC with both usb (just for power) and wired network, set PC network interface to 192.168.1.x/24, and then open browser http://192.168.1.1  that will bring up the TP-Link router admin page, and then upload the OpenWrt firmware using the standard interface that come with the router for firmware upgrade.
  5. That's it, when the router auto reboot, the OpenWrt interface will be up in the browser. From there configure the wireless network etc.

At this point, we can also access it through ssh to 192.168.1.1. But firstly we have to telnet to it (through wired interface 192.168.1.1 by default), set root password by passwd, logout, and then login using ssh. The internal flash is very small, so expanding with an external flash memory stick is highly recommended. There are several methods and I picked the extroot method which is quite nice. It transfer the whole internal flash content to the external stick, and from that point on the router boot from the memory stick, any changes will be on the stick. But if the stick is not present at boot time, the internal flash will take up although it is the snapshot image when the external flash is created.

 

Now the fun part begin! Even though the flash storage on the router is very limited, but I believe there should be enough room for a quick test drive by installing the usb acm driver and screen. When it's done, program a LaunchPad with serial communication code, plug in the USB host port on the router, and voila.

 

A simple test code in Energia used that will light up the green LED when H key is pressed and off when L key is pressed, and when the user button is clicked on the LP the console will show the ascii code. Although the code did not show any Internet related stuff, but suffice it to demo the communication capability between the LP and the router through serial.

/*

Test program for new F5529 LP with OpenWRT WR-703N

Serial communication 115200, ttyACM1

On OpenWRT:
screen /dev/ttyACM1 115200,parenb,-cstopb,cs8


*/

/*
  DigitalReadSerial with on-board Pushbutton
  Reads a digital input on pin 5, prints the result to the serial monitor 
 
  This example code is in the public domain.
 */

const int ledPin = GREEN_LED; // the pin that the Green LED that is    attached to on Launchpad 
const int ledErrPin = RED_LED; // the pin that the Green LED that is    attached to on Launchpad 
int incomingByte; // a variable to read incoming serial data into


// digital pin 5 has a pushbutton attached to it. Give it a name:
int pushButton = PUSH1;
int clickCount = 0;

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 100;    // the debounce time; increase if the output flickers
int lastButtonState = LOW;   // the previous reading from the input pin
int buttonState;             // the current reading from the input pin

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
  // make the on-board pushbutton's pin an input pullup:
  pinMode(pushButton, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);     
  digitalWrite(ledPin, LOW);
  pinMode(ledErrPin, OUTPUT);     
  digitalWrite(ledErrPin, HIGH);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int reading = digitalRead(pushButton);
  // print out the state of the button:

  // -- Debounce routine
  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  } 
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
    buttonState = reading;
    // if button S1 P2.1 is clicked, send message to BT server 
    if (buttonState == 0) {
      Serial.print("[");
      Serial.print(clickCount++);
      Serial.println("] On");
      delay(100);
    }
  }
  
  
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    if (incomingByte == 'H' || incomingByte == 'h') {
      // if it's a capital H (ASCII 72), turn on the LED:
      digitalWrite(ledPin, HIGH);
      Serial.print("[ACK] ");
      Serial.println(incomingByte);
    } 
    else if (incomingByte == 'L' || incomingByte == 'l') {
      // if it's an L (ASCII 76) turn off the LED:
      digitalWrite(ledPin, LOW);
      Serial.print("[ACK] ");
      Serial.println(incomingByte);
    }

      // blink to acknowledge
      digitalWrite(ledErrPin, HIGH);
      delay(50);
      digitalWrite(ledErrPin, LOW);
      delay(50);
      digitalWrite(ledErrPin, HIGH);
      delay(50);
      digitalWrite(ledErrPin, LOW);
      delay(50);
      digitalWrite(ledErrPin, HIGH);
      delay(50);
      digitalWrite(ledErrPin, LOW);
      delay(50);
      digitalWrite(ledErrPin, HIGH);
      delay(50);
      digitalWrite(ledErrPin, LOW);
      delay(50);

      digitalWrite(ledErrPin, HIGH);
    
  }
 
}


After programming the LP with the above code in PC, plug the LP into the USB host of the 703N, The LP should be recognised under /dev/ttyAMC1 if kmod-usb-acm is installed in the 703N. Then run the following at the ssh shell:

screen /dev/ttyACM1 115200,parenb,-cstopb,cs8

You can then press H or L to turn on or off the Green LED on the LP. On the other hand, click the LP user button and you can see the response from the ssh console. (To exit screen, press CTRL-A, and then CTRL-\, and then answer y)

 

This setup show how simple it is to bring wireless capability to the LaunchPad. There are much better way to connect to the Internet like the TI CC wifi chips and related BPs. However TI eStore won't sell these to where I live. And there is also the fact that the Arduino team did not just wire the hardware together to make the Yun, they developed and provided a bridge library so that it is very easy to access the wireless capability without much work on the Lininio side. This setup with the TP-link router is quite a good alternative with the freedom and flexibility.

 

post-286-0-24607700-1392044910_thumb.jpg

Share this post


Link to post
Share on other sites

Your idea is very attractive, even smaller than the Yun! Would you consider putting it on store?

 

Sooo... I have these dev kits called "Jupiter" that I make.  You can notice that: (a) they don't use MSP430, (b ) they are half-size Arduino Uno form, and (c ) there is a 30 pin edge connector.  It is called "Jupiter" because the plan from the beginning was to have a series of female adapter boards that attach to the 30 pin edge connector, which fill-out the rest of the Uno form factor while providing some additional functionality.  So far I have planned 3 adapter boards.  One of these would be a WiFi + Ethernet board.  It would be fairly easy to copy work that has been done already, such as Y

Share this post


Link to post
Share on other sites

Please note that the precompiled Openwrt binaries contains ACM drivers that contain a bug. When your MSP430 spits out serial messages before you open the serial port (in python or bash) the driver crashes and no communication is possible. Wasted a couple of hours figuring that out. :-(

This isn't a problem when the OpenWRT devices initiates communication. You can fix this by modifying the drivers and compiling OpenWRT yourself.

 

Verstuurd vanaf mijn HTC One met Tapatalk

 

 

Share this post


Link to post
Share on other sites

Please note that the precompiled Openwrt binaries contains ACM drivers that contain a bug. When your MSP430 spits out serial messages before you open the serial port (in python or bash) the driver crashes and no communication is possible. Wasted a couple of hours figuring that out. :-(

This isn't a problem when the OpenWRT devices initiates communication. You can fix this by modifying the drivers and compiling OpenWRT yourself.

 

Verstuurd vanaf mijn HTC One met Tapatalk

 

Thanks for the heads up, was hit by this bug when trying to program the MSP from BeagleBoard. But strangely this bug did not happen on my 703N connected with an F5529 LP. The following is the code for testing:

int i = 0;

void setup()
{
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
}

void loop()
{
  // put your main code here, to run repeatedly:
  Serial.print("Counting ");
  Serial.println(i++);
}

Disconnect and reconnect randomly still yield the output.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×