Pages: [1] 2 3 ... 5   Go Down
Author Topic: Arduino Uno + Wireless proto shield + Wifly module  (Read 14808 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Arduino community!!

Let me do a quick introduction here since i'm new, and this would be my first post on these forums.
-- a few years back i ran into this project controlling RGB leds using a PIC microcontroller. This project really triggered an interest in finding out how this stuff works, and how to program these microcontrollers.
So, a few books (mainly on c for PIC's) later, and a few projects later, i decided to try out Arduino. (Arduino is kind of hard to miss once you get to play with microcontrollers)
So i bought myself a Arduino Uno r3 .
After doing a few tutorials (bought some getting started books on arduino as well as the Arduino Cookbook.) it was time to do something a little more advanced.
To make things a bit more interesting, i bought a Wifly module to put into a Wireless proto shield
I would like to start off easy (hello world), by controlling a led:
- either wireless by making a socket to a server app. (got one by following ms c# tutorials  smiley-cool )
- or control the led through serial, and letting the arduino host a webpage showing the status of the led.

Hooking up the Wifly module wasn't very difficult, i hooked the Wifly module up to the Arduino using the Wireless proto shield, and as per instructions in the manual, i got into command mode, scan all the WLANS in my appartment, and associating with my own SSID. The unit got an IP straight away, and it responds to ping requests. So i figure the module is connected to my WLAN!

Anyway, i soon found out that there are some compatibility issues with the Wifly library and Arduino 1.0
The example code did not compile, and i don't have the skills (yet smiley-lol) to fix this myself.
after searching the internet for help i finally found a library which is supposed to be compatible, and made a VERY simple sketch:
after the
#include "WiFly.h"
#include "Credentials.h" //file modifed obviously..
in the setup i have the serial.begin, and in the main loop i just write "hi" to the serial port with a delay before looping.
If i upload this sketch i see the "hi" messages coming into my terminal.
But, once i do a WiFly.begin(); in the setup part (as in the examples) i can still compile and upload the code, but the arduino seems to get stuck. The lights of the wifly unit blinks as it's telling us it's connected to the network (still can ping the unit), but it never starts sending out the "hi" message to the serial port.
If i comment out the WiFly.begin(); the unit starts sending the mssg to the serial port again.
So it seems that the arduino hangs on the WiFly.begin(); method.
Can someone please tell me how to troubleshoot this? or, get me up and running using the Wifly shield using Arduino 1.0?
Any help would be very appreciated!
Thanks in advance,

Sander.

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can someone please tell me how to troubleshoot this? or, get me up and running using the Wifly shield using Arduino 1.0?
Without seeing your code, no, I'm afraid not.
Logged

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

thanks for your answer.
The code i used couldn't be more simple:
To see where it hangs i simply stripped out everything smiley
The code which does give me the mssg to the terminal:
Code:
#include "WiFly.h"
#include "Credentials.h"


Server server(80);

void setup() {
//  WiFly.begin();
  Serial.begin(9600);

}

void loop() {
  Serial.print("Ping");
  delay(100);
}
While this doesn't.
Code:
#include "WiFly.h"
#include "Credentials.h"


Server server(80);

void setup() {
  WiFly.begin();
  Serial.begin(9600);

}

void loop() {
  Serial.print("Ping");
  delay(100);
}
in both cases i can ping the unit though..

thanks again!
Logged

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

Well, it would be a pretty cool device if i could get it to work.
Any advice for a newb like myself to find a working library?
I'm not the only one without the issue that the library isn't working with arduino > v22
I know i'm not providing much info here, but i don't really know what i could test / try to come up with additional info.
Would my conclusion be correct to say that it is the Wifly library which does compile is the cause of the unit hanging? (since unit does not hang without the Wifly.Begin())
Any other tips how to proceed?
Many thanks!
« Last Edit: January 31, 2012, 03:39:53 am by sponder » Logged

Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not skip using the library to start with and just configure the wifly using the serial monitor? Are you wanting to do anything that would require changing the config on the fly? E.g switching between TCP and UDP protocols, sending packets to more than one host? If not then you don't need the wifly library.

Once the wifly is configured it will send anything the arduino writes to its serial port as a UDP or TCP packet to the configured host address and port. The wifly will also send the payload of any packets it receives to the Arduino's serial port.
Logged


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

ok cool! i will experiment with this! thanks!
but does this mean i cannot use the serial link to the pc and the WIFLY module at the same time? as in, connect to WLAN and print out the IP address to the console?
Logged

Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You're right; with the shield you have you can't use the serial monitor and the wifly module at the same time, since the shield connects the wifly module's serial pins to the arduino's hardware serial pins (pins 0 and 1).

One option would be to clip off shield's 0 and 1 connector pins and use two jumper wires from the shield's sockets for pins 0 and 1 to two other pin sockets (e.g. 11 and 12) and use software serial for the wifly communication.  Then you can use the serial monitor for debugging your sketch at the same time that the wifly is sending and receiving packet data.

For an example of this take a look at this post:
   http://arduino.cc/forum/index.php/topic,68007.msg667351.html#msg667351.

After you do this if you want to configure the wifly using the serial monitor you will need to load a small sketch that reads characters from the serial interface and sends them to the soft serial interface, and reads characters from the soft serial interface and sends them to the serial interface.  E.g. (not tested):
Code:
#include <NewSoftSerial.h>

NewSoftSerial wfSerial(11, 12);

void setup()
{
    Serial.begin(9600);
    Serial.println("Starting");

    wfSerial.begin(9600);
}

void loop()
{
    if (Serial.available()) {
        wfSerial.write(Serial.read());
    }

    if (wfSerial.available()) {
        Serial.write(wfSerial.read());
    }
}

This example works with the older Arduino IDE (not 1.0) and uses the NewSoftSerial library.  With the 1.0 IDE you can use the soft serial library that comes with the IDE.

I've used the software serial interface reliably at 38400 baud, but it might be able to run at a higher baud rates.

Edit: fix typo
« Last Edit: January 31, 2012, 06:02:01 pm by dhunt » Logged


Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I forgot to mention that you can also enable telnet support on the wifly module. Then when you want to configure it you just use telnet to connect to the wifly's IP address and view and modify the config using that.  A telnet client application should be available by default in linux and OS X, and I believe one comes with windows too.

You can enable telnet support with the "set ip protocol" command and setting bit 2.

Example telnet command: (wifly IP address is 192.168.1.10 - replace with the IP address of your wifly):

    telnet 192.168.1.10 2000
Logged


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

ah, things are becoming much more clearly now! thanks for helping out!
Yesterday i tried to connect to the wifly module through telnet, connected without a problem (could enter command mode straight away  smiley-cool) didn't even have to configure the module to accept telnet.
I figure once communication is up, i can also ship any info from the arduino to the pc through the wireless link. (i got the mac address of the unit reserved in my DHCP server, so the IP addy is known.)
Could you confirm that i don't need the wifly library to connect to a server over a socket? I've read through some ethernet examples, but i'm not sure how much different that would be since they all rely on the ethernet library.
Logged

Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, you've got the hardware and everything you need to start trying things out, so my advice is to go for it!  Time for some experiments :-)

Regarding any WiFly software libraries that are available; they all use exactly the same commands as you do over the serial port or telnet connection.  So you can do everything the libraries can do. The libraries make it easier to use code in a sketch to change the WiFly configuration on the fly and pull status from the WiFly.  They build text command strings and send them via serial to the WiFly, and read the text response and map it onto return codes and variables.
Logged


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

ok cool!
seems i'm on my way, being a noob the road is pretty long and the learning curve is pretty steep (imho) but hey, im learning a lot from this, which is my primary goal anyway!  smiley
fyi: yesterday i started my c# backend app, build a nice class to handle (incoming) connections, which worked with a simple client app. smiley-cool
Tonight i'm planning on coding methods for sending and receiving data. Once that's finished i can sink my teeth in some arduino code (if wlan == connected than connect to socket, once socket == connected, send back any incomming data)
Once i'm there i can think about sending commands for turning on / off a led.

Does this path sound logical or would you take a different approach?

again, thx for the help!
Logged

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

Heey Sponder

Seems u are not the only newbie. I was trying to send data from desktop app to arduino wirelessly using the wifly module. Last week I was able to successfully connect the module to my home network and viewing through my Dlink router configuration web page there it was on the list of web clients.

Now the problem was communicating with the module through telnet because I keep on getting "could not open connection to the host, on port 2000: connect failed". I cannot do much more without first solving this problem. DId you get such a problem?..what could be da way out of this?..
Logged

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

never had the problem, can't help you there.
However, i did myself a big favor by printing out the manual and i would suggest you do too! it's a great command reference.
Through serial you can check all the settings, but port 2000 is the default telnet port, so i would check if the unit would response to the network. Can you ping the unit?
Logged

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

Yah i was able to ping it but cannot communicate with it through telnet or TCP. For your info am using the WiFly Transparent Terminal Sketch provided on http://www.sparkfun.com/tutorials/158 as a start. I followed every step till the telnet part where am currently stuck.
Logged

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

oh sorry am getting this message after pinging the wifly module..."Destination host unreachable" and i guess this means that it has failed to communicate with the device....Pardon me for any trivial mistakes as I am less experienced on networking techs....
When I was configuring the wifly, I set my pc's ip as the host ip address and assigned port 19999 as the remote port number...Isn't this enough to initiate connection between the wifly and the pc....thanks...
Logged

Pages: [1] 2 3 ... 5   Go Up
Jump to: