Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuration issues: weather data and conditions; display flickering #4

Open
lmirel opened this issue Aug 8, 2018 · 29 comments
Open

Comments

@lmirel
Copy link
Owner

lmirel commented Aug 8, 2018

  1. During WiFi configuration, somehow the font size is incorrect. As you can see, the image below the last character “k” and “1” are wrapping over the next line on left. This in itself is not causing problem to set up.

  2. The display is flicking severely. Please see a short video below.

I have played around the display_updater parameters a bit (from 10 to 280) but it wasn’t improving. I noticed that during “connecting” and “online”. The display was not flicking. Please advise anything else I should try.

  1. I was not able to get weather data and parameters above time display. Below is the copy of serial output. Please advise anything else I should try.
    --
    console output:
    ..
    timezone=-7
    military=Y
    metric=Y
    date-format=M.D.Y
    connecting to weather server.. connected.
    *WM: freeing allocated params!
    display color range [0 .. 65535]
    day mode brightness
    showing the weather
    !no weather data available
    showing the date
    Got NTP time: 23:04:34 07/08/2018
    night mode brightness
    showing the weather
    !no weather data available
    showing the date
    showing the weather
    !no weather data available
    connecting to weather server.. connected.
    showing the weather
    !no weather data available
    ..
@lmirel
Copy link
Owner Author

lmirel commented Aug 8, 2018

  1. seems related to a problem with the PxMatrix lib and I'm afraid I cannot help there.
    the Instructable https://github.com/hwiguna/HariFun_166_Morphing_Clock might have more insight on that as I have not met this problem myself.

  2. there may be something else happening there but I need some more info on the console output.
    do you see the console flooding with messages? that shouldn't happen but it is usually the case for that flickering. it might be related to weather data processing since that doesn't seem to go well for you.

  3. as stated above, I'm not sure I understand why you can't get any weather data.
    in the getWeather() function, try changing the line where it says:
    delay (1000);
    to
    delay (5000);
    to see if that does anything. you might have a slower connection/hardware/etc..

@richp123
Copy link

richp123 commented Aug 8, 2018

Im having the same issue, here is my serial monitor:

*WM: AutoConnect *WM: Connecting as wifi client... *WM: Using last saved values, should be faster *WM: Connection result: *WM: 3 *WM: IP Address: *WM: 192.168.0.34 timezone=+1 military=Y metric=Y date-format=D.M.Y WiFi connected, IP address: 192.168.0.34 connecting to weather server.. connected. *WM: freeing allocated params! display color range [0 .. 65535] day mode brightness showing the weather !no weather data available showing the date Got NTP time: 13:12:35 08/08/2018 showing the weather !no weather data available showing the date showing the date showing the weather !no weather data available showing the weather !no weather data available showing the weather !no weather data available connecting to weather server.. connected. showing the weather !no weather data available showing the weather !no weather data available showing the weather !no weather data available showing the weather !no weather data available showing the weather !no weather data available connecting to weather server.. connected. showing the weather !no weather data available showing the weather !no weather data available showing the weather !no weather data available

@lmirel
Copy link
Owner Author

lmirel commented Aug 8, 2018

I assume you are referring to item 3, above.
I'll add more debug information on the getWeather function to see what is your case.

Did you try the delay change from 1000 to 5000? Did that work?

@richp123
Copy link

richp123 commented Aug 8, 2018

Tried that Yeh, much the same

�fWrmat=D.M.Y
WiFi connected, IP address: 192.168.0.34
connecting to weather server.. connected.
*WM: freeing allocated params!
display color range [0 .. 65535]
day mode brightness
showing the weather
!no weather data available
showing the date
Got NTP time: 13:30:27 08/08/2018
showing the weather
!no weather data available
showing the date
connecting to weather server.. connected.
showing the weather
!no weather data available
showing the weather
!no weather data available

@richp123
Copy link

richp123 commented Aug 8, 2018

If I make the api call in chrome from my laptop it returns valid json and the correct weather.

It's like my node can't access the information - firewall issue?

Im going to add a println to see if it's actually connected to the api

@lmirel
Copy link
Owner Author

lmirel commented Aug 8, 2018

you could replace while (client.connected ())
with
if (!client.connected ()) Serial.println ("!unable to retrieve weather data"); else while (client.connected ())

@richp123
Copy link

richp123 commented Aug 8, 2018

added the if, its not connecting:

*WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Connection result: *WM: 3 Should save config timezone=+1 military=Y metric=Y date-format=D.M.Y WiFi connected, IP address: 192.168.0.34 Saving configuration to file: timezone=+1 military=Y metric=Y date-format=D.M.Y connecting to weather server.. connected. **!i cannot retrieve weather data** *WM: freeing allocated params! display color range [0 .. 65535] day mode brightness showing the weather !no weather data available showing the date showing the weather !no weather data available Got NTP time: 14:43:04 08/08/2018 showing the weather !no weather data available showing the date

i also tried to connect the node to a mobile hotspot an the same thing happens so rules out firewall

@lmirel
Copy link
Owner Author

lmirel commented Aug 8, 2018

you could try 2 more things:
use a longer timeout for that delay or remove the client.println("Connection: close"); line to see if it changes behavior.

also, try doing this right after the delay:
String line = client.readStringUntil ('\n');
Serial.print ("weather:");
Serial.println (line);

@richp123
Copy link

richp123 commented Aug 8, 2018

getting something back in the serial now, although nothing on the board:

Failed to open config file
*WM: Adding parameter
*WM: timeZone
*WM: Adding parameter
*WM: military
*WM: Adding parameter
*WM: metric
*WM: Adding parameter
*WM: date_fmt
No Double Reset Detected
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 0
*WM:
*WM: Configuring access point...
*WM: MorphClk
*WM: AP IP address:
*WM: 192.168.244.1
*WM: HTTP server started
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Scan done
*WM: DUP AP: Virgin Media
*WM: DUP AP: Virgin Media
*WM: DUP AP: Virgin Media
*WM: DUP AP: SKY81982
*WM: VM6396260
*WM: -55
*WM: PAULS-GUEST
*WM: -55
*WM: Virgin Media
*WM: -55
*WM: ESP_364B97
*WM: -60
*WM: SKY81982
*WM: -71
*WM: virginmedia9909926
*WM: -82
*WM: VM2855170
*WM: -83
*WM: SKY11B1D
*WM: -84
*WM: VM8584101
*WM: -86
*WM: TNCAPC35D2D
*WM: -87
*WM: Sent config page
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Handle root
*WM: WiFi save
*WM: Parameter
*WM: timeZone
*WM: +1
*WM: Parameter
*WM: military
*WM: Y
*WM: Parameter
*WM: metric
*WM: Y
*WM: Parameter
*WM: date_fmt
*WM: D.M.Y
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 3
Should save config
timezone=+1
military=Y
metric=Y
date-format=D.M.Y
WiFi connected, IP address: 192.168.0.34
Saving configuration to file:
timezone=+1
military=Y
metric=Y
date-format=D.M.Y
connecting to weather server.. connected.
weather:{"coord":{"lon":-1.98,"lat":50.72},"weather":[{"id":521,"main":"Rain","description":"shower rain","icon":"09d"}],"base":"stations","main":{"temp":20.18,"pressure":1013,"humidity":53,"temp_min":19,"temp_max":22},"visibility":10000,"wind":{"speed":7.2,"deg":210},"clouds":{"all":40},"dt":1533736200,"sys":{"type":1,"id":5081,"message":0.0024,"country":"GB","sunrise":1533703539,"sunset":1533757218},"id":2640101,"name":"Poole","cod":200}
!i cannot retrieve weather data
*WM: freeing allocated params!
display color range [0 .. 65535]
Got NTP time: 15:21:07 08/08/2018
day mode brightness
showing the weather
!no weather data available
showing the date

@lmirel
Copy link
Owner Author

lmirel commented Aug 8, 2018

you don't see that on the board because this fails
while (client.connected ())

I don't know which of the 3 proposed changes you made to the code to understand what generated this behavior.
you can copy/paste your getWeather function so that I understand this.

@richp123
Copy link

richp123 commented Aug 8, 2018

void getWeather ()
{
  if (!apiKey.length ())
  {
    Serial.println ("!missing API KEY for weather data, skipping"); 
    return;
  }
  Serial.print ("connecting to weather server.. "); 
  // if you get a connection, report back via serial: 
  if (client.connect (server, 80))
  { 
    Serial.println ("connected."); 
    // Make a HTTP request: 
    client.print ("GET /data/2.5/weather?"); 
    client.print ("q="+location); 
    client.print ("&appid="+apiKey); 
    client.print ("&cnt=3"); 
    (*u_metric=='Y')?client.println ("&units=metric"):client.println ("&units=imperial");
    client.println ("Host: api.openweathermap.org"); 
    client.println ("Connection: close"); 
    client.println (); 
  } 
  else 
  { 
    Serial.println ("!unable to connect");
    return;
  } 
  delay (1000);
  String line = client.readStringUntil ('\n');
  Serial.print ("weather:");
  Serial.println (line);
  String sval = "";
  int bT, bT2;
  while (client.connected ()) 
  {
    line = client.readStringUntil ('\n'); 
    Serial.print ("weather:"); 
    Serial.println (line); 
    //weather conditions - "main":"Clear",
    bT = line.indexOf ("\"main\":\"");
    if (bT > 0)
    {
      bT2 = line.indexOf ("\",\"", bT + 8);
      sval = line.substring (bT + 8, bT2);
      Serial.print ("cond ");
      Serial.println (sval);
      //0 - unk, 1 - sunny, 2 - cloudy, 3 - overcast, 4 - rainy, 5 - thunders, 6 - snow
      if (sval.equals("Clear"))
        condM = 1;
      else if (sval.equals("Clouds"))
        condM = 2;
      else if (sval.equals("Overcast"))
        condM = 3;
      else if (sval.equals("Rain"))
        condM = 4;
      else if (sval.equals("Thunderstorm"))
        condM = 5;
      else if (sval.equals("Snow"))
        condM = 6;
      //tempM = sval.toInt();
    }
    //tempM
    bT = line.indexOf ("\"temp\":");
    if (bT > 0)
    {
      bT2 = line.indexOf (",\"", bT + 7);
      sval = line.substring (bT + 7, bT2);
      Serial.print ("temp ");
      Serial.println (sval);
      tempM = sval.toInt ();
    }
    else
      Serial.println ("temp NOT found!");
    //pressM
    bT = line.indexOf ("\"pressure\":");
    if (bT > 0)
    {
      bT2 = line.indexOf (",\"", bT + 11);
      sval = line.substring (bT + 11, bT2);
      Serial.print ("press ");
      Serial.println (sval);
      presM = sval.toInt();
    }
    else
      Serial.println ("pressure NOT found!");
    //humiM
    bT = line.indexOf ("\"humidity\":");
    if (bT > 0)
    {
      bT2 = line.indexOf (",\"", bT + 11);
      sval = line.substring (bT + 11, bT2);
      Serial.print ("humi ");
      Serial.println (sval);
      humiM = sval.toInt();
    }
    else
      Serial.println ("humidity NOT found!");
  }//connected
}

@richp123
Copy link

richp123 commented Aug 8, 2018

I removed the while loop and that fixed the issue

@wudave
Copy link

wudave commented Aug 9, 2018

Imirel,
When I tried different delays and remove client.println("Connection: close"), I was still not able to get weather data. If I moved the 3 lines as you suggested (after the delay), the console output is copied below.

