Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : WebMite Question

Posted: 10:29pm
16 Apr 2024
Copy link to clipboard
OA47
Guru


When I use "WEB NTP +10" and get the message "got ntp response: 17/04/2024 08:26:04" how do I access this info to set the RTC? or does it automatically update the Time$ and Date$ and I can use that to RTC SETTIME ?

0A47
Edited 2024-04-17 08:34 by OA47
 
Posted: 10:34pm
16 Apr 2024
Copy link to clipboard
TassyJim
Guru


  OA47 said  When I use "WEB NTP +10" and get the message "got ntp response: 17/04/2024 08:26:04" how do I access this info to set the RTC? or does it automatically update the Time$ and Date$ and I can use RTC SETTIME ?

0A47


No need. That should happen automatically.
I haven't tried with an external RTC but it works for the built-in RTC.

Jim
 
Posted: 10:56pm
16 Apr 2024
Copy link to clipboard
phil99
Guru


After "got ntp response: 17/04/2024 08:26:04" has set Time$ and Date$ do:-

RTC SETTIME DateTime$(now)
 
Posted: 10:58pm
16 Apr 2024
Copy link to clipboard
OA47
Guru


Thanks Jim, on thinking about it, I dont think I need an external RTC if I can keep the clock updated from the WEB.
 
Posted: 11:34pm
16 Apr 2024
Copy link to clipboard
OA47
Guru


Thanks Phil, I will try to remember DateTime$(Now)

0A47
 
Posted: 12:41am
17 Apr 2024
Copy link to clipboard
OA47
Guru


Can someone help me with this response?

"[CYW43] do_ioctl(2, 263, 16): timeout"

I believe it is related to the WEB NTP command.

0A47
 
Posted: 05:07am
17 Apr 2024
Copy link to clipboard
Malibu
Senior Member

  Quote  "[CYW43] do_ioctl(2, 263, 16): timeout"


...is a problem I've been chasing for ages, but it's not just restricted to the NTP command. Can't narrow it down any more than that for you, sorry... I'm still trying to nut the 'inner workings' out thus far...  
 
Posted: 05:32am
17 Apr 2024
Copy link to clipboard
OA47
Guru


Thanks Malibu I will plod on.

0A47
 
Posted: 05:39am
17 Apr 2024
Copy link to clipboard
OA47
Guru


Here is my next stumbling block:

mm.ver=5.08


Dim Web$="api.openweathermap.org"
Const Key="???????????????????????????"
Const Query="GET/data/2.5/WEATHER?q=Paris,fra&APPID="+Key+Chr$(13)+Chr$(10)

Dim buff%(4096/8)
Dim temp

WEB OPEN TCP CLIENT Web$, 80
WEB TCP CLIENT REQUEST Query, buff%()
WEB CLOSE TCP CLIENT

temp=Val(Json$(buff%(),"main.temp"))


Returns

tcp address 38.89.70.158
Connected
[113] temp=Val(Json$(buff%(),"main.temp"))
Error : Invalid JSON data


Help please
0A47
Edited 2024-04-17 16:10 by OA47
 
Posted: 07:21am
17 Apr 2024
Copy link to clipboard
TassyJim
Guru


GET /data

You need a space between GET and the /

and the returned temperature might be in Kelvin so -273

Jim
Edited 2024-04-17 17:22 by TassyJim
 
Posted: 07:38am
17 Apr 2024
Copy link to clipboard
Mixtel90
Guru


"[CYW43] do_ioctl(2, 263, 16): timeout" was a problem for me too. I don't think it's WEB NTP though as you can trap a connection error there very effectively (and connections usually work first time for me). IIRC it was related to using Telnet and I had to shut Tera Term down and reconnect. (It was just one of the problems so I may be confused about what I did in each case!).

Most problems needed a reset button on the Pico W.
 
Posted: 08:19am
17 Apr 2024
Copy link to clipboard
OA47
Guru


Thanks Mick.  

Thanks Jim, I re-inserted the space after GET and the error is no longer but the string returned is still empty.
Print Json$(buff%(),"main.temp")

Does not print anything

Where would I find a list of the key words that should be stored in the string?
0A47
Edited 2024-04-17 18:22 by OA47
 
Posted: 08:25am
17 Apr 2024
Copy link to clipboard
matherp
Guru

add the line

LONGSTRING PRINT buff%()

Then you can see what, if anything, has been received
 
Posted: 08:38am
17 Apr 2024
Copy link to clipboard
OA47
Guru


Thanks Peter, I found the list of JSON words on the website and somewhere along the line I had typed the word weather in caps and that wasn't liked.

I am making progress again  
0A47

tcp address 38.89.70.158
Connected
{"coord":{"lon":-80.6081,"lat":28.0836},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"base":"stations","main":{"temp":294.09,"feels_like":294.35,"temp_min":290.39,"temp_max":296.46,"pressure":1020,"humidity":81},"visibility":10000,"wind":{"speed":4.63,"deg":130},"clouds":{"all":20},"dt":1713343124,"sys":{"type":1,"id":4922,"country":"US","sunrise":1713351278,"sunset":1713397720},"timezone":-14400,"id":4163971,"name":"Melbourne","cod":200}
Current Temp  21.09 degrees

Edited 2024-04-17 18:41 by OA47
 
Posted: 02:46pm
17 Apr 2024
Copy link to clipboard
NPHighview
Senior Member


OA47: Very nice!

Are you using openweathermap's free 1,000 calls per day service?

This looks like a very nice addition to a digital clock app, now that you've worked out the bulk of the bugs :-)
 
Posted: 10:32pm
17 Apr 2024
Copy link to clipboard
OA47
Guru


From the website I have this list of information:
  Quote  {
 "coord": {
   "lon": 10.99,
   "lat": 44.34
 },
 "weather": [
   {
     "id": 501,
     "main": "Rain",
     "description": "moderate rain",
     "icon": "10d"
   }
 ],
 "base": "stations",
 "main": {
   "temp": 298.48,
   "feels_like": 298.74,
   "temp_min": 297.56,
   "temp_max": 300.05,
   "pressure": 1015,
   "humidity": 64,
   "sea_level": 1015,
   "grnd_level": 933
 },
 "visibility": 10000,
 "wind": {
   "speed": 0.62,
   "deg": 349,
   "gust": 1.18


I am able to get all the static info such as:
Min=Val((Json$(buff%(),"main.temp_min")))-273
Max=Val((Json$(buff%(),"main.temp_max")))-273
Prs$=Json$(buff%(),"main.pressure")
Hum$=Json$(buff%(),"main.humidity")


But I would like to get the string$ for
  Quote  "main": "Rain",
     "description": "moderate rain"

but I cannot get the syntax correct.
Further from the site.
  Quote  weather (more info Weather condition codes)
weather.id Weather condition id
weather.main Group of weather parameters (Rain, Snow, Clouds etc.)
weather.description Weather condition within the group. Please find more here. You can get the output in your language. Learn more
weather.icon Weather icon id


I have tried using "weather.main" and "weather.description" but I only get a blank.

Ideas please.
0A47
Edited 2024-04-18 08:41 by OA47
 
Posted: 11:30pm
17 Apr 2024
Copy link to clipboard
lizby
Guru

From some effort two and a half years ago, I have

Print json$(m%(),"weather[0].description")


If I recall correctly, the [0] is because of the square brackets following "weather:".
 
Posted: 11:33pm
17 Apr 2024
Copy link to clipboard
OA47
Guru


Thankyou very much lizby that fixed the problem for "weather.main" and "weather.description"  

0A47
Edited 2024-04-18 09:38 by OA47
 
Posted: 12:14am
18 Apr 2024
Copy link to clipboard
OA47
Guru


NPHighwiew,

  Quote  This looks like a very nice addition to a digital clock app, now that you've worked out the bulk of the bugs :-)





Is this what you were thinking?

0A47
 
Posted: 01:37am
18 Apr 2024
Copy link to clipboard
NPHighview
Senior Member


Almost exactly! I have an analog clock, patterned after Swiss railway clock face, and will be very happy to add this to it. It picks up UTP once an hour. I think picking up weather once every 5 to 15 minutes to stay well below the 1k per day charge limit.
 


To reply to this topic, you need to log in.

© JAQ Software 2024