Ola estou tentando usar o módulo ethernet ENC28J60, para que eu monitore um sensor DHT11, todavia estou tendo muitos problemas e somente 1 código deu certo mas não consegui modifica-lo para mostrar a temperatura do meu sensor. Gostaria de uma dica de como usar melhor este módulo pois to a um bom tempo tentando e não deu certo tive erros no qual pesquisei e vi que poderia ser IDE do arduino incompatível com a biblioteca usada mas não sei se é isso mesmo.

segue o código que deu certo:

#include <EtherCard.h>

#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = {
192,168,0,14 };
// gateway ip address
static byte gwip[] = {
192,168,0,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = {
0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

// char page[] is the HTML page you are uploading ..
const char page[] PROGMEM =
"HTTP/1.0 503 Seriavice Unavailable \r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
"<head><title>"
"2embeddedrobotics "
"</title></head>"
"<body>"
"<h3>Bem Vindo</h3>"
"<p><em>"
"monitoramento<br />"
"</em></p>"
"</body>"
"</html>"
;

void setup(){
Serial.begin(9600);
Serial.println("\n[backSoon]");

if (ether.begin(sizeof Ethernet::buffer, mymac, 8) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif

ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}

void loop(){
// wait for an incoming TCP packet, but ignore its contents
if (ether.packetLoop(ether.packetReceive())) {
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}
}

Exibições: 231

Responder esta

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço