ESP8266 Smart Sprinkler System

I started this project but can’t find the R8, out of stock. Also I wanted to use an ethernet port because i like as little wireless in my home as possible. I know, I am a freak, I purchased a sainsmart web relay that appears to do the same thing (maybe)

Just wondering if anyone has used one of these or if the code would be similar?

Thanks guys for the work on this project.



Unfortunately, that Ethernet/Controller does not use an ESP8266 microcontroller. Therefore, it does not look like you will be able to use the same code.

Maybe it has a 5200 or 5500 chipset?


Bummer… just looked. It has the ENC28J chipset

I received the R8 but I did not get a charger for the unit. Can you point me to an amazon link for an appropriate charger?

Just wanted to give you a heads up that you can order the R8 from Amazon:

1 Like

Does your scheduler work on the older system because that one no longer works

Hi folks. So I got the LinkNode R8 and I am just got around to trying to use the Arudino IDE to load up the code on it.
The problem is that the FTDI cable I have is the following:

My FTDI cable is 6 pins and the LinkNode board is 3 pins. Can someone recommend what kind of an FTDI cable I should get so I can program the LinkNode?

You can use these wires to make the connections you need.

Is there a way to give my Smart Sprinkler System a Static IP?
Also, one thing I am having problems with is removing the ESP8266 from the network after it knows my wifi credentials. I can’t seem to figure out how to have the ESP8266 ‘forget’ the credentials.

I am having an issue with the Smart Sprinkler in that when I disconnect my linknode r8’s power, then the device drops off of the network. I do not see it going into access point mode and it is not granted an IP by my router. I end up having to upload my code back to the linknode to get it working again. Obviously that is not going to work on the long run as I don’t want power outtages to knock my sprinkler system from working when the power comes back on.

Any thoughts on what might be wrong?

1 Like

First off I would love to say thanks for the start on this. Since we don’t have the st shield anymore this is a great option, not to mention I see this being used for much more.

Here is my issue I loaded everything needed the device type, discovery etc. the discovery groovy does not discover the device. :frowning: so I tried to debug and I’m getting a groovy error. It seems to hit the espxxx.xml on the device for the upnp discovery. But it fails at a certain line code. I can look it up exactly but don’t have it right at the moment.

Second issue. I finally got it working by adding manually via ip. Here is what’s weird after playing with the code for the esp I got the relays to turn on and off just fine, at first it would crash or stall on posting updates back to the hub. At first it didn’t have a hub and port saved. So I noticed it forces a ip and port when opening the gear in the device. So here is the issue I had. I finally got everything to work the device was turning on and off just fine. btw im using a linknode r8.

So everything was working I would click on and it would send then report back to st that the relay or zone 1 was on or off etc. My issue with this was it would never report back to st automatically like if you ran a full 6 zone run as each zone turned off it would never show what was running currently unless you refreshed it manually, I’m not sure if this was just never implemented to refresh every so often? If it wasn’t ok. So that would have been fine.

Here is the major issue I am having now. I got a r4 to play with the 4 relay version. So I added it the same way manually via ip. Now everything doesn’t work. I can’t get either to show status back to smart things. I can click zone one on but it never shows its on in st. I have deleted all devices out of st even removed the app.

Only added one r4 back and still nothing. I can’t get it to function at all now. I have spent hours I am lost. :frowning:

Can you please post all versions of the code you have I think there is something broken. Maybe I missed something?

One thing is when first adding the device manually then checking the device the firmware and ip don’t show up every now and again I can get it to show up then it seems to work for a second then stop working. What’s weird is this was all working great before besides the status not updating after each zone ran.

Btw I am a designer, I know little bit of Java, I am writing this on a phone I hope it’s not too crazy long.

Ok here is a update, I wrote reset bin file that resets the settings then after deleting the device from st I then restored the stock code, was able to re-add the device waited a few minutes for the firmware and ip to show up on the device and in the st ide. Then it changes the device id to the MAC address and also adds a Mac field. Then bingo its working again.

But I’m a person likes to figure out a issue. So I deleted tried to re add and now no luck. So it seems to mess up when it doesn’t populate the Mac and ip info it just sits there. :frowning:

I would like to help out with this as much as I can also if I can add some features to it.

Such as a password protected mode, uptime reporting. Password to the web access or at least the reboot and ota.

Again thank you for this project! Sorry my battery is about to die on my phone.


Ok, I feel like I’m the only one who is watching this forum I don’t know how to message the author on here?

But I guess someone will read this eventually.

I fixed up the code a bit.

Here is everything I have figured out so far.

1.) The discovery mode seems broken? --errors on the ide when requesting the esp3xxx.xml I suppose I can fix this haven’t really looked into it.

2.) The initial code would add the device manually I would know it’s working when the firmware and ip were populated. But when trying to send a on command to any of the zones it would lock on the “pushing updates to hub”. I modified the code to fix this.

3.) It wasn’t updating the status back to st for the correct on/off for each zone. I fixed this also. I am not sure if I am having these issues why anyone else isn’t? Maybe since I’m running v1 hub I wouldn’t think that would be the issue ? I did fix this also. It reports back 95% of the time.

4.) So the issues I have still is the weather does not seem to work in the scheduler *the rain or the above degrees setting.

5.) Another issue I am still having is if I remove any of the devices then try to re add them they do not work unless the device id in the st ide matches the MAC of the device? Initially the discovery groovy seems to after a minute or two change the device to the MAC but upon deletion of the device and re adding it does not. Not sure what is causing this right now. I don’t know is smart things does this for security reasons but if the MAC is not set to the device id it will not allow status updates.

I would like to have some help with any this? Does anyone want to snag up a $10-15 board and play with this stuff. We can use this for so much more than just sprinklers! Thanks to the op!

I will keep posting updates, would be nice to get some people involved testing out current code I’m working on. Thanks!

Btw I’m using a linknode r4 and r8 :slight_smile:

I’ve been traveling a lot for work lately so I haven’t had time to work on this much. My sprinkler controllers have been working pretty well all summer so I haven’t really thought about making changes. I don’t have time to review the code in detail this morning, so I’m going from memory for now. Below are a few thoughts…

I’m a little surprised to hear about some of the issues you’ve been having because I haven’t seen them and they haven’t been reported by others. I’m wondering if they may have to do with either your version of the hub or possibly your internal network. The discovery mode uses SSDP and may require UPNP to be enabled on your router.

There may very well be issues when setting the device manually. Most of that code was borrowed from others and since the discovery mode seemed to work reliably that was what I tested most. The issue of not reporting status back to ST correctly may have to do with how picky ST is about the deviceNetworkID begin set properly. ST requires the deviceNetworkID to either be the MAC of the device or a combination of IPAddress and port number all in hex. MAC address seems to work reliably but I’m not sure if the IP:port combination ever did. Setting the device manually sets the deviceNetworkID using the IPaddress:port all in hex, and if I remember correctly, the device handler tries to change the deviceNetworkID to the MAC as soon as it can. Definitely would love to see your changes and improvements to make this work reliably

Regarding the scheduler with the weather features… This seems to be an issue with the ST getWeatherFeature API call. getWeatherFeature looks up weather information from Weather Underground. Apparently Weather Underground limits the number of calls that can be made for free. It appears that too many ST handlers are calling the getWeatherFeature an overrunning the ST allotment of free ST calls. Sometimes it works and sometimes it doesn’t - but I’ve had it be fairly reliable if I set my schedule to kickoff at odd times like 10:07 rather than 10:00. I haven’t had time to really dig in and look for alternatives.

Thanks for your interest and work on these devices and integration. I agree, there are a lot of different things these can be used for besides just sprinklers!

1 Like

Great, thank you again for the start on this and the information provided in your reply!

Ok I understand the weather call now, wonder if there is another free api we can use ? Yeah it makes sense why it wasn’t communicating with the device due to do the MAC address not being in the device id.

I am wondering if the v1 hub has anything to do with this. I wouldn’t think so. Did you not have any issues with your latest code freezing on the pushing updates to hub. :slight_smile:

I was wondering that on the upnp option, I don’t have it enabled on the router. So maybe I will go ahead and enable the upnp then see if I can get the device to discover. I figured that was the case. Other than I did see the request to the espxxx.xml and then the error in the ide. So I will mess with that. :slight_smile:

Again thank you for this I’m not sure why people aren’t jumping up and down considering all the uses for this. I would like to improve on the code & design of the main dth.

I haven’t looked into the static ip option for the code yet, but for a response to the person above I would say the easiest way for that would be to assign a reservation in your router under your dhcp settings.

I think it would be great to set varriables to the device and have it stored. Like for example if you enable the pump but then the device reboots it forgets the pump was enabled then defaults back. I know most people won’t be losing power, or I guess you can hard code the pump always on but for the people who don’t know how to do that it would be nice to store these varriables on the device.

Btw do you have any issue with reporting back to the hub status of the zones? I’m getting about %95 of the responses back for each zone. Every now and again it misses zone x turned on in the history of the device. But since the timers are scheduled on the device its not a big deal. Just informational.

One last question, seems to be random delays between each zone sometimes the next zone turns right on other times it takes a minute or so? Do you know why this is? Also on the r8 the 8 relay seems to turn on for a second on reboot not sure if that’s code or the esp its self doing that?

Thank you!

@bickyb the easiest way is to set a dhcp reservation in your router to keep the ip static. I will look into the code and see if it’s possible to set a static ip. I know on the Ethernet devices you can. :slight_smile:

One reason could be because there are already other well-established solutions for integrating microcontrollers into SmartThings. Have you checked out my ST_Anything solution? You can implement basically any ST Capability (or multiples of each) with just a single simple Arduino sketch. Contact sensors, temperature sensors, humidity sensors, relays, momentary relays, water sensors, light level sensors, voltage sensors, smoke detectors, co detectors, etc… I’ve created an entire package to allow you to build your own “Anything” to meet whatever needs your project has.

@ogiewon I did not know about this? I can basically do the same thing timers and everything ? Are the timers built in to the device or do they require the cloud? It says edit one line of sketch code?

Does that mean tell it which board your using esp8266 for example ? Also it says in your drawing v2 hub is that required? Other than local processing and battery backup what is the big difference vs v1?

Have you already implemented the ability to password protect your esp uptime reports etc ? Any other cool features I would be excited about.

By the way I love the st community do you know if there is any other cloud home automation system out there that allows you to create custom device handlers and custom device types? I know about home automation assistant which is all non cloud. Openhabb, don’t get me wrong I have been using st ever since its kickstarter.

I would love to have it local and not depend on the cloud. But I don’t want to give up all the community and custom apps everyone has made.

Thank you!

Both hubs seem to work equally well for ST_Anything. I recently pulled out my old v1 hub and ran some tests successfully.

I have example sketches for each type of micro controller. You just need to start with the one matches your board. Inside the sketch, you will see lines of code in the setup() routine where devices are defined and associated with specific pins. This is the file you edit to define your specific configuration. Want 2 switches, 3 timed relays, temperature and humidity, just define them in setup(). Child devices are automatically created in ST based on what you define in the sketch.

ST_Anything does not support configuring the ESP8266 over WiFi. The configuration is in the sketch for networking. There is no automatic device discovery. I chose to keep things simple. Also, all of the features are supported on all of the various board configurations. Pros and cons to both approaches. Always room for improvements.

As for the timers, they are defined in the sketch and handled locally. This is not to say that you couldn’t set the timers for a relay from the cloud if desired and still have the micro controller perform the timing. Currently, the timing is predefined in the sketch and though.

Probably best to continue this discussion in the ST_Anything discussion thread…

1 Like

Will do thank you.

I will look more into this st anything. My thoughts are these are two different projects there are some similarities. But for people who just want a easy to setup sprinkler timer system, timers set via the app.

Stanything sounds like it would need to be coded into the sketch. Which is fine for the tinker guy who wants to do that, but for the guy who just wants to modify his times on the fly then this seems more towards them. On these devices the arduino etc. I would like to see all of the configuration done via the cloud timers being set varriables etc then stored on the device.

Thanks for your input. Do you know of any other platform where we have this much control ? Without a cloud requirement ? I’m not against smart things. :slight_smile: