Following up on my previous post about connecting an Arduino to internet with an Ethernet module, I wanted to build a quick solution to notify the support team about un-handled customer issues on the CRM system.
The objective is to connect via the REST API to SugarCRM and give an immediate feedback to the team using an Arduino. The output can be anything; from an awesome smoke machine, to a rotating light, a small set of LEDs, a LCD display, an audio alarm, whatever really. In this specific case it will be a set of 5 LED’s and a buzzer.
This practical example shows how to bring together Arduino micro-controllers, basic electronic skills and software web technologies. The result creates a physical device that gives real time feedback for software users about something that needs immediate attention.
The main challenge is that Arduino does not have enough computational power and memory to connect to SSL websites, as I mentioned on my previous blog post.
The first step, is to write a small PHP “proxy” application to handle the login to a SugarCRM system in a secure way, retrieve the required data based on some specific business logic (on this example, count the “New” support Cases) and then output the result. The Arduino micro controller will then act, based on the result retrieved from the PHP page.
Prototype Video Demo
Let’s see the prototype in action on this video.
PHP “Proxy” Website
- Make sure to have Composer installed (https://getcomposer.org)
- To get up to speed in minutes with the SugarCRM v7 REST API, install Sean Pinegar‘s SugarCRM v7 API wrapper library that seems well executed! (Just follow the instructions on GitHub, but basically create the composer.json file with the right content and then run “composer install” from command line on the web server)
- Create the index.php on the main site’s folder and then require Composer’s libraries:
- If required, protect the index.php file with a .htaccess rule (maybe an IP restriction might be the best way to go) if the information shown by the proxy site is confidential and/or sensitive eg:
deny from all allow from xxx.yyy.xxx.yyy allow from zzz.xxx.zzz.xxx
- Now we can create the business logic on the index.php, and then get the Arduino to connect to the specified url to read its output and act upon it. The PHP code I used to retrieve the count of un-handled cases from a Sugar 7 can be found below:
The prototype solution I built is exactly the same as my previous blog post in terms of Arduino and Ethernet module. In addition to that, I have 2 green LEDs and 3 red LEDs to count and display up to the first 5 support tickets. I have added also a buzzer, to play a tone every time the number of support tickets increases. The buzzer can be replaced with anything else based on preferences. Note that if the output requires more than 5V, a relay might be required together with the correct input for the additional load.
The full C++ Arduino code I built for my solution can be found below: