After updating the ethernet library for the ENC28J60 ethernet shield, I wanted a larger project to tackle. I had previously got a simple version of the internet clock working, based on the clock form tuxgraphics.org, described here. I have however updated it to have selectable character sizes using the bignum code described in this arduino forum post.
The main features of v1.0 are:
- Web based configurable network parameters
- Different sized font for clock display
- configuration stored in onboard eeprom
- Can operate in stand alone mode after getting initial time
- Link down indicator
Due to the size of the code this will only run on the Arduino Duemilanove with ATmega328.
Parts used are:
- Arduino Duemilanove with ATmega328
- ENC28J60 based ethernet shield
- protoshield with small breadboard used to wire up LCD display – modified with long pins to prevent conflict with RJ45 socket
- 4×20 LCD display, although I’ve got a 2×20 display, this has not yet been tested
- Updated Ethershield library – available here, however its nto yet been tested with the latest version. Download my original version here Download etherShield.zip
Images:
Full date and time display | Time on 2 lines | Time on 4 lines | Web page | Config page |
The code is available to download from here.
I am having a go at this although I’m pretty much a noob. I just pasted the NTP pde in my Arduino017 sketch editor and hit some snags.
Seems like the etherShield.cpp needs a fix of the EtherShield.h reference to etherShield.h, lowercase-E, but that might be because I am on a linux machine. Same thing for the references in the sketch itself.
I am now stuck at an error : “etherShield does not name a type in function ‘int8_t analyse_get_url(char*)'” and 5 more functions.
Any ideas ?
I am trying to execute the code available in this page and was stuck at an error.
The Error is
etherShield_NTPClock:59: error: ‘etherShield’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘void loop()’:
etherShield_NTPClock:670: error: ‘class EtherShield’ has no member named ‘ES_client_ntp_request’
etherShield_NTPClock:742: error: ‘class EtherShield’ has no member named ‘ES_client_ntp_request’
etherShield_NTPClock:756: error: ‘class EtherShield’ has no member named ‘ES_client_ntp_process_answer’
Could anyone help me.
Hi Andy – many thanks!
I got the NTP clock running but I do not own an LCD display. I just post some changes:
1.) Change
— etherShield_NTPClock-orig.pde 2011-01-01 15:08:32.000000000 +0100
+++ etherShield_NTPClock.pde 2011-01-01 15:09:04.000000000 +0100
@@ -8,7 +8,8 @@
^M
#include “etherShield.h”^M
#include ^M
-#include ^M
+//#include
+#include
#include ^M
#include ^M
^M
@@ -33,13 +34,13 @@
0x54,0x55,0x58,0x10,0x00,0x25};^M
^M
static uint8_t myip[4] = {^M
– 10,0,0,25};^M
+ 192,168,100,99};
^M
// Default gateway. The ip address of your DSL router. It can be set to the same as^M
// websrvip the case where there is no default GW to access the ^M
// web server (=web server is on the same lan as this host) ^M
static uint8_t gwip[4] = {^M
– 10,0,0,1};^M
+ 192,168,100,11};
^M
// change summer/winter time and your timezone here (utc +1 is Germany, France etc… in winter), unit is hours times 10:^M
// UK GMT = 0, BST = +1^M
@@ -54,7 +55,8 @@
#define BUFFER_SIZE 700^M
#define DATE_BUFFER_SIZE 30^M
static char datebuf[DATE_BUFFER_SIZE]=”none”;^M
-static uint8_t buf[BUFFER_SIZE+1];^M
+//static uint8_t buf[BUFFER_SIZE+1];
+uint8_t buf[BUFFER_SIZE+1];
^M
// Setup the EtherShield class^M
EtherShield es=EtherShield();^M
2.) regarding avinash’s comment
Edit file “ip_config.h” and use etherShield-1.2
// an NTP client (ntp clock):
//#undef NTP_client
#define NTP_client
3.) The config page needs to be called twice! (Just reload in browser)
http:///config
Best regards,
Frank
I just posted a patch but it looks like a copy / paste problem. This are the important two changes:
-#include
+#include
-static uint8_t buf[BUFFER_SIZE+1];
+uint8_t buf[BUFFER_SIZE+1];
Sorry – One more copy/paste problem in the last post – change referenced header file
edit the include statement for eeprom.h to lower case
Hi Andy,
I a noob and cannot get a successful compile. I see variants of 4 errors, butI will list them all, in the event they are related or shed light.
I am using arduino-0022 and your etherShield 1.1
etherShield_NTPClock.cpp: In function ‘int8_t analyse_get_url(char*)’:
etherShield_NTPClock:377: error: ‘class EtherShield’ has no member named ‘ES_urldecode’
etherShield_NTPClock:399: error: ‘class EtherShield’ has no member named ‘ES_urldecode’
etherShield_NTPClock:407: error: ‘class EtherShield’ has no member named ‘ES_urldecode’
etherShield_NTPClock:414: error: ‘class EtherShield’ has no member named ‘ES_urldecode’
etherShield_NTPClock.cpp: In function ‘void __vector_17()’:
etherShield_NTPClock:483: error: ‘toggleDots2’ was not declared in this scope
etherShield_NTPClock:486: error: ‘toggleDots4’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘void setDisplayMode(uint8_t)’:
etherShield_NTPClock:542: error: ‘CGRAM_BigFont2’ was not declared in this scope
etherShield_NTPClock:545: error: ‘CGRAM_BigFont4’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘void loop()’:
etherShield_NTPClock:686: error: ‘bigNumTime2’ was not declared in this scope
etherShield_NTPClock:701: error: ‘bigNumTime4’ was not declared in this scope
I added the following to etherShield_NTPClock.cpp:
#define FROMDECODE_websrv_help
#define URLENCODE_websrv_help
#define NTP_client
but no change. Do I need to add your libraries to a list of libraries in the IDE?
Help?
Thanks
OK, half way there. in your ip_config.h
//————- functions in ip_arp_udp_tcp.c ————–
// an NTP client (ntp clock):
//#undef NTP_client
#define NTP_client
and
//
// functions to decode cgi-form data:
//#undef FROMDECODE_websrv_help
#define FROMDECODE_websrv_help
Could someone shed light on the error lines (posted previously) from ‘toggleDots2 on down?
BTW Andy, nice work 🙂
OK, so we have to create a bigtime.h and bigtime.cpp from bigtime.pde…
but how to handle the byte leftAdjust and byte offset
[…] Arduino??????????? – Okiraku Programming Arduino Internet Clock « Andy’s Life Updated Arduino ENC28J60 Ethernet library available « Andy’s Life Arduino playground – […]
Hi,
I’m new to this forum. Does anyone know or have a code on ethernet clock using MAX7221 as LED driver??? I use a ENC28J60 ethernet shield from ITeadStudio. Please help me.
The above code.
hangs SPI
Help get rid of the hang-up
Looks like its had loads of additions not in the original code, so sorry, cant help as I dont have same hardware.
Admin
Hi,
I just open and verify the etherShield_NTPClock code on my Arduino0022 and copy the etherShield 1.1 Library to the libraries folder. But I can’t successfully compile the code because of the ff. errors:
etherShield_NTPClock.cpp:9:25: error: etherShield.h: No such file or directory
etherShield_NTPClock:59: error: ‘EtherShield’ does not name a type
etherShield_NTPClock:108: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:109: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:110: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:111: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:112: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:113: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:116: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:117: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock:129: error: expected initializer before ‘PROGMEM’
etherShield_NTPClock.cpp: In function ‘uint8_t gmtime(uint32_t, char*, char*)’:
etherShield_NTPClock:195: error: ‘day_abbrev’ was not declared in this scope
etherShield_NTPClock:195: error: ‘pgm_read_byte’ was not declared in this scope
etherShield_NTPClock:199: error: ‘PSTR’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘int8_t analyse_get_url(char*)’:
etherShield_NTPClock:386: error: ‘es’ was not declared in this scope
etherShield_NTPClock:410: error: ‘es’ was not declared in this scope
etherShield_NTPClock:418: error: ‘es’ was not declared in this scope
etherShield_NTPClock:425: error: ‘es’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘uint16_t print_webpage(uint8_t*)’:
etherShield_NTPClock:450: error: ‘es’ was not declared in this scope
etherShield_NTPClock:450: error: ‘strHttpHeader’ was not declared in this scope
etherShield_NTPClock:451: error: ‘strPageHeader’ was not declared in this scope
etherShield_NTPClock:452: error: ‘PSTR’ was not declared in this scope
etherShield_NTPClock:482: error: ‘strPageFooter’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘void setup()’:
etherShield_NTPClock:556: error: ‘strTitle1’ was not declared in this scope
etherShield_NTPClock:556: error: ‘strcpy_P’ was not declared in this scope
etherShield_NTPClock:559: error: ‘strTitle2’ was not declared in this scope
etherShield_NTPClock:591: error: ‘es’ was not declared in this scope
etherShield_NTPClock:600: error: ‘strCheckingLink’ was not declared in this scope
etherShield_NTPClock.cpp: In function ‘void loop()’:
etherShield_NTPClock:647: error: ‘es’ was not declared in this scope
etherShield_NTPClock:663: error: ‘strWaitingFor’ was not declared in this scope
etherShield_NTPClock:663: error: ‘strcpy_P’ was not declared in this scope
etherShield_NTPClock:666: error: ‘strNtpAnswer’ was not declared in this scope
etherShield_NTPClock:755: error: ‘IP_PROTO_P’ was not declared in this scope
etherShield_NTPClock:755: error: ‘IP_PROTO_UDP_V’ was not declared in this scope
etherShield_NTPClock:755: error: ‘UDP_SRC_PORT_H_P’ was not declared in this scope
etherShield_NTPClock:755: error: ‘UDP_SRC_PORT_L_P’ was not declared in this scope
etherShield_NTPClock:774: error: ‘strHttpHeader’ was not declared in this scope
etherShield_NTPClock:775: error: ‘strPageHeader’ was not declared in this scope
etherShield_NTPClock:776: error: ‘PSTR’ was not declared in this scope
etherShield_NTPClock:777: error: ‘strPageFooter’ was not declared in this scope
etherShield_NTPClock:781: error: ‘strHttpHeader’ was not declared in this scope
etherShield_NTPClock:782: error: ‘strPageHeader’ was not declared in this scope
etherShield_NTPClock:783: error: ‘PSTR’ was not declared in this scope
etherShield_NTPClock:805: error: ‘strPageFooter’ was not declared in this scope
etherShield_NTPClock:815: error: ‘PSTR’ was not declared in this scope
etherShield_NTPClock:816: error: ‘strPageHeader’ was not declared in this scope
etherShield_NTPClock:818: error: ‘strPageFooter’ was not declared in this scope
etherShield_NTPClock:827: error: ‘strHttpHeader’ was not declared in this scope
etherShield_NTPClock:828: error: ‘strPageHeader’ was not declared in this scope
etherShield_NTPClock:829: error: ‘PSTR’ was not declared in this scope
etherShield_NTPClock:830: error: ‘strPageFooter’ was not declared in this scope
Can anyone shed some light on what is the cause of these errors? Please help!
Thanks a lot.
I’ll find out … It’s time to port the code to EtherCard…
halfdeadjmo13:
look ip_config.h…
Hi,
I’ve imported the updated EtherShield library and I was stuck on these following errors:
_253_etherShield_NTPClock.cpp: In function ‘void loop()’:
_253_etherShield_NTPClock:679: error: ‘class EtherShield’ has no member named ‘ES_client_ntp_request’
_253_etherShield_NTPClock:751: error: ‘class EtherShield’ has no member named ‘ES_client_ntp_request’
_253_etherShield_NTPClock:765: error: ‘class EtherShield’ has no member named ‘ES_client_ntp_process_answer’
I think the library has no member on what the errors indicated. I still wonder how you make the code works… please help me on these.,.
figured out:
// /* Disable NANODE */
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
It remains to deal with a large font, but that is distortion on my VFD….
Foto?
I don’t understand. There’s no NANODE in the code. Which part of the code can this line be found?
// /* Disable NANODE */
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
We can only find this line:
void setup(){
pinMode( LED, OUTPUT );
digitalWrite( LED, LOW );
pinMode( RESET_PIN, INPUT );
digitalWrite( RESET_PIN, HIGH );
I am suspecting that maybe the updated EtherShield.h library is lacking some members. Though in its list of keywords, there’s a ‘ES_client_ntp_request’ and ‘ES_client_ntp_process_answer’, when I verify the code, it always flash an error saying ‘class EtherShield’has no member named ‘ES_client_ntp_request’ and list of errors on my last post.
Please enlighten.
P.S.
Can you give me the EtherShield library you used? Please.
Hi,
Hmm, the first lines of the code are these:
#include “etherShield.h”
#include
#include
#include
#include
The library I’ve imported was Ethershield.h and it will add these lines to the code:
#include
#include
#include
#include
#include
#include
#include
#include
Does it matter that in the code it is indicated #include “etherShield.h” whereas the Library imported was Ethershield.h???
Hi,
Good Day! About the ip_config.h, I read
Andy’s blog about the updated Ethershield
Library. It says there that you need to
modify or define that file whether you
are using webserver client, ntp, etc. I
find that file within the library BUT I
can only open it through Notepad and Oh!,
how can I modify or define that file? And
what function should i need to define to
enable the NTP functions or keywords
since the code rely on NTP time server…
Is the the ip_config.h file be open to
another software not in Notepad??? I
think that is the step I did not execute
before compiling the code… Can Anybody
help me on these? Please….
Hi, again
It works, I just edited the ip_config.h in Notepad. I define the NTPclient, verify the code and it is successfully compiled. Hmmm…,I uploaded the code to my Arduino Duemilanove with Atmega328 and ENC28J60 Ethernet Shield with my own MAC address, IP address, default gateway IP, UTC +8, and I choose the IP address of NASA. My output hardware is different because it uses a MAX7221 LED display driver to drive a 6 digit common-cathode 7-segment LED Display instead of an LCD. So I just want to test the code, I just want to see if I will browse the web with my IP address, I can see the acquisition of time from the NTP server. Unfortunately, my Ethernet Shield doesn’t respond, the LED indicators of the ethernet socket was not turning on or blinking which is a sign that it does not receive/transmit any data. Also, we test the IP addres by pinging and unfortunately it is not active or responding… Hmmm, is it just okay that I upload the program although it’s for LCD display? All i want is just to test my shield and to see if I get the time from the NTP server via web browsing…
[…] Internet Clock, with web interface configuration, and 4 row led display; ntp server used to clock3 […]