connecting to weather server.. connected.
weather:{"coord":{"lon":-122.08,"lat":37.39},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50n"},{"id":701,"main":"Mist","description":"mist","icon":"50n"},{"id":711,"main":"Smoke","description":"smoke","icon":"50n"}],"base":"stations","main":{"temp":20.88,"pressure":1015,"humidity":93,"temp_min":12,"temp_max":31},"visibility":1609,"wind":{"speed":3.6,"deg":340},"clouds":{"all":90},"dt":1533782400,"sys":{"type":1,"id":392,"message":0.0042,"country":"US","sunrise":1533820777,"sunset":1533870441},"id":5375480,"name":"Mountain View","cod":200}
*WM: freeing allocated params!
display color range [0 .. 65535]
day mode brightness
showing the weather
!no weather data available
showing the date
Got NTP time: 20:05:20 08/08/2018
showing the weather
!no weather data available
showing the date
showing the weather
!no weather data available
showing the date
night mode brightness
showing the weather
!no weather data available
showing the date
connecting to weather server.. connected.
weather:{"coord":{"lon":-122.08,"lat":37.39},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50n"},{"id":701,"main":"Mist","description":"mist","icon":"50n"},{"id":711,"main":"Smoke","description":"smoke","icon":"50n"}],"base":"stations","main":{"temp":20.88,"pressure":1015,"humidity":93,"temp_min":12,"temp_max":31},"visibility":1609,"wind":{"speed":3.6,"deg":340},"clouds":{"all":90},"dt":1533782400,"sys":{"type":1,"id":392,"message":0.0042,"country":"US","sunrise":1533820777,"sunset":1533870441},"id":5375480,"name":"Mountain View","cod":200}
showing the weather
!no weather data available

@wudave
Copy link

wudave commented Aug 9, 2018

Confirmed if I removed the while loop, the temp/hum/pressure would display. However, the icon will not, presumably b/c the weather conditions and thus icons were not defined.

@wudave
Copy link

wudave commented Aug 9, 2018

Mirel,

On the original issue #2 (display flicking), I can't identify any relevant console output. The console output is pretty much the weather data output every 5 min (copied below). One more thing I tried was to use a different board (still a NodeMCU) from a different vendor, which uses a different ESP8266 module (the previous one is, in fact, a chip-on-board). Unfortunately, the same flicking issue remains.

timezone=-7
military=n
metric=n
date-format=M.D.Y
connecting to weather server.. connected.
weather:{"coord":{"lon":-122.08,"lat":37.39},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50n"},{"id":701,"main":"Mist","description":"mist","icon":"50n"},{"id":711,"main":"Smoke","description":"smoke","icon":"50n"}],"base":"stations","main":{"temp":64.63,"pressure":1015,"humidity":100,"temp_min":53.6,"temp_max":82.4},"visibility":2414,"wind":{"speed":5.82,"deg":330},"clouds":{"all":90},"dt":1533786000,"sys":{"type":1,"id":392,"message":0.0051,"country":"US","sunrise":1533820780,"sunset":1533870437},"id":5375480,"name":"Mountain View","cod":200}
cond Haze
temp 64.63
press 1015
humi 100
*WM: freeing allocated params!
display color range [0 .. 65535]
day mode brightness
showing the weather
temperature: 64F
weather conditions 0
showing the date
Got NTP time: 21:12:07 08/08/2018
night mode brightness
showing the weather
temperature: 64F
weather conditions 0
showing the date
showing the weather
temperature: 64F
weather conditions 0
showing the weather
temperature: 64F
weather conditions 0
showing the weather
temperature: 64F
weather conditions 0
connecting to weather server.. connected.
weather:{"coord":{"lon":-122.08,"lat":37.39},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50n"},{"id":701,"main":"Mist","description":"mist","icon":"50n"},{"id":711,"main":"Smoke","description":"smoke","icon":"50n"}],"base":"stations","main":{"temp":64.63,"pressure":1015,"humidity":100,"temp_min":53.6,"temp_max":82.4},"visibility":2414,"wind":{"speed":5.82,"deg":330},"clouds":{"all":90},"dt":1533786000,"sys":{"type":1,"id":392,"message":0.0051,"country":"US","sunrise":1533820780,"sunset":1533870437},"id":5375480,"name":"Mountain View","cod":200}
cond Haze
temp 64.63
press 1015
humi 100
showing the weather
temperature: 64F
weather conditions 0
showing the weather
temperature: 64F
weather conditions 0
showing the weather
temperature: 64F
weather conditions 0
showing the weather
temperature: 64F
weather conditions 0
showing the weather
temperature: 64F
weather conditions 0
connecting to weather server.. connected.
weather:{"coord":{"lon":-122.08,"lat":37.39},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50n"},{"id":701,"main":"Mist","description":"mist","icon":"50n"},{"id":711,"main":"Smoke","description":"smoke","icon":"50n"}],"base":"stations","main":{"temp":64.63,"pressure":1015,"humidity":100,"temp_min":53.6,"temp_max":82.4},"visibility":2414,"wind":{"speed":5.82,"deg":330},"clouds":{"all":90},"dt":1533786000,"sys":{"type":1,"id":392,"message":0.0051,"country":"US","sunrise":1533820780,"sunset":1533870437},"id":5375480,"name":"Mountain View","cod":200}
cond Haze
temp 64.63
press 1015
humi 100
showing the weather
temperature: 64F
weather conditions 0

@lmirel
Copy link
Owner Author

lmirel commented Aug 9, 2018

On the original issue #2 (display flicking), I can't identify any relevant console output

I'll need to find time to try different things as I cannot reproduce this on my 2 setups.
unfortunately, I'll be out the next couple weeks and there isn't much I can do about it.

@lmirel
Copy link
Owner Author

lmirel commented Aug 9, 2018

I removed the while loop and that fixed the issue

I'll need to rewrite that condition as it seems your connection is very fast and it gets back the data and closes the connection in 1 sec or less.

@lmirel
Copy link
Owner Author

lmirel commented Aug 9, 2018

the icon will not, presumably b/c the weather conditions and thus icons were not defined

it doesn't know 'Haze' and there are many other conditions it doesn't know but this is good feedback.
I'll need to think about a way to show something default as I don't think I'll have time to draw icons for every weather condition.
any suggestions are welcome.

@lmirel lmirel changed the title configuration issues configuration issues: weather data and conditions; display flickering Aug 9, 2018
@lmirel
Copy link
Owner Author

lmirel commented Aug 9, 2018

I've pushed a workaround for the weather retrieval issue when it is there but not processed due to connection close.

@wudave
Copy link

wudave commented Aug 12, 2018

Mirel,

I think I have resolved the flicking issue. When I was first provisioning the WiFi, I encountered the issue reported in the discussion section of https://www.instructables.com/id/Morphing-Digital-Clock/. That is I wasn't able to see ESP8266 WiFi SSID b/c according to Hari: "interrupt routine that is updating the matrix is interfering with WiFi". As a result, I have to decrease the refresh rate of the display (from 0.002 to 0.025) per Hari's Experimental12E branch https://github.com/hwiguna/HariFun_166_Morphing_Clock/blob/Experimental12E/Latest/MorphingClock/MorphingClock.ino. After that, I left the setting unchanged at 0.025. I remembered that I did change back to 0.002 at one point but in the combination of changing other parameters I somehow still seen flicking. Until last night, I changed back to 0.002 (and presumably other parameters back), the flickering was gone. I went ahead and changed different ranges and found the range where it will work. My current setting is 0.0025 since that's the middle of working range to my board.

// Refresh rate: 0.001 to 0.015 - doesn't work (nothing shown on display)
// 0.002 to 0.003 w/ CPU = 80/160MHz works great; but won't work to config WiFi
// 0.004 to 0.025 w/ CPU = 80/160MHz will flicker; but can config WiFi
display_ticker.attach (0.0025, display_updater);

So, to summarize, I have to change refresh rate to 0.025 to set up WiFi configuration (my home network credential) but after that I have to change the refresh rate to 0.0025 to avoid display flickering.

I also have an update on the weather condition / icon. Since there are a whole lot other conditions, that will be hard to match / create them all up. My suggestion is to use icon when available but when it's "unknown" ("0" condition in your code), I suggest to just print out the first few characters (space allowed). I was able to print out 4 characters (I may adjust in future). It's not as pretty as icons but it's not bad to not leave it blank/space. Please see the attachment of my photo. One thing I have to do is to convert all of the characters to upper-case or it won't display correctly.

img_4258

@lmirel
Copy link
Owner Author

lmirel commented Aug 21, 2018

I like the idea of using the first 4 letters, thanks. I'll implement that as soon as I find some time - I only implemented the uppercase support for TinyFont; a faster solution is to adapt the font code to convert them to uppercase directly ;-)=

it's great that you've resolved the flickering issue and thanks for sharing.

@Racer1Tn
Copy link

Racer1Tn commented Nov 7, 2018

I have built this display using the 12E Node MCU. I managed to work thru the getHour error after following the notes about the three files and ended up only using the two specified. Took quite a few tries and rebuilds.
The problem that I cannot seem to resolve using the notes listed is the flickering. The weather connection is good and it displays the weather settings. The filckering is VERY pronounced, except for the bitmapped sun icon. The display has not changed dimmer after 20:00 either I cannot seem to locate the proper setting to eradicate the flickering. Any help is appreciated. Getting this one solved will complete my build and I'll make a frame for it on the wall for display. One thing I notice is that the Animation for the weather icon does not flicker while the rest of the display does. And what is the hidden "boo" message for, is that necessary?

20181107_123907

@lmirel
Copy link
Owner Author

lmirel commented Nov 8, 2018

I'm sorry to hear you didn't find a way to fix the flickering. it is weird that it doesn't happen for the weather icon as the whole display should refresh while flickering.
you could check the resources from 'wudave' above to try different options.
also, have you tried using just the morphing clock code from HarryFun to see if you get a different behavior?

@Racer1Tn
Copy link

Yep, I am back to running Hari's code for just the clock. It's simple and no flickering. I tried several days of changing the setting 'wudave' suggested. However there are gaps in his documentation. Esp. the part about changing some paramaters "back".

@lmirel
Copy link
Owner Author

lmirel commented Nov 16, 2018 via email

@extesy
Copy link

extesy commented Dec 6, 2018

I have a same problem with severe flickering on esp8266. Tried different refresh rates but couldn't get rid of it so I had to go back to the original morphing code. Too bad, this project looked very nice.

@lmirel
Copy link
Owner Author

lmirel commented Dec 6, 2018

Yep, I am back to running Hari's code for just the clock. It's simple and no flickering. I tried several days of changing the setting 'wudave' suggested. However there are gaps in his documentation. Esp. the part about changing some paramaters "back".

please comment line 988: draw_animations (i);
that's in the loop function and is the only major change compared to the original morphing code

also, comment out the last call to delay (0); in the loop function. this might have effect on interrupt handling which in turn might impact flickering.

let me know if it changed anything.

@lmirel
Copy link
Owner Author

lmirel commented Dec 6, 2018

I have a same problem with severe flickering on esp8266. Tried different refresh rates but couldn't get rid of it so I had to go back to the original morphing code. Too bad, this project looked very nice.

please comment line 988: draw_animations (i);
that's in the loop function and is the only major change compared to the original morphing code

also, comment out the last call to delay (0); in the loop function. this might have effect on interrupt handling which in turn might impact flickering.

let me know if it changed anything.

@extesy
Copy link

extesy commented Dec 13, 2018

@lmirel Nope, doesn't help. Still flickering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants