Go Down

Topic: Ethernet shield: setting MAC/IP from outside (Read 722 times) previous topic - next topic

FrankM

As you might know the Ethernet shield comes without a MAC address. You start the Ethernet library with furnishing your own MAC and it's your responsibility to make sure that this MAC address is unique in your network.

Unfortunately if you have more than one Arduino in your network, this means that you need to make a dedicated sketch. Or I should say: you need to alter your sketch for every upload.

I am looking for a way to make this configurable from the outside. The first idea would be to use some pins and hardwire those to +5v or GND creating an binary 'address' for the last byte of the MAC and IP. This would be possible if one had enough pins.

However my current project involves an Ethernet shield (which is not that strange given the question) using pins 10 through 13. Then an LCD is mounted that uses pin 4 through 9 and analog 0. My application uses pin 3 and analog 1 through 5. Leaving only pin 2 (as 0 and 1 are RX/TX and it is not a good idea to hardwire those) which gives not much configuration power...

Are there any thoughts on other options? Are there pins I am forgetting? Is there a technique I am forgetting? Please not that anything that does something with randomisation is not an option (as it would neither guarantee uniqueness nor make it manageble). And while on the subject... why does the Wiznet chip not carry it's own MAC? Would make live so much simpler...

mem

#1
Nov 29, 2009, 03:34 pm Last Edit: Nov 29, 2009, 03:35 pm by mem Reason: 1
You could store the mac address in EEPROM.  The address can be set  from  the serial port, and once set, your setup code could check that a valid mac address was available and use it to init the Ethernet library.

FrankM

That is an interesting thought... what I did not yet mention is that the setting of the address must be quite simple, so I can let field engineers do it. Creating some sort of dialog via the Serial would be feasible I'd say. Thanks. Open to other options of course, so enlighten me!

SoundGuyAndy

Could you do it like a wireless router setup, where there's a default MAC and IP, you connect to that IP via a web browser, where you edit the values in a form, and then those values get saved to EEPROM and take effect when you reset?

kg4wsv

+1 for EEPROM.

You could also add a small I2C flash IC, and store the MAC address (and IP, default router, etc, etc) there.  Make it a DIP package and the node's identity would be in the flash chip, which could be programmed separately.

-j

FrankM

Are the I2C pins not hardwired to other pins (digital/analog)?

mem

#6
Dec 02, 2009, 12:00 pm Last Edit: Dec 02, 2009, 12:01 pm by mem Reason: 1
the i2c pins are available when using the Ethernet shield. They are analog pins 4 and 5 (digital pins 18 and 19)

milneandfletch

You could use a analogue Pin and fit a pd, and by changing the resistor values you would get a new ADC value which could be used to change a section of the mac/ip address. This is a hard wire option if that helps?

I would only read it once at startup, as you dont want voltage changes to affect the operation!

Pete

Go Up