Pages: [1]   Go Down
Author Topic: Replacing Ethernet Shield with Wifi shield  (Read 1094 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to replace my Arduino Ethernet Shield Rev3 (without PoE Module) with a similar WiFi shield (to connect my Arduino 2009 to the Internet without need for ethernet cables). Is there such a shield around?

Thanks in advance for your help
Logged

SF Bay area
Offline Offline
Sr. Member
****
Karma: 2
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am considering this too. I would have gone with wifi if I had known the ethernet+sd uses like a ton of memory on the UNO that it almost renders it useless. The wifly (sparkfun sells them) uses serial interface, so it does not take a lot of memory space, but to answer your question, I don't think there exist a wifi shield that is a drop in replacement to the ethernet shield.
Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 277
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps a bit more detailed description of what you want to do (or are currently doing) with the ethernet shieled would help in providing you with a better answer. Connection to the Internet is a pretty broad description  smiley-wink

There are several WiFi shields available, the WiFly shield(s) are available from Sparkfun.com or the Hydrogen/Platinum at diysandbox.com.

In my own project I am currently using a Asynclabs WiShieled clone, however since Asynclabs closed their doors neither the hardware or software seem to be developed anymore. I also wanted a WiFi solution that offered the possibility to open it's own Access Point.

My project now involves several libraries that make specific use of the Ethernet shield:
I am using the DHCP and Bonjour libraries from here http://gkaindl.com/software/arduino-ethernet
and I am in process of integrating the Open Sound Control library from here https://github.com/recotana/ArdOSC

Without the Ethernet shield all of these would have to be adapted to a specific WiFi shield.

My solution is to use a little USB (5V) powered pocket WiFi router TL-WR703N (to be replaced with a TL-WR702N soon). That does not entirely eliminate the Ethernet cable but is still pretty small in footprint and I can utilize all the functions and libraries of the Ethernet shield without having to extensively rewrite code.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I'd really would like a drop in replacement for the ethernet shield  smiley I'm using the ethernet shield to GET data from a website (line client.println("GET /use?token=5b2f053f-364f-4ee7-9c30-229501907242 HTTP/1.1") in the following code), in order to activate a home device by just sending a tweet to twitter. What I would like to be able to do is to simply replace the ethernet shield with a wifi one so that I won't need anymore an ethernet cable connect to my arduino (that could be then placed far enough from my router).

Code:
/***************************************************************************/
/*                                                                         */
/*  This sketch sets 8 digital and all 6 analogic outputs of the Arduino   */
/*  board according to the inputs read by actuator instance on Paraimpu.   */
/*  v1 - December 2011                                                     */
/*                                                                         */
/*  http://paraimpu.crs4.it                                                */
/*                                                                         */
/*  This sketch is released under GPL v3. For more details, please read    */
/*  http://www.gnu.org/licenses/gpl-3.0.txt                                */
/***************************************************************************/


#include <SPI.h>
#include <Ethernet.h>

// MAC Address of your Arduino Ethernet shield
byte mac[6] = { 0x90, 0xA2, 0xDA, 0x0B, 0x00, 0x02 };



IPAddress server( 156, 148, 18, 164 );
EthernetClient client;
int p;
int i;
String data = String();
char c;
boolean take;
int waiting;
int n;
int v;
int digits;
int jump;

void setup() {
  for(i = 2; i < 10; i++){
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);
  }
  for(i = 14; i < 20; i++){
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);
  }
  //Serial.begin(9600);
  waiting = 0;
while (Ethernet.begin(mac) == 0  && waiting < 800){
delay(10);
waiting++;
}
//  Serial.println(Ethernet.localIP());

  delay(1000);
}

void loop() {
  if (client.connect(server, 80)) {
    client.println("GET /use?token=5b2f053f-364f-4ee7-9c30-229501907242 HTTP/1.1");
    client.println("Host: paraimpu.crs4.it");
    client.println();
    data = String();
    take = false;
    //Serial.println("           ");
    //Serial.println("reading ...");
    waiting = 0;
    while (!client.available() && waiting < 500){
        delay(10);
        waiting++;
    }
    while (client.available()){
        c = client.read();
        if (c == '}'){
            run();
            break;
        }
        else if(c == '{'){
          take = true;
        }
        else if(c == '\\' || c == ' '){}
        else {
          if (take){
              data.concat(String(c));
          }
        }
     }
  }
  client.stop();
  delay(1000);
}

void run(){
  if(data.charAt(2) == 'X' ){ //all data
    writeAll(data.charAt(7));
    data = "";
  }
  else {
    p = 0;
    n = 0;
    v = 0;
    digits = 0;
    jump = 0;
    while (p < data.length()){
      if (data.charAt(p + 1) == 'A'){
        n = int(data.charAt(p + 2)) - 48;
        n = n + 14;
        jump = 9;
        if (data.charAt(p + 6) == 'L'){
          digitalWrite(n, LOW);
        }
        else {
          digitalWrite(n, HIGH);
        }
      }
      else {
        n = (int(data.charAt(p + 2)) - 48) * 10;
        n = n + int(data.charAt(p + 3)) - 48;
        if (data.charAt(p + 7) == 'L'){
          digitalWrite(n, LOW);
          jump = 10;
        }
        else if (data.charAt(p + 7) == 'H'){
          digitalWrite(n, HIGH);
          jump = 10;
        }
        else {
          v = 0;
          if (isDigit(data.charAt(p + 8))){
            v = int(data.charAt(p + 8)) - 48 + (int(data.charAt(p + 7)) - 48) * 10 + (int(data.charAt(p + 6)) - 48) * 100;
            jump = 10;
          }
          else if (isDigit(data.charAt(p + 7))){
            v = int(data.charAt(p + 7)) - 48 + (int(data.charAt(p + 6)) - 48) * 10;
            jump = 9;
          }
          else {
            v = int(data.charAt(p + 6)) - 48;
            jump = 8;
          }
          analogWrite(n, v);
        }
      }
      p = p + jump;
    }
    data = "";
  }
}

void writeAll(char out) {
  if(out == 'L'){
    for(i = 2; i < 10; i++){
      digitalWrite(i, LOW);
    }
    for(i = 14; i < 20; i++){
      digitalWrite(i, LOW);
    }
  }
  else{
    for(i = 2; i < 10; i++){
      digitalWrite(i, HIGH);
    }
    for(i = 14; i < 20; i++){
      digitalWrite(i, HIGH);
    }
  }
}

boolean isDigit(char ch){
  if(ch >= 48 && ch <= 75){
    return true;
  }
  return false;
}

Logged

SF Bay area
Offline Offline
Sr. Member
****
Karma: 2
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

your best bet is headrooms suggestion to use tl-wr702n by connecting the ethernet shield to the tl-wr702n configured as a client.  There are other routers than can do similar function. any other solution will cost you more and you must modify your sketch program.

Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 277
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at the  Arduino Hydrogen WiFi shields library ( https://github.com/diysandbox/Wirefree/) I don't see any reason why your sketch should not run on that shield. The functions in their library are replacements for (some of) the Ethernet libraries functions.

I do have a Hydrogen myself. The sample sketches ran fine "out of the box".

If you are willing to change you sketch from using digital pins to writing debug-messages to the serial.monitor than I'll be glad to do that.

On the other hand, if you are a little cost sensitive, at $75 here in the USA the Hydrogen is very expensive.
You already have an Arduino Uno and the Ethernet Shield. I checked on Amazon.it:
 http://www.amazon.it/s/ref=nb_sb_noss/275-6459387-3084809?__mk_it_IT=%C5M%C5Z%D5%D1&url=search-alias%3Daps&field-keywords=TL-WR702N&x=0&y=0
and the little wireless router I spoke about in my last reply can be had there for 23Euros, which is much less expensive than the WiFi shield. at 57mm x 57mm x 18mm it's actually smaller in footprint than the Arduino Uno with the Ethernet Shield stacked on it! It only needs 5V through a USB cable and I bet after modifying the USB cable you can supply that right from the Arduino Uno without the need of the additonal power supply (the Power supply and the USB cable came with my WiFi router, so no extra hidden cost there).
Logged


Pages: [1]   Go Up
Jump to: