setup - smouldery/shock-collar-control GitHub Wiki


NOTE: this has been tested on Raspbian GNU/Linux 9 (stretch), and the automated script SHOULD work from a clean install once you have a working internet connection (this is required). results on other versions or on an existing raspbian 9 install.

HARDWARE SETUP

refer to the below images for a pinout first, the pi: pin 2 and 4 are 5v, one to each module. pin 9 and 14 are GND. you can use any GND but each module needs one. pin 11 is the TRANSMITTER data line and pin 13 is the RECEIVER data line.

a Raspberry Pi 2 model B board being held, it is in a black case and a thumb is visible holding back wires. there are six wires of various colours, and a red light above them. on pin 2 and 4 red wires are attached with the label "these are both 5v lines - one goes to each module". on pin 9, a green wire is attached, and on pin 14, a blue wire is attached, which both have the label "these are both GND pins. one to each module". on pin 11, a brown/orange wire is attached - this is labelled "this goes to the TRANSMITTER data pin". on pin 13, a yellow wire is attached - this is labelled "this goes to the RECEIVER pin"

RECEIVER pinout:

a '2008-8' model 433 MHz Receiver with annotated labels. there are 4 pins, but the second pin from the left is not attached to a wire. the leftmost pin is labelled GND on the receiver , has a blue wire attached and is labelled "GND pin - from pin 9 or 14". the pin second from the right has a yellow wire attached, and is labelled "from pin 11 - Data Out". the pin on the far right has a red wire attached, and is labelled "5v line (from pin 2 or 4)

TRANSMITTER pinout:

a '2008-8' model 433 MHz transmitter with annotated labels. there are three pins on the transmitter. the leftmost pin has an orange wire attached, and is labelled "Data line IN - from pin 11". the middle pin has a red wire attached, and is labelled "5v pin - to pin 2 or 4". the pin on the far right has a green wire attached, and is labelled "GND pin - to pin 9 or 14 (or any GND pin)

SOFTWARE INSTALL

AUTOMATED INSTALL

NOTE: this has been tested on Raspbian GNU/Linux 9 (stretch), and the automated script SHOULD work from a clean install once you have a working internet connection (this is required). results on other versions or on an existing raspbian 9 install.

  1. get your raspberry pi working and connected to the internet, with a working install of Raspbian, and make sure hardware
  2. navigate to the folder you'd like to install it. this is usually your home drive (you can use cd ~/ to do this)
  3. download https://raw.githubusercontent.com/smouldery/shock-collar-control/master/setup.sh to your pi - you can use the following command: wget https://raw.githubusercontent.com/smouldery/shock-collar-control/master/setup.sh
  4. make sure your discord bot is set up and you have the token, for help on this see this guide
  5. make the script executable with sudo chmod +x setup.sh
  6. run the script and provide your TOKEN when prompted, using sudo ./setup.sh (the script has to run as root due to the files we're modifying, and since we're installing packages.). this script will reboot your pi and it SHOULD start your bot automatically (make sure it's been invited to a channel). if it doesn't work first time, try rebooting your pi with sudo reboot

manual install - most of these need to be run as root, the code will assume you're using 'sudo' not logged in as root.

  1. update package list with sudo apt-get update
  2. install python and pip, and pigpio + python3 pigpio sudo apt-get install python3 python3-pip pigpio python3-pigpio
  3. install python module with sudo pip3 install discord
  4. make the main bot directory with sudo mkdir /opt/collarbot/
  5. download the python script and config file from github with sudo wget -O /opt/collarbot/collarbot.py 'https://raw.githubusercontent.com/smouldery/shock-collar-control/master/collarbot.py' and sudo wget -O /opt/collarbot/collarbot_config.py 'https://raw.githubusercontent.com/smouldery/shock-collar-control/master/collarbot_config.py'
  6. add your bot token to the config file sudo echo "TOKEN = '<yourtoken>' >> /opt/collarbot/collarbot_config.py (replace with your discord bot token before running this!) 6.5 set permissions on these files sudo chown -R nobody /opt/collarbot/ and sudo chmod -R 755 /opt/collarbot/
  7. download the systemd service using sudo wget -O /etc/systemd/system/collarbot.service 'https://raw.githubusercontent.com/smouldery/shock-collar-control/master/collarbot.service'
  8. add user 'nobody' to gpio user group sudo usermod -a -G gpio nobody 8.5 set permissions on systemd service chmod 755 /etc/systemd/system/collarbot.service
  9. reload systemd using `sudo systemctl daemon-reload
  10. enable the pigpio daemon to start on boot and start it sudo systemctl enable --now pigpiod
  11. enable start on boot for your bot using sudo systemctl enable --now collarbot (also starts it)

in 5-10 seconds your bot should be working - no reboot required!

TESTING

make sure your collar is on etc. follow the 'encoding' instructions for your collar but transmit using the BOT not the remote to encode it to the bot. i'm working on a way to have both the remote and the bot work at once but with the current code that won't be possible.

you can check the transmitter is working in theory by using something like piscope to check pin 17 is transmitting.

if you have a receiver connected, you can also use piscope to check it's transmitting correctly (check pin 27)

⚠️ **GitHub.com Fallback** ⚠️