The starting point for this project was to work on a concrete project to learn a few things about micro-controller boards.
The initial idea was to create a physical object that could monitor a Continuous Integration System (VSTS|Azure DevOps) and report software build failures. Due to security concerns from the IT department, I have been refused to connect a "non standard" device directly to the enterprise network.
I ended up with architecture shown in above picture. The execution workflow can be summarized as:
A Windows desktop application scans (pull) VSTS Build Definitions. It analyzes the results of the build, and then send a command to the physical device that execute a little animated sequence before showing either the red or the green flag.
Step 1: Needed Parts
The following list summarizes all the needed items:
- 1 Arduino UNO R3 (https://store.arduino.cc/usa/arduino-uno-rev3).
- 1 Expension Shield (https://www.dfrobot.com/wiki/index.php/IO_Expansion_Shield_for_Arduino_V7_SKU:DFR0265).
- 2 XBee S1 modules (https://www.adafruit.com/product/128).
- 1 XBee explorer dongle (https://www.sparkfun.com/products/11697).
- 2 continuous servo motors 5VDC with fixing accessories (https://www.parallax.com/sites/default/files/downloads/900-00008-Continuous-Rotation-Servo-Documentation-v2.2.pdf).
- 1 9VDC power supply.
- 3 LEDs.
- 3 resistors 220 Ohm.
- thermo retractable sleeve.
- 1 push button.
- 10KΩ pull resistor for the pull up.
- 100nF capacitor.
- electrical wires.
- strip-board (for the mounting of the button)
- 5mm wood (50x50cm).
- wood stick square section 5x5 mm (1m).
- 10 X screw 2mm diameter.
- 4 screw 5mm diameter.
- strong magnet.
- turning module. I reused the internal moving part of a flashing light. you can put whatever you want. You will just have to take care that the 2 mobile parts can move freely without touching together.
Step 2: Building the Box
Actually you can have a box of whatever shape you want. The main things to think about before starting is where will be the moving parts and to ensure that they can move freely without touching together. Another point is where are you going to put the device ? I ended up with a magnet (strong one) in order to stick it to any metallic support. if you want to build the same box, you can follow the instructions in the file box_drawings.pdf.
In that case you just have to cut all the different pieces, make the holes for the servomotors, the LEDs, the button and the screws and finally glue all the parts together. Once it is dry, a little sanding and some color.
The two flags have been made using some red and green cardboard. To fix the flag mast on the servomotors you can use the mounting parts provided when you buy them.
Step 3: Arduino Setup
The items connected to the Arduino extension board are:
- D2 PIN: the push button.
- D4 PIN: the LED to say the system is ON.
- D5 PIN: the LED to say we execute a cycle.
- D6 PIN: the LED to say the device has received a new message.
- D9 PIN: the PWM pulse signal for the servomotor handling the gyro.
- D10 PIN: the PWM pulse signal for the servomotor handling the flag.
- XBee Socket: one ZigBee Module.
The schematic above shows how all the items are connected to the board.
For the LEDs, the resistor and the wires are directly welded on it (take care of the polarity). Everything is then packed within some thermo retractable sleeve.
For the push button, all parts (button, resistor and capacitor) are directly welded on a small satellite strip-board. The strip-board is then directly fixed with two screws (2mm)
The servomotors operates with 5V power they can thus be connected directly to the Arduino. If you use ones with higher voltage (12V) you will have to add another layer for the power supply.
For the XBee modules, once they are configured to talk together(see next section), they can be plugged to the sockets directly.
Notes: The LEDs and the push button could have been directly connected to the Arduino pins as it may implement internally the needed securities. I just did the old way as this aspect was not very clear for me.
Step 4: Software - XCTU
As mentioned above the two XBee devices must be configured to talk together. To do that you need to use the dedicated X-CTU software from DIGI. You need to do this configuration step only once. please follow the procedure described in the xbee_configuration.pdf file.
Once the configuration is done you can connect each module on their socket. One on the USB/Serial converter and one on the Arduino extension board.
The USB/Serial converter should be automatically recognized by windows 10. If it is not you may have to install manually the driver
Using XBee modules to do a basic serial communication is a little bit overkill. At the time I started the project I did not succeed to find simple serial communication devices easily usable on windows 10 (driver issues). It was also an opportunity to learn a few things about https://www.zigbee.org
Step 5: Software - Arduino Sketch
To program the Arduino we use the IDE accessible from the official web site.
The logic of the program is rather simple it just listens on the default serial port of the board for single letters (‘a’, ‘b’, …). If the character received matches a known command, then a sub-function plays the corresponding sequence.
The 2 main useful commands are success animation (‘a’) and error animation (‘b’).
To be able playing (or debugging) a little bit more with the box there are some extra commands that can be executed. They are:
- ‘o’: force the ON LED to be ON
- ‘p’: force the ON LED to be OFF
- ‘q’: force the New Message LED to be ON
- ‘r’: force the New Message LED to be OFF
- ‘s’: force the Cycle LED to be ON
- ‘t’: force the Cycle LED to be OFF
- ‘u’: activate the servomotor of the gyro
- ‘v’: activate the servomotor of the flag.
In addition to the serial command there is a sub-routine (handlePushButton) that is activated when the push button is pressed on the device. In that case the error or success animation is played automatically. This feature allows to check that the physical device has been mounted correctly.
The code of the Arduino sketch is in the single file bsldevice.ino. You can upload it directly using the IDE.
Step 6: Software - Desktop Application
The purpose of the desktop application is to monitor Microsoft Azure DevOps (previously VSTS) web site and to detect if a Build Definition is successful or in error. Each time a build is finished, the desktop application determines the status of the build and send the corresponding command (‘a’ or ‘b’) to the serial port (COMx).
After launching the application the first action is to select the right com port on which the ZigBee module is connected. To determine the port you can use the Windows Device Manager (under Ports (COM & LPT section)). The connection to Azure DevOps is done automatically at startup using the credentials of the current user. You can also send any predefined command manually using the combo box on the right.
All sources have been generated with Visual Studio 2017 professional edition. It requires .NET Framework 4.6.1. This version of Framework is preferable to facilitate the connection/authentication to the VSTS web site.
- download the archive bslwatcher_sources.zip.
- Extract it on your disk.
- Read how_to_build.txt file for build details.
Step 7: First Start
There are two main things to have in mind when starting the box:
1- There is no way for the system to know by its own where are the flags. The system assumes that at startup the green flag is up.
2- When powering up the Arduino board nothing should move. As we used continuous servos, the zero position is set at 90 by default in the sketch file. If a servomotor starts to turn or make some noise. you may have to re-define its zero position. To do that you just have tune the potentiometer within the small hole on the side of the servomotor.
Step 8: Conclusion
This little device will physically report the status of your Continuous Integration System.
As the "intelligence" is in the desktop application you can use the box to monitor any other software or process (mail, a temperature sensor...). You just need to have access to another API and decide what is "good" or what is "bad". If you do not use red and green convention colors you can even change the meaning of the "message".
Improvements could also be brought to the box itself:
- Use a battery.
- Use another communication protocol.
- Add sensors to know which flag is at the top.
Hope you found this project interesting.
Thanks to read up to here.
Step 9: Annex
Some of the links used to create this project:
Arduino web site: https://www.arduino.cc/
DIGI web site: https://www.digi.com/products/xbee-rf-solutions/2-...
XCTU software: https://www.digi.com/products/xbee-rf-solutions/xc...
Some information used from others:
MSDN web site in general: