Serial MCU controlled relay/switch

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
Micha_he
Normal user
Posts: 206
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Serial MCU controlled relay/switch

#401 Post by Micha_he » 02 Sep 2020, 08:06

But you must new configure your device! The plugin get a other number...

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

Re: Serial MCU controlled relay/switch

#402 Post by fresnoboy » 02 Sep 2020, 08:42

Micha_he wrote: 02 Sep 2020, 08:06 But you must new configure your device! The plugin get a other number...
I know, it resets and should be broadcasting on a new SSID right, just like it was when it was initialized the first time? I don't see any wifi signal coming from it...

thx!

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

Re: Serial MCU controlled relay/switch

#403 Post by Micha_he » 02 Sep 2020, 11:28

No. If you didn't factory-reset your ESP before new flashing, it didn't loose the config. It starts with the last config.

Or flash a blank (with the suitable size of the ESP-flash) image before the new one, to clean it.

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

Re: Serial MCU controlled relay/switch

#404 Post by fresnoboy » 02 Sep 2020, 20:10

Ok, I flashed it with the PUYA image that I had used before, and the module came up fine. I configured it to talk to the wifi network, and all was well. The I tried to flash the newer ESP_Easy_mega_20200029 4M1M images, but none of them would come up and work. No contact on the wifi network, and no blue blinks as is normally seen on the PUYA image.

I used the test and custom loads, (all 4M1M .bin's) and no go. So I am clearly doing something wrong, as this isn't even getting the core functionality to work. It's still in the programmer connected to USB power (but flipped back to the UART position after programming), and I can't even connect to it via WiFi.

Any ideas?

thx
mike

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

Re: Serial MCU controlled relay/switch

#405 Post by TD-er » 02 Sep 2020, 21:42

If you had a PUYA build working, then you had 1M build?
PUYA chips only were in 1M flash sizes, as far as I know at least.

So make sure you have a build for the right flash size.

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

Re: Serial MCU controlled relay/switch

#406 Post by fresnoboy » 02 Sep 2020, 23:02

TD-er wrote: 02 Sep 2020, 21:42 If you had a PUYA build working, then you had 1M build?
PUYA chips only were in 1M flash sizes, as far as I know at least.

So make sure you have a build for the right flash size.
That was the problem, I needed to use the 1M image. However, when loading that version, I don't see any option for a serial controlled switch in the device types. This is with: ESP_Easy_mega_20200829_normal_ESP8266_1M.bin

There don't appear to be any "test" builds that are 1M in size, at least for the latest pre-release version. This is why I asked the question in the first place about which load works on the LC Tech switch 8266 and has the serial port switch compiled in.

Is there another place to get downloads than the github repository that would have an updated 1M build with the serial switch support compiled in?

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

Re: Serial MCU controlled relay/switch

#407 Post by Micha_he » 02 Sep 2020, 23:11

Same here with 'ESP_Easy_mega_20200829_normal_ESP8266_1M_VCC.bin'. No 'Serial MCU controled switch' available !

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

Re: Serial MCU controlled relay/switch

#408 Post by TD-er » 02 Sep 2020, 23:13

It is indeed labeled "testing" so only appears on the "test" builds.

I can make a separate build definition for this one.
If you're using it on a 1M unit, then you probably also don't have lots of other plugins needed, right?

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

Re: Serial MCU controlled relay/switch

#409 Post by Micha_he » 02 Sep 2020, 23:25

I need it on my MOES WIFI Dimmer with 1MB Flash.

I use only:

- openHAB MQTT
- Serial MCU controlled switch
- Switch input

Maybe 'Generic dummy device' is a good idea... But I'm not currently using it.

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

Re: Serial MCU controlled relay/switch

#410 Post by TD-er » 02 Sep 2020, 23:37

Can you make an issue for it, or else I may forget about it tomorrow.

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

Re: Serial MCU controlled relay/switch

#411 Post by fresnoboy » 03 Sep 2020, 00:13

TD-er wrote: 02 Sep 2020, 23:13 It is indeed labeled "testing" so only appears on the "test" builds.

I can make a separate build definition for this one.
If you're using it on a 1M unit, then you probably also don't have lots of other plugins needed, right?
Right, this is for the LC Tech switches in this thread, so not a lot of other stuff in terms of devices for me and I suspect people in this thread.

thx
mike

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

Re: Serial MCU controlled relay/switch

#412 Post by TD-er » 03 Sep 2020, 08:59

So somtheing like this should be OK:

Code: Select all

    "CONTROLLER_SET_ALL",
    "NOTIFIER_SET_NONE",
    "PLUGIN_SET_ONLY_SWITCH",
    "USES_P001",  # Switch
    "USES_P026",  # Sysinfo
    "USES_P029",  # Domoticz MQTT Helper
    "USES_P033",  # Dummy
    "USES_P037",  # MQTT import
    "USES_P081",  # Cron
    "USES_P091",  # SerSwitch


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

Re: Serial MCU controlled relay/switch

#414 Post by fresnoboy » 03 Sep 2020, 23:15

TD-er, I need the openhab MQTT plugin as well. That tends to be a very popular MQTT client...

thx!
mike

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

Re: Serial MCU controlled relay/switch

#415 Post by TD-er » 03 Sep 2020, 23:36

fresnoboy wrote: 03 Sep 2020, 23:15
TD-er, I need the openhab MQTT plugin as well. That tends to be a very popular MQTT client...

thx!
mike
Have you tested the test build I made?

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

Re: Serial MCU controlled relay/switch

#416 Post by fresnoboy » 04 Sep 2020, 00:04

TD-er wrote: 03 Sep 2020, 23:36
fresnoboy wrote: 03 Sep 2020, 23:15
TD-er, I need the openhab MQTT plugin as well. That tends to be a very popular MQTT client...

thx!
mike
Have you tested the test build I made?
Yes indeed. I flashed it fine and it booted and ran on the esp8266, and picked up the config from the last flash I had done on it. It seems to find the hardware, though the code for the serial controlled switch seems different than what is in the PUYA version, which has a field for the # of relays in the device as opposed too assuming 4. Based on the switch used, this should work fine, though it will report more relays up to MQTT than actually exist.

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

Re: Serial MCU controlled relay/switch

#417 Post by TD-er » 04 Sep 2020, 17:51

So this is a bug?
What should it do and what do you now see on MQTT?
Would be nice to see MQTT output.
And also if it really is a bug, it would be great to have it on Github (not on the forum, as it hard to find later)

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

Re: Serial MCU controlled relay/switch

#418 Post by fresnoboy » 04 Sep 2020, 23:45

TD-er wrote: 04 Sep 2020, 17:51 So this is a bug?
What should it do and what do you now see on MQTT?
Would be nice to see MQTT output.
And also if it really is a bug, it would be great to have it on Github (not on the forum, as it hard to find later)
Sorry for not being clear, the build didn't have the Openhab MQTT agent in it which is what I normally use and have a working config for.

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

Re: Serial MCU controlled relay/switch

#419 Post by TD-er » 05 Sep 2020, 14:27

Not any controller?

Can you try this one? https://www.dropbox.com/s/8xfhij4jpioq0 ... M.bin?dl=0
It has the stable controllers included.

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

Re: Serial MCU controlled relay/switch

#420 Post by fresnoboy » 05 Sep 2020, 20:50

TD-er wrote: 05 Sep 2020, 14:27 Not any controller?

Can you try this one? https://www.dropbox.com/s/8xfhij4jpioq0 ... M.bin?dl=0
It has the stable controllers included.
It still doesn't have the Openhab MQTT controller in it as the original PUYA one in this thread did, but I figured out how to get the Domoticz MQTT to work with my broker so at least for me, it seems to be a good replacement.

I'll test it over the next few days and see if its more reliable.

Will this be one of the standard github builds going forward?

thx
mike

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

Re: Serial MCU controlled relay/switch

#421 Post by TD-er » 06 Sep 2020, 11:44

What controller do you need then?
It should include these:

Code: Select all

#ifdef CONTROLLER_SET_STABLE
    #define USES_C001   // Domoticz HTTP
    #define USES_C002   // Domoticz MQTT
    #define USES_C003   // Nodo telnet
    #define USES_C004   // ThingSpeak
    #define USES_C005   // Home Assistant (openHAB) MQTT
    #define USES_C006   // PiDome MQTT
    #define USES_C007   // Emoncms
    #define USES_C008   // Generic HTTP
    #define USES_C009   // FHEM HTTP
    #define USES_C010   // Generic UDP
    #define USES_C013   // ESPEasy P2P network
#endif

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

Re: Serial MCU controlled relay/switch

#422 Post by fresnoboy » 06 Sep 2020, 18:24

USES_C005 is the one I was referring to... Would be great if that were included.

Thx
Mike

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

Re: Serial MCU controlled relay/switch

#423 Post by TD-er » 06 Sep 2020, 21:48

It should be included in the last test build I linked : https://www.dropbox.com/s/8xfhij4jpioq0 ... M.bin?dl=0
But since the build size hardly differs from the one I made before, I think it must also be included in the one before.

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

Re: Serial MCU controlled relay/switch

#424 Post by fresnoboy » 06 Sep 2020, 22:22

TD-er wrote: 06 Sep 2020, 21:48 It should be included in the last test build I linked : https://www.dropbox.com/s/8xfhij4jpioq0 ... M.bin?dl=0
But since the build size hardly differs from the one I made before, I think it must also be included in the one before.
TD-er, I am very sure that build only has:

Standalone
Domoticz HTTP
Domoticz HQTT
Generic HTTP
ESPEasy P2P Networking

At least thats the only thing I see when I go to controllers and select the protocol menu option.

thx
mike

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

Re: Serial MCU controlled relay/switch

#425 Post by fresnoboy » 06 Sep 2020, 22:26

PS I also don't see an option in this build for a log ("Open log output") in the tools page. The realtime updating log is pretty handy for debugging things. Did it move to a different place in the newer builds?

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

Re: Serial MCU controlled relay/switch

#426 Post by TD-er » 06 Sep 2020, 22:28

No, that's probably got something to do with me selecting the "OTA" definition to make a smaller build.
That macro also disables a lot of debug logs and some more like timing stats etc.
But since it won't fit in OTA-sizes, I guess it does not make sense to keep it small.
I will enable it and make a new test build.

New test build: https://www.dropbox.com/s/8vx1cadxlz8rb ... M.bin?dl=0

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

Re: Serial MCU controlled relay/switch

#427 Post by fresnoboy » 06 Sep 2020, 23:13

TD-er wrote: 06 Sep 2020, 22:28 No, that's probably got something to do with me selecting the "OTA" definition to make a smaller build.
That macro also disables a lot of debug logs and some more like timing stats etc.
But since it won't fit in OTA-sizes, I guess it does not make sense to keep it small.
I will enable it and make a new test build.

New test build: https://www.dropbox.com/s/8vx1cadxlz8rb ... M.bin?dl=0
Ah! Perfect! All the controllers from the original PUYA build and more, and the log window as well. I'll work on configuring this and see how well it works!

Thanks so much!
mike

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

Re: Serial MCU controlled relay/switch

#428 Post by TD-er » 06 Sep 2020, 23:21

Please let me know if you're still missing something.
Otherwise I will merge it and it will be part of the next nightly builds.

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

Re: Serial MCU controlled relay/switch

#429 Post by fresnoboy » 07 Sep 2020, 02:03

TD-er wrote: 06 Sep 2020, 23:21 Please let me know if you're still missing something.
Otherwise I will merge it and it will be part of the next nightly builds.
I am upgrading the software on my LC Tech builds with this one. It converted over from the PUYA build referenced in this thread fine, with the exception of the serial controlled switch device. After thew new firmware booted, when you go to devices, it says Plugin 165 not included in the build.

I can manually update the config and seems to work fine, but it's not a seamless upgrade. Are there two serial controlled switch plugins?

thx
mike

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

Re: Serial MCU controlled relay/switch

#430 Post by Micha_he » 07 Sep 2020, 07:50

No, but you read my post here ?

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

Re: Serial MCU controlled relay/switch

#431 Post by TD-er » 07 Sep 2020, 09:27

fresnoboy wrote: 07 Sep 2020, 02:03
TD-er wrote: 06 Sep 2020, 23:21 Please let me know if you're still missing something.
Otherwise I will merge it and it will be part of the next nightly builds.
I am upgrading the software on my LC Tech builds with this one. It converted over from the PUYA build referenced in this thread fine, with the exception of the serial controlled switch device. After thew new firmware booted, when you go to devices, it says Plugin 165 not included in the build.

I can manually update the config and seems to work fine, but it's not a seamless upgrade. Are there two serial controlled switch plugins?

thx
mike
The old provided build had a plugin ID of 165, which is from the range of the playground plugins.
The new build I made is with the code moved to the main repository, which thus have a lower plugin ID.
So your settings of P165 should be deleted and added again to make it work with this last build.

svde
Normal user
Posts: 8
Joined: 07 Aug 2018, 19:35

Re: Serial MCU controlled relay/switch

#432 Post by svde » 10 Sep 2020, 12:11

Looks like the plugin in the main repository has ID 91. I've built it and see that it was being compiled. But I don't see it in the list of devices.

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

Re: Serial MCU controlled relay/switch

#433 Post by TD-er » 10 Sep 2020, 12:23

Do you have "USES_P091" defined in your build?

svde
Normal user
Posts: 8
Joined: 07 Aug 2018, 19:35

Re: Serial MCU controlled relay/switch

#434 Post by svde » 10 Sep 2020, 13:08

TD-er wrote: 10 Sep 2020, 12:23 Do you have "USES_P091" defined in your build?
OK. Corrected that. It's working now.

svde
Normal user
Posts: 8
Joined: 07 Aug 2018, 19:35

Re: Serial MCU controlled relay/switch

#435 Post by svde » 10 Sep 2020, 18:13

Any chance that the "Output - Domoticz MQTT Helper" device can be used to control the relay?

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

Re: Serial MCU controlled relay/switch

#436 Post by fresnoboy » 10 Sep 2020, 20:03

svde wrote: 10 Sep 2020, 18:13 Any chance that the "Output - Domoticz MQTT Helper" device can be used to control the relay?
Don't think so. That relay is controlled by the 8266's serial port.

svde
Normal user
Posts: 8
Joined: 07 Aug 2018, 19:35

Re: Serial MCU controlled relay/switch

#437 Post by svde » 11 Sep 2020, 10:56

Too bad, it would make the "Output - Domoticz MQTT Helper" a lot more useful if it could do that. Another usecase is behind able to take a value from MQTT and store it in a variable. I may start a different thread on this, as it's off-topic here.

User avatar
Ath
Normal user
Posts: 243
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Serial MCU controlled relay/switch

#438 Post by Ath » 11 Sep 2020, 11:22

You could use the more generic MQTT Import plugin to receive values from Domoticz, then act on the data using the Rules event that is activated when the value changes:

Code: Select all

on MQTTImport#Value1 do
  // Send (serial) command to turn on/off relay
endon
/Ton

svde
Normal user
Posts: 8
Joined: 07 Aug 2018, 19:35

Re: Serial MCU controlled relay/switch

#439 Post by svde » 12 Sep 2020, 08:25

My understanding is that the "Generic - MQTT Import" plugin isn't suitable to get data from Domoticz. Domoticz publishes everything under one MQTT topic (domoticz/out) in json format, example:

domoticz/out {
"Battery" : 255,
"RSSI" : 12,
"description" : "",
"dtype" : "Air Quality",
"hwid" : "5",
"id" : "82228",
"idx" : 228,
"name" : "Kitchen CO2",
"nvalue" : 621,
"stype" : "Voltcraft CO-20",
"unit" : 1
}

I haven't been able to find examples of the "Generic - MQTT Import" plugin working with Domoticz.

The nice thing about the "Output - Domoticz MQTT Helper" plugin is that it takes care of parsing the json which domoticz publishes to domoticz/out.

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

Re: Serial MCU controlled relay/switch

#440 Post by TD-er » 12 Sep 2020, 13:07

So, what are you missing?
Should it -based on the IDX value- send an event with the nvalue or svalue as eventvalue?

svde
Normal user
Posts: 8
Joined: 07 Aug 2018, 19:35

Re: Serial MCU controlled relay/switch

#441 Post by svde » 13 Sep 2020, 16:38

I currently have 2 usecases:

1) Sending outside temperature and humidity values from domoticz to the ESP, so it can be displayed on an oled screen. I currently have a dzvents script which is triggered by the Buienradar device:

Code: Select all

local FQDN0 = 'esp-easy-0.XXXX.XX'

return {
	active = true,
	on = {
		devices = { 'BR THB' }
	},
	execute = function(domoticz, device)
		br_thb = domoticz.devices('BR THB')
		domoticz.openURL({
			url = 'http://' .. FQDN0 .. '/control?cmd=TaskValueSet,4,1,' .. br_thb.rawData[1] .. ''
		})
		domoticz.openURL({
			url = 'http://' .. FQDN0 .. '/control?cmd=TaskValueSet,4,2,' .. br_thb.rawData[2] .. ''
		})
	end
}
The values are written to the 4th (dummy) device:
Image

And displayed on the OLED screen:
Image

I'd like the "Output - Domoticz MQTT Helper" plugin to pick up these values from MQTT itself. In this case, follow idx 549 and put the values in the dummy device.

2) Send the state of a virtual switch in domoticz to the ESP. This ESP is a lctech board with a serial controlled relay.

At the moment a http call is done from domoticz to the ESP:
Image

It would be nice if the "Output - Domoticz MQTT Helper" plugin could also select the relay device next to the gpio.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests