Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 01:23 03 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : WebMite Question

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 10:29pm 16 Apr 2024
Copy link to clipboard 
Print this post

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
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5911
Posted: 10:34pm 16 Apr 2024
Copy link to clipboard 
Print this post

  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
VK7JH
MMedit   MMBasic Help
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1790
Posted: 10:56pm 16 Apr 2024
Copy link to clipboard 
Print this post

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

RTC SETTIME DateTime$(now)
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 10:58pm 16 Apr 2024
Copy link to clipboard 
Print this post

Thanks Jim, on thinking about it, I dont think I need an external RTC if I can keep the clock updated from the WEB.
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 11:34pm 16 Apr 2024
Copy link to clipboard 
Print this post

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

0A47
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 12:41am 17 Apr 2024
Copy link to clipboard 
Print this post

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
 
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 156
Posted: 05:07am 17 Apr 2024
Copy link to clipboard 
Print this post

  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...  

John
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 05:32am 17 Apr 2024
Copy link to clipboard 
Print this post

Thanks Malibu I will plod on.

0A47
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 05:39am 17 Apr 2024
Copy link to clipboard 
Print this post

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
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5911
Posted: 07:21am 17 Apr 2024
Copy link to clipboard 
Print this post

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
VK7JH
MMedit   MMBasic Help
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5735
Posted: 07:38am 17 Apr 2024
Copy link to clipboard 
Print this post

"[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.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 08:19am 17 Apr 2024
Copy link to clipboard 
Print this post

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
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 08:25am 17 Apr 2024
Copy link to clipboard 
Print this post

add the line

LONGSTRING PRINT buff%()

Then you can see what, if anything, has been received
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 08:38am 17 Apr 2024
Copy link to clipboard 
Print this post

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
 
NPHighview

Senior Member

Joined: 02/09/2020
Location: United States
Posts: 193
Posted: 02:46pm 17 Apr 2024
Copy link to clipboard 
Print this post

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 :-)
Live in the Future. It's Just Starting Now!
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 10:32pm 17 Apr 2024
Copy link to clipboard 
Print this post

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
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3016
Posted: 11:30pm 17 Apr 2024
Copy link to clipboard 
Print this post

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:".
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 11:33pm 17 Apr 2024
Copy link to clipboard 
Print this post

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

0A47
Edited 2024-04-18 09:38 by OA47
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 904
Posted: 12:14am 18 Apr 2024
Copy link to clipboard 
Print this post

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
 
NPHighview

Senior Member

Joined: 02/09/2020
Location: United States
Posts: 193
Posted: 01:37am 18 Apr 2024
Copy link to clipboard 
Print this post

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.
Live in the Future. It's Just Starting Now!
 
Print this page


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

© JAQ Software 2024