Wemos D1 mini - which GPIO ports for relays?
Moderators: grovkillen, Stuntteam, TD-er
Wemos D1 mini - which GPIO ports for relays?
Hi all,
I hope you can help me with my current issue.
I need to connect 2 more relays to my wemos d1 mini runnig espeasy.
The only GPIO ports which are free / not used are GPIO 0/1/2/3/15
Which ones would you use to connect a relays?
thx
sawo
I hope you can help me with my current issue.
I need to connect 2 more relays to my wemos d1 mini runnig espeasy.
The only GPIO ports which are free / not used are GPIO 0/1/2/3/15
Which ones would you use to connect a relays?
thx
sawo
- dynamicdave
- Normal user
- Posts: 258
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Wemos D1 mini - which GPIO ports for relays?
Have a look at this excellent document.
https://randomnerdtutorials.com/esp8266 ... nce-gpios/
It also depends how you are driving the relay.
I suspect you are using a transistor driven from a D-pin.
You have to be mindful of what happens to certain pins during boot-up.
This is because you can stop the Wemos from booting-up if you "pull" a pin the wrong way.
Read the above document as it explains it all.
https://randomnerdtutorials.com/esp8266 ... nce-gpios/
It also depends how you are driving the relay.
I suspect you are using a transistor driven from a D-pin.
You have to be mindful of what happens to certain pins during boot-up.
This is because you can stop the Wemos from booting-up if you "pull" a pin the wrong way.
Read the above document as it explains it all.
Re: Wemos D1 mini - which GPIO ports for relays?
Hi dynamicdave,
thanks for your answer, so in this case I think I will use a seperate wemos to controll the relays.
Thanks
sawo
thanks for your answer, so in this case I think I will use a seperate wemos to controll the relays.
Thanks
sawo
- dynamicdave
- Normal user
- Posts: 258
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Wemos D1 mini - which GPIO ports for relays?
No idea what you are using the other pins for - but if you have I2C running on them you could consider the PCF8574A I2C Port Expander.
Probaly not a lot of difference in cost between this chip and a Wemos D1 Mini.
Probaly not a lot of difference in cost between this chip and a Wemos D1 Mini.
Re: Wemos D1 mini - which GPIO ports for relays?
If you would like to avoid adding more hardware then just disable serial log and use GPIO1 and GPIO3.
FWIW, the relays might momentarily turn on during boot and you won't be able to use serial log. Sometimes this matters, sometimes it doesn't.
- Thomas
FWIW, the relays might momentarily turn on during boot and you won't be able to use serial log. Sometimes this matters, sometimes it doesn't.
- Thomas
Re: Wemos D1 mini - which GPIO ports for relays?
Hi all,
thanks a lot your your answers.
I have decided to use a separate Wemos D1 since I changed my plans, to get my pool solar Control to work.
But now I have a different problem, I bought a 4 channel SPDT relay v1.0 board from seeed, this connects via I2C interface.
My problem now is that it is not recongnized, it just shows the value 0x11 but no supported device.
Do I need to include a special driver or library to get this running?
Thanks
sawo
thanks a lot your your answers.
I have decided to use a separate Wemos D1 since I changed my plans, to get my pool solar Control to work.
But now I have a different problem, I bought a 4 channel SPDT relay v1.0 board from seeed, this connects via I2C interface.
My problem now is that it is not recongnized, it just shows the value 0x11 but no supported device.
Do I need to include a special driver or library to get this running?
Thanks
sawo
Re: Wemos D1 mini - which GPIO ports for relays?
I don't think that I2C device is supported, at least I don't see its address 0x11 handled in the I2C Scanner source code.
Do you have any data sheet for that device available?
Edit:
Found the Seeed github library for these devices (they have 2 and 4 relay boards, and 2, 4 and 8 port solid state versions, all supported by this lib), but it will need a little work to implement, as the library does things not ESPEasy compatible (initialization of the I2C bus is handled by ESPEasy already), but that's fixable.
I will put it on my TODO list, but that will take a little time.
Do you have any data sheet for that device available?
Edit:
Found the Seeed github library for these devices (they have 2 and 4 relay boards, and 2, 4 and 8 port solid state versions, all supported by this lib), but it will need a little work to implement, as the library does things not ESPEasy compatible (initialization of the I2C bus is handled by ESPEasy already), but that's fixable.
I will put it on my TODO list, but that will take a little time.
Last edited by Ath on 17 Nov 2021, 21:08, edited 1 time in total.
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
I hope that it is okay to post the web link IF NOT PLEASE DELETE
https://wiki.seeedstudio.com/Grove-4-Ch ... PDT_Relay/
https://wiki.seeedstudio.com/Grove-4-Ch ... PDT_Relay/
Re: Wemos D1 mini - which GPIO ports for relays?
@ATH
sorry haven´t read your previous post.
Thanks for your info and your effort!!!!
I try to be patient.
sawo
sorry haven´t read your previous post.
Thanks for your info and your effort!!!!
I try to be patient.

sawo
Re: Wemos D1 mini - which GPIO ports for relays?
There is a start already:
(see below for an updated screenshot)
Most important still to do though, command handling
(see below for an updated screenshot)
Most important still to do though, command handling

Last edited by Ath on 18 Nov 2021, 23:19, edited 1 time in total.
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
There will be some more options, like initial state of a relay, and also an output value holding the current state (as a bitmap), that can optionally be sent to a Controller.
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
I've put in some legwork, so this is what I've ended up with:
The settings screen: The Devices overview (not actually tested as I don't own the hardware) And an ESP8266 4M Custom locally created build:
(updated, see below)
If required I can also provide an ESP32 build.
The settings screen: The Devices overview (not actually tested as I don't own the hardware) And an ESP8266 4M Custom locally created build:
(updated, see below)
If required I can also provide an ESP32 build.
Last edited by Ath on 20 Nov 2021, 14:38, edited 1 time in total.
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
What is "startup" ?
A call to PLUGIN_INIT?
This is also called if you press save on the task settings page and then this might not be what you want.
A call to PLUGIN_INIT?
This is also called if you press save on the task settings page and then this might not be what you want.
Re: Wemos D1 mini - which GPIO ports for relays?
Yes, that's at PLUGIN_INIT, and it does have that 'side-'effect. Not sure if it's possible to suppress that behavior when saving, so that's going to be a fair warning in the documentation 

/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
Sure you can.
Define a static int32_t with initial value of 0 in the .ino file, which may act as a task index bitmap.
When you call PLUGIN_INIT, check the bit for this task and if it is not set, call the @setup stuff you need to do and set the bit to 1.
This protection could be made optional too in the settings of course.
Define a static int32_t with initial value of 0 in the .ino file, which may act as a task index bitmap.
When you call PLUGIN_INIT, check the bit for this task and if it is not set, call the @setup stuff you need to do and set the bit to 1.
This protection could be made optional too in the settings of course.
Re: Wemos D1 mini - which GPIO ports for relays?
OK, I'll fix that as suggested.
For a documentation preview, there are a few commands supported:
For a documentation preview, there are a few commands supported:
Code: Select all
multirelay,on,<channel> (channel 1..8, max. accepted as configured)
multirelay,off,<channel>
multirelay,set,<bit-relay-8..1> (value in decimal, 0xnn hex or 0bnnnnnnnn binary)
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
I do get why you're counting from 1...N for the relais, but the bit labelling feels a bit strange.
I know it should be consistent and you are, but still describing bit positions with an index 1 too high (for computer nerds like me
) seems itching...
Not sure how it should be described, but maybe you have some idea?
I know it should be consistent and you are, but still describing bit positions with an index 1 too high (for computer nerds like me

Not sure how it should be described, but maybe you have some idea?
Re: Wemos D1 mini - which GPIO ports for relays?
The numbering in the used library is already that way, and the same for the labeling on the hardware, AFAICS.
I acknowledge that itch about the numbering, and initially even implemented it wrong
had to fix by not subtracting 1 when passing the argument for the on and off commands...
Tried to 'compensate' for that by adding the bit-wise Relay state presentation in the Devices overview page.
Edit:
From the library code (in the turn_on_channel/turn_off_channel methods):
I acknowledge that itch about the numbering, and initially even implemented it wrong

Tried to 'compensate' for that by adding the bit-wise Relay state presentation in the Devices overview page.
Edit:
From the library code (in the turn_on_channel/turn_off_channel methods):
Code: Select all
channel_state |= (1 << (channel - 1));
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
Hi sawo,
Any chance you have been able to test the workings of this plugin? As so often, I don't own the required hardware, so am unable to test it myself

Just to be sure you have the latest version available, here's an updated build:
(Updated, see below)
Last edited by Ath on 21 Nov 2021, 22:26, edited 1 time in total.
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
I did some more work on this plugin the last couple of days, so here's an updated build:
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
Hi Ath,
sorry I was quite busy in the last days.
No I didn´t had the time to test ist yet. But will do in the evening.
Thanks so far!
Sawo
sorry I was quite busy in the last days.
No I didn´t had the time to test ist yet. But will do in the evening.
Thanks so far!
Sawo
Re: Wemos D1 mini - which GPIO ports for relays?
Hi Ath,
I updated my wemos with your version.
The relay modul is conencted and recognized.
But how do I controll them?
What is the command?
Regards
Sascha
I updated my wemos with your version.
The relay modul is conencted and recognized.
But how do I controll them?
What is the command?
Regards
Sascha
- Attachments
-
- device.JPG (28.83 KiB) Viewed 28477 times
-
- i2c.JPG (20.41 KiB) Viewed 28477 times
Re: Wemos D1 mini - which GPIO ports for relays?
A direct link to the help(source), as it will be included in ESPEasy: https://github.com/letscontrolit/ESPEas ... fa02R2-R30
in short:
Channel is 1..8 (or 4 or 2, depending on the number set)
Channel_bitmap is 1 bit per relay from 8..1, can be set in decimal, hex or binary notation, f.e. 0b0011 = 0x3 = 3 (decimal) will turn on relay 1 and 2, or 0b10000100 = 0x84 = 132 (decimal) will turn on relay 8 and 3
in short:
Code: Select all
multirelay,on,<channel>
multirelay,off,<channel>
multirelay,set,<channel_bitmap>
Channel_bitmap is 1 bit per relay from 8..1, can be set in decimal, hex or binary notation, f.e. 0b0011 = 0x3 = 3 (decimal) will turn on relay 1 and 2, or 0b10000100 = 0x84 = 132 (decimal) will turn on relay 8 and 3
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
Hi Ath,
thx works for me so far!!!
Is it possible to get the status of each relay seperatly?
Instead of in one state.
thx
sawo
thx works for me so far!!!
Is it possible to get the status of each relay seperatly?
Instead of in one state.
thx
sawo
Re: Wemos D1 mini - which GPIO ports for relays?
Well, ESPEasy only supports 4 output values, and though technically that number can be changed, that would make migration from/to other versions nearly impossible, because the settings file structure would have to change, so that's not an option.
I can add a command like multirelay,get,channel that will put the channel number in value 3, and the state in value 4 (to get a relation between the on/off state and the involved channel), or maybe even loop the (configured) channel numbers on each read, but I'm not sure if that matches with what you have in mind?
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
I implemented both options, so you can use the command "multirelay,get,<channel>" and get the Channel and Get state (0/1) in 2 extra variables. Or use the command "multirelay,loop,1" to enable updating the channel on each Interval and read the next channel state. That last feature is also an option in the Device Configuration.
A snippet from the help:
And a snippet from the Devices page:
And a local Custom build including these features:
A snippet from the help:
And a snippet from the Devices page:
And a local Custom build including these features:
/Ton (PayPal.me)
Re: Wemos D1 mini - which GPIO ports for relays?
Hi Ath,
will try it tomorrow.
Thanks a lot for your assistance.
Sawo
will try it tomorrow.
Thanks a lot for your assistance.
Sawo
Re: Wemos D1 mini - which GPIO ports for relays?
Hi Ath,
everything works fine for me!!!!
Thanks a lot for your help, hope to finally to complete my project!!!!
Sawo
everything works fine for me!!!!
Thanks a lot for your help, hope to finally to complete my project!!!!
Sawo
Re: Wemos D1 mini - which GPIO ports for relays?
The plugin has been merged into the main 'mega' branch of ESPEasy today, and a formal release will most likely be made available in the coming days.
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 13 guests