Posted on Leave a comment

Youtube Chat-Actuated Chicken Feeder System

Foreword:

There’s not a whole lot of documentation that i can find on the web that details how to make devices work via a youtube chat command without some kind of “over the top” custom designed youtube hooks that make you sign up for some crazy developer accounts on youtube or write a bunch of custom code specific to a certain kind of hardware. I aim to be simple, as complexity brings other issues like the “Wife Usability Factor”, or WUF – As WUF goes down, so too does overall relational happiness.

While my setup isn’t what I would consider “SCADA System Reliable”, With some proper system tuning on the “Gotchas”, you can prevent failure, or get the failure rate close enough to zero that it’s mostly irrelevant. Mostly. 

I won’t go into detail on every nuance of my setup in this document(cause it’s a lot), but i’ll go though what you need to get a feeder working in youtube chat… then YOU TOO can have the “most advanced” youtube channel in the world. Barf. 

Fore-Afterword:

If you have questions about this setup, or trouble, feel free to shoot me an email. I’m not going to spoon feed you, but relevant questions get relevant answers. Good english helps a lot. 
RyansAviary@gmail.com

Afterword:
If you find this article helpful, and exactly what you’re looking for: 
Consider tossing a few bucks my way, and potentially crediting/linking me on your channel. 
Not only would it be super cool of you, but any donations will go right into feeding the chickens. 

https://www.paypal.me/RyansGoslings

Hardware Prerequisites:


The Feeder:

You’ll need some kind of Actuator. Either a feed auger, or feed spinner. This matters for the type of feed you’re planning to dispense. You’re not going to want a spinner if you’re feeding a dusty feed like layer mash or even crumbles. You’ll need to fabri-cobble a feed storage bin to feed from – I recommend a Plastic 55gal Barrel with a funnel on the inside, and the bottom for feed drop. 

Inside funnel: https://www.amazon.com/gp/product/B000FGS1RS
Outside Funnel: https://www.amazon.com/Wildgame-Innovations-Inch-Polycarbonate-Funnel/dp/B004ZWM354
Barrel Stand: https://www.amazon.com/gp/product/B06VS5BV1V/
Barrel Cover: https://www.amazon.com/gp/product/B005Z7OC02

For Dusty feed, I’d consider building a traeger grill shaftless auger system:
Feed Motor: https://www.amazon.com/Pellet-Grill-Upgrade-Traeger-Grills/dp/B01CZI9MPS
Feed Auger: https://www.amazon.com/Traeger-Pellet-Replacement-Assembly-KIT0023/dp/B076JLFWT4

For Pelleted Feed or Corn/Seed, A spinner feeder is fine.
Varmint Proof Spin feeder: https://www.amazon.com/SpinTech-12VDEZSU-Volt-Digital-Spinner/dp/B003TJ9WEE
12v Powersupply: https://www.amazon.com/MEAN-WELL-RS-75-12-Supply-Single/dp/B005T8XCLW 

You’ll need wire to run to the feeder from the PSU as well. 

BOM Cost with Auger: 205
BOM Cost with Spinner: 250
(You can find all of this stuff cheaper, i’m just linking parts)


Device Contol
You’ll need an outlet that’s cURL-able. (https://en.wikipedia.org/wiki/CURL)
TH3D sells a pre-flashed with Tasmota Outlet here: https://www.th3dstudio.com/product/ezplug-open-source-wifi-smart-plug/

You can buy one of the other super crappy tuya/smartlife plugs on amazon, and flash it to Tasmota or ESPHome, but for the sake of simplicity, we’ll stay with the TH3d plug. It’s good for 10 amps, it’s UL rated, and it supports newer 2.4ghz wi-fi networks(like G). 

Software Prerequisites: 

None of this works on MAC. Get a real computer with a NVIDIA Card that supports NVENC. 

Install Streamlabs Chatbot on your machine: https://streamlabs.com/chatbot
Install OBS on your machine: https://obsproject.com/

You’ll need some plugins, as well.
For script scene execution in OBS: https://github.com/marklagendijk/obs-scene-execute-command-script
For OBS remote control: https://obsproject.com/forum/resources/obs-websocket-remote-control-obs-studio-from-websockets.466/
For SLCB OBS Control: https://github.com/Consoletation/OBSRemoteParameters

I’m not going to walk you through how to install a script into the respective program. There’s PLENTY of documentation on how to do that and it’s fairly simple anyway. 

You need to connect/setup SLCB. It needs to connect to your youtube channel, or branded account. There’s plenty of documentation on this here: https://cdn.streamlabs.com/chatbot/Documentation_Youtube.pdf

You need to install the OBS plugins Websockets and OBS Scene Execute. 

Set up websockets in OBS to allow remote connections. Use a password. Insecure stuff is bad.

Config:

In SLCB, click the little “person” icon in the bottom left of the window. You’ll see “OBS Remote”.
-Enter your IP address of the box OBS is running on. Port should be 4444, unless you changed it. Enter password. 
-Click Connect. If this connects, “Connect” will fade in color, and “Disconnect” will become brighter.
-Make sure all your other stuff is connected, too, like Youtube Streamer and Youtube Bot. 

I *HIGHLY* recommend clicking on the gear icon, and under “general” choosing “Auto Connect On Launch”. 
This will automatically connect SLCB to all the services when you open the program. 

In SLCB, Again, You need to create a command.
-Click “Commands”.
-Enter a command name, like !feeder
-In the response section, enter: $OBSscene(“Feeder”)
This will trigger OBS Remote Parameters to send a scene change command to OBS, To the Scene “Feeder”, or whatever you choose to name your scene. The command above must match the scene name.

In OBS.
-Create your Scene called “Feeder”. The scene doesn’t actually have to “do” anything besides just be there with your video feed.
-In “tools -> scripts”, import your scene_execute_command.lua script. You’ll need a copy of this script for every new command you send. Just copy it and create multiple instances of the script if you want to run multiple things, like lights or whatever.
-In the “Command” section, Enter the path to your script file. If you have spaces in your path, you need to use quotes:
 “C:\Program Files\obs-studio\feeder.bat”
-Check the box “Execute when ‘Feeder’ is activated. Do not enter anything in the value box.

Before we make a script for your feeder… you need to configure your smart plug.
Plug it in, Give it a few seconds to boot, and on your cellphone or laptop with wireless, find the AP the plug is broadcasting and connect to it. On android, it usually tries to make you sign in, and in turn takes you to the config page. 

If it doesn’t, go to 192.168.4.1.

On the config page, enter your Wireless AP name, and it’s password. You can name the plug here too, if you desire. 

If all goes well, get into your router and find it’s IP. I’d heavily recommend setting a static IP address or reserved DHCP address at this time. On the Tasmota page, you should be able to actuate the switch. 

The script… 

Alright, back on your PC, you’ll need to create a script in whatever path you entered for the “command” section of the Scene Execute plugin.

In that script, Enter this, with your specifics:

curl -s http://192.168.1.10/cm?cmnd=Power%%20On
ping 127.0.0.1 -n 4 > nul
curl -s http://192.168.1.10/cm?cmnd=Power%%20Off

This will turn the plug on, and after 4 seconds, turn it off. 
***Do NOT use toggle here. The plug can default to “on” and run out your feeder… 
***Make sure you keep the double %%, as CMD does some real dumb stuff called command expanding. 
Could the scripting be better, sure. Absolutely. It’s all PoC. 
Tasmota supports backlog, too, so realistically, this could all be one line without the need for a batch file. 
For all in-tents and purposes, this should be all you need to do. 

Try your !feeder command in youtube chat and see what happens. 

It’ll either work, or you have some debugging to do. 

Now… Those Gotchas. 

OBS, SLCB, and a bunch of other ancillary software was built for short-session streaming. This means that RTSP Streams freeze, OBS cracks out, and SLCB will become… deaf? I’ve noticed Tasmota likes to crash on garbage hardware too, so be prepared for unresponsive outlets if you use something other than the ezplug. 

Gotcha 1: Freezing and failure

Task Scheduler/cron is your best friend to keep your stream up. 

Here’s a windows based restart script. You’ll need psexec and OBSCommand if you want to set a start scene:

taskkill /im obs64.exe /f /t
taskkill /im obs64.exe /f /t
ping 127.0.0.1 -n 1 > nul
cd “C:\Program Files\obs-studio\bin\64bit”
..\..\psexec.exe -i -d obs64.exe –startstreaming –multi
ping 127.0.0.1 -n 4 > nul
cd “c:\Program Files\obs-studio\OBSCommand”
OBSCommand.exe /server=127.0.0.1:4444 /password=password52 /scene=”Inside”
exit

Gotcha 2: Latency
You want some user satisfaction, too, when they send the feed command. 

Make sure your youtube stream is set for ultra-low latency, otherwise there can be a 8-10 second delay between command and video. This is why you need a real computer. 

Gotcha 3: Pay-to-Play
If you want people to pay for this fun, you’ll need to have one of two things happen:

  1. Get 1000 subscribers and 4000 watch hours on youtube to enable superchats. 
  2. Get a streamlabs account so you can use their tip page and payment processor. 
Leave a Reply

Your email address will not be published. Required fields are marked *