Next thing to learn

I’m new to programming and photon. I’ve completed my first project that opens and closes the door for my chickens (yes, I said chickens) so that they can get out during the day and back in at night and be safely locked up when we are away. I’ve had an automatic door for awhile using a sprinkler timer but by using the photon I can get notifications through ifttt and my phone that it has actually happened. It is working great and I’m very happy with it so far. However, currently, I have to manually adjust the open/close time from the opener box. I would like to be able to do that using my phone. What I need are recommendations on what to learn next to accomplish that. Can it be done from a local webpage on my phone like the led toggle example in the manual? Is that the best way? Learning HTML seems like the best way but I don’t want to spend a lot of time on that and then discover it won’t work. Suggestions?

Without knowing what equipment is used to open/close the door, I’ll ask could you simply use 2 limit switches instead of manually adjusting the Time?

Think of a switch that is pressed when the door if in the fully closed position.
Another switch that is pressed when the door is in the fully open position.

To open or close, the Photon performs the action until the opposite switch is contacted.

Thanks for the input Rftop. I’m just looking for a way to remotely change the start time for the opening and closing. I am using a limiting apparatus for making it stop once it starts. I am using LEDS which feed sections of fiber optic cable that then shine on another piece of fiber optic cable that returns to two photo sensors. Works great and the chickens can’t get to any of the electronics because it’s all located in a box out of their reach. I know I have to learn something new for the next step, I just want to make sure what I spend my time on is the correct thing. I’ve looked at coding apps for smartphones but it seems like there are different languages for iOS or Android. HTML looks promising because it appears I can make a webpage that can be locally saved on any device. However, I want to get input on whether this will allow me to upload new start times to my photon through the particle cloud. Any experience with this?

@diver1rn Have you looked at Blynk? It is free, you can create a nice App on your phone and you can receive and send data to the photon. There are many tutorials out there to setup Blynk - not sure about whether there is a time input. Next I would look at a library like DailyTimerSpark in the community library to allow you to send a on/off time to you chicken house door photon and for it to then open and close on its own according to the schedule.

You can definitely use HTML to send a string of data to the Photon. I did this to control our garage door openers. This screen shot is from my computer, but it runs from a Firefox script icon on my family’s Android phones as well.

To get started, simply add the following to your firmware:

  • Particle Variables so you can query values
  • Particle Functions so you can trigger actions and set values

Then use your device’s Particle Console to get the basic functionality working. Once you have that, you can shift to the HTML side of things.

Just my thoughts:

Assuming you want the hen house to open and close in relation to sun rise and sun set…

You should be able to get the sun rise/set time from any number of weather API’s that will return data for your location. That can the be used as a time to compair against the photos time functions and hey presto it will adjust itself on a daily basis. You can add an offset factor and give the hens a few minutes before/after sun set to head in, as your hens have trained you to respond.

One question, how do you know all the hens are in? Isn’t it possible that one lazy bird might miss the deadline, and be left out side alone?

1 Like

Armor, thanks for that input. I gave Blynk a quick look when I was first deploying the new door. I went with ifttt because it was very easy to set up the notification part and is was in a hurry to get it in place because I have some trips coming up. I will give it another look and see if there is a way to upload input.

Bear, I really like your webpage interface. That is exactly what I had in mind. Even if I’m able to pull off the self adjusting feature that videolam is mentioning. Once I finish reading up on HTML and put something together I will post it for you to see. Thanks for the input.

VideoLiam, that’s an interesting idea. I’ll look into that because then there would never need to be an input. As far as how to tell if they are all in, if they are able, they wil be in. You will never see anything as stressed out as a chicken that can’t follow it’s nightly routine for getting back into the pen. If they aren’t able, it’s probably too late anyway. Thanks for the input.

Following this thread as well. Interested in the other options, but wondering if you’ve considered using a light sensor positioned somewhere to read local sun up/down and adjust your open/close times based on those readings?

I had considered the light sensor option, but for tihs application there are a number of drawbacks. First the weather, can make the detection of the light level inconsistant, in relation to dawn or dusk, but not impossible. Secondly as the sensor needs to local, and this application is a hen house, other factors such as dirt, inqesitive pecky things like hens could damage it etc… To avoid this it means placing the sensor well away from interferance and that can be a pain.

It could be possible to simply write and algorythum which advance the time by 2min each day, as after all the movement of the sun is pretty predicable… Just thoughts…

Sorry, I’ve got to get in the habit of checking this each day. Yea, outside light sensors can get fooled by clouds and such. Since the waterer is inside the coop wouldn’t want it to close during the day. I’ve added the waterer to the project also since I last posted. I’ve been spending most of my free time studying the W3 schools online HTML and JavaScript tutorials. Pretty sure that will get me where I need to be. Also, I’ve been chasing down hardware and software bugs that I’m sure appear in most projects as they go on. This is my first project and it’s causing me to have a better understanding of why car manufactures have to occasionally recall cars for software upgrades when the cars do unexpected things. Currently chasing down what appears to be an intermittent loop problem. Keep losing cloud connectivity randomly. Happens at completely random intervals of several days. The photon breathes green and locks up the program. That’s ok though. This is the way I learn best. Beat my head against a wall until I hear a squishy sound. Thanks for the help.

