So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Alex90
#77954 Dear all,

I need help on a small project I'm working on at the moment. In our house the shadings are controlled via a homepage of a local network which goes on my nerve because I always have to switch between WiFi's on my phone. So I thought I could learn my NodeMCU (Arduino IDE) to controll the shadings.

So far I can access the network and also connect to the homepage but I'm stuck at virtually pressing the buttons (which are actually images as far as I know).

I accessed the source code of the hompage. I think what I would need to do is to execute the highlighted "set_request" command:

SourceCode.png


Does anybody know an easy solution for my problem?

Thank you so much and kind regards,
Alex


P.S.: The code I use to access the homepage.

Code: Select all#include <WiFiClient.h>

#include <ESP8266WiFi.h>


const char *ssid =  "exampleNetwork";     // replace with your wifi ssid and wpa2 key
const char *pass =  "PASSWORD";

IPAddress server(192,168,82,10);

WiFiClient client;
 
void setup()
{
       Serial.begin(9600);
       delay(10);
               
       Serial.println("Connecting to ");
       Serial.println(ssid);
 
       WiFi.begin(ssid, pass);
       while (WiFi.status() != WL_CONNECTED)
          {
            delay(500);
            Serial.print(".");
          }
      Serial.println("");
      Serial.println("WiFi connected");
      Serial.println('\n');
      Serial.println("Connection established!"); 
      Serial.print("IP address:\t");
      Serial.println(WiFi.localIP());         // Send
      while(!client.connect(server, 80)){
        delay(500);
        Serial.print(".");
      }
  Serial.println();
  Serial.println("Connected");
}
 
void loop()
{     
 
}
You do not have the required permissions to view the files attached to this post.
User avatar
By schufti
#77990 looks like the blinds controller open an extra WiFi (are not connected to his home WiFi).
He most likely wants to build a small esp8266 powered http client that connects with the blinds WiFi and pushes the virtual button.
Would be less effort to look at the user manual of the controller to find how to get them into the domestic WiFi...
User avatar
By Alex90
#77996 Hi!

Just as schufti said, it's an extra WiFi. The problem is, I'm only a user of this system which is shared with other people. So I don't have access to any manual and can also not get in into my personal WiFi.

I will try the suggestion of philbowls and try to learn more about javascript and HTML.
Thank you very much for your help!
User avatar
By Alex90
#78009 Hi again,

I just wanted to tell you that I finally got it working :-) I will birefly summarize how I did, maye that's useful for somebody else.

I used fiddler to get the signal which is emitted from the pressed button. (Thanks PhilipBowles!) In my case, command.php is called when you press the button, and for instance "name=blind_1_up" is posted (In Fiddler you find it under Inspectors -> TextView). The content type can be found at Inspectors -> RAW.

Then this can easily be done by the NodeMCU:

Code: Select all#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>


const char *ssid =  "SSID";     // replace with your wifi ssid and wpa2 key
const char *pass =  "******";

IPAddress server(192,168,82,10);
int port = 80;
WiFiClient client;

void setup() {
  // put your setup code here, to run once:
       Serial.begin(115200);
       delay(10);
       WiFi.mode(WIFI_STA);
       
       Serial.println("Connecting to ");
       Serial.println(ssid);
 
       WiFi.begin(ssid, pass);
       while (WiFi.status() != WL_CONNECTED)
          {
            delay(500);
            Serial.print(".");
          }
      Serial.println("");
      Serial.println("WiFi connected");
      Serial.println('\n');
      Serial.println("Connection established!"); 
      Serial.print("IP address:\t");
      Serial.println(WiFi.localIP());         // Send
   
  Serial.println();
  Serial.println("Connected");

}

void loop() {
  if (Serial.available()==1){
    Serial.read();
    HTTPClient http;
    http.begin("http://192.168.82.10/command.php");
    String postData = "name=blind_1_up" ;
   
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");    //Specify content-type header
   
    int httpCode = http.POST(postData);   //Send the request
    String payload = http.getString();    //Get the response payload
   
    Serial.println(httpCode);   //Print HTTP return code
    Serial.println(payload);    //Print request response payload
   
    http.end();  //Close connection
   
    delay(5000);  //Post Data at every 5 seconds
  }
 

}