#1 2016-09-05 14:13:57

Slavko
Учасник
Зареєстрований: 2016-09-05
Повідомлень: 1

Arduino Nano + Ethernet shield ENC28J60 + EtherCard lib

Доброго дня форумчани!

Працюю над проектом регулятора для електричного бойлера.
Хочу щоб час включення та температуру води можна було змінювати через браузер.

Дано:
Arduino Nano
Ethernet shield ENC28J60
EtherCard lib

Для тестування вебсервера використав стандартний приклад з бібліотеки rbbb_server.ino замінивши

if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println(F("Failed to access Ethernet controller"));

на

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

Як видно із скетча, я не використовую Serial Monitor, але скетч виконується тільки коли відкритий Serial Monitor.
Якщо Serial Monitor закритий,  то браузер нічого не показує.

Чи в когось з вас була така проблема? Чи є ідеї як її вирішити?
Підкажіть може я не бачу очевидного рішення.


// This is a demo of the RBBB running as webserver with the Ether Card
// 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// 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 () {
 ether.begin(sizeof Ethernet::buffer, mymac, 10);
  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 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "<meta http-equiv='refresh' content='1'/>"
    "<title>RBBB server</title>" 
    "<h1>$D$D:$D$D:$D$D</h1>"),
      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
}

Неактивний

Швидке повідомлення

Введіть повідомлення і натисніть Надіслати

Підвал форуму