User:Ctag/litearm-pi-node

From Makers Local 256
Jump to: navigation, search

Overview

This is a little project to drive a litearm-i2 directly from a Raspberry Pi. The system involves a NodeJS server (what I made), along with WiringPi and ServoBlaster.

Parts List

  • A LiteArm-i2 (w/ servos)
  • A Raspberry Pi (I'm using model B original)
    • A USB wireless card (one that supports AP)
  • 5V power supply (I'm using a solar panel and battery)
  • A small breadboard
  • PWM Wire
  • An SPST switch (for GPIO shutdown)

Setup

Software

Set up the Pi with an OS. I strongly suggest ArchLinuxARM because it has most of the dependencies available already. You're going to need systemd (so at least Debian Jessie).

Install WiringPi, npm, node, nodemon, authbind, hostapd, dnsmasq.

# pacman -S wiringpi npm node ...

Set up a Hostapd Access Point, this is tricky, and I'm working on better documentation.

Install ServoBlaster. An additional resource. Don't worry about the init.d file, I've created a (shoddy) systemd service file below.

Clone my git project.

$ git clone https://github.com/ctag/litearm-pi-node.git
$ cd litearm-pi-node
$ npm install
# cp systemd/gpio_halt.sh /usr/local/sbin/gpio_halt.sh
# cp systemd/gpio_halt.service /etc/systemd/system/gpio_halt.service
# cp systemd/servod.service /etc/systemd/system/servod.service
# cp systemd/litearm-pi-node.service /etc/systemd/system/litearme-pi-node.service
# systemctl daemon-reload
# systemctl enable gpio_halt.service
# systemctl enable servod.service
# systemctl enable litearm-pi-node.service

Power down the pi. Continue to setting up the hardware. The gpio_halt service will shutdown the pi if you press and hold the spst switch for >5 seconds.

Hardware

Wire the servos signal pins, halt button, and power to the gpio headers as shown in the litearm-pi-diagram.

Should be good to go. Power up the pi and wait for the litearm to move to the "Starting" position.

Links

http://crompton.com/hamradio/RPi2_halt_switch/

https://github.com/richardghirst/PiBits

http://blog.mdda.net/oss/2015/02/16/forever-node-service-systemd/