Getting Arduino to talk to CloudBit?

Hi, I’m new to the forums. Quick question: I’ve looked around quit a bit, and haven’t found any reference to connecting the Arduino module to the Cloud module. There’s projects where people have incorporated both, but no mention of programming Arduino to send to or receive from the CloudBit. Specifically I’m wondering if I could create an IFTTT recipe that pipes a number to the Arduino module, and program the Arduino react based on that number. For simplicity’s sake, let’s say I connect 2 LEDs to the Arduino, and I want one of them to switch on. One LED would switch on if I text IFTTT a number between 1 and 50. The other LED would switch on if the number is between 51 and 100. (Does it need to be limited to between 1 and 100?) I know Arduino and IFTTT, and I get the CloudBit. I need help mixing the peanut butter with the chocolate.

1 Like

Yes, you absolutely can do that, and to a finer granularity.

I did something similar in my Smart Playhouse #NFC project. Try the NFC family.ino code; the circuit I used is described in the beginning of the .ino file.

You don’t need NFC chips or the cloudBit to test the code initially. I used a dimmer + number. If you don’t have a number module, and you still want to aim for percentages of 10, I recommend a low tech cardboard circle marked with a compass. EDIT: You can then place the cardboard circle over the dimmer to precisely test input %.

I hope this helps! Let me know if this brings up more questions. :wink:

2 Likes

Remember, the cloud bit’s input is a voltage - 0 to 5v, and
the out put is a voltage from 0 to 5v based on your ifttt recipe.

Here’s an example:

Send a low value to the cloudBit: (Do Button app: 25%; forever)

vs send a high value: (Do Button app: 75%; forever)

and the sketch running on the Arduino bit:

/*
 * switch output based on input value
 * 
 * pin 0 is connected to input (output from the cloudBit)
 * pins 5 and 9 have LEDs - I used bargraph & number bits.
 * but use whatever LEDs or other output bits that you have.
 *
 */

void setup()
{
  pinMode(5, OUTPUT);  // bargraph + analog meter
  pinMode(9, OUTPUT);  // number bit set to voltage
}

void loop()
{
  // get the sensor value (range is 0 to 1023)
  int val = analogRead(0);
  
  // arbitrary cutoff is 450.
  // but if you want to be precise, then use 511.
  // d5 is on/d9 is off if input is > 45%
  if (val > 450) {  // set 75%/forever in ifttt 'Do' app
    digitalWrite(5, HIGH);
    digitalWrite(9, LOW);
  }
  else {            // set 25%/forever in ifttt 'Do' app
    digitalWrite(9, HIGH);
    digitalWrite(5, LOW);
  }
  
  // prevent LED flicker when switching
  delay(15);
}
2 Likes

Hi @chris101. Do you have an equally useful and brilliant explanation of going the other way (i.e. FROM a cloudBit to an ArduinoBit)? I want to make a tweet-o-meter that get input from the cloudBit™ and sends the number to an ArduinoBit.
~Bridget

Hi again Bridget (@Thingfully)!

You don’t say, but I’m assuming that you are going from Twitter to the cloudBit via IFTTT. Taking tweeted input from IFTTT to a cloudBit output with a specific number is a 'non-trivial problem.

Here is a thread - pay attention to the exchanges between @JackANDJude and @syedBits in the thread. Syed presents a somewhat convoluted (;)), two step process to send numeric information using a hashtag in the tweet.

One problem with using a connection from IFTTT directly from a cloudBit, is that only numbers from 78-99 can trigger the littleBits recipe. So the information sent must be within this range. An arduino can certainly be used to expand that range, but the resolution won’t change.

So in a word: no (I do not have a simple explanation.)

Thank you @chris101. I may need to use smoke and mirrors to simulate the effect. :smiling_imp:

2 Likes

Here’s a link to the thread that solved our issue. @jakilevy saved the day with @JackANDJude 's help!

1 Like

I saw that Bridget - Thanks!

It’s an interesting way to approach the problem.

1 Like

I Have one question how would I connect the cloud bit so the Arduino is sending data and the cloud bit is receiving the data.