Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By GeordieGuy
#87645 Hi all! I'm trying to get one, any, of the pins on this module to go high. The module looks like this;

IMG_5358.jpg


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...
You do not have the required permissions to view the files attached to this post.
User avatar
By schufti
#87650 since you have to ask such thing and mix up esp modules (ESP-12F) and boards (WeMos XYZ):
use the correct board setting: WeMos (mini???) and correct pin naming convention D? (like D0, D1,...) as found on the board.
then your pin control will start working