Serial MCU controlled relay/switch

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
HarpieC
Normal user
Posts: 22
Joined: 20 Mar 2016, 20:33

Re: Serial MCU controlled relay/switch

#351 Post by HarpieC » 31 Dec 2019, 12:52

Hello,

I just flashed the plugin on a Tuya wall dimmer (1 gang dimmer Board labeled with YDM_WIFI_SV4). Which was very painful because i had to cut the RX trace on the PCB to make it work. Sending command work but after every command the MQTT connection is lost.
Working (somehow) with tuya / dimmer#2
I`m using the homie controller. When I send commands via SYSTEM/cmd/set I get this

Code: Select all

10008544: SerSW : SetDim 255
10008559: SerSW : Dimmer d1:255
10008844: MQTT : Connection lost, state: Connection lost
10008869: MQTT : Connected to broker with client ID: ESPClient_80:7D:3A:3E:70:FA
10008872: Subscribed to: homie/Wanddimmer-01/+/+/set
10008975: SerSW : ReadState
Using The homie receiver plugin & trigger the command form there (aka via rules) works perfectly, so perhaps there is a timing problem in my homie controler plugin:


Here are the rules you need. Configure the homie receiver in (my case index 2) with an integer (1) and a boolean (2) parameter

Code: Select all

on Walldimmer#dimmer do
 ydim,%eventvalue1%
 let,1,%eventvalue1% // store to restore last dimmer state on switch=1
 HomieValueSet,2,1,%eventvalue1% // acknowledge dimmer
endon

on Walldimmer#switch do
 if [Walldimmer#switch]=0 
  relay,0,%eventvalue1%
 else
  ydim,[var#1]
  HomieValueSet,2,1,[var#1] // acknowledge dimmer optional
 endif
 HomieValueSet,2,2,%eventvalue1% // acknowledge switch
endon
But manual changes (button presses) are not read by the plugin or sent back to the broker. That`s a pity because I loose consistency between the homie state and the actual state. Homie has the ability to restore the last state after reboot and it works perfectly if the state is set via mqtt but if the state was done manually than this mechanism fails (restoring the last state on the mqtt broker)

I can live with it for now but if somebody has an idea to fix the update problem I would be thankful. Or anybody has a tip to flash the dimmer without cutting the RX trace. Now writing this I think I have to check if I repaired the RX line correctly.

Thank you for this plugin!

Chris

HarpieC
Normal user
Posts: 22
Joined: 20 Mar 2016, 20:33

Re: Serial MCU controlled relay/switch

#352 Post by HarpieC » 31 Dec 2019, 16:26

I checked TX and RX and it all seams fine. But still no readings from the tuya mcu.

HarpieC
Normal user
Posts: 22
Joined: 20 Mar 2016, 20:33

Re: Serial MCU controlled relay/switch

#353 Post by HarpieC » 09 Jan 2020, 17:49

Finally I got it working. The dimmer readings are still inconstant in example set to 185 read 85 or other values but the "relay" state (Relay0) works and the last state is restored after reboot or restart if the last command origin was the touch button too.
Here is the rules if somebody is interested:

Code: Select all

on Walldimmer#dimmer do
 ydim,%eventvalue1%
 let,1,%eventvalue1%
 HomieValueSet,2,1,%eventvalue1% // acknowledge dimmer
endon

on Walldimmer#switch do
 if [Walldimmer#switch]=0 
  relay,0,%eventvalue1%
 else
  ydim,[var#1]
  HomieValueSet,2,1,[var#1] // acknowledge dimmer state
 endif
 HomieValueSet,2,2,%eventvalue1% // acknowledge switch state
endon

on Dimmer#Relay0 do
 if [Dimmer#Relay0]!=[var#2] // only update on state change
  let,2,[Dimmer#Relay0]
  if [Dimmer#Relay0]=1
   HomieValueSet,2,4,true // acknowledge switch /set
  else
   HomieValueSet,2,4,false // acknowledge switch /set
  endif
 endif
endon

mix
New user
Posts: 1
Joined: 13 Jan 2020, 12:46

Re: Serial MCU controlled relay/switch

#354 Post by mix » 13 Jan 2020, 13:45

enesbcs wrote: 03 Aug 2019, 21:10
fiets wrote: 03 Aug 2019, 18:58 Can you give me an example?
Examples given at the first post viewtopic.php?p=16998#p16998
The following command switches the second relay on the panel, if it has a second relay and you set the correct number of relays on the plugin settings page:

Code: Select all

relay,1,1
The following command switches the first relay on the panel.

Code: Select all

relay,0,1
If it is not working, there are several other possibilities, from unstable power supply to not correct baud rates which render this device unusable. (for example: some units has misprogrammed MCU firmware which will not work without IPD setting, and some of them has absolutely no firmware...)
Quite by accident I came across the cause of the problem with LCTech Relay 4X (I was close to a nervous breakdown;)) why, despite the fact that the status of the relay in Hardware changes, the relay remains in an unchanging state. Pay attention to which of the LEDs on the relay board is lit after the EspEasy start. If BLUE is shining you will not work. The solution is to connect the module to the power supply while holding the Reset Switch (S2). Then the RED led will light up and the GREEN led will blink longer - then the module is really ready for work. It is enough to do it once or until the state changes.

In my LC Tech Relay 4X original AT Firmware in AP client mode the blue is lit, while the red one is in AP mode, which is misleading because it is usually not used in this mode.

Ps. maybe someone has already described a similar situation here and I haven't read (although I searched ... for 4 days) if it was so and now I repeat myself after someone, forgive me :)

Cosimo
New user
Posts: 2
Joined: 24 Jan 2020, 18:39

Re: Serial MCU controlled relay/switch

#355 Post by Cosimo » 24 Jan 2020, 18:42

Hello.
I don't know how to declare my lctech 4ch in Hassio. I wrote this in the configuration.yaml mo but it doesn't work what am I wrong?

- platform: mqtt
name: "LCtech"
command_topic: "cmnd/lctech/Relay0/power"
state_topic: "stat/lctech/Relay0/POWER"
# availability_topic: "tele/lctech/LWT"
qos: 1
payload_on: "relay,0,1 "
payload_off: "relay,0,0 "
payload_available: "Online"
payload_not_available: "Offline"
retain: false

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#356 Post by enesbcs » 24 Jan 2020, 18:49

Cosimo wrote: 24 Jan 2020, 18:42 I don't know how to declare my lctech 4ch in Hassio. I wrote this in the configuration.yaml mo but it doesn't work what am I wrong?

- platform: mqtt
name: "LCtech"
command_topic: "cmnd/lctech/Relay0/power"
state_topic: "stat/lctech/Relay0/POWER"
I do not know neither HA nor Hassio. Command topic is "<MQTT subscribe template>/cmd" in ESPEasy so i guess it is "LCtech/cmd" for you.
State topic may be "LCtech/Relay0/POWER".. depends on your device and value names. I am a Domoticz only user.

Cosimo
New user
Posts: 2
Joined: 24 Jan 2020, 18:39

Re: Serial MCU controlled relay/switch

#357 Post by Cosimo » 25 Jan 2020, 23:59

- platform: mqtt
name: lctech
command_topic: "lctech/cmd"
state_topic: "lctech/Relay0/POWER"
payload_on: "relay,0,1"
payload_off: "relay,0,0"


Not work ,my friend....WHY???

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#358 Post by enesbcs » 26 Jan 2020, 09:53

Cosimo wrote: 25 Jan 2020, 23:59 - platform: mqtt

Not work ,my friend....WHY???
Maybe you did not add the necessary mqtt controller to espeasy.
Mosquitto_pub and Mosquitto_sub is a great tool in case of mqtt debuggin:
http://www.steves-internet-guide.com/mo ... b-clients/

vince59
Normal user
Posts: 30
Joined: 30 Jan 2020, 21:41

Re: Serial MCU controlled relay/switch

#359 Post by vince59 » 30 Jan 2020, 21:59

Hey all.
My first post after a quite long reading. I am playing with IoT and had some successes....quite simple tests.
I would like to use a lctech 4 relay channell with ESP8266 over the internet and my understanding is I must flash a new firmware.
The one that could apply to my device seems to be the "ESPEasy_Mega_P165_1M_128kS_lwip20_PUYA" that can be flashed with ESPEasyflasher.
Am I right? Should I use Arduino instead?....if so which file to be used? I tried the file found on gitHUB but no success in compiling.
Any help would be greatly appreciated.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#360 Post by enesbcs » 31 Jan 2020, 17:37

vince59 wrote: 30 Jan 2020, 21:59 Hey all.
My first post after a quite long reading. I am playing with IoT and had some successes....quite simple tests.
I would like to use a lctech 4 relay channell with ESP8266 over the internet and my understanding is I must flash a new firmware.
The one that could apply to my device seems to be the "ESPEasy_Mega_P165_1M_128kS_lwip20_PUYA" that can be flashed with ESPEasyflasher.
Am I right? Should I use Arduino instead?....if so which file to be used? I tried the file found on gitHUB but no success in compiling.
Any help would be greatly appreciated.
You could use the last 1M beta binary from this post:
viewtopic.php?p=41547#p41547
You could compile this plugin with 2018 december or earlier ESPEasy releases. Newer releases changed serial usage, and i stopped developing this plugin, so unless you are a skilled Arduino programmer, it will not compile.

vince59
Normal user
Posts: 30
Joined: 30 Jan 2020, 21:41

Re: Serial MCU controlled relay/switch

#361 Post by vince59 » 02 Feb 2020, 15:01

Thanks for your answer. I need to study the subject as I am not quite confident how to proceed and then what software to use.
In the meantime I was able to reprogram the ESP8266-1 and make it work again with wifi direct and through the router.
BTW I have a question. I am using two ESP modules flashed with same firmware. Both of them work good with wifi direct but ONLY one works with router.
I wonder if this is normal or not. I mean...I suppose there is something linked to the router or wifi IP assignment.
The IP address is correctly seen but something happens with the router.
I checked AT command and tried to set parameters with AT command but no success.
Am I right?...any hint about this issue?

vince59
Normal user
Posts: 30
Joined: 30 Jan 2020, 21:41

Re: Serial MCU controlled relay/switch

#362 Post by vince59 » 04 Feb 2020, 23:48

I feel somehow discouraged. I am not expert but a selfmade hobbyst.
I was able to flash the ESPEasy (right now I am working with ESP8266-1 as this is installed on the relay module).
I flashed release 120 to test and the PUYA version. Apparently the mega firmware does not work as I do not see the ESP_0 wifi network. I will try again.
Connection works and I can go into ESPEssy gui...other than this I ma quite lost.
I navigated through the different pages but I could not understand. I watched a video but I got lost into Node Red compilation.
I sent command through IP and the device works but I can activate two of four relay.
What do I miss?

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#363 Post by enesbcs » 05 Feb 2020, 17:59

vince59 wrote: 04 Feb 2020, 23:48 I sent command through IP and the device works but I can activate two of four relay.
What do I miss?
If you flashed the device with the binary that i proposed: ESPEasy_P165.BETA.1M_128k.bin (2019.12.20)
then it has to be a "Number of relays" settings on the Serial MCU controlled switch plugin settings page...or your device is simply faulty.
Attachments
lctech4.jpg
lctech4.jpg (135.94 KiB) Viewed 91973 times

vince59
Normal user
Posts: 30
Joined: 30 Jan 2020, 21:41

Re: Serial MCU controlled relay/switch

#364 Post by vince59 » 05 Feb 2020, 20:20

Dear friend, I have 2 devices (different version old ESP 01 and ESP 1s) and I tried 3 firmwares. I got the device properly connected and working with PUYA and 120 release as well as with stock firmware.
When flashed with these fw the ESPs work correctly when connected to the USB adapter as well when installed to the LCtech relay module
No network when using both files you told me: P165 BETA1M 128 as well as BETA4M 1M.
I am looking forward to flash the nodeMCU but I would like to understand why not working with ESP8266

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#365 Post by enesbcs » 05 Feb 2020, 21:11

vince59 wrote: 05 Feb 2020, 20:20 No network when using both files you told me: P165 BETA1M 128 as well as BETA4M 1M.
Just a hint: when you flash the same device with different ESPEasy main versions after each other, do a "full erase" when uploading with serial, they use different data format in flash SPIFF. Could help a lot.

For other users this last beta works well:
download/file.php?id=4247

Altough you can try the previous one:
download/file.php?id=3976

Or there are some compiled for 3 different core versions:
download/file.php?id=3785

And this is the first one which supports 4relay LCTECH: (oldest)
download/file.php?id=3336&sid=622fad533 ... 869d1d3f58

vince59
Normal user
Posts: 30
Joined: 30 Jan 2020, 21:41

Re: Serial MCU controlled relay/switch

#366 Post by vince59 » 05 Feb 2020, 23:04

köszönöm my friend :mrgreen:
I tried the last PUYA file. It works, I have wifi network and connection as well.Actually one of the ESP is not getting wifi when inserted in the relay module, the other one works good.
So I was able to setup ESPEasy and even control the relay through the "tools" section of the ESP Easy panel.
Now, if you don't mind, I kindly ask guidance for the next steps.
I watched the video over the web by Csongor Vaga but I get lost when he explains about procedure with NodeRed and swhitching back to ESP Easy.
My understanding is that it is necessary to connect/link the ESP to the web via MQTT but I can not follow the steps.
Am I right?....do I absolutely need MQTT broker?
I tried something with openHAB but was able to control a TV in my wifi network and I found the software quite complicated with GUI and CLI.
So I would appreciate guidance to complete the steps.
Thanks for any help.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#367 Post by enesbcs » 06 Feb 2020, 17:37

vince59 wrote: 05 Feb 2020, 23:04 Am I right?....do I absolutely need MQTT broker?
Controlling a relay is available either by URL or MQTT, with the standard ESPEasy methods:
https://www.letscontrolit.com/wiki/inde ... _Reference

nygma wrote a complete guide at 2018:
viewtopic.php?f=6&t=3245&p=28044&hilit= ... cmd#p28044

vince59
Normal user
Posts: 30
Joined: 30 Jan 2020, 21:41

Re: Serial MCU controlled relay/switch

#368 Post by vince59 » 07 Feb 2020, 00:10

Definitely there is something I do not understand...I do not know what I am doing wron or not doing.
I can control relay via http with ESPEasy as well as wih Domoticz but I did not manage to gain control over the web.
I am trying to install Mosquitto to be used with openHab but so far no success. Mosquitto does not work (OS Win 10 pro).
It is not yet clear to me wht is necessary to control the device over internet.

guschtl
New user
Posts: 1
Joined: 07 Feb 2020, 12:55

Re: Serial MCU controlled relay/switch

#369 Post by guschtl » 07 Feb 2020, 14:09

Hi all,
exist there a Version, or is it possible for the 1M ESP-01 that the LcTech Relays working together with DS18B20 Temp Sensors?
With all tried Versions I had not found this in combination
Cheers Alex

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#370 Post by enesbcs » 07 Feb 2020, 18:43

guschtl wrote: 07 Feb 2020, 14:09 exist there a Version, or is it possible for the 1M ESP-01 that the LcTech Relays working together with DS18B20 Temp Sensors?
The ESP-01 only has GPIO-0 and GPIO-2 neither of them are optimal for an input pin, but can be done.

The plugin source is available from github and there are several hints in this forum about compiling it against an ESPEasy '2018 source:
viewtopic.php?p=36579#p36579
viewtopic.php?p=36186#p36186
viewtopic.php?p=40201#p40201

This is the generic Arduino compiling method:
https://www.letscontrolit.com/wiki/inde ... are_Upload

In case you are unable to compile you can ask a binary in exchange a Coffee... :D https://ko-fi.com/rpieasy
(Necessary informations: Flash size: 1M/4M, PUYA or not PUYA?, ESP core version 2.4.0/2.4.1/2.4.2/2.50, Controllers included, Plugins included)

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#371 Post by enesbcs » 09 Feb 2020, 14:55

ESPEasy with P165 + Ds18b20
compiled with core 2.5.2
Attachments
ESPEasy_P165_252.zip
ESPEasy with P165 + Ds18b20
(1.3 MiB) Downloaded 1011 times

moamo67
New user
Posts: 2
Joined: 22 Feb 2020, 10:00

Re: Serial MCU controlled relay/switch

#372 Post by moamo67 » 22 Feb 2020, 10:05

hello all, *

thank you for you development and integration of the P165 module !!!!!!!!

i flashed le last post esp8266 firmware ( v147, 1MB 64kb) ,its ok serial mcu is good my relay shuting down good !

no im trying to get the (v200 1MB ,128K ), when i flashed i have a probleme with config dat writing ( at wifi register page ) , and "PID" bug , and after a boot loop , what is the pronbleme ?

because the first have 64kb and the last 128k ?

moamo67
New user
Posts: 2
Joined: 22 Feb 2020, 10:00

Re: Serial MCU controlled relay/switch

#373 Post by moamo67 » 22 Feb 2020, 10:06

enesbcs wrote: 09 Feb 2020, 14:55 ESPEasy with P165 + Ds18b20
compiled with core 2.5.2
thank you !!!!!!

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#374 Post by enesbcs » 22 Feb 2020, 10:24

moamo67 wrote: 22 Feb 2020, 10:05 i flashed le last post esp8266 firmware ( v147, 1MB 64kb) ,its ok serial mcu is good my relay shuting down good !

no im trying to get the (v200 1MB ,128K ), when i flashed i have a probleme with config dat writing ( at wifi register page ) , and "PID" bug , and after a boot loop , what is the pronbleme ?

because the first have 64kb and the last 128k ?
Ye, when you upgrade from v147 to v200, or to alternative SPIFFS size binary, always do a complete flash erase before upload. In case of bootloop use PUYA binary.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#375 Post by Micha_he » 28 Feb 2020, 09:51

enesbcs wrote: 09 Feb 2020, 14:55 ESPEasy with P165 + Ds18b20
compiled with core 2.5.2
Still with the 2018 source code, right?

Because I've a delay-problem with the plugin (viewtopic.php?f=6&t=7460) at my MOES-WIFI-Dimmer, it's interest me, if it's possible to compile the plugin with the current sourcecode. Preferably with Platformio. Where's the main problem ?

Can anyone guide me on the way there?

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#376 Post by enesbcs » 29 Feb 2020, 08:35

Micha_he wrote: 28 Feb 2020, 09:51 if it's possible to compile the plugin with the current sourcecode. Preferably with Platformio. Where's the main problem ?
The main problem is, that the ESPEasy source code evolved much with the controllers&plugins handling, and replaced the full serial library at 2018.12.31. So the current P165 will never compile.. unless someone spent some weeks to adapt this changes to the plugin.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#377 Post by Micha_he » 02 Mar 2020, 08:57

enesbcs wrote: 24 Oct 2019, 14:01 Mravko wrote some instructions for platformio: viewtopic.php?p=36756#p36756
Hi. This instructions doesn't seem to match with the current source-code. Can someone explain, how I integrate a experimental plugin with a suitable build environment into the current ESPEasy code with Platformio ?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#378 Post by TD-er » 02 Mar 2020, 09:10


Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#379 Post by Micha_he » 02 Mar 2020, 09:29

Yes, I want try to compile a image with the _P165_SerSwitch-plugin, based on the current ESPEasy-source. If necessary, see if I can modify the plugin to work with current source.

Is there a manual/wiki somewhere, how to add my own build (with a additional plugin) to the Platformio-IDE. The system/integration is somewhat unclear and complicated for a beginner :(

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#380 Post by TD-er » 02 Mar 2020, 09:32

I just moved it to the mega branch for test build on my computer and there doesn't seem to be anything difficult in merging it.
I will make a test build for you.
What size flash do you need? (and what CPU, ESP8266 or 8285?)

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#381 Post by Micha_he » 02 Mar 2020, 09:49

1MB.

But better: Can you explain the integration steps?

1. copy plugin.ino to /src
2. add '#ifdef USES_P165' and endif to the plugin-source
3. in '/src/define_plugin_sets.h' I've found the plugin only in the experimental section

Here I stopped yesterday...

What are the next steps to a special P165-build? And, if I was able to build with a 'experimantal'-base, the image doesn't get too big with all experimental-plugins ? Wouldn't it be better if I created my own plugin-set ?
Last edited by Micha_he on 02 Mar 2020, 10:00, edited 1 time in total.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#382 Post by TD-er » 02 Mar 2020, 10:00

You can see the changes here: https://github.com/letscontrolit/ESPEasy/pull/2913
What I mainly did was this:
- Copy file from Playground to main repo
- Add #ifdef USES_Pxxx at the begin and /endif at the end (only when the plugin does not already have those.
- Add the reference to the plugin to the define_plugin_defs.h file in the right scope ("PLUGIN_SET_TESTING" for now)

For the integration into the main repo, I also renamed all references to "165" to "090" (note that you need to make sure no number (<space><number>) starts with a 0, or else it will be interpreted as an octal number, not a decimal one.
This is mostly the only exception; #define PLUGIN_ID_091 91

If you need to build a custom build, please use the Custom.h file and define your set of used plugins, by adding "#define USES_P165" or whatever number you need and use the PlatformIO selector to build a custom build with the right flash size.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#383 Post by Micha_he » 02 Mar 2020, 10:18

I'll try to implement your instructions in my build environment. But only today evening.

Can I also have two custom.h files, if I need two special builds ?
Last edited by Micha_he on 02 Mar 2020, 11:02, edited 1 time in total.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#384 Post by TD-er » 02 Mar 2020, 10:40

Not at this point, but you can create a sub section for yourself wrapped in #ifdef ... #endif sections and then add a section in the platformio.ini file where you add a special define.

See platformio_esp8266_envs.ini file:

Code: Select all

; Custom: 1M version --------------------------
[env:custom_ESP8266_1M]
extends                   = esp8266_1M
platform                  = ${regular_platform.platform}
platform_packages         = ${regular_platform.platform_packages}
build_flags               = ${regular_platform.build_flags} 
                            ${esp8266_1M.build_flags} 
                            -DPLUGIN_BUILD_CUSTOM
lib_ignore                = ESP32_ping, ESP32WebServer, ESP8266WiFiMesh
extra_scripts             = pre:pre_custom_esp82xx.py
Duplicate this section and rename the section name (env:custom_ESP8266_1M) and add an extra line to the build_flags where you define your extra build define (start with -D)

For example:

Code: Select all

; Custom: 1M version --------------------------
[env:custom_misha_ESP8266_1M]
extends                   = esp8266_1M
platform                  = ${regular_platform.platform}
platform_packages         = ${regular_platform.platform_packages}
build_flags               = ${regular_platform.build_flags} 
                            ${esp8266_1M.build_flags} 
                            -DPLUGIN_BUILD_CUSTOM
                            -DPLUGIN_BUILD_MISHA
lib_ignore                = ESP32_ping, ESP32WebServer, ESP8266WiFiMesh
extra_scripts             = pre:pre_custom_esp82xx.py

Then in your Custom.h you make a section based on your newly added define like this:

Code: Select all

#ifdef PLUGIN_BUILD_MISHA
  #define USES_P001


#else
  #define USES_P002

#endif
This can be done with everything you need to define in your Custom.h, as long as you only define things once.
By using these #ifdef ... #else ... #endif sections, you can define different values based on a single define you set in your platformio.ini section.

You can also add multiple configs like this (e.g. PLUGIN_BUILD_MISHA2, PLUGIN_BUILD_MISHA3, etc) and then you must make sure to use a slightly more complex #ifdef schema:

Code: Select all

#ifdef PLUGIN_BUILD_MISHA
...
#elif defined(PLUGIN_BUILD_MISHA2)
...
#elif defined(PLUGIN_BUILD_MISHA3)
...
#else
...
#endif

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#385 Post by Micha_he » 02 Mar 2020, 20:43

Top, works :D With custom build and custom plugin-set.
Thank you very much...

But the Wifi-settings from the custom.h, have caused me some problems. Can I delete the all network-/wifi-/IP-/name-settings in the custom.h (lines 33-133), so the default setup wizard is starting in first boot?

Or is it necessary that some of the definitions have to be present in my custom.h?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#386 Post by TD-er » 03 Mar 2020, 08:38

If you do not set default parameters for the WiFi credentials, the setup mode will be started.
If there are credentials present, it will try to use those and if it cannot connect to an AP, it will be starting an AP on its own as normal.
However, this is not as user friendly as it could have been.

So either fill in your own credentials, or place those lines in comments or use an empty string "" for those.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#387 Post by Micha_he » 03 Mar 2020, 10:26

Ok, I'll try a new attempt tomorrow.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#388 Post by Micha_he » 06 Mar 2020, 13:58

TD-er has build a test-image with current source here https://github.com/letscontrolit/ESPEas ... -595455760.
Maybe someone can test the reverse data transmission from the switch/dimmer. My MOES-WIFI-D01 have no real state feedback.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#389 Post by enesbcs » 08 Apr 2020, 13:43

Now, after three years, i have decomissioned my last _Tuya based serial device_ from my home, replaced by Sonoff and Shelly devices. They are unnecessarily complicated by design and the firmware replacement process is also complex, so i will not buy any of them in the future.
FYI: Further support of this plugin is stopped.

_Cyber_
Normal user
Posts: 113
Joined: 20 Oct 2019, 09:46

Re: Serial MCU controlled relay/switch

#390 Post by _Cyber_ » 08 Apr 2020, 13:56

damn - now it is merged into espeasy mega mega and you throw them away? o_O
mine is still working flawless, have a punch of them lying around and waiting for them to get a job in my environments. :D

before I bought the 4-relay thing I took a look at the shelly. sadly they were not appliciable for me as they cannot simulate a 4-way-switch (https://en.wikipedia.org/wiki/Multiway_ ... _locations ) and I do not want to exchange all hardware-switches with push-button-switches of the lamps ...

hopefully your plugin will be maintained enough in the public repository, otherwise I have your custom firmware. :-)

thanks for your work enesbcs

best regards
Alois

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Serial MCU controlled relay/switch

#391 Post by riker1 » 01 May 2020, 12:21

Hi

anyone knows how to identify if :LC Tech has:
LC Technology WiFi Relay X2 with Nuvoton N76E003AT20

build on?

Thanks

fensoft
New user
Posts: 1
Joined: 09 Jul 2020, 01:52

Re: Serial MCU controlled relay/switch

#392 Post by fensoft » 09 Jul 2020, 01:57

I have a lc 2relay and need to add the last write to make it work:

Code: Select all

          if (Plugin_165_ipd) {
            Serial.write(0x0D);
            Serial.write(0x0A);
            Serial.write(0x2B);
            Serial.write(0x49);
            Serial.write(0x50);
            Serial.write(0x44);
            Serial.write(0x2C);
            Serial.write(0x30);
            Serial.write(0x2C);
            Serial.write(0x34);
            Serial.write(0x3A);
            Serial.write("\nWIFI CONNECTED\nWIFI GOT IP\nAT+CIPMUX=1\nAT+CIPSERVER=1,8080\nAT+CIPSTO=360\n");
          }
i've also added this as rules:

Code: Select all

On System#Boot do
  relay,0,0
  timerSet,1,10
endon

On Rules#Timer=1 do
  relay,0,0
endon

elsalior
New user
Posts: 1
Joined: 10 Jul 2020, 12:10

Re: Serial MCU controlled relay/switch

#393 Post by elsalior » 10 Jul 2020, 12:14

hi all,
i'struggling with a password for the AP mode which seem to be different for the bin image ESPEasy_Mega_P165_1M_128kS_lwip20_PUYA.bin
does anyone knows that password ?

thx

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#394 Post by TD-er » 10 Jul 2020, 13:26

You can change it via serial.

Run

Code: Select all

WifiAPKey,<password>
save

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#395 Post by enesbcs » 10 Jul 2020, 17:13

elsalior wrote: 10 Jul 2020, 12:14 i'struggling with a password for the AP mode which seem to be different for the bin image ESPEasy_Mega_P165_1M_128kS_lwip20_PUYA.bin
does anyone knows that password ?

Code: Select all

#define DEFAULT_AP_KEY      "configesp"

fresnoboy
Normal user
Posts: 17
Joined: 01 Sep 2020, 22:34

Re: Serial MCU controlled relay/switch

#396 Post by fresnoboy » 01 Sep 2020, 22:41

Hi. I am running ESPEasy_Mega_P165_4M_1MS_lwip20.bin on my lctech 4 relay switches, but the openhab MQTT broker in that version seems to lose contact with the MQTT broker occasionally (after a week or so). I am wondering if there is a more up to date mega version that has the serial port support for the Nuvotron part in the lc tech relays that people find works reliably.

It's a little hard to tell from the github repository which version will run on the the LC Tech relays...

thx!
mike

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#397 Post by enesbcs » 01 Sep 2020, 22:58

fresnoboy wrote: 01 Sep 2020, 22:41 It's a little hard to tell from the github repository which version will run on the the LC Tech relays...
Serial MCU plugin is now included in ESPEasy TESTING releases.
https://github.com/letscontrolit/ESPEasy/releases

fresnoboy
Normal user
Posts: 17
Joined: 01 Sep 2020, 22:34

Re: Serial MCU controlled relay/switch

#398 Post by fresnoboy » 01 Sep 2020, 23:38

enesbcs wrote: 01 Sep 2020, 22:58
fresnoboy wrote: 01 Sep 2020, 22:41 It's a little hard to tell from the github repository which version will run on the the LC Tech relays...
Serial MCU plugin is now included in ESPEasy TESTING releases.
https://github.com/letscontrolit/ESPEasy/releases
Thats great to know. So any of the normal ESP8266 4M1M images will work then?

thx
mike

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#399 Post by TD-er » 01 Sep 2020, 23:58

Not the "normal" but the "test" named builds.

fresnoboy
Normal user
Posts: 17
Joined: 01 Sep 2020, 22:34

Re: Serial MCU controlled relay/switch

#400 Post by fresnoboy » 02 Sep 2020, 03:20

TD-er wrote: 01 Sep 2020, 23:58 Not the "normal" but the "test" named builds.
Well, I just tried flashing the ESP_Easy_mega_20200829_test_beta_ESP8266_4M1M.bin file to the LC Tech 8266, and it doesn't seem to come up. Sorry if I am missing something obvious...

Do I flash it with the same parameters as I did the older one:

esptool --port /dev/ttyUSB0 write_flash -fs 32m 0x00000 ESP_Easy_mega_20200829_test_beta_ESP8266_4M1M.bin

Thx
mike

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests