How to send data to a website with Cloudbit?

Hi everyone,

I am wondering how I could send data from a cloudbit to one of my website?
My project is as follow.
As a university teacher my students would be interested to know if I am at my office or not.
I would be interested in inserting littlebits components within a cushion.
If the button is pushed then I would like the cloudbit to send the data to my personnal website indicating that I am at my desk. If the button is not pushed(that would mean that I am not seated) then send the information that I am not at my desk to my website.
Can it be send thanks to the cloudbit? Do I need to use the cloudbit api in order to do that?
I have a full access to my website which is using Wordpress,

Many thanks for your help

1 Like

You should be able to do it by connecting your littleBits circuit to Wordpress using IFTTT.

Hi Chris,

Thanks for your answer but Ifttt for Wordpress is very basic, it is just about posting an article or an image. In my case I would like to send just a piece of data, either I am there(if the button is pushed) either I am away(the button is not pushed) I cannot create an article each time the action occurs.

Typically when using the control cloudbit it seems that there is this function. When we test the cloudbit within Littlebits interface we can see that when we interact with the cloudbit the button is pushed, if not nothing happened. I would like to be able to take this behaviour and insert it within a website.

1 Like

The two options with cloudbit are IFTTT and API. IFTTT is very simple and as you have seen, limited. API is very complex, and support is minimal. Syed of littleBits has written some documentation for using API, you should probably read through those and decide if that it the direction you want to go.

I have used Wordpress, but not extensively (I used to have an art blog there - it didn’t go very far.) However, isn’t Wordpress scriptable? If so, you might have some luck sending a post to WP then scripting that into the kind of data update you want. Wordpress is local, but CB is … I don’t really know where it is, but it’s not local, I know that.

ps, I am a former Frontier/Radio Userland user. I sorely miss that software for the power it gave us mortals …

Thanks again for your answer. I am going back then within the Littlebits API documentation, but it is always the same story the guy who are writing the documentation do not understand that what people need are concrete examples.

Have a nice sunday Chris

Hey @ronan

At a high level your solution would require:

  1. CloudBit AcessToken (available under settings after you have
    activated your cloudbit at
  2. Creating a web application which will subscribe to your cloubit much like IFTTT does. If you are comfortable with coding I would probably create it with PHP since WordPress is based on that. PHP is just one option since you can do it in Java, NodeJS, ASP, etc.
  3. Create logic in your application to check the status of your bit and modify a variable in a file. Ex: var inOffice = true
  4. In your wordpress site create a new page template (Office Hours perhaps) and render the variable in a pleasant manner. Ex: If variable inOffice is true then display image or text else display other image or text

That should get you on the right path. Let me know if you need additional guidance and Ill be happy to help when I can.

1 Like

Thanks for your answer, I just find out and going to give it a try in a second, I guess it is gonna help a lot with the integration of the platform credentials.

Ok I just tested the plugin and it is not doing what I was looking for.
Typically this plugin is pushing data from a Wordpress website to Littlebits and not the other way around. So if a comment or an order is made through the website then it is sending an output to littlebits, could be a victory sound or something similar.

Hi mmalpartida,

I am going to try your solution(it is going to take me a while).
1st step (no problem to get the access)
2 nd step (huge problem I am going to see if Wordpress is providing help to code that out)
3 rd step (I guess it is closely linked to step 2)
4 th step (no problem)

Thanks for your help

Hey @ronan,
I might have time this weekend to write something up. If I were to make it a WordPress Plugin, what features do you think would be useful not only for yourself but also for our fellow bitsters?


Thanks for your answer and sorry for the delay, I was away from a good connection.
Honestly I think the biggest step is the integration from Littlebits to Wordpress.
If I just take the plugin I mentioned you before, those guys made the most difficult part, just by having a look at the plugin we can then understand how to add additionnal functions.
So I think if you can build an easy application which can send data from Littlebits to Wordpress I think most of us can figure and add it special functions. The credentials parts is to me the most complicated.
I just received a littlebits arduino coding kit if it can help.

Thank you very much for your time.

Ill take a stab at it later this week and let you know how it turns out. If not via a WP plugin then at least by PHP and then you can go from there.

Thanks, I am trying to understand how to do it in PHP.
So far I understood how to send a variable through http via IFTTT, the receipe is as follow:
when littlebits reacts then through the MAKER send a http post request with:
URL equals the one of my website file where I want to send the data
Method = POST
Content type = application/x-www-form-urlencoded
Body = state=seated

Then on Wordpress, so far I understood that in the file of my website I need to have a variable such as

<?php $_POST["state"]; ?>

Then after I am totally lost, one told me that I need to store the state within a database… but I don’t have a clue about how to proceed

One of the important thing about using the cloudbit api is how the http headers are sent. Also you do not need a database since we can use PHP to write a variable to a file which would just get read back when the status page is processed. If you wanted to have more complex behavior then a database would be a better place to manage the status.

Here is a rough example of writing to a file with PHP:
$bitStatus = checkPresence() //Results of method call that checks on your cloudbit either true or false

$file_handle = fopen(“officestatus.txt”, “w”);
$file_contents = “status:” . $bitStatus;

fwrite($file_handle, $file_contents);

thanks once more for your help,
the only challenge that I can see here is
$bitStatus = checkPresence()

how can checkPresence get the variable from the cloudbit?
any idea of how I should structure my http request?

Hi there,

I think again about it and I think I am going to face an issue as I need a state when the button is not pushed. So basically it should send an information to the system when the button is not pushed.
I am going to try this solution this evening:

and will let you know if it works.

Hey @ronan,

Sorry I havent been on for a bit. I think I have a solution in PHP which Ill post up this weekend though you will probably want to use the motion detector bit.

So I’ve looked all over the place for good documentation on how to connect your cloudbit to a php script to get the data from for example a button press and I’ve come up short.

Does anyone have a simple php script that authorises and connects to their cloudbit?

I’d ask @Patrick_littleBits or @syedBits what they’d suggest. They are the kings of the cloudBit™ as far as I can tell… :crown:

I’ve created a website that is designed to solve problems exactly like this. It’s got more far flexibility than IFTTT or Zapier, more like a LittleBits for building simple web stuff.

I’m still working on a demo page specific to Littlebits, for now this video1 shows me using LittleBits to open my real world garage door by pressing a button in Minecraft. The video is a demo of how to build such a thing using my site, called Boomtree. The Minecraft demo is at the 21 minute mark; it uses ComputerCraft in Minecraft to send the necessary HTTP message.

Boomtree offers the ability to make what you’re looking for without needing your own web server. Additionally, it has a few other features like allowing you to share the page you build so your cushion-button log could be visible to others.

I’d love to help set this up for you if you’re interested.