Sou novo nesse assunto e gostaria de saber se alguem saberia me dizer se o Ethernet shield ENC28j60 tem as mesmas funções que o Ethernet shield w5100 ?? Pois estou tentando rodar o mesmo programa que roda em um (Ethernet shield ENC28j60)  e no outro (Ethernet shield w5100) nao. Eu sei que a biblioteca do Ethernet shield ENC28j60 e diferente do Ethernet shield W5100, estou usando a UIPEthernet.h, mas mesmo assim nao funciona. 

O programa que estou tentando rodar no Ethernet shield ENC28j60:

#include <UIPEthernet.h> //Para o Ethernet shield w5100 basta substituir essa biblioteca pelas SPI.h e Ethernet.h.

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 0, 100);
EthernetServer server(80);
String readString;
byte i;
byte ports = 8;
byte Pin[] = {2, 3, 4, 5, 6, 7, 8, 9};
bool PS[] = {0, 0, 0, 0, 0, 0, 0, 0};

void setup() {

Ethernet.begin(mac, ip);

for (i = 0; i < ports; i++)
{
pinMode(Pin[i], OUTPUT);
digitalWrite(Pin[i], LOW);
}
}

void loop() {
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100) {
readString += c;
}
if (c == '\n')
{
if (readString.indexOf("on=1") > 0)
{
PS[0] = 1;
}
if (readString.indexOf("on=2") > 0)
{
PS[1] = 1;
}
if (readString.indexOf("on=3") > 0)
{
PS[2] = 1;
}
if (readString.indexOf("on=4") > 0)
{
PS[3] = 1;
}
if (readString.indexOf("on=5") > 0)
{
PS[4] = 1;
}
if (readString.indexOf("on=6") > 0)
{
PS[5] = 1;
}
if (readString.indexOf("on=7") > 0)
{
PS[6] = 1;
}
if (readString.indexOf("on=8") > 0)
{
PS[7] = 1;
}
if (readString.indexOf("off=1") > 0)
{
PS[0] = 0;
}
if (readString.indexOf("off=2") > 0)
{
PS[1] = 0;
}
if (readString.indexOf("off=3") > 0)
{
PS[2] = 0;
}
if (readString.indexOf("off=4") > 0)
{
PS[3] = 0;
}
if (readString.indexOf("off=5") > 0)
{
PS[4] = 0;
}
if (readString.indexOf("off=6") > 0)
{
PS[5] = 0;
}
if (readString.indexOf("off=7") > 0)
{
PS[6] = 0;
}
if (readString.indexOf("off=8") > 0)
{
PS[7] = 0;
}
for (i = 0; i < ports; i++)
{
digitalWrite(Pin[i], PS[i]);
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

client.print("[");

for (i = 0; i < ports; i++)
{
client.print("{");
client.print("\"port\":\"");
client.print(PS[i]);
client.print("\"");
client.print("}");
if (i < ports - 1)
{
client.print(",");
}
}
client.print("]");

delay(1);
client.stop();
readString = "";
}
}
}
}
}

Deixei anexado o Ethernet shield ENC28j60 que estou usando que e para arduino nano.

Muito Obrigado pela atenção!!

Exibições: 431

Anexos

Responder esta

Respostas a este tópico

Samuel,

Aqui tem um exemplo usando a biblioteca ethercard com enc28j60.
https://forum.arduino.cc/index.php?topic=116117.0
Me parece uma biblioteca melhor.

Outra sugestão seria passar seu projeto para o ESP8266 ou ESP32.

Abs

tentei trocar a biblioteca e nao funcionou

Aparece algum erro? Não funcionou como? 
Tente rodar algum exemplo da própria biblioteca.

consegui!!! deppois de muita pesquisa, achei essa biblioteca BlynkSimpleUIPEthernet.h e funcionou.

Obrigado pela ajuda!!!

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço