Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:45 10 May 2025 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 URL access

Author Message
Gerad
Regular Member

Joined: 10/01/2024
Location: Germany
Posts: 49
Posted: 02:36pm 03 Apr 2025
Copy link to clipboard 
Print this post

Hello everyone,
Can I use Webmite to access a URL like "http://"yourIP"/RELAY=ON-OFF"?
I want to switch a WiFi relay on and off.

regards
Gerad
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3309
Posted: 04:10pm 03 Apr 2025
Copy link to clipboard 
Print this post

For a Sonoff Pow R3 16 AC current monitor and switch, I use "http://192.168.1.183/cm?cmnd=Power%20On" to turn on (or ending in "Off" to turn off).

This works from the devices I have tried it on: PC, Raspberry Pi, ESP32-C3SuperMini flashed with annex basic.

I don't have a WebMite set up at present, but I don't know why it wouldn't work from that device.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Gerad
Regular Member

Joined: 10/01/2024
Location: Germany
Posts: 49
Posted: 06:41pm 03 Apr 2025
Copy link to clipboard 
Print this post

My question is:
How can I send the URL "http://yourIP/RELAY=ON" with Webmite Basic 6.00.02?

Gerad
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 459
Posted: 08:56pm 03 Apr 2025
Copy link to clipboard 
Print this post

Hello Gerad,

You can find the solution in the manual. This should help you to call up the URL.

PicoMite User Manual, MMBasic BASIC Interpreter Ver 6.00.01, page 77:
Implementing a TCP Client
The WebMite can also act as a TCP client to request data from a remote server. This is managed with three
commands. The first is:
WEB OPEN TCP CLIENT Domain$, PortNumber
This opens a TCP connection to Domain$ (for example "openweathermap.org") using the specified
PortNumber (normally 80 for a web page).
With the connection open you can send one or more requests using this command:
WEB TCP CLIENT REQUEST query$, inbuf [, timeout]
The request to be sent is 'query$' and the response will be saved in 'inbuf' which is normally a long string
variable such as buff%(4096/8). The size of this buffer (in bytes) will limit the amount of data received
from the server and should be increased if more data is expected.
'timeout' is optional and is the timeout in milliseconds.
If you are accessing a website 'query$' can be something as simple as "GET / HTTP" which will retrieve the
default page for that website. Your program will then be responsible for picking out the data that you want
from within the response.
Finally, you close the connection with:
WEB CLOSE TCP CLIENT

PicoMite Benutzerhandbuch, MMBasic BASIC Interpreter Ver 6.00.01, Seite 77:
Implementieren eines TCP-Clients
Das WebMite kann auch als TCP-Client fungieren, um Daten von einem entfernten Server anzufordern. Dies wird mit drei
Befehlen verwaltet. Der erste ist:
WEB OPEN TCP CLIENT Domain$, PortNumber
Dies öffnet eine TCP-Verbindung zu Domain$ (zum Beispiel "openweathermap.org") unter Verwendung der angegebenen
PortNumber (normalerweise 80 für eine Webseite).
Wenn die Verbindung geöffnet ist, können Sie mit diesem Befehl eine oder mehrere Abfragen senden:
WEB TCP CLIENT REQUEST query$, inbuf [, timeout]
Die Anfrage, die gesendet werden soll, ist „query$“ und die Antwort wird in „inbuf“ gespeichert, was normalerweise ein langer String ist
Variable wie buff%(4096/8). Die Größe dieses Puffers (in Bytes) begrenzt die Menge der vom Server empfangenen Daten
und sollte erhöht werden, wenn mehr Daten erwartet werden.
timeout' ist optional und gibt die Zeitüberschreitung in Millisekunden an.
Wenn Sie auf eine Website zugreifen, kann 'query$' etwas so Einfaches wie "GET / HTTP" sein, was die
Standardseite für diese Website abruft. Ihr Programm ist dann dafür verantwortlich, die Daten, die Sie
wünschen, aus der Antwort herauszusuchen.
Zum Schluss schließen Sie die Verbindung mit:
WEB CLOSE TCP CLIENT

Matthias
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025