Blynking an IoT Yunshan ESP8266 250V 10A AC/DC WIFI Network Relay Module

wifi_relay1

I purchased a few of these Yunshan Wifi Relays through ebay for approximately $7.50US. The device should be perfect for use in simple IOT projects which require controlling household AC power. The onboard JQC-3FF relay is rated to 250VAC or 30VDC at up to 12A. There are routered slots between the high voltage PCB traces for circuit isolation and arc-over protection. Transient voltage suppression is incorporated on both the board power supply and the photocoupler (see description below) input line.

The device requires a power supply between 7 and 30V DC. I unsuccessfully attempted to run it with an inexpensive 5V, 2A wall-wort, even though the onboard MP2303 buck converter is rated down to 4.8V. I did get it to operate successfully using a 9VDC wall-wort.

The device contains an integrated ESP8266-12E, but appears to only use the GPIO4 and GPIO5 pins. That was a disheartening discovery because it discards a significant amount of functionality inside the ESP8266 WIFI module. Hence the ESP8266 low power, wake from sleep provisions (where GPIO16 and RESET need to be linked together) would require some skillful soldering of the module’s exposed pins.

The good news is, programming the module is very easy, as I discuss later. I also found the overall build quality of my device to be above the typical level found on ebay-sourced Chinese electronics.

The ebay listing contained a link to a zip file, entitled U4648-datasheet, which contained example programs, schematics, and a Chinese manual. Through the Google translation service I managed to translate the manual, but there’s no reason to do that, as there isn’t much there. More information can be learned from a quick study of the schematic and the board itself.

Module Description
The Chinese manual presents the following limited module description:

wifi_relay3

1 – The power input terminals.
2 – The relay output terminals.
3 – IO input terminal.
4 – Enter the status indicator, IO input high when lit, blue light.
5 – The relay output status indicator, the relay is turned on, the red light.
6 – TTL serial output.
7 – Boot mode selection jumper.

Board Connectors

Here are the connections on my board:

wifi_relay2

A: 7-30V+ DC power supply
B: Power supply ground
C: Normally closed (NC) relay contact
D: Common (COM) relay contact
E: Normally open (NO) relay contact
F: 5V+ out
G: ESP8266 GPIO5 Optocoupler Input
H: Ground (isolated optocoupler input)

AP MODE Webpage

I was easily able to connect a 9V power supply to the A-B connector (see above picture and connector description) and control the device via WIFI. To do this, simply connect your computer or phone to the yunshan_wifi_xx_xx_xx network (where it appears the xx are hexadecimal numbers pulled from the ESP8266 MAC address). My device responded to the supplied password of yunshan123456789. Once a connection was established, I simply entered the IP address of 192.168.4.1 into my browser. Once there, I was greeted by a Chinese web page, the translation of which appears below. From this webpage, I was able to open and close the relay. The status of the GPIO5 optocoupler input is also displayed on this webpage.

wifi_relay4

Since I have big IOT home automation plans for these devices, my next task was to attempt a re-program of the onboard ESP8266 module. For a quick test, I uploaded the traditional Arduino IDE ESP8266 blink program, and was rewarded with a 1Hz blinking blue LED on the ESP8266 module.

Program Upload

On the lower left portion of the PCB is a section that grants access to the ESP8266 pins for programming (see the above photo). These same pins are also useful for TTL serial output purposes (debugging, etc.). Separate 2 and 3-pin headers will need to be soldered into these connector holes (labeled P5 and P6). The ESP8266 GPIO4 controls the relay through a 2N3904 transistor. Setting GPIO4 high, causes the relay to close the NO contact with Common and the NC contact to open. Additionally, taking connector “G” high causes GPIO5 to also go low isolated via a PC817 photocoupler. On my board the blue LED is connected to GPIO2, and can be illuminated by pulling the pin low.

To program the ESP8266 module, I connected the TX, RX and ground pins of connector P6 to a SparkFun USB FTDI programmer, and jumped the two pins of connector P5 together when I was ready to upload. Connector P5 grounds GPIO0 and GPIO15, sending the device into bootloader mode. If you have trouble programming the ESP8266 like I did on the first attempt, ensure you also ground your FTDI device through the P6 connector.

A very good introduction to the ESP8266 module can be found here. Excellent programming information for the individual ESP8266 modules is also widely available (two examples: ESP8266-01 and ESP8266-12e).

Board Schematic

wifi_relay_sch

Blynk Relay Control Application

/*************************************************************************
 * Title: Simple ESP-8266 blynk/yunshan wifi relay control
 * File: esp8266_yunshan_relay.ino
 * Author: James Eli
 * Date: 12/25/2016
 *
 * This program controls a Yunshan wifi relay module communicating through 
 * the onboard esp-8266-12e module. The module is controlled from the
 * internet via the Blynk cloud app. 
 * 
 * Notes:
 *  (1) Requires the following arduino libraries:
 *      ESP8266
 *      Blynk
 *  (2) Compiled with arduino ide 1.6.12
 *  (3) Uses three Blynk app widgets:
 *       V0: button configured as a switch.
 *       V1: led.
 *       V2: led.
 *************************************************************************
 * Change Log:
 *   12/25/2016: Initial release. JME
 *   12/31/2016: Added input pin status. JME
 *   01/15/2017: Added volatile. JME
 *************************************************************************/
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// Esp8266 pins.
#define ESP8266_GPIO2    2 // Blue LED.
#define ESP8266_GPIO4    4 // Relay control.
#define ESP8266_GPIO5    5 // Optocoupler input.
#define LED_PIN          ESP8266_GPIO2
// Blynk app authentication code.
char auth[] = "***";
// Wifi SSID.
const char ssid[] = "***";
// Wifi password.
const char password[] = "***";    
// Flag for sync on re-connection.
bool isFirstConnect = true; 
volatile int relayState = LOW;    // Blynk app pushbutton status.
volatile int inputState = LOW;    // Input pin state.

void setup() {
  pinMode( ESP8266_GPIO4, OUTPUT );       // Relay control pin.
  pinMode( ESP8266_GPIO5, INPUT_PULLUP ); // Input pin.
  pinMode( LED_PIN, OUTPUT );             // ESP8266 module blue LED.
  digitalWrite( LED_PIN, LOW );           // Turn on LED.
  Blynk.begin( auth, ssid, password );    // Initiate Blynk conection.
  digitalWrite( LED_PIN, HIGH );          // Turn off LED.
}

// This function runs every time Blynk connection is established.
BLYNK_CONNECTED() {
  if ( isFirstConnect ) {
    Blynk.syncAll();
    isFirstConnect = false;
  }
}

// Sync input LED.
BLYNK_READ( V2 ) {
  CheckInput();
}

// Blynk app relay command.
BLYNK_WRITE( V0 ) {
  if ( param.asInt() != relayState ) {
    relayState = !relayState;                  // Toggle state.
    digitalWrite( ESP8266_GPIO4, relayState ); // Relay control pin.
    Blynk.virtualWrite( V1, relayState*255 );  // Set Blynk app LED.
  }
}

// Debounce input pin.
int DebouncePin( void ) {
  // Read input pin.
  if ( digitalRead( ESP8266_GPIO5 ) == HIGH ) {
    // Debounce input.
    delay( 25 );
    if ( digitalRead( ESP8266_GPIO5 ) == HIGH )
      return HIGH;
  }
  return LOW;
}

// Set LED based upon state of input pin.
void CheckInput( void ) {
  if ( DebouncePin() != inputState ) {
    Blynk.virtualWrite( V2, inputState*255 );
    inputState = !inputState;
  }
}

// Main program loop.
void loop() {
  Blynk.run();
  CheckInput();
  //yield(); //Updated: 3/8/2017
}

TCP Client Demo

Here is a basic server which responds to TCP client HTTP GET commands (added 1/8/17):

#include <ESP8266WiFi.h>

// Esp8266 pinouts
#define ESP8266_GPIO2    2  // Blue LED.
#define ESP8266_GPIO4    4  // Relay control. 
#define ESP8266_GPIO5    5  // Optocoupler input.
#define LED_PIN          ESP8266_GPIO2
// WiFi Definitions.
const char ssid[] = "***";
const char pswd[] = "***";
WiFiServer server( 80 );
volatile int relayState = 0;      // Relay state.

void setup() {
  initHardware();
  connectWiFi();
  server.begin();
}

void GetClient( WiFiClient client ) {
  // Read the first line of the request.
  String req = client.readStringUntil( '\r' );
  Serial.println( req );
  client.flush();

  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\n";

  if ( req.indexOf( "OPTIONS" ) != -1 ) {
    s += "Allows: GET, OPTIONS";

  } else if ( req.indexOf( "GET" ) != -1 ) {
    if ( req.indexOf( "open" ) != -1 ) {
      // relay on!
      s += "relay on!";
      relayState = 1;
      digitalWrite( ESP8266_GPIO4, 1 ); // Relay control pin.
    
    } else if ( req.indexOf( "close" ) != -1 ) {
      // relay off!
      s += "relay off!";
      relayState = 0;
      digitalWrite( ESP8266_GPIO4, 0 ); // Relay control pin.
    
    } else if ( req.indexOf( "relay" ) != -1 ) {
      if ( relayState == 0 )
        // relay off!
        s += "relay off!";
      else
        // relay on!
        s += "relay on!";

    } else if ( req.indexOf( "io" ) != -1 ) {
      if ( digitalRead( ESP8266_GPIO5 ) == 0 )
        s += "input io is:0!";
      else
        s += "input io is:1!";
    
    } else if ( req.indexOf( "MAC" ) != -1 ) {
      uint8_t mac[WL_MAC_ADDR_LENGTH];
      WiFi.softAPmacAddress( mac );
      String macID = String( mac[WL_MAC_ADDR_LENGTH - 5], HEX) + String( mac[WL_MAC_ADDR_LENGTH - 4], HEX) +
                     String( mac[WL_MAC_ADDR_LENGTH - 3], HEX) + String( mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
                     String( mac[WL_MAC_ADDR_LENGTH - 1], HEX) + String( mac[WL_MAC_ADDR_LENGTH], HEX);
      macID.toUpperCase();
      s += "MAC address: " + macID;

    } else
      s += "Invalid Request.<br> Try: open/close/relay/io/MAC";

  } else 
    s = "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\n";
         
  client.flush();
  s += "</html>\n";

  // Send the response to the client.
  client.print( s );
  delay( 1 );
  Serial.println( "Client response sent." );
}

void loop() {
  // Check if a client has connected.
  WiFiClient client = server.available();
  if ( client ) 
    GetClient( client );
}

void connectWiFi() {
  byte ledStatus = LOW;
  Serial.println();
  Serial.println( "Connecting to: " + String( ssid ) );
  // Set WiFi mode to station (as opposed to AP or AP_STA).
  WiFi.mode( WIFI_STA );

  // WiFI.begin([ssid], [passkey]) initiates a WiFI connection.
  // to the stated [ssid], using the [passkey] as a WPA, WPA2, or WEP passphrase.
  WiFi.begin( ssid, pswd );

  while ( WiFi.status() != WL_CONNECTED ) {
    // Blink the LED.
    digitalWrite( LED_PIN, ledStatus ); // Write LED high/low.
    ledStatus = ( ledStatus == HIGH ) ? LOW : HIGH;
    delay( 100 );
  }

  Serial.println( "WiFi connected" );  
  Serial.println( "IP address: " );
  Serial.println( WiFi.localIP() );
}

void initHardware() {
  Serial.begin( 9600 );
  pinMode( ESP8266_GPIO4, OUTPUT );       // Relay control pin.
  pinMode( ESP8266_GPIO5, INPUT_PULLUP ); // Input pin.
  pinMode( LED_PIN, OUTPUT );             // ESP8266 module blue LED.
  digitalWrite( ESP8266_GPIO4, 0 );       // Set relay control pin low.
}
Advertisements

About Jim Eli

µC experimenter
This entry was posted in iot and tagged , . Bookmark the permalink.

59 Responses to Blynking an IoT Yunshan ESP8266 250V 10A AC/DC WIFI Network Relay Module

  1. Peter says:

    Hi Jim,
    her article gives me hope. Try now for several days to find a solution to reprogram this circuit.
    First of all, all circuits that I bought were broken by the hardware. All the coils had been soldered incorrectly and the fuses were also broken.
    Repaired, I can now AT commands and adjust also. But I can not take a separate function from any of the circuits.
    The circuit can not be reprogrammed.
    My question to you:
    You set the P5 (jumper) permanently during programming and RX TX = 1: 1 or RX cross TX.?
    I have tried various 3.3 V FTDI’s some work not at all (seemingly felled cn).
    Do you have a solution for me?
    thank you
    Peter

    Sorry 😦 Google Translate

    • Jim Eli says:

      Peter,
      So sorry you are having these problems. My devices worked correctly from the beginning. I hope I can be of some assistance.
      (1) You must connect a separate and appropriate power supply independent of the FTDI programmer when programming. The FTDI programmer probably has insufficient power.
      (2) P5 connector is meant to be jumped together only during programming. When programming is complete, remove the jumper and reboot.
      (3) Connect your FTDI RX to P6 TX, and FTDI TX to P6 RX, and FTDI ground to the ground.
      (4) Often when I attempt to program, the download will not occur. In this case, I simply remove the power from the device and reboot with the jumper in place, and then re-attempt the download. There is no need to disconnect the FTDI programmer. This usually works.
      (5) I program via the Arduino IDE. Make sure you are selecting a generic ESP8266 module.
      (6) Try programming at lower baud rates before trying a higher rate.
      Jim

  2. Hi Peter, same with me: fuses appear to be broken and coils rotated 90 degrees. weird…

    • Jim Eli says:

      The devices I received have a single 5-pin JQC-3FF relay. The pins are asymmetrical, so nearly impossible to solder wrong (but I guess its possible). Also my boards have just a single fuse on the 30VDC board power input line. Is it possible someone mistakenly applied AC power here?

      • Peter says:

        Hello,
        Sorry Jim a little addendum:
        It’s been told wrong. It is the coil of the voltage regulator it is incorrectly soldered, it creates a short circuit and the fuse 500mA is destroyed.
        Three unsung boards had the fuse already broken.
        There was no alternating voltage, I’m an electronics engineer
        My board is working, my problem was the reset. The board may only be reset shortly before the end of the slow compilation? (Timeout)
        thank you
        Peter

    • Hi Peter, can you show me a before/after picture?

  3. Kenanda says:

    Just a question…. this yunshan device is supposed to receive tcp commands. The question is… , what command do I use to turn the relay on and off with my tcp client? I did not find it.

  4. what is the command do I use to turn the relay on and off with my tcp client? I did not find it.

  5. Ferenc Tolnai says:

    hi guys, I purchased one of these from china.
    I can only get start if i bypass the fuse F1, by connecting the + to the right side of the diode ( M7 ) should this not be a fuse instead as?

    • Ferenc Tolnai says:

      It turned out that the M7 diode was soldered in in wrong direction. I turned it around 🙂

      • Ivan Vachovsky says:

        Yes. I had this M7 diode experience as well with unit purchased from Amazon. Furthermore, this unit came blank (not programmed) and I returned it. Over 20 different vendors are selling same device on eBay. Mostly from China and 1-2 local in the U.S. Bought another one from US Vendor on eBay. I managed to activate the web interface for this one, but FTP doesn’t work. Port 8000 is open and listening but commands like “relay on!” or “open relay!” do not work.

  6. Ivan Vachovsky says:

    Jim,
    Like you I had big plans for this device and purchased 5 from Amazon along with 5 12V DC power supplies..
    Unlike you I’m not set to do the programming of it.
    I trusted some Amazon reviews that the device is not perfect but workable and can be accessed by HTML and FTP similar to what you describe.
    To my great disappointment the device creates only own unsecured WiFi called AI-THINKER. It has IP address 192.168.4.1 and does respond to pings. That’s all. I scanned for open ports/services – none. I specifically looked for TCP service on port 8000 (link from Amazon review mentioned this port specifically for FTP) – none. No web service either. It seems that this is blank AI-THINKER device not programmed with Yunshan features as described at Amazon.
    Based on your experience, am I missing something here or should I return everything to Amazon.
    Did you get yours from US vendor on eBay or from China?

    • Jim Eli says:

      Ivan,
      I didn’t spend much time playing with the installed software, other than to test the AP mode webserver. I briefly looked at the demo software I mention in the download zip file (see link in blog). Response for a TCP client appears to be implemented in an entirely different program than the version that was installed on my devices. My guess is that what you are looking for isn’t there. I suggest you install what you need, as programming is really easy (especially when using the Arduino IDE). Good luck.
      Jim

  7. Ivan Vachovsky says:

    Jim,

    Thanks for the response. Appears that Amazon is selling visually the same device with different programming (blank actually) while the description is for Yunshan programmed device.
    Anyhow, I returned it to Amazon and bought true Yunshan device from eBay.
    It matches your description above perfectly all the way down to your “Program Upload” paragraph.
    Since I have no intention of uploading programs (not qualified for that) I was wondering if you can help me setting up the device. I can connect to it trough its own wifi network to address 192.168.4.1. I can see the web page, however none of the buttons work. Browser tells me “No Internet connection”. Of course no Internet since I’m connected to the device alone. I also managed connecting to TCP port 8,000 however it will not respond to any of the commands “relay on!” or off. So basically I’m stuck again.

    Thanks,

    Ivan

  8. Ivan Vachovsky says:

    P.S. Managed to connect the device to my WiFi network. I don’t know why but it needed Internet connection for that. So I used a desktop computer with wired connection to the Internet and WiFi connection to Yunshan WiFi.
    Now I can control the relay over the web interface. However the TCP commands “relay on!” and “relay off!” do not work.
    My postings seem somewhat off topic I just couldn’t find a better place to share my experience and help others who may struggle with the same Chinese problems.
    My objective is to integrate the relay in my IoT system by standard means (HTTP or FTP control) There are many other solutions on the market however most of them are proprietary with secret hidden protocols and hard to integrate.

    • Nikola Stojanovic says:

      Hi Ivan, I wasn’t able to connect it to my WiFi network. I’ve put the network ID and password in Yunshan WiFi settings over 192.168.4.1 web interface, using my laptop. If I try to connect to web interface over my phone, the commands doesn’t work, because no internet is available. Is there a catch?

  9. Ivan Vachovsky says:

    Hi Jim,

    It’s me again. As the French proverb goes “Appetite comes with the eating”. I have the Yunshan relay completely under control now incl. commands and responses. Thank you again for the help on the commands.
    I’m now interested in extending the functionality as explained below. Is it possible for you to write the code that is needed and guide me step by step of how to upload it. Contact me privately how to get paid for the time and effort.
    In many instances one needs to introduce “timeout” feature when controlling significant power trough home automation – examples – pool pumps, sauna, steam room, electric room heaters etc. It can be implemented trough software but it defeats the purpose since the timeout is there to kick-in when the controlling software/system fails. That’s why it is preferably that the timeout is implemented outside of the control system and is build-in in the firmware/hardware at lower level.
    Long story short I need the relay to execute a command like this

    relayon, t

    where t= timeout in seconds,
    if t=0 then no timeout
    the relay will turn on and than turn off automatically after t seconds

    In addition to timeouts, this function will come handy in creating short pulses that are necessary to operate some devices such as garage doors for example.

    of course such function can be achieved by adding external timer relays, but it wouldn’t be an elegant solution.

  10. Zeric E says:

    Ivan, I have a suggestion for you if you haven’t already worked out another solution. There is firmware for the esp8266 called Esp Easy that has considerable flexibility to perform different tasks in different esp8266 based hardware without requiring re-compiling or reloading it into the device. It can be downloaded in binary form so you don’t need to setup the Arduino environment to compile or load it into a device. There is a simple windows tool to upload the firmware to the esp8266. I have successfully loaded it into this relay board as well as other esp8266 based devices and been able to do what I needed to do with my home automation system.

    Even though I have a working Arduino IDE that I’ve used to do things with the esp8266, my go to solution is Esp Easy for these simple esp8266 IOT devices.

    For the USB/TTL hardware interface, I prefer ch340g based converters even though I own FTDI and CP2102 ones as well. The ch340g boards are cheap and I’ve never had any issues with them (they also work fine with the Arduino IDE). Whatever interface you use, be sure it can work with 3.3v logic levels, most boards have a switch or jumper to go between 3.3v and 5v. If you have an Arduino UNO, that should also work to do the programming but it’s not as straight forward as a stand alone USB/TTL converter and I haven’t tested it with the uploader.

    If this is a path you want to explore, I’ll be happy to give you some pointers.

  11. Ivan Vachovsky says:

    Zeric, Thanks a lot for the proposal. I did hire a freelancer to do the programming for me but I’m also curious and eager to try Esp Easy for other projects possibly. I will appreciate a guidance of how to do it. I have this device for uploads – Qunqi 3.3V 5.5V FT232RL FTDI Usb to TTL Serial Adapter.

    • Zeric E says:

      Ivan, Your Qunqi adapter should be fine as long the device driver is working okay with your PC. Most people on Amazon didn’t seem to have any issue with it. Just be sure you have the jumper set to 3.3v. There is quite a bit of information on Esp Easy here: http://www.letscontrolit.com/wiki/index.php/ESPEasy

      Esp Easy was originally designed for sensors, but it works well controlling simple on/off things like relays too. Enabling “rules” in the Tools > Advanced menu enables it to perform some simple definable autonomous function (ex. when this pin changes state, turn on this other pin for XX seconds). I use it with an MQTT broker, but other types of access are also possible such as HTTP. I’ve been impressed with the flexibility without having to re-compile/upload.

      It’s worth taking a look at when you have a chance.

  12. Larks says:

    Hi jim, in your opinion is it possibile use the Optocoupler Input for a 220v Main sense?

  13. Ivan Vachovsky says:

    This will not burn anything but is not a good solution because of the sine wave there will be periods of low current and false readings of 1 when power is present. First determine what current I holds solid steady 0. Say it is 1 ma. Than build a simple rectifier one diode (better 4 diodes bridge widely available) and one capacitor will do the job for such low current. Than measure the voltage on your rectifier say 200 V. Connect the IO input trough a resistor R. R=U/I. For the example R = 200/0.001 = 200Ko. Check the power on the resistor (approximately ignoring the voltage drop on the optocoupler) P=U*I. For the example P=200*0.001= 0.2 W. This is acceptable power level, however if the real values show power over 1.0 W it may get too hot.

    • Larks says:

      But the input has just an R of 4,7k on input in the schema… In this case is sufficient a Diode before? Which task has the parallel diode(D5)?
      Thanks for info, i’m newbie 🙂

  14. Ivan Vachovsky says:

    The parallel diode prevents negative portion of the sine wave from hitting the opto-coupler. This schema will work if implemented completely as shown. It will not work if you implement only the portion that feeds the opto-coupler and leave the rest to Yunshan board. Follow my instructions above for a much simpler solution for the Yunshan board.

  15. Nick P says:

    Cool little project Jim, thanks for leaving it for people to try.
    I’ve successfully burnt your code to my Yunshan board and made a small Blynk app to control it. The only thing is that it loses the wifi connection after a period of time and doesn’t seem to attempt to re-connect so I just get a message from Blynk telling me that “device went offline at xxxx” and I have to reboot the board to get everything working again. Any ideas?

    • Jim Eli says:

      Nick,

      My device has dropped offline a few times too. I haven’t had the time to fully investigate this, and I’m open to suggestions. Here are a few of my initial thoughts: (1) Is the power supply adequate? (2) Is it an issue with Blynk, ESP8266 or the WIFI router side? (3) Would the the ESP8266 boot ROM log shed any light?

      However, since some of my other devices don’t have this problem, I’m thinking it might be a HW/PS issue.

      Jim

  16. Nick P says:

    Hi Jim,
    The power supply is fine (it’s a regulated lab power supply, easily big enough). The router to ESP Wifi connection is strong and so I doubt that’s a problem. Yesterday it was online for some hours and then went off shortly after midnight. This morning I tried to reboot the unit a few times without success (just blue LED showing no connection). I tried re-flashing the code to the ESP and that worked.
    The only thing I can think from my end is that our connection to the internet can drop out for a minute or two (this often happens around the time the unit went offline, just after midnight) so hence my earlier question. I’m afraid code-wise I’m a newbie at this stuff so can’t really help de-bug at that level. I’ve tried a couple of Sonoff devices in the same place and they work fine.
    Wonder if anyone else has had issues like this?
    Thanks!

  17. Nick P says:

    It’s 12V.
    Will try the yield thing and let you know. Thanks

  18. Nick P says:

    Well, code is still working after removing the yield. Will leave the module on and unattended and let you know. In fact I might try turning the wifi network off for a minute and see if the module tries to re-connect by itself.

  19. Nick P says:

    Just tried turning off the wifi and the module re-connects and starts working again when the wifi comes back up.

  20. Nick P says:

    Hi Jim,
    Well, that seems to have sorted it. The module was on for over 24hrs without a problem. Whilst doing other stuff nearby I knocked the power supply leads a couple of times and the power was lost briefly; both times the module powered back up and connected to wifi and the Blynk server within 3-4 seconds. I’ll keep you posted if anything changes. Thanks!

  21. Bart says:

    Hi,

    Did you really manage to make the relay switch? I’ve bought three of those network boards but no luck switching the relay. After flipping a diode where a fuse needs to be, I can make everything work and when I switch the relay the output LED will go on but the relay does not switch. After removing the MP2303 Buck converter on one of them and connecting 5V directly to the LM1117-3.3V it does switch the relay. So I checked the output of the MP2303 on the other two boards and it seems to be configured to give 3V3. So it provides 3V3 to the LM1117-3V3 which gives 2V5 on his output, enough to power the ESP8266 but the 3V3 is to little to switch the relay…
    I checked the values on the boards and they are all the same as on your schematic. It’s just weird I’m having this issue on three boards?

    • Bart says:

      After reading Peter his comment, I can confirm that the coil of the voltage regulator was placed incorrect. Although there are no fuses but diodes on the boards, replacing the coil solved the issues.
      Conclusion: bad build quality although different suppliers..

  22. Bart says:

    BTW, I think when you replace the diode with a real fuse you will not have a voltage drop of 0.7V over the diode. Giving you the possibility to use a 5V power supply (5-0.7 = 4.3V which is below the 4.8V minimum)

  23. Ferenc Tolnai says:

    now I got hold of another one, this has Resistor R8, 52kOhm instead of 4.7k, so the input doesnt work, what a quality…. how difficult would it be to test 2 out of the 2 functions.

  24. Nick Procktor says:

    It seems that there’s a large variation in the build quality of these boards. I bought mine (just one) from Ebay and it worked first time. The link is here…

    http://www.ebay.co.uk/itm/142240467734

  25. Nick Procktor says:

    Also, for the optocoupler input you need to provide a second ground reference. This input is totally isolated and needs it’s own ground and voltage supply to trigger the opto.

  26. Timo says:

    thank you very useful information – mine had has well diode soldered wrong around.

  27. Nikola Stojanovic says:

    Hi, I intended to hook up the device to my home network and access it with TeamViewer. There is a problem with hooking up. I’ve managed to access the web interface via 192.168.4.1 and I’ve entered user name and password of my home wireless network. However, I’m only able to change the state of relay if I’m directly connected to its wireless network (yunshan_wifi_xx_xx_xx) via laptop. This means that I cannot change its state from my phone, since the phone disconnects from home wireless network to connect with relay wireless network. It seems that relay is not connected to home wireless network at all.
    Did anyone have similar problem?

  28. Nick P says:

    If you can program the board using an RS232 converter and PC then upload the code at the top of this page. You then use a program on your phone called Blynk and use that to control the module. The software that comes already installed when you buy the board is not very good and just a demo really, in my opinion.

    • Nikola Stojanovic says:

      Thanks, Nick. That’s too complicated for me, though. I’m just a guy trying to find a way to make it work. 🙂 Have you tried to change the state of the relay over the web with its pre-installed software, as described in Chinese manual?

  29. Michael Barkley says:

    Since my board, does not seem to produce an SSID, when it’s powered up, am I correct in thinking it’s not properly programmed?

    • Jim Eli says:

      Make sure you provide enough voltage to the board, the esp8266 needs an appropriate amount of juice before it works properly. Otherwise I would assume so.

      • Michael Barkley says:

        Thanks, I have been merely using a 9 volt battery, will try a 12 volt source instead.

  30. Stefan says:

    Hi Jim,
    did you managed to read the input correctly? For me, reading GPIO5 is always “1”, even if I connect “F” to “G”.
    I flashed nodeMCU to my board, anything else is running fine, also switching the relay. Putting GPIO5 to OUTPUT-State is also possible, the little blue LED can be put on and off.

    Anybody else some experience with reading input?

    • Jim Eli says:

      The optocoupler has a (properly) isolated ground, so the 5V out is reference a different ground. Therefore, simply connecting F to G will do nothing.

      • Stefan says:

        Thank you Jim,
        that solved my problem. Connecting the external ground (“B”) to connector “H” did the job.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s