Michael makes a beeline to some Mayhem with the .Net Gadgeteer and XBee
- Posted: Jun 29, 2012 at 6:00AM
- 5,848 views
Today's Hardware Friday post is an example of how we can make mesh our software and hardware worlds, all the while taking advantage of plug-and-play like features. Michael Dodaro, friend of the blog shows us how we take the Plug-and-play features of Mayhem and hook them up to the plug-and-play hardware features of the .Net Gadgeteer platform...
Mayhem is an open source application that supports triggers, events, and reactions. The core Mayhem application runs on a PC, but the events and reactions it uses are interoperable with just about any platform or device. The guys making Mayhem say that non-programmers can use it to automate anything! This seems an invitation to try Mayhem with .NET Gadgeteer.
Creating events and reactions that run with Mayhem is not difficult after a look at the API Reference, which explains methods to override. The example implemented in this article requires a static class in order to use a single instance of Paul Mineau’s XBeeClient. The XBeeClient is a driver for XBee radios. It provides a serial interface that services two events. Mayhem persists state information when the events are turned off or Mayhem is shut down.
As you might expect, the post not only provides a short introduction to Mayhem but how to integrate it with a .NET Gadgeteer project.
.NET Gadgeteer Devices Automated by Mayhem Events and Reactions
Embedded microcontroller devices often run without an operating system, and they communicate with PCs in various ways. Mayhem EventBase and ReactionBase classes can automate .NET Gadgeteer devices as in the example we’re building, which uses XBee radio communication to and from a device. The device uses .NET Gadgeteer compatible GHI Electronics Light Sensor and Seeed Relay modules and the .NET Gadgeteer XBee adapter for XBee radio communication.
The relay module in this device can control AC electrical circuits that use power up to 15 Amps/120 Volts or 7 Amps/250 Volts. The light sensor is an analog device. Mayhem automation of this device includes events that originate on the device and events that originate on the PC. Paul Mineau wrote the XBeeClient open-source driver , available on CodePlex, that runs the XBees.
The code behind this hardware sets up the device so Mayhem can automate its modules. The code runs the XBeeClient to communicate with the PC hosting Mayhem. It runs a timer that reads the Light Sensor at 10 second intervals and sends notifications when the sensor detects light greater than 92.00 percent of maximum. It toggles the Relay that reacts to Mayhem automation events.
The post includes Mike's entire module as well;
Complete code for both Mayhem modules
We’ve discussed all the elements of a Mayhem/ .NET Gadgeteer implementation. This is a basic example, but adaptable in many ways. The Mayhem vision is to connect everything to everything else.
Here’s a few more links you might find interesting: