Pages: [1]   Go Down
Author Topic: real data rate official wifi shield  (Read 281 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 99
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello everyone...for my experiment i need to test the real data rate of the official arduino wifi shield...I use an arduino uno+the shield and the data rate that i found was about 2Kbps...i think that is a little slow...there's anyone that can help me to improve the throughput?
thank you

PS here there is the sketch

#include <Arduino.h>
#include <SPI.h>
#include <WiFi.h>

//pay attention dim_pkt must be divided by four
//#define dim_pkt 100
//#define dim_pkt 200
//#define dim_pkt 300
//#define dim_pkt 400
//#define dim_pkt 500
//#define dim_pkt 600
//#define dim_pkt 700
#define dim_pkt 800

unsigned long time[2]={0,0};//calculate the trasmission time of a single byte
int cont=0;
byte bytetest;

char ssid[] = "***";      //  your network SSID (name)
char pass[] = "****************";   // your network password

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}



//union that will have inside the dimension of the packet
union numero{
unsigned long dim;
byte dim_vect[4];
};

//union che conterra il buffer
byte bufferbyte [dim_pkt];
union buffer{
unsigned long timeer[dim_pkt/4];
byte bufferbyte[dim_pkt];
};




int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while(true);
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
  }
  server.begin();
  // you're connected now
  printWifiStatus();
}

int j=0;
union numero Dimension;
union buffer Buffer;

void loop() {
  // listen for incoming clients
  WiFiClient client = server.available();
  if (client == true) {
      Serial.println("client connected");

    // write bytes from the incoming client
    // to any clients connected to the server:
    for (int i=0;i <dim_pkt/4;i++) {
                  //Serial.println(time[0]);
                 // time[1]=micros();
                  Buffer.bufferbyte[j]=i;//it's only a test of trasmission
//                  server.write(Buffer.bufferbyte[0]);//
//                  Buffer.bufferbyte[j*4+1]=i*4+1;
//                  server.write(Buffer.bufferbyte[1]);
//                  Buffer.bufferbyte[j*4+2]=i*4+2;
//                  server.write(Buffer.bufferbyte[2]);
//                  Buffer.bufferbyte[j*4+3]=i*4+3;//i*4+3
                  //server.write(Buffer.bufferbyte,4);
                  //server.write(prova);
                  //time[0]=micros()-time[1];
                  j++;
                  if ((i+1)%90==0){
                    server.write(Buffer.bufferbyte,90);//because if i write a number>90 the connected client doesn't read anything
                    j=0;
                  }
     }
     server.write(Buffer.bufferbyte,j);
   }
   if (j!=0){
        Serial.println("client disconnected");
        j=0;
        Serial.println("*********************************************************");
   }
}



Logged

Pages: [1]   Go Up
Jump to: