Category Archives: DIY

LC Technology WiFi Relay

Wanted to get this LC Technology WiFi Relay X4 with Nuvoton MS51FB9AE controller working with Tasmota. It took a bit of tinkering but with the following changes do have it running.

After flashing the ESP01 module supplied with the board with Tasmota the following configuration changes made the module working with the 4 onboard relays so they can be configured with your home automation controller.

Configuring the template:

Name

Based On

GPIO0, 2 , 4 and 5

GPIO1

GPIO3

GPIO9 and higher

LC-ESP01-4R-5V

4 Channel (13)

User

Serial Tx

Serial Rx

None

After configuring the above a rule needs to be added in the console, copy the below code and paste it within the console of Tasmota:

Rule1
on System#Boot do Backlog Baudrate 115200 endon
on SerialReceived#Data=41542B5253540D0A do SerialSend5 5749464920434f4e4e45435445440a5749464920474f542049500a41542b4349504d55583d310a41542b4349505345525645523d312c383038300a41542b43495053544f3d333630 endon
on Power1#State=1 do SerialSend5 A00101A2 endon
on Power1#State=0 do SerialSend5 A00100A1 endon
on Power2#State=1 do SerialSend5 A00201A3 endon
on Power2#State=0 do SerialSend5 A00200A2 endon
on Power3#State=1 do SerialSend5 A00301A4 endon
on Power3#State=0 do SerialSend5 A00300A3 endon
on Power4#State=1 do SerialSend5 A00401A5 endon
on Power4#State=0 do SerialSend5 A00400A4 endon

In order to turn on the rule enter ‘Rule1 1’ in the console and you should be good to go.

Getting this to work was partly based on the following page found on Tasmota’s Github pages: https://tasmota.github.io/docs/devices/LC-Technology-WiFi-Relay/

MySensors Relay Sketch

Using an array rather than the incremental value that is now published on the mysensors.org website. This array method was used in the older version of the relay sketch before the upgrade to version 2.0. In order for upgrading from 1.5 to 2.0 for the relay boxes I’ve build it is far easier to stick to the the array method as most have an single relay board with eight relays on it which doesn’t fit in the current sketch any more.

/*
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
 * Copyright (C) 2013-2019 Sensnology AB
 * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 *
 * DESCRIPTION
 * Example sketch showing how to control physical relays.
 * This example will remember relay state after power failure.
 * http://www.mysensors.org/build/relay
 *
 *******************************
 *
 * UPDATES
 * Version 1.1 - Eugene Dullaard
 *
 * DESCRIPTION
 * This version uses an array of defined PINs like the v1 example
 * sketch did, instead of a startpin and counting from there.
 * The example is currently setup for Arduino Nano with 12 Relays
 * configured. Debugging and repeater is turned off.
 */

// Enable debug prints to serial monitor
//#define MY_DEBUG

// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95

// Enable repeater functionality for this node
//#define MY_REPEATER_FEATURE

#include <MySensors.h>;

/* Just adjust the number of relays to your need, the Maximum is twelve
 * There is no need to adjust the amount in the RELAY variable inless
 * you want to change the order in pins as used in your project.
 * As a reminder pins A6 and A7 are analog only and cannot be used.
 */
 
const int RELAY[] = {3, 4, 5, 6, 7, 8, A0, A1, A2, A3, A4, A5}; // I/O pins for the relays
#define NUMBER_OF_RELAYS 12 // Total number of attached relays
#define RELAY_ON 0  // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay


void before()
{
    for (int sensor=1, pin=0; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(RELAY[pin], OUTPUT);
        // Set relay to last known state (using eeprom storage)
        digitalWrite(RELAY[pin], loadState(sensor)?RELAY_ON:RELAY_OFF);
    }
}

void setup()
{

}

void presentation()
{
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Relay", "1.1");

    for (int sensor=1; sensor<=NUMBER_OF_RELAYS; sensor++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
    }
}


void loop()
{

}

void receive(const MyMessage &message)
{
    // We only expect one type of message from controller. But we better check anyway.
    if (message.getType()==V_STATUS) {
        // Change relay state
        digitalWrite(RELAY[message.getSensor()-1], message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.getSensor(), message.getBool());
        // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.print(message.getSensor());
        Serial.print(", New status: ");
        Serial.println(message.getBool());
    }
}

Sound issues on Sony STR-DE475 receiver

Relays on the main PCBI’ve had this receiver for quite a while now and it served me well but lately it started acting up where the center speaker and the subwoofer would start to drop out from time to time. The usual hit would bring it back and there was always a clicking sound when it happened. The clicking sound normally is related to electronic relays which are shown in the first picture (The blue ‘boxes’ are the relays in this case). A little bit of searching on the internet revealed that contact problems are a known problem with this receiver and resoldering the connection points of the relays fixes the problem. Bottom part of the main PCBOnce I opened up the receiver there are three relays which I suspect each controls two channels of the receiver being center and sub (and my problem area), front left and right and as last rear left and right. In order to fix the problem you will have to take the whole unit apart, if you aren’t sure you can piece it together use a digital camera or a smartphone to take some pictures before you start so you can see where all connections went. After you removed all the components and have the main PCB in front of you, you can look at the front side where the relays are and on the back which connections need your attention. Each relay has six connections and just heating them up should be enough. In my case I needed some additional tin for one of the connections, maybe this will be the case for you too. After finishing this you can assemble the unit and test the fruits of your labour. So far it is working out for my unit just fine.