Forum >Reading Serial data received by WIFI shield 2.1
Reading Serial data received by WIFI shield 2.1

Hi,
Ho do I read the data that is received through the 2.1 wifi shield?
At the moment the only thing I can achieve is sending strings to the
serial monitor, but I don't know how to use them...
Are there any links of good tutorials to read?
I'm using the bellow code for testing:
[code]
void setup() {
}
void loop() {
if ( Serial.available()) {
int pos = Serial.read();
Serial.println(pos);
}
}[/code]
Ho do I read the data that is received through the 2.1 wifi shield?
At the moment the only thing I can achieve is sending strings to the
serial monitor, but I don't know how to use them...
Are there any links of good tutorials to read?
I'm using the bellow code for testing:
[code]
void setup() {
}
void loop() {
if ( Serial.available()) {
int pos = Serial.read();
Serial.println(pos);
}
}[/code]
2011-12-29 23:56:29 Hi guys,
First of all, thanks a lot for all the help!
Now I tried both scripts with and without Serial.begin and as before it's not working when Serial.begin is present. Actually I've noticed that when I haven't included Serial.begin and
I'm connected to the shield with putty whenever I'm sending some text the arduino TX light is
flashing, whereas when I include the Serial.begin nothing is happening.
I would like to add that I'm following this tutorial to setup the wifi shield: [url=http://goo.gl/SuRz1]http://goo.gl/SuRz1[/url]
I'm also including two screen shoots with and without Serial.begin
Thanks
manolis
First of all, thanks a lot for all the help!
Now I tried both scripts with and without Serial.begin and as before it's not working when Serial.begin is present. Actually I've noticed that when I haven't included Serial.begin and
I'm connected to the shield with putty whenever I'm sending some text the arduino TX light is
flashing, whereas when I include the Serial.begin nothing is happening.
I would like to add that I'm following this tutorial to setup the wifi shield: [url=http://goo.gl/SuRz1]http://goo.gl/SuRz1[/url]
I'm also including two screen shoots with and without Serial.begin
Thanks

2011-12-29 23:56:29 Hi guys,
First of all, thanks a lot for all the help!
Now I tried both scripts with and without Serial.begin and as before it's not working when Serial.begin is present. Actually I've noticed that when I haven't included Serial.begin and
I'm connected to the shield with putty whenever I'm sending some text the arduino TX light is
flashing, whereas when I include the Serial.begin nothing is happening.
I would like to add that I'm following this tutorial to setup the wifi shield: [url=http://goo.gl/SuRz1]http://goo.gl/SuRz1[/url]
I'm also including two screen shoots with and without Serial.begin
Thanks
manolis
First of all, thanks a lot for all the help!
Now I tried both scripts with and without Serial.begin and as before it's not working when Serial.begin is present. Actually I've noticed that when I haven't included Serial.begin and
I'm connected to the shield with putty whenever I'm sending some text the arduino TX light is
flashing, whereas when I include the Serial.begin nothing is happening.
I would like to add that I'm following this tutorial to setup the wifi shield: [url=http://goo.gl/SuRz1]http://goo.gl/SuRz1[/url]
I'm also including two screen shoots with and without Serial.begin
Thanks

2011-12-29 18:39:26 Why aren't you initializing your serial port in your setup loop??
Setup{
Serial.begin(9600);
delay(500); //not necessary but may be useful during troubleshooting.
}
You need to have that line in there with whatever baud rate you want to use. I'm surprised you are getting any feedback.
Try this:
[code]
void setup() {
Serial.begin(115200);
dealy(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}
[/code]
Hector
Setup{
Serial.begin(9600);
delay(500); //not necessary but may be useful during troubleshooting.
}
You need to have that line in there with whatever baud rate you want to use. I'm surprised you are getting any feedback.
Try this:
[code]
void setup() {
Serial.begin(115200);
dealy(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}
[/code]

2011-12-29 18:39:26 Why aren't you initializing your serial port in your setup loop??
Setup{
Serial.begin(9600);
delay(500); //not necessary but may be useful during troubleshooting.
}
You need to have that line in there with whatever baud rate you want to use. I'm surprised you are getting any feedback.
Try this:
[code]
void setup() {
Serial.begin(115200);
dealy(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}
[/code]
Hector
Setup{
Serial.begin(9600);
delay(500); //not necessary but may be useful during troubleshooting.
}
You need to have that line in there with whatever baud rate you want to use. I'm surprised you are getting any feedback.
Try this:
[code]
void setup() {
Serial.begin(115200);
dealy(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}
[/code]

2011-12-29 07:35:41 Try to display what the actual char is.
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
}
}
}[/code]
Let me the result.
R2D2C3PO
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
}
}
}[/code]
Let me the result.

