Serial MCU controlled relay/switch

Moderators: grovkillen, Stuntteam, TD-er

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

Re: Serial MCU controlled relay/switch

#71 Post by riker1 » 02 Feb 2018, 08:30

Hi
I am using a b3603 buck converter.
showing esp01 only on 80mA and additional 50 mA for each relay. Power should be stable.

I set input power to 5 V 1 A, when 2 Relay were open, current was 200mA.

Hard to put resistors and capacitator in the relay ESP is onboard plugged on.

maybe it is also possible to control / program the onboard STM8S003 SWIM.

hard to give up....

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

Re: Serial MCU controlled relay/switch

#72 Post by riker1 » 05 Feb 2018, 15:34

Hi
good news,

problem was related to power supply via breadboard.

all working now. Thanks for your support.

will p165 be part of a normal release?

compiling a release myself failed with always different errors....

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

Re: Serial MCU controlled relay/switch

#73 Post by TD-er » 05 Feb 2018, 17:08

riker1 wrote: 05 Feb 2018, 15:34 [...]
will p165 be part of a normal release?

compiling a release myself failed with always different errors....
If it is considered stable, you can always make an issue for it on Github.
I think there are lots of plugins on the playground which may benefit others.

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

#74 Post by enesbcs » 05 Feb 2018, 18:45

TD-er wrote: 05 Feb 2018, 17:08
riker1 wrote: 05 Feb 2018, 15:34 [...]
will p165 be part of a normal release?

compiling a release myself failed with always different errors....
If it is considered stable, you can always make an issue for it on Github.
I think there are lots of plugins on the playground which may benefit others.
Plugin is currently working only with Arduino core 2.4.0-rc or newer, so compilation with default settings is not straightforward. I think the plugin status is better than "DEVELOPMENT", but reported to run out of memory on Sonoff Dual after a month uptime. On my Tuya wall light switch, i have no such problems, but it is moderately used by me. So i guess my plugin falls under "TESTING" category.
The supported 3 type of hardware: Sonoff Dual, Tuya touch light switch and LCTech relays is not typically used as sensors (only a few GPIOs accessible) so i remove a lots of plugin before compiling it, for speed and size reasons.
I think i will offer pre-compiled binaries in 3 versions for users who have problems with compilation:
1. ESPEasy Mega 4MB/1MB SPIFFS
2. ESPEasy Mega 1MB/128k SPIFFS
3. ESPEasy R147 1MB/64k SPIFFS (legacy version for PUYA - SPIFFS not used in this release, but checked by ESPEasy to be greater than 0 for some reasons)

In these binaries i will include the following:
Controllers: All (C001-C011)
Notification plugins: All (N001-N002)
Plugins: P165 SerSwitch, P001 Switch, P002 ADC, P003 Pulse, P020 Ser2Net (for debugging purposes), P021 Level, P026 Sysinfo, P029 Output, P033 Dummy, P037 MQTTImport, P043 ClkOutput (not sure if it can be useful for this devices), and for in case also including my Modemsleep plugin P166 just in case. :)

If anyone has other needs, write it.

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

Re: Serial MCU controlled relay/switch

#75 Post by riker1 » 05 Feb 2018, 19:48

Hi
that sounds great.

one hint maybe.

looks like for lc Tech relays with 2 relays, only statsu of 1. rleay is send to fhem

message is rel:on rel:off

but only for first relay0 not relay1

thanks Thomas

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

#76 Post by enesbcs » 05 Feb 2018, 22:24

riker1 wrote: 05 Feb 2018, 19:48 one hint maybe.

looks like for lc Tech relays with 2 relays, only statsu of 1. rleay is send to fhem

message is rel:on rel:off

but only for first relay0 not relay1
Yes from the beginning this device reports itself as SWITCH, and in ESPEasy it can report exactly one value, the first. This is why i am using Rules, to report back each relays separately, as this mentioned in the first post.
To address this issue, now i changed it to SENSOR_TYPE_TRIPLE and tried to change it according the selected number of buttons.
Hint: if selecting the LCTECH type for the first time in the device settings, please refresh the page and Submit another time, after selecting the number of buttons, and other options, to make sure to save it.
Binary attached to the first post of this thread:
download/file.php?id=1930

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

Re: Serial MCU controlled relay/switch

#77 Post by riker1 » 06 Feb 2018, 07:38

Hi

ok top thanks

will try

it is working,
only small thing. relay names must be short to be distinguished in fhem:
fhem is showing Rel: 0 Rel: 0

changed in EasyESP : shorter names : R1: 0 R2: 0 appears in fhem

Thanks

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#78 Post by dent » 01 Mar 2018, 18:30

Hi!

Thank you very much taking the time to produce this. I admire your work here and greatly appreciate what you accomplished.

I have recently purchased a Tuya clone 1-gang wall switch from aliexpress. I like them since they don’t have any branding in the glass pane like sonoff and their glass cover color matches the case color.

I’ve disassembled the switch, luckily I saw the pins out there with labels on the back.

I am quite new to these things and don’t have any electronics background but have some programming knowledge. I had previously flashed sonoff devices with tasmota with success and have embedded them into my home assistant network running on a raspberry pi 3. On the other hand, I have tried to use your firmware but to no luck. I have listed the steps I have followed below. I will be glad if you can help me figure out how to make it work with the device I have.

1) I connected the ESP8266 module to a raspberry pi 3 running on raspbian in flashing mode. I don’t have a USB-UART device, so I am limited to using linux based solutions for flashing
2) I downloaded the compiled version of your plugin for Tuya
3) I backed up the existing firmware using esptool.py (just in case I need to revert to the original firmware in the future)
4) power cycled, erased the existing firmware
5) power cycled, uploaded the new firmware, namely ESPEasy_Mega_P165_4M_1MS.bin from the zip file in the first post.
6) exited flashing mode (disconnected GPIO0 from ground) and power cycled
7) I was now able to see ESP_XXXX access point available in the wireless networks list. However, when I connected, I was unable to open the webpage on 192.168.4.1. I tried to ping and it worked, but the webpage did not show up
8) Still connected to raspberry pi, I ran miniterm.py to listen to the serial log. See the log output below. Seems like ESP was constantly rebooting itself due to an error (which I cannot figure out) and repeats the same error message continously.
9) I also tested powering the switch from a wall plug instead of raspberry pi, but the results were the same/

Any ideas how I can make this work? Is there something that I am missing?
By the way, the product works fine with the vendor app and other third party software on its original firmware.

Thanks!
ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v4ceabea9
~ld
�U

INIT : Booting version: (custom)
INIT : Warm boot #10
FS : Mounting...
FS : Mount failed
FS : Mount failed
RESET: Resetting factory defaults...
RESET: Warm boot, reset count: 3
RESET: Too many resets, protecting your flash memory (powercycle to solve this)
CRC : No program memory checksum found. Check output of crc2.py
FS : Error while reading/writing config.dat in 1091

PID:0
Version:0
INIT : Incorrect PID or version!
RESET: Resetting factory defaults...
RESET: Warm boot, reset count: 3
RESET: Too many resets, protecting your flash memory (powercycle to solve this)

Exception (0):
epc1=0x4000e25d epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3fff3bf0 end: 3fff3e50 offset: 01a0

>>>stack>>>
3fff3d90: 3fff4e8c 00000100 00000001 40201980
3fff3da0: 40202a82 3fff4ebc 00000001 40202b88
3fff3db0: 00000000 0000001c 00000003 3fff4ea4
3fff3dc0: 3fffdad0 3fff2e20 3fff2d60 3fff2e20
3fff3dd0: 3fffdad0 00000001 3fff2d60 4022d0f8
3fff3de0: 00000000 0000001c 00000000 40202932
3fff3df0: 402018b6 3fff2d60 3fff1d48 40207e61
3fff3e00: 3fffdad0 3fff2d60 3fff1d48 402251ac
3fff3e10: 00000000 00000000 00000000 3fff4fc4
3fff3e20: 0000002f 00000014 feefeffe feefeffe
3fff3e30: 3fffdad0 00000000 3fff2e1a 4022ee20
3fff3e40: feefeffe feefeffe 3fff2e30 40100710
<<<stack<<<
Attachments
195B67E3-370A-42C0-B532-D97FD03C7457.png
195B67E3-370A-42C0-B532-D97FD03C7457.png (1.28 MiB) Viewed 68873 times
6610B890-DBB9-4A5F-A952-8EF72A8FB0C8.jpeg
6610B890-DBB9-4A5F-A952-8EF72A8FB0C8.jpeg (1.85 MiB) Viewed 68873 times
4A5207F2-76D4-47AB-AD1D-B18F442E5A62.jpeg
4A5207F2-76D4-47AB-AD1D-B18F442E5A62.jpeg (1.88 MiB) Viewed 68873 times
4176A19F-4944-4F08-9881-667E8E894E1B.jpeg
4176A19F-4944-4F08-9881-667E8E894E1B.jpeg (1.64 MiB) Viewed 68873 times

itanczos
New user
Posts: 4
Joined: 25 Jan 2018, 00:05

Re: Serial MCU controlled relay/switch

#79 Post by itanczos » 01 Mar 2018, 18:57

dent wrote: 01 Mar 2018, 18:30 ...
5) power cycled, uploaded the new firmware, namely ESPEasy_Mega_P165_4M_1MS.bin from the zip file in the first post.
Please try the ESPEasy_Mega_P165_1M_128kS.bin flash image.
I think this ESP module has only 1MB of flash.

itanczos
New user
Posts: 4
Joined: 25 Jan 2018, 00:05

Re: Serial MCU controlled relay/switch

#80 Post by itanczos » 01 Mar 2018, 19:02

I'm using the downloadable P165_18 version.
The problem is that if I restart the router, it will not re-connect the ESPEasy to the router, but switch to the AP mode.
The rest of ESPEasy will re-connect to the router.

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#81 Post by dent » 01 Mar 2018, 19:25

Thanks for the quick response! I was able to connect to the device using the 1M version. Now it’s time to figure out the correct settings...
By the way, the physical button does not function at all after the flash. Does it have to do with the settings?

itanczos wrote: 01 Mar 2018, 18:57
dent wrote: 01 Mar 2018, 18:30 ...
5) power cycled, uploaded the new firmware, namely ESPEasy_Mega_P165_4M_1MS.bin from the zip file in the first post.
Please try the ESPEasy_Mega_P165_1M_128kS.bin flash image.
I think this ESP module has only 1MB of flash.

itanczos
New user
Posts: 4
Joined: 25 Jan 2018, 00:05

Re: Serial MCU controlled relay/switch

#82 Post by itanczos » 01 Mar 2018, 19:43

Of course!
You must also set the button as an input device.
dent wrote: 01 Mar 2018, 19:25 Thanks for the quick response! I was able to connect to the device using the 1M version. Now it’s time to figure out the correct settings...
By the way, the physical button does not function at all after the flash. Does it have to do with the settings?

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

#83 Post by enesbcs » 01 Mar 2018, 22:44

This Kinco switch seems very interesting, on the Yewelink the main button works all the time, because that was hardwired to the MCU. Are you sure, that this switch communicates serially with an MCU?
If it is, you can try to enable all 3 button in the Serial MCU settings, then do a soft reboot and see if anything shows in log when you press the main button. And also see if relay,0,1 or relay,1,1 commands doing anything with the relay.
FYI there are some Tuya clone which does not use the serial API, instead using direct GPIO-s: (in this case buttons are controlled by the ESP and you have to code some logic (Rules) in the same way like the Sonoff Touch)
such as GPIO-12=RELAY,GPIO-5=PWR LED

barrymossel
Normal user
Posts: 12
Joined: 06 Mar 2018, 08:59

Re: Serial MCU controlled relay/switch

#84 Post by barrymossel » 06 Mar 2018, 09:01

I ordered the Kinco switch yesterday and want to flash it to be used through Domoticz when it arrived. How would I know if this will work with any firmware?

---edit---
Hmm, the description on AliExpress says it uses the eWeLink app, just like Sonoff. Wouldn't that mean they function quite like the Sonoffs? So through the GPIO's?

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

#85 Post by enesbcs » 06 Mar 2018, 17:29

barrymossel wrote: 06 Mar 2018, 09:01 I ordered the Kinco switch yesterday and want to flash it to be used through Domoticz when it arrived. How would I know if this will work with any firmware?

---edit---
Hmm, the description on AliExpress says it uses the eWeLink app, just like Sonoff. Wouldn't that mean they function quite like the Sonoffs? So through the GPIO's?
I am afraid there are absolutely zero informations about Kinco switches, you can be the first who take apart one, measure with multimeter that which GPIO's connected to which relay if any.. as i do with my own switch. :)
1/ If you are lucky, the ESP GPIO's are connected directly to the relays, and can be used simply with some Rules in ESPEasy.
2a/ If not, you have to listen the serial communication between the ESP and the MCU modul (i did it with P20 Serial server plugin), if the packages starting with 0x55aa then they are using the Tuya protocol, and P165 plugin can be used. (Yewelink/TUYA) Tuya has published it's official serial API that is licensed by Yewelink, so it has to work.
2b/ If the packages starting with 0xA004 or 0xA000 then it is using the Sonoff protocol and can be used as a Sonoff Dual device also supported by this plugin.
3/ If none of the above then you are on your own.

barrymossel
Normal user
Posts: 12
Joined: 06 Mar 2018, 08:59

Re: Serial MCU controlled relay/switch

#86 Post by barrymossel » 07 Mar 2018, 10:00

We will just have to wait I guess ;)

But I can imagine that as it uses the same app as Sonoff (T1) switches, it might be compatible with ESPEasy + some rules.

I will take it apart as soon as I receive it!

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

#87 Post by enesbcs » 07 Mar 2018, 18:31

barrymossel wrote: 07 Mar 2018, 10:00 We will just have to wait I guess ;)

But I can imagine that as it uses the same app as Sonoff (T1) switches, it might be compatible with ESPEasy + some rules.

I will take it apart as soon as I receive it!
The Sonoff Dual also uses EweLink app, but do not use direct GPIO controlling.. but hope dies last.

barrymossel
Normal user
Posts: 12
Joined: 06 Mar 2018, 08:59

Re: Serial MCU controlled relay/switch

#88 Post by barrymossel » 07 Mar 2018, 19:47

Haha, let's keep hoping... :)

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#89 Post by dent » 13 Mar 2018, 20:14

I have managed to figure out that the Kinco switch uses the GPIO pin 4 to manage the relay.
I can turn it on and off using the commands but I am struggling with operating the physical button still. My initial idea was that it would be linked to one of the GPIO pins and I would be able to program a trigger that switches GPIO4 when the button is pressed.
I am checking the values of all GPIO pins and then pressing the button and then checking again. However, I don’t see any change in GPIO values.

Any thoughts how I can capture the physical button press?

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

#90 Post by enesbcs » 13 Mar 2018, 20:36

dent wrote: 13 Mar 2018, 20:14 I am checking the values of all GPIO pins and then pressing the button and then checking again. However, I don’t see any change in GPIO values.

Any thoughts how I can capture the physical button press?
If i were you, i would set up switches in ESPEasy to "Switch" devices for the following GPIO's:
GPIO-0
GPIO-2
GPIO-4
GPIO-5
GPIO-12
GPIO-13
GPIO-14
GPIO-15

Then when you touch the button, it will be in the ESPEasy logs.

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#91 Post by dent » 13 Mar 2018, 21:00

I did the following
gpio setup.jpg
gpio setup.jpg (178.44 KiB) Viewed 69871 times
but can't see anything in the log when I press the button. any other thoughts?

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

#92 Post by enesbcs » 13 Mar 2018, 21:33

dent wrote: 13 Mar 2018, 21:00 I did the following

but can't see anything in the log when I press the button. any other thoughts?
I only see 4 gpio's on the picture. Can be GPIO12-GPIO13-GPIO14?
When you said "GPIO pin 4" you referring GPIO-4 as the picture below?
Image
Perhaps you can trace back the GPIO's from ESP to the touch with a multimeter...

Also there is a CR302..whatever chip with 16 legs on the back side i can not read every letter from the picture, maybe the central K2 touch is connected to it's R2?? Could you find out what's this chip full name?

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#93 Post by dent » 13 Mar 2018, 21:47

Rest of the GPIOs were on the next page. Didn't take a screenshot of that. I have all the GPIO pins that are available defined as switches.

By GPIO4 I mean using the command - GPIO,4,0

Regarding the multimeter - I haven't used it for this purpose before. Should I connect the black line of multimeter to ground pin of ESP and test the red line with the other pins while pressing the button on and off? Or should I use the continuity mode somehow?

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#94 Post by dent » 13 Mar 2018, 22:00

enesbcs wrote: 13 Mar 2018, 21:33
dent wrote: 13 Mar 2018, 21:00 I did the following

but can't see anything in the log when I press the button. any other thoughts?
I only see 4 gpio's on the picture. Can be GPIO12-GPIO13-GPIO14?
When you said "GPIO pin 4" you referring GPIO-4 as the picture below?

Perhaps you can trace back the GPIO's from ESP to the touch with a multimeter...

Also there is a CR302..whatever chip with 16 legs on the back side i can not read every letter from the picture, maybe the central K2 touch is connected to it's R2?? Could you find out what's this chip full name?
it says:
CR302
B747U005PG4

nothing pops out in google when I search for it

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

#95 Post by enesbcs » 13 Mar 2018, 22:37

dent wrote: 13 Mar 2018, 22:00 it says:
CR302
B747U005PG4

nothing pops out in google when I search for it
It's a bit confusing, if the touch sensors not wired to ESP, than maybe it's some sort of touch controller (CR302) which is wired to ESP8266 serial/I2C/SPI i can not tell it from pictures. :(
I used the multimeter continuity function to backtrace wiring, more or less success. :) Multiple layered PCB's are hard to backtrace.

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

#96 Post by enesbcs » 14 Mar 2018, 10:40

Attachments updated in the first post, plugin compiled against the new TurboCharge 20180311 ESPEasy Mega
viewtopic.php?f=6&t=3245&start=90#p16998

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#97 Post by dent » 14 Mar 2018, 23:42

I used a multimeter to measure the changes in voltage on my kinco touch switch and figured out that the voltage on the serial pin market with R changes (goes down to 0 depending on how long I press) when I touch the physical button. I guess now I have to figure out how to read serial pin values. I am quite new to the esp easy firmware, please forgive me if this is something trivial.

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

#98 Post by enesbcs » 15 Mar 2018, 09:07

dent wrote: 14 Mar 2018, 23:42 I used a multimeter to measure the changes in voltage on my kinco touch switch and figured out that the voltage on the serial pin market with R changes (goes down to 0 depending on how long I press) when I touch the physical button. I guess now I have to figure out how to read serial pin values. I am quite new to the esp easy firmware, please forgive me if this is something trivial.
Nice work, you are in the right direction.
Easy and ugly way if you have only one button on the Kinco:

In ESPEasy menu:
Tools->Advanced->Enable serial port (check box unticked - so disable!)
Tools->Advanced->Serial log level: None

Now you are able to create a Switch device on RX it's GPIO3, and see if it changes state in the log.

The harder way:
- Enable serial port usage, but disable serial logging, also disable all plugin (P165) and device that using serial pins.
- Setup "Communication - Serial Server" plugin for debugging (port 23, baud 9600, 8n1)
https://www.letscontrolit.com/wiki/index.php/Ser2Net
- install Realterm to your PC, setup for displaying in hexadecimal in Display menu, in Capture write the ESP device IP address and port (23) and set the serial settings that matches with the ESP Ser2Net plugin

In that way when you press the touch, you have to see the same Hex byte array - maybe two different: one when switching off, another when switching on. If you see only garbage or not the same numbers every time, you have to change bitrate on each of them and retry. If you can provide the correct hex array i can include in this plugin. :)

barrymossel
Normal user
Posts: 12
Joined: 06 Mar 2018, 08:59

Re: Serial MCU controlled relay/switch

#99 Post by barrymossel » 17 Mar 2018, 08:59

It appears that the one I received is a bit different than the one posted before:

Image

Also it doesn't use the EweLink app as described but the (Tuya?) SmartLife app. I am willing to open it up and experiment with it, but first I'll wait off the dispute with the seller as the front (the only reason why I bought this particular one) is different from the pictures (icons of lamps and can only be placed with the buttons op top of each other instead of next to each other).

Image

dent
New user
Posts: 8
Joined: 01 Mar 2018, 12:04

Re: Serial MCU controlled relay/switch

#100 Post by dent » 21 Mar 2018, 21:28

enesbcs wrote: 15 Mar 2018, 09:07
dent wrote: 14 Mar 2018, 23:42 I used a multimeter to measure the changes in voltage on my kinco touch switch and figured out that the voltage on the serial pin market with R changes (goes down to 0 depending on how long I press) when I touch the physical button. I guess now I have to figure out how to read serial pin values. I am quite new to the esp easy firmware, please forgive me if this is something trivial.
Nice work, you are in the right direction.
Easy and ugly way if you have only one button on the Kinco:

In ESPEasy menu:
Tools->Advanced->Enable serial port (check box unticked - so disable!)
Tools->Advanced->Serial log level: None

Now you are able to create a Switch device on RX it's GPIO3, and see if it changes state in the log.

The harder way:
- Enable serial port usage, but disable serial logging, also disable all plugin (P165) and device that using serial pins.
- Setup "Communication - Serial Server" plugin for debugging (port 23, baud 9600, 8n1)
https://www.letscontrolit.com/wiki/index.php/Ser2Net
- install Realterm to your PC, setup for displaying in hexadecimal in Display menu, in Capture write the ESP device IP address and port (23) and set the serial settings that matches with the ESP Ser2Net plugin

In that way when you press the touch, you have to see the same Hex byte array - maybe two different: one when switching off, another when switching on. If you see only garbage or not the same numbers every time, you have to change bitrate on each of them and retry. If you can provide the correct hex array i can include in this plugin. :)
I tried your suggestions and I am now able to command the switch and the leds on it trough GPIO commands. I set some rules, installed mqtt and now I am able to control the whole thing both physically and wireless.

I have also tried the 'hard way'. The hex output I see is "00" almost all the time when I press or hold the button. Is this normal or is "00" an error of some sort?
I have also purchased 2 and 3 gang versions and waiting for their delivery. I will let you know when I get them and try to find out their hex outputs.

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

#101 Post by enesbcs » 21 Mar 2018, 22:37

dent wrote: 21 Mar 2018, 21:28 I tried your suggestions and I am now able to command the switch and the leds on it trough GPIO commands. I set some rules, installed mqtt and now I am able to control the whole thing both physically and wireless.

I have also tried the 'hard way'. The hex output I see is "00" almost all the time when I press or hold the button. Is this normal or is "00" an error of some sort?
I have also purchased 2 and 3 gang versions and waiting for their delivery. I will let you know when I get them and try to find out their hex outputs.
I am glad that it helps, maybe you can publish the used GPIO numbers and rules for the others who are buying Kinco switches in Hardware topic. :)

I think:
1/ maybe 00 means "button 0" as it is the first and only button on this switch which is returned from the simple serial touch sensor - in which case this is absolutely not a Tuya compatible device - the Tuya protocol seems like "55aa 00 07 0005 01 01 00 01 01 0F". (in hex for the first button)
2/OR the serial baudrate setted in the ESPEasy did not match with the MCU builtin speed in which case the zeroes means nothing. 9600 and 19200 are the most popular default speeds with 8N1.

I did not find anything about this specific chip, however in the AR1000 touch controller datasheet there are a comment in the UART communication mentioning "Sleep mode will cause the TX line to drop low, which may appear as a 0x00 byte sent from the controller"

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#102 Post by xury » 03 Apr 2018, 19:37

Hello everybody.
I'm newbie on this forum, and totally beginner with platformio.
I'd like to ask tou how to compile this plugin on 2.3.0 core?
I got error:
:/ESPEasy-mega-20180402/src/_P165_SerSwitch.ino: In function 'boolean Plugin_165(byte, EventStruct*, String&)':
L:/ESPEasy-mega-20180402/src/_P165_SerSwitch.ino:481:16: error: 'class HardwareSerial' has no member named 'setRxBuffer
Size'

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

#103 Post by enesbcs » 04 Apr 2018, 07:38

xury wrote: 03 Apr 2018, 19:37 Hello everybody.
I'm newbie on this forum, and totally beginner with platformio.
I'd like to ask tou how to compile this plugin on 2.3.0 core?
I got error:
:/ESPEasy-mega-20180402/src/_P165_SerSwitch.ino: In function 'boolean Plugin_165(byte, EventStruct*, String&)':
L:/ESPEasy-mega-20180402/src/_P165_SerSwitch.ino:481:16: error: 'class HardwareSerial' has no member named 'setRxBuffer
Size'
This plugin made for core 2.4.0rc2, 2.4.0rc1 or 2.4.0 stable.
Lack of setRxBuffer is the main reason i do not use previous cores, because for Tuya compatibility the buffer needs to be extended at least 100 bytes! I am serious, their transmitting al three button state every time when change occurs, even if the device only have one button or only one button state changed. If buffer is smaller than 3x33 bytes
that will cause very funny errors, for sure.
In core 2.3.0 the hardware serial buffer is defaulted to 32 bytes and can not be altered in the user space.

If you are desperately want to use the older, KRACK-affected 2.3 core, and DO NOT want to use Tuya, than be my guest, and try the following modifications with the plugin source (Dual and LCTech might work):

Modify:
#define BUFFER_SIZE 100
To:
#define BUFFER_SIZE 32

And comment out the two following lines:
//Serial.setDebugOutput(false);
//Serial.setRxBufferSize(BUFFER_SIZE);

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#104 Post by xury » 04 Apr 2018, 12:02

Thank You enesbcs
I will try to compile with your sugestions this evening when I come back home. I need it for lc tech relay so I hope should be good with buffer size 32.
I have one more request. Would you like give me a link for a core 2.4.0 source because as I said im totally beginner.
A don't know how to work with 2.4.0 in platformio without git.
Maby is a zip package with 2.4.0 enviroment to get easy way as in toutorial?

I also found a solution how to reflash lctech IC to get info about relay state.
https://www.esp8266.com/viewtopic.php?p=74262#p74262
From above post after reprogram chip we can use:
B0 01 01 B2 -> Reading relay in text format ("ON" and "OFF" ending with a linefeed).
B0 01 00 B1 -> Relay reading in binary format (00 = ON and 01 = OFF).

B0 00 01 B1 -> Reading the firmware version in text format ending with a linefeed.
Im succesfuly reprogram STC15F104W so I can confirm it's work properly

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

#105 Post by enesbcs » 04 Apr 2018, 15:13

xury wrote: 04 Apr 2018, 12:02 A don't know how to work with 2.4.0 in platformio without git.
Maby is a zip package with 2.4.0 enviroment to get easy way as in toutorial?

B0 01 01 B2 -> Reading relay in text format ("ON" and "OFF" ending with a linefeed).
B0 01 00 B1 -> Relay reading in binary format (00 = ON and 01 = OFF).
B0 00 01 B1 -> Reading the firmware version in text format ending with a linefeed.
I am also do not know platformio, because i am compiling with Arduino:
https://github.com/esp8266/Arduino

I checked this user provided binary for the STM. The new commands is nice, but i am not sure what can i do with the nonstandard replies without headers? Also there are a two relay version of this device what about that?

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#106 Post by xury » 04 Apr 2018, 18:29

As your suggestion I managed to compile on 2.3.0 core. Plugin sims work OK but when I try add new device I have error in red frame:
I guess is a filesystem error. Maybe not enough flash? Or is wrong organization, because I had another version of firmware before.
I'll tray to disable some unneeded plugins for me and check again.
bladesp.png
bladesp.png (53.75 KiB) Viewed 105989 times

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#107 Post by xury » 16 Apr 2018, 01:09

Ok. I finally managed to compile with what I need.
It was a problem with PUYA chip.
After patching Esp.cpp it works well.

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: Serial MCU controlled relay/switch

#108 Post by nygma » 24 Apr 2018, 23:45

Hi Guys, I have used ESP Easy before, but so far I only uploaded the precompiled bins.
So to make this work for the LCTech relay board I need to compile my own version e.g. from Arduino? This also means that this core 2.4 is not the same as the 20180428 binary versions?
A slightly off topic question: I tried playing around with the ESP_Easy_mega-20180424_normal_ESP8266_1024.bin version (I have a black ESP-01 and not with the PUYA chip). I cannot get it to connect to the AP. I put the password in and nothing happens it comes back to setup. If I flash the older 147 build that works just fine. Any pointers?
Cheers,
Csongor

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#109 Post by xury » 25 Apr 2018, 18:41

If you want use another plugins not included in bin files shared at first post you have to compile using Arduino or Platformio.
About problems with new releases you mast observe serial output during connection and read logs data.

P.S I have request to enesbcs. If is possible to fix a plugin? On recent sources I have :" Bug in PLUGIN_WEBFORM_LOAD, should not append to string, use addHtml() instead" I cannot it fix myself.

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

#110 Post by enesbcs » 25 Apr 2018, 19:38

nygma wrote: 24 Apr 2018, 23:45 Hi Guys, I have used ESP Easy before, but so far I only uploaded the precompiled bins.
So to make this work for the LCTech relay board I need to compile my own version e.g. from Arduino?
There are always precompiled binaries in the first post in this thread with P165 plugin, no need to compile, if you are not familiar with it. If you need a plugin that is not contained the binaries, name it.

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

#111 Post by enesbcs » 25 Apr 2018, 19:45

xury wrote: 25 Apr 2018, 18:41 P.S I have request to enesbcs. If is possible to fix a plugin? On recent sources I have :" Bug in PLUGIN_WEBFORM_LOAD, should not append to string, use addHtml() instead" I cannot it fix myself.
I saw that WEBFORM_LOAD changes, i fixed it, but it also means that this plugin will not compile in ESPEasy R147 version, only the latest Mega edition.
https://github.com/enesbcs/ESPEasyPlugi ... Switch.ino

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: Serial MCU controlled relay/switch

#112 Post by alabama » 27 Apr 2018, 16:00

enesbcs wrote: 31 Aug 2017, 17:24
rira2005 wrote: 31 Aug 2017, 13:55 Bought this ESP8266 5 V WiFi relaismodul in china
https://de.aliexpress.com/item/ESP8266- ... 0.0.5Thz2C
it also works with a serial controled MCU... May you have a idea to get it work with easyesp?
I am sure that it can be done. But first we need to know the commands, that the ESP-01 is sending to drive the relay ON/OFF state.

I see the serial speed is: 9600,8,1,0,0.

And i've found a fantastic article by makerrelay:
https://www.hackster.io/makerrelay/esp8 ... ome-e8a437

According to it:
A00101A2 open relay,
A00100A1 closed relay

If you're willing to try, i can make a test binary with the above commands, but there is no guarantee. :)

Update: attached 1M/128k SPIFFS for black ESP-01
Please let me refer to this some months old post. Is it right that you have made a binary to download? If yes, is it possible to get it?
Thanks.

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

#113 Post by enesbcs » 27 Apr 2018, 18:53

alabama wrote: 27 Apr 2018, 16:00
enesbcs wrote: 31 Aug 2017, 17:24 And i've found a fantastic article by makerrelay:
https://www.hackster.io/makerrelay/esp8 ... ome-e8a437

According to it:
A00101A2 open relay,
A00100A1 closed relay

If you're willing to try, i can make a test binary with the above commands, but there is no guarantee. :)

Update: attached 1M/128k SPIFFS for black ESP-01
Please let me refer to this some months old post. Is it right that you have made a binary to download? If yes, is it possible to get it?
Thanks.
Yes, as i mentioned on several occasions, that every binary is attached at the first post of this thread:
viewtopic.php?p=16998#p16998

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: Serial MCU controlled relay/switch

#114 Post by alabama » 29 Apr 2018, 18:55

Ok - thanks.
(Sometimes I'm wondering myself,why don't I get the simplest ideas?? ;) )

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: Serial MCU controlled relay/switch

#115 Post by alabama » 30 Apr 2018, 02:36

Again: Thanks a lot for this. It works wunderfull!

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

#116 Post by enesbcs » 30 Apr 2018, 07:37

You're welcome. In the meantime i also bought an LCTech relay, but a 12V version which is also works with the same commands. But some reason it only works reliable with 115200 baud setting.
Older models speed was 9600 baud at default.
Attachments
LCTech 12V relay
LCTech 12V relay
lctech12.jpg (34.33 KiB) Viewed 106795 times

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: Serial MCU controlled relay/switch

#117 Post by alabama » 30 Apr 2018, 10:24

Now I have seen that my post was to fast: Wit the original ESP8266-01 it seems not to work. But if I change with another one it works. The only difference I saw up to now is that there is the writing "AI-Cloud inside" on that one wich works and not on that one which not works. Further it seems it's only possible to flash R120 on the original. Today I made a test with my second Rely-Modul ans again I can't flsh neither your FW nor the other 2.x.

I think it is the ESP8266-01 the reason, but I have to continue my tests.

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

#118 Post by enesbcs » 30 Apr 2018, 14:28

alabama wrote: 30 Apr 2018, 10:24 Now I have seen that my post was to fast: Wit the original ESP8266-01 it seems not to work. But if I change with another one it works. The only difference I saw up to now is that there is the writing "AI-Cloud inside" on that one wich works and not on that one which not works. Further it seems it's only possible to flash R120 on the original. Today I made a test with my second Rely-Modul ans again I can't flsh neither your FW nor the other 2.x.

I think it is the ESP8266-01 the reason, but I have to continue my tests.
Puya SPIFF error is an old story. I did not patched ...1M_128kS.bin, instead from P165_19.zip use ESPEasy_R147_1M_64kS.bin this is not affacted by Puya, i am using this version also.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: Serial MCU controlled relay/switch

#119 Post by alabama » 30 Apr 2018, 21:31

Ok, seems you are right. The second one of the modules is working now.

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#120 Post by xury » 30 Apr 2018, 23:51

If someone would like test it. Compiled using recent sources (core 2.4.1)
I compiled it with PUYA patched Esp.cpp
It should by work with differ than PUYA flash IC too.
To fit in 1MB II got rid of some plugins that I think it can not be used with serial controlled boards.
Attachments
ESPEasy_1M_128kSPIFFS_PUYA.zip
(427.4 KiB) Downloaded 3108 times

Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests