First steps with WiFly and Arduino

I guess you know you have to change the MY_SERVER_GET and MY_SERVER_GET_URL defines to match your server's setup? This is what's being inserted into your request and if the values in it are not correct you won't reach your server.

Your request is executed (if this is possible to say, the request line is sent over the existing connection) in this line:

WiFly <<  (const char*) strRequest;

pylon:
I guess you know you have to change the MY_SERVER_GET and MY_SERVER_GET_URL defines to match your server's setup? This is what's being inserted into your request and if the values in it are not correct you won't reach your server.

Your request is executed (if this is possible to say, the request line is sent over the existing connection) in this line:

WiFly <<  (const char*) strRequest;

Hi

Yes, I just put false details for the forum. Ah ok that is that line that's sending the GET request. Mmm, not sure what's happening then as the php script doesn't execute. It works fine when I do it via a browser.

You mentioned about a serial adaptor for testing before. Is it this adaptor?

I think I need to get one of these as its impossible to test what's going on, its perhaps something small like a typo in the request URL.

Thanks.
Garrett

You mentioned about a serial adaptor for testing before. Is it this adaptor?
FTDI Serial TTL-232 USB Cable : ID 70 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Almost, but this is the 3V version. I'd go for the 5V version as the standard Arduino runs it's pins on 5V. Usually 60% of the max level should be enough to trigger as HIGH but 3V is exactly on the edge then which is something I would avoid.

I often use the original Arduino USB2Serial LIght (http://store.arduino.cc/ww/index.php?main_page=product_info&cPath=11&products_id=143) or the Foca (http://shop.boxtec.ch/product_info.php/products_id/40332) which has the possibility to switch between 3V3 and 5V for the signal lines and includes a XBee socket to access any Bee directly from the PC.

pylon:
Almost, but this is the 3V version. I'd go for the 5V version as the standard Arduino runs it's pins on 5V. Usually 60% of the max level should be enough to trigger as HIGH but 3V is exactly on the edge then which is something I would avoid.

I often use the original Arduino USB2Serial LIght (http://store.arduino.cc/ww/index.php?main_page=product_info&cPath=11&products_id=143) or the Foca (http://shop.boxtec.ch/product_info.php/products_id/40332)

ah right I'll see if I can find a 5v version. I can't find an image of how the Arduino USB2Serial LIght is to be wired up to the Arduino so that's making me hesitant about that - I have found images of the USB FTDI TTL-232 cable - TTL-232R cable connected to Arduino. Is the FTDI friend (FTDI Friend + extras [v1.0] : ID 284 : $14.75 : Adafruit Industries, Unique & fun DIY electronics and kits) the same thing again?

Garrett

The FTDI friend is almost the same as the Foca but without the XBee interface. If you just need a USB2Serial adapter, it's a good way to go.

The connection usually is quite easy, in your case you just need GND, TX and RX.

Hi

Sorry to ask again but I want to be sure before I purchase and I've discovered there seem to be an enormous variety of usb/ttl adaptors.

I've found a 5V adaptor here:
http://robosavvy.com/store/product_info.php/manufacturers_id/33/products_id/986
which is cheaper than all the usb to ttl cables I've seen (I have a usb male to female extension already). It looks the same to me but the (CP210) number is not one I'm seeing anywhere else. Maybe its just the brand id number?

and I've found a tutorial here:

which is nice and clear - even though the adaptor is different, same principle right?

thanks in advance
Garrett

The adapter you linked to is using another chip doing the conversion between serial and USB. In the Arduino world the FTDI chip is very common for that and that's why almost everybody doing development with Arduinos has installed the necessary drivers already. This adapter uses the CP210 chip which is not that common and you probably have to install drivers (for Windows or Macintosh, current Linux distros include the driver already). Because it's not used as broad as the FTDI chip, future availability of drivers for Windows or Macintosh are not assured but apart from that it's a viable and good choice, I think.

Ah ok I should probably stick to one of the others then. Thanks again.

Garrett

Hi

My usbserial cable has arrived and I'm not having much luck getting software serial to work. At the moment I've disconnected the RN-XV and xBee Shield to keep things simple to just test how software serial works. I've installed the VCP driver (http://www.ftdichip.com/Drivers/VCP.htm), I guess this is the one I need as opposed to the D2XX driver? I've restarted and I'm using osx terminal to monitor the software serial port, so I ls /dev/tty.* like so:

garrett-macbook:~ garrett$ ls /dev/tty.*
/dev/tty.Bluetooth-File-Exchange	/dev/tty.Bluetooth-PDA-Sync
/dev/tty.Bluetooth-File-Transfer	/dev/tty.usbserial-A6008dRD
/dev/tty.Bluetooth-Modem		/dev/tty.usbserial-AH019JWT

I'm following the instructions here (arduino, terminal and two serial ports | Conversations with spaces) but I don't see anything like the "/dev/tty.SparkFun-BT-COM0" port he has. Anyway I connect to the last one:

screen /dev/tty.usbserial-AH019JWT 9600

This is the code I'm testing which I upload to the arduino via hardware serial:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);

void setup()  
{
  Serial.begin(57600);
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

In Arduinos Serial Monitor (set to 57600 baud), the serial lines execute but the software serial lines are never shown in terminal. I've attached a photo of the usbserial cable wired up just in case there is anything wrong there but I've used the same RX,TX in the script.

Any suggestions as to what I'm doing wrong, perhaps I'm missing another driver or something small like that, would be greatly appreciated.

Thanks in advance.
Garrett

I guess the connections of your USB2Serial are equivalent to my Arduino USB2Serial Light. If this is so, you have to swap the RX/TX lines, at least that's my interpretation of your picture. My wiring is:

Arduino -> USB2Serial
GND -> 1 (GND)
2 -> 4 (TX)
3 -> 5 (RX)

I don't have a Mac, so I don't know how the USB adapter show up there. I have /dev/ttyACM0 and /dev/ttyACM1. You probably can test which one it is by disconnecting the cable and see which device disappears (at least on my Linux box this is the easiest way).

I tried your test code and it works like a charm. Immediate response (when I don't use the Arduino Serial Monitor but a serial terminal program) in both ways.

Hi

Yes that worked perfectly, thanks very much, I read the diagram I was looking at wrong (2313ConnectSerial | Photos and illustrations for a tutorial … | Flickr).

So I'm testing with software serial in my WiFly code now and it seems that the begin() command being sent to the WiFly is where everything stops. I've stripped it down to keep it simple (i.e. just starting up the wifi) and in the code below it never gets as far as the loop(). Physically all the connections on the arduino to the shield and RN-XV look good, the switch is on xbee and I have no problems configuring the RN-XV from CoolTerm on my computer so I think this elimintates any issues with connections. Maybe I'm forgetting to include a key library that's needed or could there be something wrong wih the WiFlySerial.h library?

Thanks in advance
Garrett

#include <Arduino.h>
#include <Time.h>
#include <SoftwareSerial.h>
#include <Streaming.h>
#include <PString.h>
#include <WiFlySerial.h>


//various buffer sizes
#define REQUEST_BUFFER_SIZE 180
#define TEMP_BUFFER_SIZE 60

//server hosting GET example php script
#define MY_SERVER_GET "http://www.asquare.org/"
#define MY_SERVER_GET_URL "in-progress/arduino-test/counter/index.php"


//WiFly pins
#define ARDUINO_RX_PIN  2
#define ARDUINO_TX_PIN  3

WiFlySerial wifi(ARDUINO_RX_PIN, ARDUINO_TX_PIN);
char bufRequest[REQUEST_BUFFER_SIZE];
char bufTemp[TEMP_BUFFER_SIZE];


//sotware serial pins for testing
SoftwareSerial mySerial(4, 5);



//loop counter
int iLoopCounter = 0;

//start time
unsigned long startTime = 0;


void setup()
{
  //set up serial
  //Serial.begin(9600);
  
  //set the data rate for the SoftwareSerial port and send a message to test
  mySerial.begin(9600);
  mySerial.println("Software serial working");
  
  //start up WiFly
  wifi.begin()
  
  //I tried testing with this in the hope it would send back an error code of some sort but nothing
  //mySerial.write(wifi.begin());
  
}


void loop()
{
  //to test
  mySerial.println("test");

  //to prevent spamming serial monitor too much
  delay(250);
}