2011-12-29 07:35:41 Try to display what the actual char is.
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
}
}
}[/code]
Let me the result.
R2D2C3PO
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
Serial.println(input);
}
}
}[/code]
Let me the result.

2011-12-29 01:56:12 My setup is as follows:
I'm using an arduino Diecimilia and an DFROBOT wifi shield 2.1.
I have configured the Wifi Shiled to connect to my wifi router, the wifi router is forwarding
port 4000 to the wifi shield
I have loaded the following code to arduino:
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]
The arduino is connected to my pc and the serial monitor is open.
On an other machine on an other network I'm running putty and I'm connect to the wifi shield.
Whatever I write on the remote machine's putty, it appears on the arduino serial monitor.
Now that's all good and working fine, but what I can't do is use any of the information send to the arduino
through the wifi. I tried to use the above code so that when I send 0 or 1 to turn on/off the led
but it doesn't work. Any ideas how to make it work?
manolis
I'm using an arduino Diecimilia and an DFROBOT wifi shield 2.1.
I have configured the Wifi Shiled to connect to my wifi router, the wifi router is forwarding
port 4000 to the wifi shield
I have loaded the following code to arduino:
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]
The arduino is connected to my pc and the serial monitor is open.
On an other machine on an other network I'm running putty and I'm connect to the wifi shield.
Whatever I write on the remote machine's putty, it appears on the arduino serial monitor.
Now that's all good and working fine, but what I can't do is use any of the information send to the arduino
through the wifi. I tried to use the above code so that when I send 0 or 1 to turn on/off the led
but it doesn't work. Any ideas how to make it work?

2011-12-29 01:56:12 My setup is as follows:
I'm using an arduino Diecimilia and an DFROBOT wifi shield 2.1.
I have configured the Wifi Shiled to connect to my wifi router, the wifi router is forwarding
port 4000 to the wifi shield
I have loaded the following code to arduino:
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]
The arduino is connected to my pc and the serial monitor is open.
On an other machine on an other network I'm running putty and I'm connect to the wifi shield.
Whatever I write on the remote machine's putty, it appears on the arduino serial monitor.
Now that's all good and working fine, but what I can't do is use any of the information send to the arduino
through the wifi. I tried to use the above code so that when I send 0 or 1 to turn on/off the led
but it doesn't work. Any ideas how to make it work?
manolis
I'm using an arduino Diecimilia and an DFROBOT wifi shield 2.1.
I have configured the Wifi Shiled to connect to my wifi router, the wifi router is forwarding
port 4000 to the wifi shield
I have loaded the following code to arduino:
[code]void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]
The arduino is connected to my pc and the serial monitor is open.
On an other machine on an other network I'm running putty and I'm connect to the wifi shield.
Whatever I write on the remote machine's putty, it appears on the arduino serial monitor.
Now that's all good and working fine, but what I can't do is use any of the information send to the arduino
through the wifi. I tried to use the above code so that when I send 0 or 1 to turn on/off the led
but it doesn't work. Any ideas how to make it work?

2011-12-28 22:57:55 I'm not sure I follow you.
You are connecting from a machine outside of your local network? That doesn't work.
could you be more clear about your last statement also. What do you mean about initializing the serial port? in the sketch it's self or opening a serial monitor when you have the USB cable connected?
In the sketch you need to initialize the serial port, otherwise it won't work. If you open a serial monitor with the Wifi shield connected, the Wifi shield takes priority of the Tx/Rx lines and will not let the Arduino communicate through the USB...You need to remove the shield in order for it to work properly.
Hector
You are connecting from a machine outside of your local network? That doesn't work.
could you be more clear about your last statement also. What do you mean about initializing the serial port? in the sketch it's self or opening a serial monitor when you have the USB cable connected?
In the sketch you need to initialize the serial port, otherwise it won't work. If you open a serial monitor with the Wifi shield connected, the Wifi shield takes priority of the Tx/Rx lines and will not let the Arduino communicate through the USB...You need to remove the shield in order for it to work properly.

2011-12-28 22:57:55 I'm not sure I follow you.
You are connecting from a machine outside of your local network? That doesn't work.
could you be more clear about your last statement also. What do you mean about initializing the serial port? in the sketch it's self or opening a serial monitor when you have the USB cable connected?
In the sketch you need to initialize the serial port, otherwise it won't work. If you open a serial monitor with the Wifi shield connected, the Wifi shield takes priority of the Tx/Rx lines and will not let the Arduino communicate through the USB...You need to remove the shield in order for it to work properly.
Hector
You are connecting from a machine outside of your local network? That doesn't work.
could you be more clear about your last statement also. What do you mean about initializing the serial port? in the sketch it's self or opening a serial monitor when you have the USB cable connected?
In the sketch you need to initialize the serial port, otherwise it won't work. If you open a serial monitor with the Wifi shield connected, the Wifi shield takes priority of the Tx/Rx lines and will not let the Arduino communicate through the USB...You need to remove the shield in order for it to work properly.

2011-12-28 21:56:14 I'm not really following the tutorial of the Ethernet shield, I just wanted to find a way to make use of the received RAW data. I'm using putty on a remote mashing outside of the local network and whenever I write something on the remote machine is successfully displayed on the serial monitor. But when I send 1 and 0 it doesn't affect the state of the led. I'm using putty on the remote machine. By the way, if I initialise the serial port then I don't get anything on the serial monitor.
manolis

2011-12-28 21:56:14 I'm not really following the tutorial of the Ethernet shield, I just wanted to find a way to make use of the received RAW data. I'm using putty on a remote mashing outside of the local network and whenever I write something on the remote machine is successfully displayed on the serial monitor. But when I send 1 and 0 it doesn't affect the state of the led. I'm using putty on the remote machine. By the way, if I initialise the serial port then I don't get anything on the serial monitor.
manolis

2011-12-28 21:41:45 Manolis,
I'm not sure which ethernet demo code you are referring to, but I can tell you the Wifi shield is not compatible with ethernet sample codes. The sample code you attached seems like it should work through a hyper terminal such as putty the same as discussed in the Wifi manual.
Try adding a small delay on the setup after you initialize the serial port. Sometimes this can make a difference...
how are you connecting to the wifi shield from your pc? Are you using Putty?
Hector
I'm not sure which ethernet demo code you are referring to, but I can tell you the Wifi shield is not compatible with ethernet sample codes. The sample code you attached seems like it should work through a hyper terminal such as putty the same as discussed in the Wifi manual.
Try adding a small delay on the setup after you initialize the serial port. Sometimes this can make a difference...
how are you connecting to the wifi shield from your pc? Are you using Putty?

2011-12-28 21:41:45 Manolis,
I'm not sure which ethernet demo code you are referring to, but I can tell you the Wifi shield is not compatible with ethernet sample codes. The sample code you attached seems like it should work through a hyper terminal such as putty the same as discussed in the Wifi manual.
Try adding a small delay on the setup after you initialize the serial port. Sometimes this can make a difference...
how are you connecting to the wifi shield from your pc? Are you using Putty?
Hector
I'm not sure which ethernet demo code you are referring to, but I can tell you the Wifi shield is not compatible with ethernet sample codes. The sample code you attached seems like it should work through a hyper terminal such as putty the same as discussed in the Wifi manual.
Try adding a small delay on the setup after you initialize the serial port. Sometimes this can make a difference...
how are you connecting to the wifi shield from your pc? Are you using Putty?

2011-12-28 21:33:32 Thanks hector,
what I'm Trying to achieve here is something very similar to the demo code for the Ethernet shield. The only difference is in my case when I send 0 and 1 remotely through telnet it appears on the serial monitor but it doesn't alter the state of the led.
[code]void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]
manolis
what I'm Trying to achieve here is something very similar to the demo code for the Ethernet shield. The only difference is in my case when I send 0 and 1 remotely through telnet it appears on the serial monitor but it doesn't alter the state of the led.
[code]void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]

2011-12-28 21:33:32 Thanks hector,
what I'm Trying to achieve here is something very similar to the demo code for the Ethernet shield. The only difference is in my case when I send 0 and 1 remotely through telnet it appears on the serial monitor but it doesn't alter the state of the led.
[code]void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]
manolis
what I'm Trying to achieve here is something very similar to the demo code for the Ethernet shield. The only difference is in my case when I send 0 and 1 remotely through telnet it appears on the serial monitor but it doesn't alter the state of the led.
[code]void loop() {
if (Serial.available()){
char input = Serial.read();
switch (input){
case '1':
digitalWrite(13, HIGH);
Serial.println("ON");
delay(500);
break;
case '0':
digitalWrite(13, LOW);
Serial.println("OFF");
delay(500);
break;
}
}
}[/code]

2011-12-28 18:21:44 Manolis,
It works just the same as a regular serial monitor (its just wireless). So this means that instead of connecting to the serial monitor via a comm port you connect to it via IP, but you can send and receive info on it just the same way you would using the serial monitor.
I'm not sure what kind of tutorial or sample code you are looking for. It really depends on what your project goal is. Could you give me an idea of what it is you are trying to achieve?
Hector
It works just the same as a regular serial monitor (its just wireless). So this means that instead of connecting to the serial monitor via a comm port you connect to it via IP, but you can send and receive info on it just the same way you would using the serial monitor.
I'm not sure what kind of tutorial or sample code you are looking for. It really depends on what your project goal is. Could you give me an idea of what it is you are trying to achieve?

2011-12-28 18:21:44 Manolis,
It works just the same as a regular serial monitor (its just wireless). So this means that instead of connecting to the serial monitor via a comm port you connect to it via IP, but you can send and receive info on it just the same way you would using the serial monitor.
I'm not sure what kind of tutorial or sample code you are looking for. It really depends on what your project goal is. Could you give me an idea of what it is you are trying to achieve?
Hector
It works just the same as a regular serial monitor (its just wireless). So this means that instead of connecting to the serial monitor via a comm port you connect to it via IP, but you can send and receive info on it just the same way you would using the serial monitor.
I'm not sure what kind of tutorial or sample code you are looking for. It really depends on what your project goal is. Could you give me an idea of what it is you are trying to achieve?

2011-12-28 09:46:31 Hi,
Ho do I read the data that is received through the 2.1 wifi shield?
At the moment the only thing I can achieve is sending strings to the
serial monitor, but I don't know how to use them...
Are there any links of good tutorials to read?
I'm using the bellow code for testing:
[code]
void setup() {
}
void loop() {
if ( Serial.available()) {
int pos = Serial.read();
Serial.println(pos);
}
}[/code]
manolis
Ho do I read the data that is received through the 2.1 wifi shield?
At the moment the only thing I can achieve is sending strings to the
serial monitor, but I don't know how to use them...
Are there any links of good tutorials to read?
I'm using the bellow code for testing:
[code]
void setup() {
}
void loop() {
if ( Serial.available()) {
int pos = Serial.read();
Serial.println(pos);
}
}[/code]
