Skip to main content

Salesforce and LittleBits integration - IoT device

Integrating Salesforce with IoT devices (Internet of Things)  is one of my favourite topics and I was waiting for a long time to work on that topic and somehow I got time and managed to get one IoT device littleBits to experiment with it.

The littleBits cloud starter kit consists of 5 modules cloud bits, sound trigger, long led, button,servo and USB power. The main heart of this kit is cloud bits which have onboard wifi adapter which will connect the device to the internet. When the kit is connected to the internet, we can able to collect and post information to the device using the littleBits cloud API.
Let's get into the action

1. Setup littleBits device

Once you purchased the littleBits cloud starter kit, you can able to connect the device by following the steps given in the link control.littlebitscloud.cc or you can download the littleBits mobile application to connect your device to the internet. Build the device module as shown in the below picture



2. Connecting littleBits and Salesforce

The next step is to collecting the data from the electronic devices and write it in salesforce. To make the connection easy I have created a public web service REST class to connect with salesforce. Create the following web service class in your org



Now we have created the custom apex REST web service class in salesforce and to make this web service class public. You have to create force.com site and assign this apex class to that force.com site guest user profile. Check this link for more detail http://forceguru.blogspot.ca/2012/09/creating-public-web-service-in.html

Now you will have the public web service URL something like below
https://<your-force.com-site-URL>/services/apexrest/myservice

3. Subscribe to the device event

Whenever there is an event occurs in the device its has to send the data to our web service to create that information in salesforce.  Using the littleBits cloud API we can subscribe to the device event using our public web service URL.  Run the below code in the execute anonymous window in your developer org, this is the one-time activity



All setup process are completed and now we are ready to send the information from the device to salesforce. When you are going to press the button in the kit it will insert a new record in salesforce.



References

The blog post from Salesforce MVP Andrew Fawcett helped me to lot understand more about the device and made this experiment possible - https://andyinthecloud.com/2015/01/02/introducing-the-littlebits-connector-for-salesforce/


Comments

  1. The Internet of Things refers to electronic devices that are able to connect to the Internet and share data with other Internet enabled devices. Also known as connected devices, this includes laptops, smart home devices , and computers, however they are far from limited from just these three things.

    ReplyDelete

Post a Comment

Popular posts from this blog

Avoid Duplicate Records Using Flow

In this blog post lets see how to avoid duplicate records in Salesforce using the powerful feature – Flow , As the word says, flow easily flows to fulfill the requirements with ease. ☺  Many think of appexchange solutions and source code to avoid the duplicate record in salesforce, But the method I'm going to explain here is completely different and very simple. It helps you to reduce your code and can easily rebuild for other objects with different field logic with simple clicks. Lets jump into the solution, we will use flow to check duplicate record logic and use apex trigger to initiate the Flow whenever a record is created or updated. Visual Work Flow : [Click] First we will create the Flow to check the duplicate records based on the name and store the result in the variable. In this example, we will use the Account object for the dupe check. Step 1  : Create a new visual flow with the Name ‘ DuplicateAccountCheck ' Step 2  : Click and drag the RecordLookup into t

Export records from List view – ListView API

As part of the Winter’15 release salesforce introduced the List View API features which helps us to get details and records of list views for an object. I was started exploring more about the List view API and trying to build an use case using that. So I searched about List View in the IdeaExchange site then found that many users are looking for a solution to export records to excel directly from the list view. I built a solution for that Idea, which helps user to download all the records directly from the List view for both standard and custom object. You don’t have to make any change in the code to use this functionality for different objects. All you need is to create a custom button for that object as mentioned below. Lets take an example for Account object 1. Go to Setup –> Accounts –> Buttons, Links and Actions 2. Click ‘New Button or Link' 3. Enter  Label, Name and select display type as ‘List Button’ 4. Content source as “Onclick Javascript” and paste the

Become an Apex Integration Specialist in 2 hours

In the series of my favourite trailhead module blogpost this time, I’m going to cover about one of the most expected and important developer focused trailhead module “ Apex Integration Service ”. This time salesforce launched with new a Trail and 6 badges which brings over all 13 trails and 70 shiny badges in the Trailhead. Most of the salesforce projects will have an integration with the other application in the project life cycle. As a salesforce developer, we must have a sound knowledge in Integrations and salesforce provides this free “ Apex Integration service ” trailhead module which has 4 units with the followings topics Apex Integration Overview   This overview module makes you understand the difference between the Webservice and HTTP callouts and use of external site in Webservice topic salesforce Apex REST callouts  This module covers the both consuming and sending data through REST callouts. You will learn about the Deserialize  and  serialize   JSON strings in ap