Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / Re: ETHERNET library : using as SERVER - How to get remote client IP ? on: November 16, 2011, 06:41:42 am
There have been lots of changes to the Ethernet library since 0022 - DHCP and DNS have been added, and some of the classes renamed so that it's easier to switch between Ethernet and WiFi shields.

But there still isn't a way to find the remote IP address.  I don't think it would be really hard to add - just no-one has needed it yet.  If you want to try adding it, use the latest release candidate of Arduino 1.0 - which you can get from

I'd suggest adding a remoteIP method to the EthernetClient class (and as a pure virtual in Client too, ideally):

virtual IPAddress remoteIP();

That would make the most sense, as it would match the one already in EthernetUDP.h.  You'll have to look at the w5100 datasheet, or poke through the existing code to work out how you'd actually read the remote IP though.

Then submit a patch/pull request and we can add it to a future release of the Ethernet library :-)

Or, if none of that makes sense, submit a feature request to but it might be a while before I'll have enough free time to implement it :-/


2  General Category / General Discussion / Re: RFID readers on: August 01, 2011, 08:12:21 am
I've moved to the Stronglink SL018 after the shield was discontinued.  It's easy to interface with, and Marc Boon has written a nice library for it too.
3  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet cleint println() makes new packet every time on: July 26, 2011, 04:44:54 am
I'm not sure what you mean by "freezes"?  If the server isn't turned on then there won't be any reply to the packets the Arduino sends out to try to bring up the connection.  The Arduino will spend some time (it's usually ~40 seconds on most TCP implementations but I've not double-checked the Arduino one) retrying the connection before it gives up.

So in your code it would spend a while inside the clientREST.connect() call if the server isn't on at all.  For the case when the PC is turned on, but the server program isn't running, the PC will respond to the first connection request with a reset packet, and so the Arduino will give up trying to connect almost immediately.

Hope that helps,

4  Community / Workshops and Events / Howduino Lancaster on 25th/26th June on: May 24, 2011, 07:32:41 am
The next Howduino hack-weekend has just been announced, and this time we're bringing the joy of Arduino to Lancaster in NW England.

For the weekend of 25th/26th June 2011 we'll be taking over part of the shiny new LICA building on the Lancaster University campus and dedicating the space to learning more about Arduino and electronics, or just to working on projects in the company of like-minded tinkerers.

Head to to sign up.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Converting long to big-endian 32 bit number on: October 02, 2010, 01:58:55 pm
You should use htonl and htons to convert numbers from "host" to "network" (i.e. big-endian) format.  They're both in sockutil.h in the Ethernet library.  htonl will convert 32-bit numbers and htons does the same for 16-bit.

There's also ntohl and ntohs to map things coming the other way (although IIRC they're basically synonyms).
6  Forum 2005-2010 (read only) / Development / Re: Arduino Uno - sending UDP message on: January 20, 2011, 02:13:35 pm
Since (I think) Arduino 0019, and definitely by Arduino 0021 there is a UDP API in the core Ethernet library.  If you look at the Ethernet examples there are two that use UDP.

Unfortunately, the API is due to change a little in the next release (or maybe the one after).  See for details of the proposed changes.
7  Forum 2005-2010 (read only) / Development / Re: Problem with NeoCat's Twitter Library on: October 06, 2010, 11:46:25 am
Try adding:

#include <spi.h>

into your sketch.  I haven't moved to 0021 yet myself, but there was discussion about it on the developers mailing list recently and I think that's the required solution.

See for the archive of the discussion.
8  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 02:37:51 pm
Oops.  Thanks for the comment Mikal - I hadn't realised strcmp was provided in Arduino.  Indeed you should use that, but you'll still need to NUL-terminate the array first.  Which I've just realised also means that you'll need to make your array 11 chars rather than 10, otherwise you'll overwrite part of 'bytesRead'.
9  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 02:25:01 pm
Okay, I think this will be the last problem...

