Friday, March 25, 2016

Chilipeppr GPIO JSON Server Setup

On the Chilipeppr interface, I noticed there was a button under Workspace TinyG titled GPIO. When you click on it, it gives you two options:

  • 'Download the GPIO JSON Server (Raspberry Pi & BBB) 
  • 'Connect to Host'

So, I went to the google machine, entered 'chilipeppr GPIO' into the search bar and came across this post from John Lauer. Basically, this feature will allow you to configure GPIO pins on the Raspi or Beagle Bone Black which can be controlled through the Chilipeppr interface. Sounds to me like we need a relay and we can remotely control our spindle (on/off, no speed) and vacuum!

Safety note: Do not mess with mains voltage! You can seriously shock yourself or even cause death. Please consult a professional.

Items used in this build: (purchasing through these affiliate links helps me to hack on)

How to install GPIO JSON Server on a Raspi2

As with most of my raspi tutorials, please make sure download and install an OS for the Raspi. I chose Raspian - Here is an installation guide. Then make sure to update and upgrade your OS before continueing. 

Step 1: Download and 'install' the server to your Raspi (<1 min)

To download the gpio-json-server directly on your raspi, type in:

Then to make the file executable...
sudo chmod +x gpio-json-server

And to run it...

sudo ./gpio-json-server
At this point you should be able to connect to your GPIO JSON server through chilipeppr by entering your Raspi-ip address into the GPIO widget.

Step 2: Automatically Start GPIO JSON Server on Boot (~2 mins)

If you followed step 3.1 from my X-Carve TinyG and Raspi post, you should have a file set up to start up the JSON server when your raspi boots up. If not, go back and look at that step first. 

Now, we need to edit the auto-start script to include the GPIO JSON server as well.

First, we need to know the location you placed the gpio-json-server. Mine was located here:

Then we need to add this file location to the /etc/init.d/serial-port-json-server file:
sudo nano /etc/init.d/serial-port-json-server

Within the file enter your gpio-json-server location from above after the '#do something" line as shown below in blue.
case "$1" in
    log_begin_msg "Starting Serial Port JSON Server service"
# do something
        /home/pi/serial-port-json-server_linux_arm/serial-port-json-server -regex usb|acm &
Be sure to add an '&' at the end of the line above the blue location to ensure both files are started. Then all we have to do is re-build the auto-start script.
sudo update-rc.d serial-port-json-server defaults

Step 3: Reboot Raspi and Enjoy (~2 mins)

Reboot your Raspi, 
sudo reboot
and enjoy GPIO control through Chilipeppr!

Step 4: Hook up your relay

Go to the google machine and search 'Raspi relay' to learn how to wire up your GPIOs to a relay.



  1. Hi, thanks for posting this. I got the serial Json server fully working but I still cant get the GPIO server to run at boot. I posted my script below. Also is there a way to save your chilipepper work space so the gpio widget doesn't need to be reconfigured. Thanks, MQ

    #! /bin/sh
    # Provides: serial-port-json-server
    # Required-Start: $all
    # Required-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Manage my cool stuff


    . /lib/init/
    . /lib/lsb/init-functions
    # If you need to source some other scripts, do it here

    case "$1" in
    log_begin_msg "Starting Serial Port JSON Server service"
    # do something
    /home/pi/serial-port-json-server-1.88_linux_arm/serial-port-json-server -regex usb|acm &
    log_end_msg $?
    exit 0
    log_begin_msg "Stopping the Serial Port JSON Server"

    # do something to kill the service or cleanup or nothing
    killall serial-port-json-server
    log_end_msg $?
    exit 0
    echo "Usage: /etc/init.d/serial-port-json-server {start|stop}"
    exit 1

    1. Thanks for the comment Mark! Your script looks correct from my untrained eyes (it is the same as mine). Have you updated the script via sudo update-rc.d serial-port-json-server defaults? Also, try running the script from the terminal with sudo service serial-port-json-server stop and sudo service serial-port-json-server start. Do you see any errors when doing that?

      Unfortunately, I have not looked into a way to save the configuration of the GPIO server. As long as I don't reboot the server, the settings are saved. I will look around and see if there is any new development with this because I feel your pain. I just updated to JSON v1.92 last night and had to reset the GPIO pins...