0

I have Arduino Uno, and recently obtained ESP8266 WiFi Relay by LC Technology. I tried to look up some information about that on the net, but all the answers / suggested solution didn't work for me. Let me briefly explain the problem.

I have connected this module to arduino in a very simple way:

  • TX -> pin 7
  • RX -> pin 6
  • 5V -> IN +
  • GND -> IN -

Simple code:

#include "Arduino.h"
#include <SoftwareSerial.h>

#define TxPin 7
#define RxPin 6

SoftwareSerial ESPrelay(RxPin, TxPin);

void setup() {
    Serial.begin(9600);
    ESPrelay.begin(9600);

    readRx();

    ESPrelay.println("AT");
    readRx();
}

void loop() {
    Serial.println(ESPrelay.read());
    // this above is constant -1
}

void readRx() {
    String msg = "";
    while (ESPrelay.available()) {
        char rxByte = ESPrelay.read();
        msg += rxByte;
    }
    Serial.println(msg);
    delay(500);
}

I can see WiFi AP created by the module - so I think module itself works fine - communication between Arduino and module is somewhat broken.

I tried all different AT commands, but none of them seems to take an effect (tried switching modes and connecting to home WiFI, but no luck) also, no response is returned. Could someone try and help me debug this issue?

I tried changing 9600 to 115200 when communicating, but no luck with this either.

enter image description here

  • Did you remove the ESP-01 from the relay board? – Juraj Oct 21 '18 at 5:42
  • No, I didn't... – pagenoare Oct 21 '18 at 16:49
  • and how did you wire it then? – Juraj Oct 21 '18 at 19:10
  • imgur.com/a/xoNjI62 - from the left: 1) IN+ -> 5V 2) IN- -> GND 3) RXD -> pin 6 4) TXD -> pin 7 – pagenoare Oct 22 '18 at 13:02
  • connect everything to the pins header, not to screw terminals. the IN terminals are for powering the relay coil – Juraj Oct 22 '18 at 13:33
1

Serial connection requires connecting transmit TX pin to receive RX pin. Your SoftwareSerial pins ar pin 6 RX and pin 7 TX. So your wiring should be esp8266 TX to Uno pin 6 and esp8266 RX to Uno pin 7.

Connect 5 V and ground to the pins header, not to screw terminals. The IN terminals are for powering the relay coil.

Call read readRx() in the loop(). Add delay before sending "AT" in setup to let the esp8266 time to boot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.