-->
Page 1 of 1

NodeMCU HTTP communication

PostPosted: Sat Mar 04, 2017 11:30 am
by WisterDesigns
Hello everyone,
I made a small website with PHP that runs on my computer and all it does it sends posts to the url.
Code: Select all<?php

   if(isset($_POST['gpio'], $_POST['pinmode'], $_POST['status'])){
      $gpio = $_POST['gpio'];
      $pinmode = $_POST['pinmode'];
      $status = $_POST['status'];
   }

 ?>

<!DOCTYPE html>
<html>
<head>
<title>Home Automation</title>
</head>
<body>
   <form action="index.php" method="get">
      GPIO: <input type="text" name="gpio"><br><br>
      pinMode: <input type="text" name="pinmode"><br><br>
      status: <input type="text" name="status"><br><br>
      <input type="submit" value="submit">
   </form>
   <!--<div>
      <bold>'POST'</bold> Method:
      <input value="">
      <button type="button">POST</button>
   </div>-->
</body>
</html>

I want to connect this to my NodeMCU and my NODEMCU will get the posts and do something with it for example turning on a LED or something in this case.
for example the address is:
Code: Select all192.168.0.205:80/HomeAutomation/index.php?gpio=12&pinmode=0&status=1

how can I save this data in variables with the NodeMCU that it will get this data and save it, the GPIO the PinMode and the Status. Can someone please give me an example of code that does it?
Thanks!

Re: NodeMCU HTTP communication

PostPosted: Mon Mar 06, 2017 2:09 pm
by gbafamily1
This shows how access HTTP arguments using Arduino ESP8266.

viewtopic.php?p=47271

Re: NodeMCU HTTP communication

PostPosted: Tue Mar 07, 2017 9:40 am
by martinayotte
The OP need to clarify on which side he wish the POST is done, because in the above PHP code, it seems to be posted to the PHP server, not posted to the ESP.