Gracias, funciona muy bien. Uso PlatformIO y tuve que hacer dos ligeras modificaciones que son: - linea: for ( int i = 0 ; i < (int) (width * message.length() + matrix.width() - spacer); i++ ) { - línea: if ( letter < (int) message.length() ) { Como ves solo (int) porque es mas estricto el compilador. Desde hoy seguiré tus proyectos... Thanks, it works great. I use PlatformIO and I had to do two slight modifications which are: - line: for ( int i = 0 ; i < (int) (width * message.length() + matrix.width() - spacer); i++ ) { - line: if ( letter < (int) message.length() ) { As you can see, only (int) because the compiler is more strict. From today I will follow your projects...
Thanks for the quick response. I added the lines, but I keep getting an error from this line time = time.substring(0,11) + str_hours+ time.substring(13, 24); the error is stray '\357' in program. Can you help with this?
Well it worked, thanks. I have to wait until 10pm to see if the format stills works. I have it so it displays the time in 12hr format with the AM/PM after the time. here are the changes I made that you suggested. Again Thanks. String time = String(ctime(&now)); int hours = time.substring(11,13).toInt(); Serial.println(time); Serial.println (hours); String str_hours = "PM"; if (hours%24 < 12) str_hours = "AM"; // Now needs to be added in to time string if (hours%12==0) str_hours = str_hours + "12"; else if (hours%12 < 10) str_hours = str_hours + " " + String(hours%12); else str_hours = str_hours + String(hours%12); time = time.substring(0,11) + str_hours + time.substring(13, 24); time.trim(); //removes white space time.substring(11, 18).toCharArray(time_value, 10); Serial.println (time_value); // starts at charactor 11 of string time and stops // at charactor 19 then assigns that string to time_value the 10 is the buffer size Serial.println (time_value[0]); matrix.drawChar(48, 0, time_value[0], HIGH, LOW, 1); matrix.drawChar(56, 0, time_value[1], HIGH, LOW, 1); matrix.drawChar(12, 0, time_value[2], HIGH, LOW, 1); matrix.drawChar(18, 0, time_value[3], HIGH, LOW, 1); matrix.drawChar(24, 0, time_value[4], HIGH, LOW, 1); matrix.drawChar(30, 0, time_value[5], HIGH, LOW, 1); matrix.drawChar(36, 0, time_value[6], HIGH, LOW, 1); matrix.write(); // Send bitmap to display delay(2000);
Usually this is the power bank that is turning off due to insufficient load. Try using using a phone charger and see if the same thing happens. Phone chargers are usb 5v supplies.
hi david. I want to change weekday and month name in "ESP_MAX7219_Specific_Format_Time" programe. How can I do that? Could you help me for this, please?
See the lines: // See www.cplusplus.com/reference/ctime/strftime/ for strftime functions // Desired format: ( Sun ,Jul 21 2019 ) ( AM 10:03:20 ) strftime(time_output, buffer_size, "( %a %d-%m-%y ) ( %p %T )", localtime(&now)); Check the link to cplusplus that I provided change d m y to what ever format you need.
The ESP32 compiler does not support setlocales so you have to do it manually, get the month and replace with your own language. Same with the day. You can get month number say 6 and then do a simple if (month == 6) month_text = “June” or your language.
struct tm timeinfo; char time_output[30], day_output[30], update_time[30]; while (!getLocalTime(&timeinfo, 10000)) { // Wait for 10-sec for time to synchronise Serial.println("Failed to obtain time"); return false; } strftime(day_output, sizeof(day_output), "%a %b-%d-%Y", &timeinfo); // Creates 'Sat May-31-2019' Date_str = day_output; Now adjust a b d Y to your requirement just m maybe
Compiled OK. Show correct time and date on serial monitor. Follow the diagram for connections. Max 7219 panel does not scroll anything. It is lit up entirely. How can I solve that?
@@G6EJD Manage to make it work. I had to change the board to LOLIN D1 R2 and rotate the displays ('option 3'). One question. Can I extend this to 2 (8 modules)? I tried, but the clock (numbers stay central to first module), but the text scroll to both modules (change the number display to 8 and add 4 lines for the new added displays) Thank you for taking time to answer Gabi
Unfortunately (unlike the ESP32) the ESP8266 cannot give you a 12-hour clock format, so after this line: String time = String(ctime(&now)); //You now have a time string of format "Thu Jan 01 00:00:00 1970" So how to get to add AM/PM indicator? First extract hours: int hours = time.substring(11,12).toInt(); String str_hours = "PM"; // Now add AM/PM prefix if (hours%24 < 12) str_hours = "AM"; // Now needs to be added in to time string if (hours%12==0) str_hours = str_hours + "12"; else if (hours%12 < 10) str_hours = str_hours + " " + String(hours%12)); else str_hours = str_hours + String(hours%12); then finally : //"Thu Jan 01 00:00:00 1970" time = time.substring(0,11) + str_hours+ time.substring(13, 24);
Thank you for a nice video. However I have problem compiling the code. I keep having this error: 'configTime' was not declared in this scope. Could you please help with this problem?
This is because you have not selected the Wemos D1 Mini or other ESP8266 board. In the IDE menu select Tools, then Board, then scroll down and select the correct board.
G6EJD Thank you so much. I selected the right board for the esp8266 as you advised and the code has compiled. However the time is 1 hour ahead of the current time. I live in the UK. It will be correct from 25 March when the time will be adjusted by +1 for DST. Is there any way around this current time displayed? Thank you so much.
I'ev uploaded to Github a second version that has corrected the Timezone problem that existed in the core 2.30 build of the Ardunio IDE, if you have updated your IDE to 2.4 it will now function and change time correctly when BST begins and ends. Code: github.com/G6EJD/ESP8266-simple-timezone-example
G6EJD Thank you so much. I used the updated code and it worked! The current UK time was displayed correctly. However, I have this question: Is this code region-specific? I am on holiday in the US and the clock will not work correctly. It's displaying incorrect time and Thu Jan 1 1970 date. I tried re-uploading the code and it still displays the wrong time and date. I visited the link 'github.com/nayarsystems/posix_tz_db' you commented on the line: setenv ("TZ ","GMT0BST,M3.5.0/2 ,M10.5.0/2", 0); I tried replacing the argument in parenthesis with "CST6CDT,M3.2.0,M11.1.0", 0 which I think is for America according to nayarsystems, the output is still the same. Have you any idea how to adjust this?
If the time is zero which it is then there is no connection to the time servers. This could be the network you use does not allow connections to those servers or ports or try changing the server address for a US based NTP server. The code for time zone looks good. Try adding some serial port diagnostic prints around the time setting to see what’s happening. Also try adding some delays delay(500) just before setting the time services with config and then one after as maybe the servers are slow.
Hi, super video well done, i´m completely new to this, what am i not doing right, i get this when i try to compile from Arduino IDE to esp8266. "D4 was not declared in this scope", i have CS connected to D4?
OK, that's the problem then. It needs to be the Wemos D1 Mini board where the D4 etc pins are defined. Choose the D1 Mini board type and it will compile OK.
Once Again, an awesome Video, I have been wanting to try these displays for a while, It works great, But of course I have One Question,... How do I change the time -5 Hours (Since I am eastern Time in the US... always have trouble figuring that out... Once again You make great Projects... keep them coming !
Thanks, time on the ESP8266 does not work fully, but you can change your time at this line: configTime(0 * 3600, 0, "pool.ntp.org", "time.nist.gov"); The 3600 refers to one hour (60x60secs) so to move time back -5 hours change it to configTime(5 * 3600, 0, "pool.ntp.org", "time.nist.gov"); The ,0, element is the DST offset but does not work, e.g. add 1-hr to EST would be configTime(5* 3600, 3600, "pool.ntp.org", "time.nist.gov");
Thanks , However changing the line to : configTime( 5* 3600, 0, "pool.ntp.org", "time.nist.gov"); Actually moved the time forward an additional 5 hours, I thought I would be clever and move it 19 hours forward, but that put me into tomorrow, been looking up how to subtract 5 but no luck so far.....
@@G6EJD Connection I did as per your suggestion in the video. Uploaded the same code. Display problem. I am using www.amazon.in/gp/product/B073DCYNVC/ref=ppx_yo_dt_b_asin_title_o00_s01?ie=UTF8&psc=1 display
Praveen GS you need to check your using the correct pins on the ESP and that the cables are connected correctly there are no code issues just hardware connection errors
thanks for these realy helpful tutorial. You are my hero. I try your sketch but unfortunately I don't get any actual time/date. Time is allways 00:00 and date 01.01.1970. The reason should be that I have no access to pool.ntp.org. Further on I don't see any settings for WLAN. I'll try to fix these but unfortunately I am a real noob for these topics. Again thanks for the video. Hope we get much more of these from you. kind reguards Uwe
It is most likely your Router or Service Provider is not allowing access to the Time Servers, does your PC get its time from a server? IF so use that address in the source code. You can use two a primary and secondary.
I have tried to add your code to my MQTT stuff. In these coding I use login for my local wlan including internet access. And now I get time and date. Unfortunately time is one hour before German time. But I try my best to fix these.
After the line : String time = String(ctime(&now)); time = time.substring(start,finish); Change start to be the beginning of time and finish the end of time, eg Mon 28 Jun 16:24 2017 would be 11,16
@@wl11lm, You didn't say which board/processor your using but they code body is the same, what I've suggested is to leave the time string as is and take a substring of it that has just the time, it is just as efficient. Just modify the line after it as I suggested.
hello David ,nice project,i also wanna one clock for my radio shack,untill i waiting wemos board from ebay i try compile sketch Time.ino and Specific format time.ino but arduino ide tells me: D:\Program Files\arduino-1.8.5\libraries\Adafruit_GFX\Adafruit_GFX.cpp:1509:6: warning: unused parameter 'i' [-Wunused-parameter] void Adafruit_GFX::invertDisplay(boolean i) { maybe you know ,what s the problem ? thanks in advance,73 de 9a3xz Mikele
Hi Mikele, it’s possible your Adafruit GFX library needs updating, if you go to Libraries, Manage and then top-left select ‘updateable’ that will check for you. 73 Dave de G6EJD
Please check the library ‘include ’ is present as the error is occurring in the GFX library called by the Max72xx library. Also make sure you select the 8266 board type e.g. 8266 D1 Mini
@@G6EJD i put another max72xx library but nothing ,in my boards list David is Lolin Wemos D1mini Lite ,Lolin Wemos D1 mini Pro ,Lolin Wemos D1 R2 mini...
Checking that you have installed the ESP extensions for the Arduino IDE and you can select a generic ESP8266 board for testing, Adafruit have a good tutorial for installing the ESP extension.
Gracias, funciona muy bien.
Uso PlatformIO y tuve que hacer dos ligeras modificaciones que son:
- linea: for ( int i = 0 ; i < (int) (width * message.length() + matrix.width() - spacer); i++ ) {
- línea: if ( letter < (int) message.length() ) {
Como ves solo (int) porque es mas estricto el compilador.
Desde hoy seguiré tus proyectos...
Thanks, it works great.
I use PlatformIO and I had to do two slight modifications which are:
- line: for ( int i = 0 ; i < (int) (width * message.length() + matrix.width() - spacer); i++ ) {
- line: if ( letter < (int) message.length() ) {
As you can see, only (int) because the compiler is more strict.
From today I will follow your projects...
Yes I can see the need for int casting if there is ambiguity, thanks for letting me know.
Thanks for the quick response. I added the lines, but I keep getting an error from this line
time = time.substring(0,11) + str_hours+ time.substring(13, 24); the error is stray '\357' in program. Can you help with this?
Well done, just what I needed, is there a way to combine this with your scrolling message, so I can have time and a message. Thx.
Yes, check out my Github for other variants, or just add your message to the time string
Well it worked, thanks. I have to wait until 10pm to see if the format stills works. I have it so it displays the time in 12hr format with the AM/PM after the time. here are the changes I made that you suggested. Again Thanks.
String time = String(ctime(&now));
int hours = time.substring(11,13).toInt();
Serial.println(time);
Serial.println (hours);
String str_hours = "PM";
if (hours%24 < 12) str_hours = "AM"; // Now needs to be added in to time string
if (hours%12==0) str_hours = str_hours + "12";
else
if (hours%12 < 10) str_hours = str_hours + " " + String(hours%12);
else
str_hours = str_hours + String(hours%12);
time = time.substring(0,11) + str_hours + time.substring(13, 24);
time.trim(); //removes white space
time.substring(11, 18).toCharArray(time_value, 10);
Serial.println (time_value);
// starts at charactor 11 of string time and stops
// at charactor 19 then assigns that string to time_value the 10 is the buffer size
Serial.println (time_value[0]);
matrix.drawChar(48, 0, time_value[0], HIGH, LOW, 1);
matrix.drawChar(56, 0, time_value[1], HIGH, LOW, 1);
matrix.drawChar(12, 0, time_value[2], HIGH, LOW, 1);
matrix.drawChar(18, 0, time_value[3], HIGH, LOW, 1);
matrix.drawChar(24, 0, time_value[4], HIGH, LOW, 1);
matrix.drawChar(30, 0, time_value[5], HIGH, LOW, 1);
matrix.drawChar(36, 0, time_value[6], HIGH, LOW, 1);
matrix.write(); // Send bitmap to display
delay(2000);
amzing video gotr it to work but how can i flip the display ??
Flip vertically?
Project work if I connect nodemcu in USB port of my pc.
If I connect it in a USB port of a powerbank or in a usb powersupply display turn off, why?
Usually this is the power bank that is turning off due to insufficient load. Try using using a phone charger and see if the same thing happens. Phone chargers are usb 5v supplies.
hi david. I want to change weekday and month name in "ESP_MAX7219_Specific_Format_Time" programe. How can I do that? Could you help me for this, please?
What format do you need to get?
See the lines:
// See www.cplusplus.com/reference/ctime/strftime/ for strftime functions
// Desired format: ( Sun ,Jul 21 2019 ) ( AM 10:03:20 )
strftime(time_output, buffer_size, "( %a %d-%m-%y ) ( %p %T )", localtime(&now));
Check the link to cplusplus that I provided change d m y to what ever format you need.
@@G6EJD Yes I saw this link but I want to change language of time line as "Pzt ,Haz 08 2020" . how can I edit language options?
The ESP32 compiler does not support setlocales so you have to do it manually, get the month and replace with your own language. Same with the day. You can get month number say 6 and then do a simple if (month == 6) month_text = “June” or your language.
struct tm timeinfo;
char time_output[30], day_output[30], update_time[30];
while (!getLocalTime(&timeinfo, 10000)) { // Wait for 10-sec for time to synchronise
Serial.println("Failed to obtain time");
return false;
}
strftime(day_output, sizeof(day_output), "%a %b-%d-%Y", &timeinfo); // Creates 'Sat May-31-2019'
Date_str = day_output;
Now adjust a b d Y to your requirement just m maybe
Compiled OK. Show correct time and date on serial monitor. Follow the diagram for connections. Max 7219 panel does not scroll anything. It is lit up entirely. How can I solve that?
Gabi Balsanu, have you checked the wiring DuPont cable connections can be unreliable, make sure the pins defined are those connected to the display.
@@G6EJD Manage to make it work. I had to change the board to LOLIN D1 R2 and rotate the displays ('option 3'). One question. Can I extend this to 2 (8 modules)? I tried, but the clock (numbers stay central to first module), but the text scroll to both modules (change the number display to 8 and add 4 lines for the new added displays)
Thank you for taking time to answer
Gabi
Gabi Balsanu, you need to change the screen address of the time to match the wider screen
Thanks for a great project. I followed your video and made one, it works great, but how can I change it from 24hr to 12hr?
Unfortunately (unlike the ESP32) the ESP8266 cannot give you a 12-hour clock format, so after this line:
String time = String(ctime(&now));
//You now have a time string of format "Thu Jan 01 00:00:00 1970"
So how to get to add AM/PM indicator?
First extract hours:
int hours = time.substring(11,12).toInt();
String str_hours = "PM";
// Now add AM/PM prefix
if (hours%24 < 12) str_hours = "AM"; // Now needs to be added in to time string
if (hours%12==0) str_hours = str_hours + "12"; else
if (hours%12 < 10) str_hours = str_hours + " " + String(hours%12)); else str_hours = str_hours + String(hours%12);
then finally :
//"Thu Jan 01 00:00:00 1970"
time = time.substring(0,11) + str_hours+ time.substring(13, 24);
When the time has been reformed to 12hr, it may be useful to serial.println(time) to make sure all those substring number positions are correct.
ESP 01 can be use for this project , and if yes please update me pin connection
Yes, you can google esp01 for a pin out diagram and use GPIO-0 for data and GPIO-2 for clock
DIN-GPIO02/CS-GPIO-01/CLK-GPIO-00 its right
Nalin Chaminda Manchanayke you may have to permanently CS the display as there are insufficient IO pins on the ESP 01
@@G6EJD thank u
Thank you for a nice video. However I have problem compiling the code. I keep having this error:
'configTime' was not declared in this scope.
Could you please help with this problem?
This is because you have not selected the Wemos D1 Mini or other ESP8266 board. In the IDE menu select Tools, then Board, then scroll down and select the correct board.
G6EJD Thank you so much. I selected the right board for the esp8266 as you advised and the code has compiled.
However the time is 1 hour ahead of the current time. I live in the UK. It will be correct from 25 March when the time will be adjusted by +1 for DST. Is there any way around this current time displayed?
Thank you so much.
I'ev uploaded to Github a second version that has corrected the Timezone problem that existed in the core 2.30 build of the Ardunio IDE, if you have updated your IDE to 2.4 it will now function and change time correctly when BST begins and ends. Code: github.com/G6EJD/ESP8266-simple-timezone-example
G6EJD Thank you so much. I used the updated code and it worked! The current UK time was displayed correctly.
However, I have this question: Is this code region-specific?
I am on holiday in the US and the clock will not work correctly. It's displaying incorrect time and Thu Jan 1 1970 date. I tried re-uploading the code and it still displays the wrong time and date.
I visited the link 'github.com/nayarsystems/posix_tz_db' you commented on the line:
setenv ("TZ ","GMT0BST,M3.5.0/2
,M10.5.0/2", 0);
I tried replacing the argument in parenthesis with "CST6CDT,M3.2.0,M11.1.0", 0 which I think is for America according to nayarsystems, the output is still the same.
Have you any idea how to adjust this?
If the time is zero which it is then there is no connection to the time servers. This could be the network you use does not allow connections to those servers or ports or try changing the server address for a US based NTP server. The code for time zone looks good. Try adding some serial port diagnostic prints around the time setting to see what’s happening. Also try adding some delays delay(500) just before setting the time services with config and then one after as maybe the servers are slow.
there is a way to edit the time between scroll texts?
Only in the source code at the end of the loop() section, add a delay say delay(30000); for 30-secs
Everything working fine I cant get Dubai time please help to get correct
EET-4EEST,M3.5.5/0,M10.5.5/0
@@G6EJD Done thanks
Hi, super video well done, i´m completely new to this, what am i not doing right, i get this when i try to compile from Arduino IDE to esp8266. "D4 was not declared in this scope", i have CS connected to D4?
Most likely you have not selected the correct board type, I assume your using a Wemos D1 Mini, if so select that board type.
i am using the "Generic ESP8266 Module" board setting for the connected
ESP8266 -F
OK, that's the problem then. It needs to be the Wemos D1 Mini board where the D4 etc pins are defined. Choose the D1 Mini board type and it will compile OK.
Hi, if i understand right, i cannot use my ESP8266-F, i Need to aquire a Wemos D1 Mini board, is this correct?
No need for a Wemos D1 Mini, just set the pins as required. e.g
#define DIN 14
#define CS 13
#define CLK 12
I think I figured it out,. It finally compiled. I will let you know what happens after I upload it.
Once Again, an awesome Video, I have been wanting to try these displays for a while, It works great, But of course I have One Question,... How do I change the time -5 Hours (Since I am eastern Time in the US... always have trouble figuring that out... Once again You make great Projects... keep them coming !
Thanks, time on the ESP8266 does not work fully, but you can change your time at this line:
configTime(0 * 3600, 0, "pool.ntp.org", "time.nist.gov");
The 3600 refers to one hour (60x60secs) so to move time back -5 hours change it to configTime(5 * 3600, 0, "pool.ntp.org", "time.nist.gov");
The ,0, element is the DST offset but does not work, e.g. add 1-hr to EST would be configTime(5* 3600, 3600, "pool.ntp.org", "time.nist.gov");
Thanks , However changing the line to : configTime( 5* 3600, 0, "pool.ntp.org", "time.nist.gov"); Actually moved the time forward an additional 5 hours, I thought I would be clever and move it 19 hours forward, but that put me into tomorrow, been looking up how to subtract 5 but no luck so far.....
Change the sign to -5 that’s my mistake you need to move the reference clock back 5-hours:
configTime(-5*3600,0,...
Worked Like a Charm ! Thanks for the fast response !...Cool Project ! Making a case and putting it in my kitchen !
Great, For the xmas period I am thinking of putting one in the porch to welcome visitors and I can change the message from my iPhone 😊 as each arrives
Thankyou
G6EJD
Used the shared code. But it doesnot scrolls ordered manner. Where can be the issue?
Praveen GS, connection or display problem do you have the correct display type?
@@G6EJD Connection I did as per your suggestion in the video. Uploaded the same code. Display problem. I am using www.amazon.in/gp/product/B073DCYNVC/ref=ppx_yo_dt_b_asin_title_o00_s01?ie=UTF8&psc=1 display
Praveen GS you need to check your using the correct pins on the ESP and that the cables are connected correctly there are no code issues just hardware connection errors
@@G6EJD All cables are proper and cooections are as follows.
VCC ->3v3, GND-GND, DIN->D7, CS->D4, CLK->D5
What is your board type?
thanks for these realy helpful tutorial. You are my hero. I try your sketch but unfortunately I don't get any actual time/date. Time is allways 00:00 and date 01.01.1970. The reason should be that I have no access to pool.ntp.org. Further on I don't see any settings for WLAN. I'll try to fix these but unfortunately I am a real noob for these topics.
Again thanks for the video. Hope we get much more of these from you.
kind reguards
Uwe
It is most likely your Router or Service Provider is not allowing access to the Time Servers, does your PC get its time from a server? IF so use that address in the source code. You can use two a primary and secondary.
I have tried to add your code to my MQTT stuff. In these coding I use login for my local wlan including internet access. And now I get time and date. Unfortunately time is one hour before German time. But I try my best to fix these.
How to show second in clock?
EXTRA GOD, there isn’t space to show seconds in the static display only 5 chars max. I don’t understand what your trying to achieve?
@@G6EJD I have ever seen the smaller text size clock with second but I don' t know how to do it.
The font size is fixed with the 7219 display, so what you’ve seen was not these or they were using 6 display modules.
@@G6EJD 4 module
I don’t know then
how to show only the time?
After the line : String time = String(ctime(&now));
time = time.substring(start,finish);
Change start to be the beginning of time and finish the end of time, eg Mon 28 Jun 16:24 2017 would be 11,16
@@G6EJD more one question, which code do I use?
@@wl11lm, You didn't say which board/processor your using but they code body is the same, what I've suggested is to leave the time string as is and take a substring of it that has just the time, it is just as efficient. Just modify the line after it as I suggested.
@@G6EJD hi, i can't find the libraries. Can you send me all code with libraries? I'll use this project using a esp32.
You don’t need any libraries, they are all built-in. Do you have the ESP32 extensions for the IDE installed?
hello David ,nice project,i also wanna one clock for my radio shack,untill i waiting wemos board from ebay i try compile sketch Time.ino and Specific format time.ino but arduino ide tells me:
D:\Program Files\arduino-1.8.5\libraries\Adafruit_GFX\Adafruit_GFX.cpp:1509:6: warning: unused parameter 'i' [-Wunused-parameter]
void Adafruit_GFX::invertDisplay(boolean i) {
maybe you know ,what s the problem ?
thanks in advance,73 de 9a3xz Mikele
Hi Mikele, it’s possible your Adafruit GFX library needs updating, if you go to Libraries, Manage and then top-left select ‘updateable’ that will check for you. 73 Dave de G6EJD
@@G6EJD thanks David for quick answer but nothing ,i reinstaleted and put new newest 1.5.7 gfx library but nothing...same problem like before ;(
Please check the library ‘include ’ is present as the error is occurring in the GFX library called by the Max72xx library. Also make sure you select the 8266 board type e.g. 8266 D1 Mini
@@G6EJD i put another max72xx library but nothing ,in my boards list David is Lolin Wemos D1mini Lite ,Lolin Wemos D1 mini Pro ,Lolin Wemos D1 R2 mini...
Checking that you have installed the ESP extensions for the Arduino IDE and you can select a generic ESP8266 board for testing, Adafruit have a good tutorial for installing the ESP extension.
Dear Thank you Done
Superb