I have some lights set to come on automatically when I come home, but only if it’s also night time. To figure out what “night” is, I use ifttt to call a particle function at sunrise and sunset. It works quite well. I believe it’s getting data from wunderground but it’s been a while since I set it up.

It’s a good question about not locking out any stragglers though.


Photons breathing green and being not responding tend to be due to an unbreakable loop in the code, so the code is stuck and can not complete a cycle of the void loop(). Thats what I’ve found. A basic way to think of it is that, once the code has completed a cycle the photon checks to see if its still conected to the cloud. Assuming it is and it hasn’t been told otherwise it runs the loop again. Now if the loop is trapped doing some thing like adding 1 to an interger like ‘A’, but you forgot to design the loop to stop once it reaches its max value say 100, it keeps adding, and adding, never exits the loop and times out checking for the cloud… hence it breaths green, and its stuck apparently sulking. Very easy to do when using ‘while’ loops.

Pluging in the photon via USB, and putting it in to DUF mode, and flashing the tinker code on the command line interface ‘CLI’, usually recovers the photon easily, and is an indication that the problem it in your code.

One to watch out for…


Thanks. All I had in the code were if/else statements but I had several spots were I had some 60 second delays and some convoluted and/or statement conditions to keep it from publishing the events that notify me when the door opens and closes more than once each time it changes. I dug through the forum for other folks having the same kind of problem. A lot of people had posted their code and I noticed that several had used the same long delay mechanism although that was never identified as the culprit I thought it was something worth trying. I went back and rewrote the code and eliminated all the long delays. I simplified the and/or conditions and used a variable that changes once the event has published and won’t publish again until the variable changes again. So far it’s been 48 hours with no freeze ups. I really appreciate that you are following this post and taking your time helping me out.

1 Like

Well, went for a little over 72 hours without a hitch then locked into listening mode again. Odd to me because my program is based on a 24 hour period. No multi date action at all. Using the time on the LCD as a reference for when it stopped, the program should have been running in the Main loop. Nothing should have been happening at that time. Activated an event in IFTTT to let me know when the photon went online and offline because the coop is a good ways from the house. I was connecting to a netgear extender that I use in my workshop because it should be physically closer to the coop. Got over 60 notifications that the photon had gone offline in a 24 hour period. Not sure if this is normal or not. Was never more than a few seconds. Used my phone to walk around and noted that the nighthawk router from inside the house had a stronger signal than the extender. Used WiFi.setCredentials() to change to the nighthawk. Also found WiFi.setListenTimeout() and added it with a 60 second timeout. Hoping that will kick it out of listening mode if it gets stuck. Also thinking of turning WiFi off except when the photon is expected to publish an event. Will monitor for improvement. Any thoughts on my changes?


I’ve had a photon and a core, publishing enviromental data for about 2 years now. One at home and one at work… I have noticed the one at home go offline from time to time, Some times it flashes blue, and others it flashed green for a while. Sometimes it even will flash red. Its always been out of the corner of my eye so I’ve not made proper notes regarding the colour cycles, times or dates. Usually it sorts itself out and I have dismissed it as something on particles end. However it could be something to do with the service provider. It is possible that which ever port the particle system use’s can be blocked/broken by your service provider, so typical web services might be uneffected. Thus it could be a service provider issue and you just don’t realise becasue everything else is fine. I wonder if anyone else has thoughts to that extent. Other wise it could be a case of running wireshark and trying to monitor the packets going through your router… Do-able, but will take some homework.

Do you have another Photon you can set up and run side by side to see if it is a connection issue?


It’s been a little over 6 days since the changes. No hang ups so far. The IFTTT applet I use to monitor offline/online status only goes off 4 or 5 times a day with the new connection vs the over 60 on the extender. Hoping this has the problem fixed. I’ve been working on your API suggestion for using the sunrise/sunset info from a website. Wunderground doesn’t offer an API for free any more but the TSA does. I built a webhook using the Particle console on the web IDE and it seems to work fine to the console. Still trying to figure out to get the info into my firmware. Any suggestions on a place to read about pulling data into firmware? Most of the stuff I found in the Particle documentation talks about sending data from your device but not how to get data with a webhook and pull it into your firmware. LukeUSMC had a good tutorial on webhooks at Tutorial: Webhooks and Responses with Parsing (JSON, Mustache, Tokens) However, it was done in 2015 possibly before the console was developed? Just haven’t figured how to adapt that into what I need.

Using @LukeUSMC’s tutorial I figured out how to get the data into the firmware. Just had to walk it through slow.


Great news. I don’t supposed you could add a link to the tutorial, as I’m sure there will be people following this thread who might be interested to look over your solution.