Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By 3v0
#80259 This has gotten a bit long but I fear that if I don't provide enough detail much time will be wasted on going over what I have already looked at. Thanks.

S01 + relay modules from AliExpress. The ones that require a jumper and a resistor mod to the relay board. "ESP8266 ESP-12 ESP-12F CH340G CH340 V2 USB WeMos D1 Mini WIFI Development Board D1 Mini NodeMCU Lua IOT Board 3.3V With Pins"

I have them working on a breadboard, no relay, and on a patched relay module. The WiFi/webpage is working but the serial is not. Given that I can flash the ESP I can't see where there is a hardware problem. To 2X check I looked at the TX pin and see no pulses after programming is over, so not a baud rate problem.

Seems one can re-purpose TX and RX as digital IO and they can be changed back to RX, TX. But adding this seems to keep the program from running. That is I can not connect to it on the web. No joy.

Code: Select all//********** CHANGE PIN FUNCTION  TO TX/RX **********
//GPIO 1 (TX) swap the pin to a TX.
pinMode(1, FUNCTION_0);
//GPIO 3 (RX) swap the pin to a RX.
pinMode(3, FUNCTION_0);
//***************************************************


Tried Serial.begin with these parameters and the program still works no serial output. Any ideas ?

Code: Select all 
 Serial.begin(115200,SERIAL_8N1,SERIAL_TX_ONLY);
 



The sketch I am using follows, not mine.

Code: Select all#include <ESP8266WiFi.h>
#include "Creds.h"
 
//const char* ssid = "YOUR SSID"; // fill in here your router or wifi SSID
//const char* password = "YOUR PASSWORD"; // fill in here your router or wifi password
 #define RELAY 0 // relay connected to  GPIO0
WiFiServer server(80);
 
void setup()
{
  Serial.begin(115200); // must be same baudrate with the Serial Monitor
 
  pinMode(RELAY,OUTPUT);
  digitalWrite(RELAY, LOW);
 
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
  // Start the server
  server.begin();
  Serial.println("Server started");
 
  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("https://192.168.1,55/");
  Serial.print(WiFi.localIP());
  Serial.println("/");
 
}
 
void loop()
{
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client)
  {
    return;
  }
 
  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available())
  {
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();
 
  // Match the request
  int value = LOW;
  if (request.indexOf("/RELAY=ON") != -1) 
  {
    Serial.println("RELAY=ON");
    digitalWrite(RELAY,LOW);
    value = LOW;
  }
  if (request.indexOf("/RELAY=OFF") != -1) 
  {
    Serial.println("RELAY=OFF");
    digitalWrite(RELAY,HIGH);
    value = HIGH;
  }
 
  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  this is a must
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.println("<head><title>ESP8266 RELAY Control</title></head>");
  client.print("Relay is now: ");
 
  if(value == HIGH)
  {
    client.print("OFF");
  }
  else
  {
    client.print("ON");
  }
  client.println("<br><br>");
  client.println("Turn <a href=\"/RELAY=OFF\">OFF</a> RELAY<br>");
  client.println("Turn <a href=\"/RELAY=ON\">ON</a> RELAY<br>");
    client.println("</html>");
 
  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");
}