Makery Monitoring Microcontroller

From Projects of The Omaha Maker Group
Jump to: navigation, search

The Makery Monitoring Microcontroller project comprises three major systems, a serial-attached Arduino microcontroller, a .Net 4.0 Windows service, and a web page.


The microcontroller monitors and controls hardware that is located at the Makery. This hardware currently consists of one or more of temperature sensors, light sensors, and hobby servos. It also provides direct access to the digital and analog pins. The controller communicates with a host system via a simple serial protocol.

Serial Protocol

Commands consist of a literal command character, followed by one or more comma separated parameters, and terminated by a carriage return (0x13). A response of 'E' indicates an error processing the command. '0' indicates success. Read commands will return data indicating the requested value, generally an ASCII encoded decimal value.

"Inn,m" : Set digital pin mode, 'nn': pin number 2-13, 'm': mode, 1 output, 0 input
"An" // Read an analog input, 'n': analog pin number 0-5
"Dnn" // Read a digital input, 'nn' : digital pin number 2-14
"an,vvv" // Set an analog output, 'n' : pin number, 'vvv': value to write 0-255
"dnn,v" // Set a digital output, 'nn' : pin number 2-13, 'v' : value 0-1
"Tn" // Read a temp sensor, 'n' : temp sensor id
"sn" // Read a servo position, 'n' : servo id
"Sn,vvv" // Set a servo position, 'n' : servo id, 'vvv' : servo position

Web Service

The web service is a Windows service written in C# on the .Net 4.0 framework, and self-hosts a WCF-based web service to present a control interface for the microcontroller.

When the web service host is up, it is self-documenting via the 'help' interface:


The service can be compiled to run without hardware. In this mode it generates fake data for various outputs.


Temperature sensor operations:

Get defined sensors:
 GET	http://localhost:8000/mmm/temp/enum  
 Example output:

Get sensor value:
 GET	http://localhost:8000/mmm/temp/{SENSOR}
 Example output:

Light sensor operations:

Get defined sensors:
 GET	http://localhost:8000/mmm/light/enum
 Example output:

Get sensor value:
 GET	http://localhost:8000/mmm/light/{SENSOR}
 Example output:

Servo operations:

Get defined servos:
 GET	http://localhost:8000/mmm/servo/enum
 Example output:
Get the position of the specified servo id:
 GET	http://localhost:8000/mmm/servo/get?s={SERVO}
 Example output:
Set the position of the specified servo id:
 GET	http://localhost:8000/mmm/servo/set?s={SERVO}&v={VAL}
 Example output:

Pin operations:

Get defined digital pins:
 GET	http://localhost:8000/mmm/pins/enumd
 Example output:
Get defined analog pins:
 GET	http://localhost:8000/mmm/pins/enuma
 Example output:
Get the value on an analog input pin:
 GET	http://localhost:8000/mmm/pins/aget?p={PIN}
 Example output:
Set the value on an pwm output:
 GET	http://localhost:8000/mmm/pins/pwmset?p={PIN}&v={VAL}
 Example output:

Get the value on a digital input pin:
 GET	http://localhost:8000/mmm/pins/dget?p={PIN}
 Example output:
Set the value on a digital output pin:
 GET	http://localhost:8000/mmm/pins/dset?p={PIN}&v={VAL}
 Example output:
Set the mode of a digital pin to input or output
 GET	http://localhost:8000/mmm/pins/pmode?p={PIN}&m={MODE}
 Example output:

Camera operations

Change the position of the specified camera to a specified pan, tilt, & zoom
 GET	http://localhost:8000/mmm/camera/{CAMERA}/go/ptz?p={PAN}&t={TILT}&z={ZOOM}
 Example response:
Change the position of the specified camera using a defined tag
 GET	http://localhost:8000/mmm/camera/{CAMERA}/go/tag?t={TAG}
 Example response:
Get the current position of the specified camera
 GET	http://localhost:8000/mmm/camera/{CAMERA}/pos
 Example response:
 { "Pan":90, "Tilt":90, "Zoom":0 }

Define a tag for the specified camera using the camera's current position
 GET	http://localhost:8000/mmm/camera/{CAMERA}/newtag?t={TAG}
 Example response:
Enumerate the tags defined for the specified camera
 GET	http://localhost:8000/mmm/camera/{CAMERA}/tags
 Example response:

Enumerate the cameras
 GET	http://localhost:8000/mmm/camera/enum
 Example response:
   "Pan": {"Max":170,"Min":25,"Name":"pan","Value":-1,"ValueCacheSeconds":5},

Web Page