![]() |
Forum Index : Microcontroller and PC projects : Webmite URL access
Author | Message | ||||
Gerad Regular Member ![]() Joined: 10/01/2024 Location: GermanyPosts: 49 |
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 StatesPosts: 3309 |
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: GermanyPosts: 49 |
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: GermanyPosts: 459 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |