- join a specified wireless network in a user-friendly manner (with only the on-board, existing and minimal, hardware resources);
- synchronize the time from a specified NTP server (e.g. pool.ntp.org);
- read and display RSS feed from a specified server (e.g. http://w1.weather.gov/xml/current_obs/KRDU.rss);
Before getting excited and jumping to compile and upload the new sketch, there are a few steps to be done on the ESP8266 module:
1. pull the CHPD pin high with a 10k resistor to Vcc;
2. make sure you can communicate with the module using a serial port; this could also include checking the version of the installed firmware (AT+GMR);
3. upgrade the firmware on ESP8266 to version 0.9.6.
After you download the bin files, the next step is to find a tool that would upload those bin files onto the chip. There are many tutorials on how to do this, some sketchy and ambiguous, some detailed and very helpful. In my search, I found references to a few different tools: XTCOM (old MFC Windows app), "NODEMCU Firmware Programmer", ESP flash downloader, ESPtool (python).
The easiest one to use for me seemed XTCOM, with my only complaint being that COM port selection was limited to COM1-6. Luckily, on Windows XP I am using, I was able to change the serial port from the default (assigned by the OS) COM9 to COM2 (the only one available in the range COM1 - COM6). I used this tutorial to load this firmware.
4. Change the baud rate from the default (after firmware upgrade) 115200 to 38400, for the following reason: according to the datasheet (table 20-6, page 189), ATmega328 running at 8MHz has an error rate of approx. 8% communicating on serial port at 115200.
Now, with the ESP8266 module prepared and plugged in, to connect to your wireless network, you will need to configure the module by providing the SSID and the password. To start this process, select "Init" for the "Wifi" menu item. There is an additional "init y/n" option to confirm the init. Once in "init" mode, the ESP8266 module starts acting as access point (another wireless network), using the SSID "WiFiChron". Connect to it using the key "WiFiChron" (*).
The clock will display (scrolling) an IP address, something like "192.168.4.1". Connect to the WiFiChron's access point with your computer/laptop/tablet/phone and web-browse to that IP address, as shown in the screenshot below.
Use that page to configure your local access-point SSID and key. You can also configure an optional SNTP host for synchronizing time and an optional RSS URL. Fill in something like pool.ntp.org for the SNTP host or http://w1.weather.gov/xml/current_obs/KNYC.rss for the RSS URL.
Clicking on the "Submit" button will send the configuration to the WiFiChron system, which will write it into its eeprom. If you check "Activate" before submitting, the WiFiChron will immediately switch out of access-point mode and attempt to connect to the SSID/key that you've entered. If you have problems, you can power-cycle the WiFiChron. It will use whatever settings it has stored in eeprom.
(*) Although the "WiFiChron" network was detected, I could not connect to it from my Windows XP machine (acquiring network address takes forever and eventually fails). It worked much better with my Android tablet. This is the reason why the first screenshot above is from my XP machine and the second is from my tablet.
Now, with the ESP8266 module prepared and plugged in, to connect to your wireless network, you will need to configure the module by providing the SSID and the password. To start this process, select "Init" for the "Wifi" menu item. There is an additional "init y/n" option to confirm the init. Once in "init" mode, the ESP8266 module starts acting as access point (another wireless network), using the SSID "WiFiChron". Connect to it using the key "WiFiChron" (*).
The clock will display (scrolling) an IP address, something like "192.168.4.1". Connect to the WiFiChron's access point with your computer/laptop/tablet/phone and web-browse to that IP address, as shown in the screenshot below.
Use that page to configure your local access-point SSID and key. You can also configure an optional SNTP host for synchronizing time and an optional RSS URL. Fill in something like pool.ntp.org for the SNTP host or http://w1.weather.gov/xml/current_obs/KNYC.rss for the RSS URL.
Clicking on the "Submit" button will send the configuration to the WiFiChron system, which will write it into its eeprom. If you check "Activate" before submitting, the WiFiChron will immediately switch out of access-point mode and attempt to connect to the SSID/key that you've entered. If you have problems, you can power-cycle the WiFiChron. It will use whatever settings it has stored in eeprom.
Update Jan 21, 2020: In Windows 10, connecting to WiFiChron setup page and submitting the parameters works just fine.
NOTE: The ESP8266 module must be taken out of the socket while uploading the sketch (since it's connected to Rx/Tx as well).
how often does the wifichron query the time etc ?
ReplyDeletehow many times a day?
also is it supposed to update immediately once you click the activate / submit button ?
The current code queries the SNTP server every 12 hours (line 320 of esp8266.cpp).
DeleteThe time from RTC is queried many times every second (in the main loop()).
As for the WiFi setup, here is s tidbit from the comments of the beginning of the wifichron.ino:
Clicking on the "Submit" button will send the configuration to the WiFiChron
system, which will write it into its flash. If you check "Activate" before
submitting, the WiFiChron will immediately switch out of access-point mode and attempt to connect to the SSID/key that you've entered.
How far did you get with the wifi setup?
Deletei did all that the page shows here, but it does not update.
ReplyDeleteeverything is filled in correctly as your screen shot shows in the wifi set up.
i know you said that filling in the SNTP and the RSS url were optional.
( "You can also configure an optional SNTP host for synchronizing time and an optional RSS URL.) so does leaving this blank have any effect on time setting? or does it have to be filled in to get time? ( mine is filled in )
as for the RSS feed,, what is this supposed to show on the clock ? temp? or more ?
thanks,
i look forward to talking to you soon.
Hi Ray,
DeleteThe "RSS feed" is an XML page received when you access an URL. For example, try this (default) RSS in the browser to see the XML:
http://w1.weather.gov/xml/current_obs/KRDU.rss
Once received, the XML is parsed (as string) to find the temperature.
All I know is by looking at the code, which is not written by me. The commands for the WiFi module are all found in the file ESP8266.cpp.
The commands are sent in state-machine sequence. Once a command is sent, the machine state is changed to the next one.
Take for example the commands for the SNTP server lines 871-907):
case ESP8266_CIPSTART_SNTP:
Serial.print(F("AT+CIPSTART=4,\"UDP\",\""));
cp = (uint8_t *)EEPROM_SNTP;
while((cp < (uint8_t *)EEPROM_RSS)
&& ((c = eeprom_read_byte(cp++)) != 0)
&& (c < 127)) {
Serial.write(c);
}
Serial.print(F("\",123\r\n"));
sntpStat = 1;
timeNextSntp = ms + (random(1024, 2048) * 2048); // 35 - 69 minutes later
timeCloseSntp = ms + 5000; // close this connection in 5 seconds
nextState = ESP8266_CIPSEND_SNTP;
timer = ms + 500;
timerActive = true;
break;
case ESP8266_CIPSEND_SNTP:
memset(msgBuf, 0, 48);
mPos = 0;
msgBuf[0] = 0x1b;
Serial.print(F("AT+CIPSEND=4,48\r\n"));
delay(5);
Serial.write(msgBuf, 48);
sntpStat = 2;
nextState = ESP8266_NOOP;
timer = ms + 500;
timerActive = true;
break;
case ESP8266_CIPCLOSE_SNTP:
Serial.print(F("AT+CIPCLOSE=4\r\n"));
sntpStat = 0;
nextState = ESP8266_NOOP;
timer = ms + 500;
timerActive = true;
break;
The first state is "ESP8266_CIPSTART_SNTP". To start the SNTP comm, send command
AT+CIPSTART=4,"UDP","pool.ntp.org",123
Next command (in state "ESP8266_CIPSEND_SNTP") is:
AT+CIPSEND=4,48
Then (state "ESP8266_CIPCLOSE_SNTP"):
AT+CIPCLOSE=4
I'm not very familiar with the AT coomands for ESP8266, but, if you send these commands you should get a string back from the NTP server. That string is then decoded and the time is extracted from it.
Florian.. i tried something new today.
ReplyDeletei brought the clock to work and tried to connect to the wifi here.. it seems to have finally connected.
so i know now that the wifichron does not like SSID's with spaces in the name, i think there needs to be a update or something, so that it does not fill in spaces with +'s
right now my clock is showing me with a connected IP of 192.168.1.112
and after it shows the date there is a "up arrow" i do not know what it means but i assume it means i am connected to the router now ?
the clock has not updated yet, but i'll let it go over night and see what it does the next day.. hopefully i see the correct time and date.. BTW the router shows the IP i mentioned, so that is a plus..
please advise what can be done about the +'s in the SSID resolve is.. and what is the meaning of the "up arrow" after the date.. thanks..
Hi Ray,
DeleteI was going to suggest you do that (trying to connect to another WiFi).
The up arrow means connected and, supposedly, synchronized. I have to look at the code to see how time is synchronized (it may be only the minutes and the seconds).
As for the +, I think the only option at this point is just modifying/fixing the code and upload to the processor.
yes i think your right, it only syncs the minutes and seconds. it will not set the clock automatically.
ReplyDeletei fixed my connection issue by changing my router name.
how does the RSS URL work ? i used the weather link you posted, all i changed was my location (KFAY) i see you had KRDU which is very near me.
are you in NC ?
anyway..what all should the weather link show ?
or is that not in the code yet ?
i have dreams to use a bunch of green alphanumeric leds i have here. for another clock.
how or what has to be done to connect a GPS to the wifichron? i have a Neo-6 on another clock i have - it is 10" digits x6 and gets its time from GPS.
The KRDU location is MikeM's, the author of the software. I am in Toronto, Canada.
DeleteI will have to look at the code to see how the weather info is processed.
Talking about the multiple displays, I managed to have 2 (of the parallel kind) connected to WiFiChron and displaying individual things. I have still to integrate the feature in software. I plan to write a post on it.
For the GPS, check out this post:
http://timewitharduino.blogspot.ca/2015/03/modding-wifichron-with-gps-or-bluetooth.html
or you can connect even one of the cheaper ($10 or so) GPS boards available on ebay. You will need to leave out the 2mm XBee headers if you want that GPS to fit in the box.
I have the code developed for the GPS.
thanks for all your help..i have learned a lot in the past 2 weeks.
ReplyDeletei am always fascinated of unique clocks.
if i had a way to send you pictures, i want to show you a dumb clock i built. looks awsome, but it's time is dependent on the 60Hz AC. and it runs only on 4017 IC's
Great job Ray!
DeleteYou can send me photos at the email address you find in the right column at the top of the page (starts with someone).
thanks...
ReplyDeletei sent the fotos of the 4017 clock,, hope you get them.
i'd like to try to make contact with "Mike M" also since he is only an hr away from me,, would be cool to meet someone new.
Hi Florian, Mike has worked out all the bugs in the "WiFiChron" there are no more over lapping issues in the weather report, there was a issue with the IP address not showing up completely also, that too is fixed, the clock is totally bug free now..
ReplyDeletei like how it operates now, great clock.
do you know of any other weather addresses that will work besides the weather.gov site ?
the weather.gov displays a bit too much useless info and i'd like to try some other sites, but i am not having much luck..
BTW. for those of you using the weather.gov site, if you do not know how to get the correct weather for your area. you can find the local identifier for your local airport, and use this 4 letter character to use Ex. KFAY , KRDU, KLAX
( http://w1.weather.gov/xml/current_obs/KFAY.rss )
change the 4 letters just before the .rss to your local airport. then copy the address to your RSS URL window. hope this helps..
That sounds great! I appreciate Mike's and your effort.
Deleteyahoo used to have a weather RSS/API (http://weather.yahooapis.com/forecastrss?w=24153215&u=c). It still looks active, but it seems it requires some sort of registration key.
See this older post of mine:
http://timewitharduino.blogspot.ca/2012/01/adventures-in-wifly-land-part-1.html
I have redesigned the WiFiChron to use ATmega1284 and I am testing it right now.
First thing I noticed is that the INPUT_PULLUP is not implemented correctly in the sanguino library. Plus others.
I will soon post my findings.
can you make change, it can syncronized with pc time, no internet connected
ReplyDeleteHi Jamal,
DeletePC time is synchronized through the network/internet.
To sync with the PC, the clock must be either connected to the PC (USB cable) or to the internet.
If you don't want internet connection/wifi, you can resort to GPS.
I hope this helps.
FlorinC
Hi, Florin.
ReplyDeleteI can no longer receive the weather reports via RSS. Can you please update the WifiChron software with the RSS changes from the new Wise Clock software? Thanks!
I honestly thought I did post the latest release of the WiFiChron software. MikeM made a few adjustments and sent me in Jan 2019 a few files that he changed. I will make sure to post them.
DeleteAny smart Arduino programmer know if Nextbus queries could be added to WifiChron? Here's a standalone Nextbus clock:
ReplyDeletehttps://learn.adafruit.com/personalized-esp8266-transit-clock/software