[ESP8266]How I can make a client work one time?

I have e project: A buton on a special case makes a door opener work one time to open the door (not with smart phone; it’s not at every time avialable). The server is programmed on an esp with a relais which will open the door. I could make this work (afaik) but the client is a problem to me. I choosed first the normal httpclient in the examples but this will not work since it works nopthing or more than one time. First it connects to this server (at the local address with the start point “/” in the setrup at all. I have changed the setup to make the connection 10 times and the relais (it is hearable) goes onn the first time inside the wifi connect (before the http connect) and the relais (as the http get is in the loop) goes on and off in turn like the client loops. So first I have to change the server to react nt inside the “/” routine but in any other. So there is the first problem I haven’t solved yet how to make this client ask for any other than “/”. I have changed the server t react too on the two files “REL.on” and “REL.off” from the client but I can’t yet this to the server … only to check from a browser.

Here is the code for the client as far ass I got it yet:

 * BasicHTTPClient.ino
 *  Created on: 24.05.2015

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;

void setup() {

   // USE_SERIAL.setDebugOutput(true);

    for(uint8_t t = 10; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);

    WiFiMulti.addAP("Rx5dsT", "Eqb73nDfmPasWcCgqz81XtHReyuB");


void loop() {
    // wait for WiFi connection
    if((WiFiMulti.run() == WL_CONNECTED)) {
        USE_SERIAL.print("Connection o.k.\n");
        HTTPClient http;

        USE_SERIAL.print("[HTTP] begin...\n");
        // configure traged server and url

        USE_SERIAL.print("[HTTP] GET...\n");
        // start connection and send HTTP header
        int httpCode = http.GET();

        // httpCode will be negative on error
        if(httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
            USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

            // file found at server
            if(httpCode == HTTP_CODE_OK) {
                String payload = http.getString();
        } else {
            USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());

      USE_SERIAL.print("WiFi noch nicht da.\n");

The output from the client (another esp, if not kown yet) I’m not able to show due to some not working. The first reaction of the relais after reset is at the point setup loop at 5 or so and than it is in turn at some point after the LED is on and off on the client device. The server has a routine switching the relais in turn too but is turned off through a software switch so only the client can switch the relais on or off.

I possibly need only an advice to make the server react ‘special’ one time … no more, no less. Or you can help me send the file names ‘REL.on’ and ‘REL.off’ to the server since if it only sent once on a button and back again the time for opening the door is on behalf of a setting in the server too. The button will work of a 2032 lithium battery at the end and thsi was the reason to make it this way … no app, no serching and no recharging of the mobile akku and possibly more than one client later on.

Can you make me any advice to ‘jump to the next level’?



add: If I make the client work one time after reset it will the greatest since than the battery holds for years I think.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.