ENC28J60 칩을 사용하는 이더넷 모듈입니다.
아두이노와는 SPI를 이용하여 통신합니다.
배선을 해주어야 한다는 단점이 있으나 쉴드에 비해 작은 사이즈를 가지고 있습니다.
관련 자료
https://github.com/jcw/ethercard
http://jeelabs.net/pub/docs/ethercard/
예제
ENC SO -> Arduino pin 12
- ENC ST -> Arduino pin 11
- ENC SCK -> Arduino pin 13
- ENC CS -> Arduino pin 10
- ENC Q3 -> Arduino 3V3 pin
- ENC GND -> Arduino Gnd pin
아두이노 코드
#include
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,203 };
byte Ethernet::buffer[500];
BufferFiller bfill;
void setup () {
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
ether.staticSetup(myip);
}
static word homePage() {
long t = millis() / 1000;
word h = t / 3600;
byte m = (t / 60) % 60;
byte s = t % 60;
bfill = ether.tcpOffset();
bfill.emit_p(PSTR(
"HTTP/1.0 200 OKrn"
"Content-Type: text/htmlrn"
"Pragma: no-cachern"
"rn"
""
""
"
$D$D:$D$D:$D$D
"),
h/10, h%10, m/10, m%10, s/10, s%10);
return bfill.position();
}
void loop () {
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if (pos) // check if valid tcp data is received
ether.httpServerReply(homePage()); // send web page data
}