Connect an ENC28J60 Ethernet module to an Arduino

With prices of ENC28J60 Ethernet modules coming down drastically with some as low as 4,60 euro, (even cheaper here much cheaper even here), buying one of these to connect barebones Arduino projects to the web becomes more and more attractive. With the official ENC28J60 Ethershield and Ethercard, just sticking it in  the Arduino is easy and takes care of the proper connections, but with one of these modules, we need to make the following connections. (Though the Vcc is 3.3 Volt, the datasheet states the pins to be 5 V tolerant, just like the W5100 chip)

ENC SO -> Arduino pin 12
ENC SI -> Arduino pin 11
ENC SCK -> Arduino pin 13
ENC CS -> Arduino pin 8 (or 10, read further)
ENC VCC ->  3V3  (watch out, it needs quite some juice, you may consider a  separate supply, rather than feeding it from the Arduino 3V3 pin)
ENC GND -> Arduino Gnd pin

For the ENC28J60 chip/module, there are three Arduino libraries available: Ethershield (development has stopped) and Ethercard (the newest). There is also the UIPEthernet library (Thanks for pointing that out Norbert Truchsess) that is compatible to the Ethernet library. To be clear:  the Ethernet library is for the WIZ5100 ethernetshield, using the UIPEthernet library makes (most of) the WIZ5100 based programs suitable for the ENC28J60.

A note on the Chipselect CS
The use of the proper CS pin is depending on what library one uses for the ENC28J60.
there are defacto three libraries: The EtherShield library, the EtherCard library and the UUPEthernet library.
The Ethershield library uses pin 10 as a chipselect
The EtherCard library uses pin 8 as a chipselect
The UUPEthernet library uses pin 10 as a chipselect
The reason for this change  is to be able to use the Ethercard together with an SD card.

If you buy a module, rather than a shield, it is very easy to determine what chipselect pin you want to use. If you use the older EtherShield library, use pin 10 as CS, if you use the somewhat newer Ethercard library, use  pin 8.

If for whatever reason you want to use the Ethercard library with pin 10, change the pin assignment in the library files ENC28J60.h (line 25 and 41 I believe)   and the EtherCard.h  (Line 134: uint8_t csPin = 8 ). (Depending on the version it can also be in line 154.)

Screenshot from 2013-10-01 17:15:11

It is also possible to add the declaration for pin 10 in the program itself like this:

ether.begin(sizeof Ethernet::buffer, mymac, 10)

This card works with a Mega2650 if you override the CS pin in the sketch. The pin mapping is –
ENC  Mega2650
SO 50 (MISO)
SI 51 (MOSI)
CLK 52 (SCK)
CS 53 (SS)

In the sketch you need to override the begin with ether.begin(sizeof Ethernet::buffer, mymac, 53) (note the 53) because the default is for pin 8 on a UNO. If you use another pin for the CS you will need to manually set pin 53 as an output or SPI doesn’t work.

Similar info here

Good info here as well.
Much info on use of the ENC28J60 can be found in Luca Dentella’s blog

Microphone pre-amp for microcontrollers


This microphone amplifier is based arond the TLC272 double opamp.
The first opamp is  used as an amplifier. The voltage offset on the positive input is set to half Vcc with R2 and R3. The Closedloop gain is set at 100 by R5 and R4. There is an AC coupling/high pass filter to the 2nd opamp by C4 and R6. The second opamp is used as comparator: R7 and R8 determine a level sensitivity of 71 mV (with 5 Volt Vcc).

SPL is the sound pressure level. There is also an audio output for the amplified microphone signal. As the audio signal is DC coupled, the signal will swing around 1/2 Vcc

Microphone pre-amp for Arduino
Note: In the picture you may see a TL072 chip rather than a TS272 (TLC272). That is because I briefly tried that one. The TL072 is a double opamp especially for audio purposes. My results with it however were not so convincing. Best use the TS272 (TLC272)