Strings in C and C++ are NUL-terminated, which means there's a '\0' character on the end of them.  Although you can't see it, the "0415E9B02D" has a '\0' on the end, and your "code" array doesn't.  If you stick
code[bytesread] = '\0';
before the if statement then you should be good.  (Actually, you should really do that before the "Serial.println(code);" line, so that it doesn't end up printing any garbage that's after the array)
10  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 08:42:26 am
I've just tried compiling the strcmp example I pointed to, and the Arduino compiler doesn't like the brackets round the function name.  This code compiles for me (but I don't have an Arduino to hand to try it out):

int strcmp(const char *s1, const char *s2)
    unsigned char uc1, uc2;
    /* Move s1 and s2 to the first differing characters
       in each string, or the ends of the strings if they
       are identical.  */
    while (*s1 != '\0' && *s1 == *s2) {
    /* Compare the characters as unsigned char and
       return the difference.  */
    uc1 = (*(unsigned char *) s1);
    uc2 = (*(unsigned char *) s2);
    if (uc1 != uc2)
       return ((uc1 < uc2) ? -1 : (uc1 > uc2));
       return 0;

If you stick that at the top of your sketch, then the "if (strcmp(code, "0415E9B02D") == 0) {" should work.

I think you're right with being able to put TextString into hardware/libraries, but I'm not an expert on where it looks for the libraries.
11  Forum 2005-2010 (read only) / Development / Re: RFID tag compair problem on: December 10, 2008, 05:08:35 am
It sounds like you're pretty close, and you're right in your analysis that it's the "if" statement at fault.

It isn't skipping the "if" - the problem is how strings are handled.  Without getting too deep into C/C++ and pointers work, you can't use "==" to compare strings.

What you'd need to do is either use the TextString library - see, or if you just want to compare basic strings like you're trying here, add a strcmp function to your code.

Here's an example that you could cut and paste into your Arduino sketch.  I don't think you'd need the "#include <string.h>" line, and then your "if" line would become:

"if (strcmp(code, "0415E9B02D") == 0) {"

I hope that's all right, give a shout if it's not and I'll try compiling it into a sketch myself :-)
12  Forum 2005-2010 (read only) / Interfacing / Re: Recomendation for an Ethernet shield on: September 17, 2009, 03:43:37 pm
I'd avoid the Nuelectronics shield, but only because the TCP/IP stack has to be included in the sketch and so it eats up a chunk of the available space.

Other than that I've used both the Adafruit shield with XPort, and the official Arduino Ethernet shield and they're both good (particularly now that you can get DHCP for the official shield).

I'd go with the official shield myself as it's becoming more and more popular.
13  Forum 2005-2010 (read only) / Interfacing / Re: twitter on arduino on: April 23, 2009, 04:11:11 pm
Bubblino, my twitter-watching, bubble-blowing Arduino-bot parses through the XML returned by

It's fairly simple because it's just looking for dates, but the code (using an Arduino and one of the Adafruit XPort ethernet shields) is available at  One note about the code at present - it doesn't work with Arduino 0015, but does on Arduino 0012 - I haven't had time to work out why exactly just yet.
14  Forum 2005-2010 (read only) / Interfacing / Re: Ethernet Shield data transfer on: March 27, 2009, 09:37:20 am
The most obvious reason for getting a 100061 "Connection Refused" error is if there isn't a server listening at the remote end.

And as you say that you're using the Client example for the Arduino then that's true - there won't be anything listening on the Arduino.

TCP isn't quite like a serial connection where you just open the serial port at each end and can send and receive data.  It's a client-server model where one end initiates the connection (the client) and the other end must already be listening for that incoming connection (the server).

It sounds like you're using something like telnet on your PC, which is effectively trying to connect two clients together, and won't work.

The easiest solution is probably to use the ChatServer example on your Arduino.  Then the Arduino will be acting as a server, listening on port 23, and you'll be able to telnet to it from your PC.

Anything you type into telnet will then be echoed back to you by the Arduino.  It might not look like anything much is happening at first, because you'll just see what you're typing, but because of how telnet works the text will have been sent to the Arduino and back if it's appearing :-)
15  Forum 2005-2010 (read only) / Interfacing / Re: Ethernet shield - basic intro to networking on: March 03, 2009, 05:42:24 pm
Hopefully some simple to understand answers then :-)  

One thing I'm not sure about, but which might cause problems (and I'm sure someone will be along soon with the right answer) is your ethernet cable.  If you aren't connecting through a hub or a switch, and just plugging the ethernet shield direct to your Mac then you might need a crossover cable rather than a standard ethernet cable.

Now to your questions:

A) Assigning the IP address to the shield is just a case of setting the right value in the sketch.  The examples have an array where you fill in the IP address you want to use.  If you're only connecting to your Mac then just make sure it's different to your Mac's IP address.  

Normally, I'd just find out the IP address of another computer on the network, and then change the last number at random and see if anything responds to that when you try to ping it.  For example, my laptop's IP address is, so I'd try typing "ping" in a terminal.  If I got a reply then that address is in use, so I'd try different ones until I didn't get a reply.  (It might be that a machine does exist with that address, but is turned off - if it starts behaving strangely in future I'd double-check)

B) I wouldn't worry about it too much, and use the one given in the examples.  You only need to change it if you start having more than one Arduino with an ethernet shield on the same network

C) Do you need to set that for the ethernet shield?  If so then just copy whatever your Mac is using - I'm not sure how you check on a Mac, but you might be able to type "ifconfig" in a terminal.  Or if you're using the 192.168.1.x private network, the standard netmask is

Pages: [1] 2