Capturing Button Data in a SQL Database


With a SQL database it is possible to capture the JSON data generated by an AT&T LTE-M or AWS Enterprise Button. With the help of our friends at Tek-Connect, Revolution11 has created a serverless app to make the process of capturing button clicks for these devices in a SQL database as intuitive as possible.

Our serverless application supports the following flavors of SQL: MySQL, MS SQL, Postgres SQL, Oracle SQL, SQL Lite or Web SQL.

How to Deploy and Use a Custom Serverless Application to Capture the JSON Button Output

Setting Up The Application

1. Log in to the AWS Console and choose the Lambda service. Once you are on the dashboard, press ‘Create Function’ in the upper right hand corner.


2. On the next screen, choose the AWS Serverless Repository – the panel located on the right side.


3. In the search bar, type in “SQL” or “Revolution11” in the Public Applications area. Click on the rev11-attiotbutton-SQLi application.


4. A Read Me section is found on the left-hand side of the page; this provides the parameters necessary to use the application. Fill out the parameters for your SQL Server address, sql type, and other information on the right-hand side of the page and press the ‘Deploy’ button.


5. A status screen will appear while the application is being deployed. Once the process finishes, press the Test App button in the upper right of the screen.


6. An overview screen for the app appears. Click on the hyper-linked name of the application (rev11atttiotbuttonsqli).


7. The next page sets up the function for the buttons. Add the AWS IoT trigger by clicking on it in the list of triggers to the right.


8. The AWS IoT Trigger appears in the workflow now. Scroll down to the configuration triggers area to set up the function to work with buttons.


9. It is possible to use one of the rules created for another button, but in case a rule has not been created, we will create a new one. Choose Custom IoT rule, give the rule a name, and add a query statement as shown in the screenshot below. Press the Save button in the upper right-hand corner to save the changes.


10. Let’s test the function! On the top of the screen, find the dropdown to ‘Select a test event’. Since we haven’t created any tests to use, the only choice in the dropdown is to ‘Configure a test event’ — choose this option.


11. Go ahead and use the supplied Hello World template. Give the test event a name and press the Create button at the bottom right of the screen. This test will send the JSON in the body of the test with the function.


12. You will now see the name of the test you created in the dropdown. Press the Test button to the right of the dropdown to run the test.


13. When the test has finished running, you will see the results at the top of the page. In this case it was successful. Now, check your SQL Database, there should be a new record with the JSON from the test event.


14. In the event of an unsuccessful test, this same area will tell you what failed. For this screenshot, I have changed the name of the “column” environment variable to a column not in the database. You should see that error in the details.


Configuring the Button

1. Configuring the LTE-M or AWS to use this Lambda function is the same as in past blog posts. In the AWS Server Console, navigate to the one click service and click on ‘Create a project’.


2. Give the project a name and press next.


3. Press ‘Start’ to define a device template.


4. Press ‘All button types’ on the next screen.


5. Enter the Device template name; in the Action dropdown, choose ‘Select a Lambda’ function and choose the function that was just created when you created the application; press ‘Create project’.


6. On the next screen choose Create your first placement – click ‘Create placements’.


7. Give the placement a name and press the choose device button to choose a device to tie to the function.


8. On the next screen, select the device and press ‘Create placement’.


You can now test your button!


Download a PDF of this blog: Capturing Button Data in a SQL Database

Capturing Button Data in a SQL Database

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.