NodeMCU HTTP communication
Posted: Sat Mar 04, 2017 11:30 am
Hello everyone,
I made a small website with PHP that runs on my computer and all it does it sends posts to the url.
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:
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!
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 all
192.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!