Introduction: Working With the Funduino W5100 Ethernet Module.
Though many people nowadays will choose an ESP8266 if they want Ethernet connectivity, there might be reasons why you'd still want a cable connection between an Arduino and your router. The Ethernetshield can easily do that for you, but if you have an Arduino Nano, or a Promini, an Ethernetshield is not the best choice, save that for your UNO or Mega.
For a Promini or Nano, a small Ethernet module is the better choice.
There are plenty of ENC28J60 modules available. They are easy to use, most likely work right out of the chinese webstore box, but the ENC28J60 is a bit memory greedy as it has to build its stack in Software.
The better choice is a W5100 module as that leaves more memory for your program.
A popular one is the Funduino W5100 module, but it can be a bit tricky to use.
If you look at a modern Ethernetshield and then look at the Funduino W5100 module (circuit), it is immediately clear that the former packs more components than the latter, and you will find out there is a good reason for that.
Connecting to your Arduino
The Module has a 2x5 pin header.
- V+ This is a 5 Volt pin
- Ground: There are two
- NSS: This is your 'chip select'. Usually it connects to D10 on the Arduino
- RST: This is your Reset pin. It should not be connected to your Arduino
- MO: This is your MOSI it must connect to the MISO pin of your arduino (D12)
- SOK: This is your Clock pin. It should connect to the SCK pon of your Arduino (D13)
- MI: This is your MISO, it must connect to the MOSI of your Arduino (D11)
- POE - & POE+: These are your PowerOverEthernet pins. However, they are not the standard PoE connection, as they derive from pins 7&8 on your RJ45 jack
Should you think, Well heck, I will just connect that RST pin to my Arduino. Well, no harm done, but you will notice that you cannot upload any sketches
Getting the module to work
When you first try your module with one of the example programs of the Ethernet library, chances are you will not be able to get a connection. There might be many reasons for that but most likely you have a reset problem. If you would bother to check the circuit of the Ethernetshield you would see it is triggered from the Arduino, via a special reset chip, whereas the Funduinomodule just has its RST pin pulled up to 3V3 with a 10k resistor. This causes some unreliability in the Reset and may lead to the Arduino already wanting to initialize the module, while it is not ready.
Some people get around that by resetting the bord a few times and in the mean time make a quick prayer, but that doesnt always work. You could try adding a capacitor, but you need to find the right value and it still might not be reliable.
I found that if I give the Module a but more time to start, it worked without any problems. I do that by adding a small delay in the the setup, before I initialize the module. Like this:
void setup() { // setup ethernet communication using DHCP delay(250);//<--important for W5100 module if (Ethernet.begin(mac) == 0) { //Serial.println(F("Unable to configure Ethernet using DHCP")); for (;;); }
Some modules may need a bit longer, maybe up to 750mS, try what works for you.
Sharing the SPI
By now your module should work properly, you upload some examples, a webserver or something and things go well. However You want to use your Ethernet connected Arduino for more meaningful things, maybe as an RFM/LoRa gateway, maybe even with a Small LCD such as the Nokia 5110 or a small OLED.
All these devices, (may) have an SPI bus. Well that should not be a problem because the SPI bus is made for sharing right? Well yes it is, but I guess the designers of the Funduino board or maybe even the developers of the W5100 didn't get that memo. The W5100 chip is not Tr-State and keeps the MISO active.
"But", I hear you say, "But it works with my Ethernetshield". Indeed it does. Remember I pointed out the Shield had more hardware than the module? It is there for a reason.
In order for the W5100 to release the SPI bus, it isn't sufficient to just make the ChipSelect HIGH. The W5100 needs a complete disable of the SPI bus. To do that you need to make the SEN (SPI Enable) pin LOW.
The Shield does this with by inverting the CS signal and feeding that to the SEN pin, so when you disengage the active LOW CS pin bij making it HIGH, subsequently the SEN pin will be made LOW which disables the SPI mode.
The Shield uses the 74LCV14 Inverter Schmitt-trigger, but no doubt other inverters such as the 74LVT14 or 74HC(T)14 or CD4011 will do the job as well and probably a 74LC04 or 74LVT04 will be fine too.
Mind you that some of those chips may need 5 Volt rather than 3V3, but both are available on the Funduino board. The problem however is that these chips are 14 pin DIL chips and it is hard to find space for them on the Funduino board. That is why I ordered a 74AHC1G04 as that is only a single inverter chip that measures only 2x3mm and can easily find a place on the module.
So, where to find the SEN pin?
The SEN pin is in fact pin 31 of the W5100. As an 80LQTF chip might not be the most inviting chip to solder on, fortunately there is an easier solution. The pull up resistor that is attached to the SEN pin makes a good entry point for the inverted CS signal. In the above picture it needs to be soldered to the right side of the '103' resistor. The CS signal can be picked up from the NSS pin. The 3V3 signal from the Regulator.
Although not really an issue confined to the funduino board, when sharing the SPI another problem may occur because the library doesnt protect the W5100 against interrupts when it is active. This can be remedied by a xhange in the Ethernet lib's w5100.h file:
Look for te section:
#else
inline static void initSS() { DDRB |= _BV(2); };
inline static void setSS() { PORTB &= ~_BV(2); };
inline static void resetSS() { PORTB |= _BV(2); };
#endif
and replace with
#else
inline static void initSS() { DDRB |= _BV(2); };
inline static void setSS() { cli(); PORTB &= ~_BV(2); };
inline static void resetSS() { PORTB |= _BV(2); sei(); };
#endif
Power Over Ethernet (PoE)
The Funduino module does have PoE pins. However it is not the standard PoE.
In Standard PoE the twisted pair 4&5 transport Positive power and 7&8 negatieve power.
In the Funduino module. pin 7 of the Ethernet jack transports negative power and pin 8 positive.
So if you want to use the PoE of the module you would need to make your own adapter, injecting power to the 7 and 8 pair of your UTP cable. On the module of course you would still need to convert that power to say 5 Volt or 3V3 and supply that to the Module. It is risky to do that via the on board stabilizer, as that may expect exactly 5 Volt on its Vin pin, when other 5 Volt devices are connected to it. The safest would be to use a separate 5 Volt stabilizer and use that to feed the module and connected other devices
9 Comments
3 years ago
Interesting module. Maybe something for my greenhouse! =)
4 years ago
Please correct your wiring.
MOSI to D11
MISO to D12
Reply 4 years ago
Hi, yes I confirm, the article states MOSI->D12 and MISO->D11, however it should be the other way around.
5 years ago
Excellent Instructable. I have used these Funduino boards quite a lot (I call them "the red board") and I do recall having an issue with reset 3 or 4 years ago when I started out with this, which I got over by setting a delay in my sketches. Haven't had a problem since, probably because I just copy from one sketch to another the basics.
Similarly I hadn't given much thought to sharing SPI because I've always used the Arduino Mega and can switch other devices to other pins, as there are so many.
But now I'm in the process of thinking about making my own Arduino PoE Ethernet board based on ATmega328, W5100 and a Silvertel AG8012s POE module, and I'm SO glad I came across this comment about the SPI bus, as I just hadn't thought about it.
I'm nervous about making my own board, as I've never soldered QFP, but with this article, a reflow solder station, and my existing understanding of the W5100, I'm hoping to give this a go now!
Reply 4 years ago
My Ethernet module not working. Hoe to solve?? Please help...... Always got "Failed to configure Ethernet using DHCP"
Reply 5 years ago
I am happy I could be of help. Quite an undertaking you plan. Are you sure about the W5100? did you consider the W5500? that last one is a bit more modern
Reply 5 years ago
I previously decided on W5100 because it's fully supported by Arduino Ethernet library, and I have some projects that use libraries that depend on this library. I couldn't work out from a quick google whether the W5500 is fully supported under the Arduino Ethernet library or not. i.e. I'm lazy, I know it works well, and there is plenty of good resources online tying Arduino with W5100 which I can rely on when troubleshooting. (Such as this great article!)
Having just googled about the improvements of the W5500 over the W5100, Wiznet wrote a few years ago:
"W5500 is more cheap, better performance and have 8 sockets"
also "W5100 is in Arduino official ethernet shield and we don’t have plan to discontinue."
Perhaps given I'm going to the trouble of designing a new board I should at least get myself a W5500 break-out board and test. Thanks for bringing that up. See here for a link to my main project that uses the "red board": http://www.automatedhome.co.uk/hardware/video-mqtt-smart-home-wall-controller-code-published.html
5 years ago
Awesome ;)
Thanks :0
Clear, informative and concise!
Reply 5 years ago
My pleasure. Glad to help