Working With the Funduino W5100 Ethernet Module.

by diy_bloke in Circuits > Arduino

14984 Views, 13 Favorites, 0 Comments

Working With the Funduino W5100 Ethernet Module.

funduino.jpeg
Funduinoback.png
img_20170412_130317.jpg
w5100-bug.jpg

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