PDA

View Full Version : Turn an Arduino into a Girder IO peripheral



Ron
March 29th, 2016, 03:48 PM
Guys, I've had requests for an affordable device that supports more than 4 inputs that the PIR-1 supports. Looking around it appears an Arduino Uno (or similar/clone) will fit the bill nicely and be really affordable. To further this goal I've put together a Arduino Sketch for that purpose along with a Simple Serial template for driving this sketch. In this Github repository (https://github.com/promixis/GirderIOSketch) you'll find the source code (aka sketch) that you can compile with the Arduino IDE. This can be programmed onto a Arduino Uno, or a compatible device.

Once you have that done you can configure individual pins as outputs or inputs with or without the pullups ( and even invert the HIGH/LOW output ). Here is the docs that go with the sketch.



/* Girder 6 IO Sketch
* ==================
*
* This code allows an Arduino compatible device to function as
* a cheap input output device for Girder 6.
*
*
* License
* =======
* Copyright 2016 (c) Promixis, LLC
* Licensed for use with Promixis Girder.
*
* Usage
* =====
* All but the serial ports can be configured as input/outputs by using the
* serial protocol. Events are generated when a level changes.
*
* Protocol
* ========
*
* The protocol is a fixed length, CR terminated ASCI protocol for easy parsing
* easy manual control if needed.
*
* C####<CR>
*
* C = Command [A-Z]
* #### = Parameters [0-9, A-Z]
*
* Protocol Commands
* =================
* The Arduino Uno has 6 analog pins (A, 0-5) and 14 digital pins, however the
* first two digital pins 0 and 1 are used by the serial communications so 2-13 '
* are available.
*
* Baud rate is 9600, 8 bits, 1 stop bit.
*
* ERROR RESPONSE
* --------------
* If any command was not understood the response is
* Response: EXXXX<CR> XXXX error code.
*
* Error codes:
* 0001 protocol error
* 0002 unknown command
* 0003 invalid pin number
* 0004 invalid pin mode
* 0005 invalid must choose A or D for analog or digital pin.
*
* GETVERSION
* ----------
* Request: V0000<CR>
* Response: VHHLL<CR> answers with version of firmware.
*
* DDR
* ---
* Set direction and polarity.
*
* Request: DXYYZ<CR> X = [A (analog pins), D(digital pins)]. YY is pin number. Z is the polarity and mode or ? to request current mode.
* Response: DXYYZ<CR> echos request or error code 0002.
*
* Available modes
* 0 = INPUT
* 1 = INPUT WITH PULLUP
* 2 = OUTPUT
*
* 4 = INPUT INVERTED
* 5 = INPUT WITH PULLUP INVERTED
* 6 = OUTPUT INVERTED
*
* DEBOUNCE
* --------
* Request: BXXXX<CR> X = debounce value, if X is all ? it returns the current debounce value.
* Answer: BXXXX<CR>
*
* PIN
* ---
* Request: PXYYZ<CR> X = [A (analog pins), D(digital pins)]. YY is pin number. Z is 0, 1 or ?. ? requests current state without changing.
* Response: PXYYZ<CR>, echos first part adds Z which is 1 if pin is high, zero if pin is low.
*
* PIN NOTIFICATION
* ----------------
* This is sent without a request if a pin level changes.
* Notification: NXYYZ, X = [A,D], Y = pin number, Z = level
*
* RESET
* -----
* Reset configuration to factory defaults.
* R0000<CR>
*
*
*/


Once you have this running simply open Girder enable the simple transport plugin and download the Promixis/GirderIOSketch using the "Import from Web..." button. All you need to do to trigger an event is simply connect one of the digital pins 2-13 or analog pins 0-5 to ground.


Download: https://github.com/promixis/GirderIOSketch

tonyG
April 4th, 2016, 04:17 AM
Downloaded - looks good.

I use various Arduinos for IO and with Girder using the transport plugin. Ideal for sensors, encoders and LED control (RGB and "Neopixel"). Makes me wonder why we first consider expensive and proprietary solutions (z-wave and the like) - and having this Arduino library is a great solution. Thanks Ron.

Ron
April 4th, 2016, 06:49 AM
Thanks! Yes it makes total sense to use the widely available, affordable hardware for IO control. Now we need to find some cheap hardware with built-in BLE or WIFI and create a similar firmware for it!

KRO74
April 5th, 2016, 01:52 AM
Maybe the ESP8266 could be an option for WIFI, either stand-alone or with an Arduino,
www.esp8266.nu (http://www.esp8266.nu/index.php/Main_Page)
ESPEasy (http://www.esp8266.nu/index.php/ESPEasy)

NodeMCU is an open source IoT platform. It uses the Lua scripting language...
NodeMCU (https://en.wikipedia.org/wiki/NodeMCU)