A few years back I decided to start raising chickens. By that time I had beetles, worms, snakes, and frogs; you name it! But raising these cute yellow nuggets is a different beast altogether.
At first, it sounds fun. All you do is buy a dozen online and follow the instructions. But what I didn’t know is that your entire experience is driven by the survival rate of your chicks.
So be sure you are ready to commit to their well being. It’s not easy being a chicken master! Many of them pass into the light right in front of you.
In fact, mastering the light is the most important instrument in raising your chicks. The lamp provides constant heat, regulating their body temperature. It must stay consistent at 95–100 degrees, especially in the first two weeks.
I’ve raised a dozen with a regular thermometer and a heat lamp. And noticed that sometimes chicks would get cold and cuddle into a large ball, only to squish a few in the process.
But then when the heat got high, some of the chicks would sweat and often fall ill.
This time, I knew controlling the heat would help the chicks through the initial two weeks. I had to find a way to control the light and measure the temperature.
All you need is the Wireless Sensor Tag (with Temperature) and device to control the light.
Its true, they are very small and come with 700 ft range and 1-year battery life. I have been using them for years.
Wireless Sensor Tags integrates with Belkin Wemo Switch, which controls an appliance power.
You can buy the Belkin Wemo Switch here or on e-bay
After you have both, all you do is plug the Tag Manager into your router and set up the Belkin Wemo Switch, it just works.
This is one of the easiest setups on the market.
Afterward, go to http://my.wirelesstag.net/ and create an account for your tag manager. There you’ll be able to associate it and your Wemo Switch. Just click the + Associate button on the top left corner.
After setting it all up, you should have both light and sensor in Wireless Tag List:
1) Now, click on the Kumo Apps to set up your app
2) In the top right corner select Install
3) Click on this icon
4) In the search start typing “When temperature is too high, turn on Wemo, when temperature is back to normal, turn off Wemo (with delay)” and select it. We are going to use this application as a starter.
5) In the “Configure the App” screen select your sensor, switch & pick delay of 5. Click Apply
6) You should have an app setup in the Kumo Apps list
7) Expand it and click on View Code
8) Take a minute to study the code and you’ll find that the program is rather simple. It consists of two main functions. The wemoAction & sensor.temperatureCross
A detailed description of all the KumoApp API calls:
sensor.temperatureCross — gets executed when the tag has too hot/too cold monitoring enabled. This boundary is configured as part of the sensor configuration.
This routine then calls wemoAction to turn on or off the Wemo Switch.
This should have been good enough, but I found that KumoApp would not work as intended when Wemo Switch disconnected from the internet. This happens with WIFI enabled devices.
The temperatureCross event would execute but my Wemo Switch can’t receive the event. I decided to re-write the program with a more pro-active approach.
Instead of having to wait for a temperatureCross callback from the sensor, I need to have the program ping the sensor to see if the heat lamp needs to be on.
9) Go ahead and copy paste the following code into the application, and click Create / Update App. I will explain how it works below:
10) Click the Start Button!
Let’s go over the code.
In the beginning, I added initial properties used by the application.
- updateFrequencyMin is a very important parameter. It indicates how often the program will ask the sensor for the latest temperature value. The less often you query the sensor, the longer its battery life. In fact, I’ve drained the battery by 50% while making the program. Since I ended up pinging the sensor every few seconds during testing.
- tempRange is the temperature range. The chicks should have 95–100 degrees for the first two weeks. Afterward, reduce by 5 degrees each week until chicks are a month old. I set mine from 95–98.5.
The KumoApp.Log outputs only the latest message passed to it. So I added console.log & console.flush methods to make debugging easier. Every console.log message gets appended to console.str, which gets passed to KumoApp.Log when console.flush executes at the end of the program.
This simplified my debugging.
I changed the wemoAction method to make sure the Wemo Switch is connected. The program pings the wemo switch for its latest properties with wemo.ReloadProperties()
Then added application initialization routine initApp(), where I update the latest sensor temperature. It figures out if the heat lamp needs to be on or off. This only gets executed once when the program starts.
Removed the temperatureCross event from the sensor logic. Modified the logic to use KumoApp.setInterval, which executes every so often. We are executing this logic every 5 seconds.
Every time the setInterval executes, it reloads sensor properties, as indicated in updateFrequencyMin. It then uses the tempRange.higher & tempRange.lower heat range values to figure out whether to turn the heat lamp off or on.
After the first night of testing, I conclude my program a success.
Here is the temperature without the program where I turn off and turn on the heat lamp. The temperature fluctuates between 79–110 degrees.
And here is the temperature with the program, under control, fluctuating between 93–99 degrees.
Update: After two weeks of testing, the survival rate of the chicks increased by over 50%. I had 11 chicks die in my prior batch vs 5 chicks this time around.
Check out my open source framework QQ:
Check out my other articles
Just a few years ago, I wish there was somebody who would tell me what React was without introducing me to ES6, JSFX…
Understanding Reducers from scratch
One of the core concepts that have recently changed how we structure our UI applications is the reducer.
Using Redux standalone
In my prior article “Understanding Reducers from scratch” I’ve introduced Reducers as a concept and expanded on that to…
Awesome ES6 Features By Example