I use your wifi shield http://www.seeedstudio.com/wiki/Wifi_Shield with DFRduino Uno.
I need to send results from some ultra sound/IR detectors that are connected to board's ADCs to my PC via wifi. But! It sends only rubbish when wifi shield is initialized.
My code is:
Code: Select all
#include "Wifly.h"
#include <SoftwareSerial.h>
#define SSID "MyWiFi"
#define PASSWORD "12345678"
#define IP "192.168.137.1"
#define PORT "40020"
#define _W_I_F_I_
WiflyClass Wifly(2,3);
int sensors[6];
void setup()
{
Serial.begin(9600);//use the hardware serial to communicate with the PC
#ifdef _W_I_F_I_
Wifly.init();//Initialize the wifishield
Wifly.setConfig(SSID,PASSWORD);//here to set the ssid and password of the Router
Wifly.join(SSID);
Wifly.checkAssociated();
while(!Wifly.connect(IP,PORT));//connect the remote service
Wifly.writeToSocket("Connected!");
#endif
}
void loop(){
Serial.print("Sensors:");
for( int i = 0 ; i < 6 ; i++ ){
analogRead(i);
delay(5);
sensors[i] = analogRead(i);
Serial.print(sensors[i]);
Serial.print(", ");
}
Serial.println(";");
delay(30);
}
Code: Select all
$$$CMDopen 192.168.137.1 40020
Söýÿþþ.ÃþþþÑþÁþ2
Connect to 192.168.137.1:40020
<2.23> *OPEN*Connected!Sensors:472, 1023, 1019, 1023, 1023, 1023, ;
Sensors:791, 1023, 1019, 1023, 1023, 1023, ;
Sensors:908, 1023, 1020, 1023, 1023, 1023, ;
Sensors:954, 1023, 1019, 1023, 1023, 1023, ;
Sensors:966, 1023, 1020, 1023, 1023, 1023, ;
Sensors:986, 1023, 1019, 1023, 1023, 1023, ;
Sensors:998, 1022, 1020, 1023, 1023, 1023, ;
Sensors:1013, 1023, 1019, 1023, 1023, 1023, ;
Sensors:1014, 1023, 1019, 1023, 1023, 1023, ;
Sensors:1007, 1023, 1018, 1023, 1023, 1023, ;
Sensors:996, 1023, 1019, 1023, 1023, 1023, ;
Sensors:986, 1023, 1019, 1023, 1023, 1023, ;
Sensors:993, 1023, 1019, 1023, 1023, 1023, ;
Sensors:1002, 1023, 1020, 1023, 1023, 1023, ;
Sensors:1016, 1023, 1020, 1022, 1023, 1023, ;
Sensors:1015, 1023, 1020, 1023, 1023, 1023, ;
Sensors:1005, 1023, 1019, 1023, 1022, 1023, ;
Sensors:995, 1023, 1019, 1023, 1023, 1023, ;
Sensors:988, 1022, 1020, 1023, 1023, 1023, ;
Sensors:995, 1023, 1019, 1023, 1023, 1023, ;
And when I remove #define _W_I_F_I_
It works correctly:
Code: Select all
Sensors:131, 131, 32, 65, 55, 42, ;
Sensors:102, 122, 31, 57, 53, 44, ;
Sensors:87, 117, 30, 40, 56, 84, ;
Sensors:69, 109, 31, 39, 63, 114, ;
Sensors:74, 103, 31, 44, 86, 129, ;
Sensors:103, 109, 31, 52, 90, 126, ;
Sensors:114, 111, 31, 65, 84, 86, ;
Sensors:132, 116, 31, 70, 76, 52, ;
Sensors:130, 125, 30, 63, 52, 33, ;
Sensors:97, 116, 31, 57, 48, 35, ;
Sensors:85, 110, 33, 44, 52, 70, ;
Sensors:68, 108, 31, 36, 60, 105, ;
Sensors:66, 99, 32, 43, 79, 125, ;
Sensors:94, 104, 31, 50, 90, 129, ;
I am sure that the sensor is Ok. So.. What should I do?
Cheers! Anton. Sorry for bad english.