Can't get any pin control on ESP-12F
Posted: Thu Jun 25, 2020 1:01 am
Hi all! I'm trying to get one, any, of the pins on this module to go high. The module looks like this;
And is allegedly an ESP-12F, but its pinout seems slightly different to what I've been able to look up (there's a 5V out that isn't in most of the images).
My code, using Arduino IDE, looks like this;
The last few lines are to try and diagnose, but when I try to detect a pin going up and down every second, I can't. What am I doing wrong? The rest of the code works fine...
And is allegedly an ESP-12F, but its pinout seems slightly different to what I've been able to look up (there's a 5V out that isn't in most of the images).
My code, using Arduino IDE, looks like this;
Code: Select all
#include <ESP8266WiFi.h>
const char *ssid = "MYSSIDREMOVEDFORFORUMPOST";
const char *password = "LIKEWISE";
WiFiServer server(80);
const int bourbon_pin(4);
const int vermouth_pin(5);
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println();
Serial.println();
Serial.println("Manhattan project v1.0 - Geordie Guy 2020");
Serial.println();
Serial.print("Connecting to wifi network ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected to ");
Serial.println(ssid);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Starting server...");
server.begin();
Serial.println("Server started. Listening for command on port 80");
Serial.println();
Serial.println();
Serial.println("Setting up bourbon pump relay on GPIO 1 and sweet vermouth pump relay on GPIO 2");
pinMode(bourbon_pin, OUTPUT);
pinMode(vermouth_pin, OUTPUT);
digitalWrite(bourbon_pin, 0);
digitalWrite(vermouth_pin, 0);
Serial.println("Both pumps initaliased and set to off.");
}
void loop()
{
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("client connected, waiting for instructions");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
if (req.indexOf("/make") != -1){
Serial.println("Received instruction to make a Manhattan, running pumps...");
} else {
Serial.println("Got an invalid instruction?");
client.stop();
}
client.flush();
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nMaking Drink ";
s += "</html>\n";
// Send the response to the client
client.print(s);
delay(1);
Serial.println("Client disonnected");
delay(1000);
digitalWrite(bourbon_pin, 1);
delay(1000);
digitalWrite(bourbon_pin, 0);
delay(1000);
digitalWrite(bourbon_pin, 1);
delay(1000);
digitalWrite(bourbon_pin, 0);
delay(1000);
digitalWrite(bourbon_pin, 1);
delay(1000);
digitalWrite(bourbon_pin, 0);
}
The last few lines are to try and diagnose, but when I try to detect a pin going up and down every second, I can't. What am I doing wrong? The rest of the code works fine...