Skip to content

Instantly share code, notes, and snippets.

@v-i-s-h
Last active January 20, 2018 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v-i-s-h/eeed830cd9a609bcaffec8adffb8e332 to your computer and use it in GitHub Desktop.
Save v-i-s-h/eeed830cd9a609bcaffec8adffb8e332 to your computer and use it in GitHub Desktop.
Gist of setting up Raspberry Pi

Setting Up Raspberry Pi

Disabling Serial TTY (For EnOcean Pi)

Edit /boot/cmdline.txt and remove any references to serial1 or ttyACM0

Setting up NodeJS: The Easy Way

  1. cat /proc/cpuinfo to determine CPU arch
  2. wget https://nodejs.org/dist/vX.Y.Z/node-vX.Y.Z-linux-armv??.tar.gz
  3. tar -xzf node-vX.Y.Z-linux-armv??.tar.gz
  4. node-v6.2.1-linux-armv6l/bin/node -v
  5. cd node-v6.2.1-linux-armv6l/
  6. Remove all README, CHANGELOG and LICENSE files (optional)
  7. sudo cp -R * /usr/local/

Setting up NodeJS: The Neat Way

  1. cat /proc/cpuinfo to determine CPU arch
  2. wget https://nodejs.org/dist/vX.Y.Z/node-vX.Y.Z-linux-armv??.tar.gz
  3. sudo mv node-vX.Y.Z-linux-armv??.tar.gz /opt
  4. tar -xzf node-vX.Y.Z-linux-armv??.tar.gz
  5. cd /opt
  6. sudo tar -xzf node-vX.Y.Z-linux-armv??.tar.gz
  7. sudo mv node-vX.Y.Z-linux-armv?? nodejs
  8. sudo rm node-vX.Y.Z-linux-armv??.tar.gz
  9. sudo ln -s /opt/nodejs/bin/node /usr/bin/node
  10. sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm

Setting up git

  1. sudo apt-get install git
  2. git config --global user.name "v-i-s-h"
  3. git config --global user.email get.vichu@gmail.com

Installing Mosquitto with Websockets

Install official Mosquitto from debian repo

  1. sudo apt-get install mosquitto

Configure Websockets

  1. Edit /etc/mosquitto/conf.d/mosquitto.conf like
    port 1883
    protocol mqtt
    
    listener 1884
    protocol websockets
    
  2. For auto start on boot:
    1. sudo nano sudo nano /lib/systemd/system/mosquitto.service
    2. Put contents as
    [Unit]
    Description=Mosquitto MQTT Broker daemon
    ConditionPathExists=/etc/mosquitto/conf.d/mosquitto.conf
    After=network.target
    Requires=network.target
    
    [Service] 
    Type=forking 
    RemainAfterExit=no 
    StartLimitInterval=0 
    PIDFile=/var/run/mosquitto.pid 
    ExecStart=/bin/sh -c "/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d"
    ExecReload=/bin/kill -HUP $MAINPID 
    Restart=on-failure 
    RestartSec=2
    
    [Install] 
    WantedBy=multi-user.target
    
    1. sudo chmod 644 /lib/systemd/system/mosquitto.service
    2. sudo systemctl daemon-reload
    3. sudo systemctl enable mosquitto.service
    4. sudo systemctl start mosquitto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment