Beginner Tutorial: IFTTT Publish an Event + Spark Internet Button


#21

Since it keeps yapping about the undeclared ‘b’, I think you haven’t changed the orange arrow line?
I prefer to start with the errors from bottom to top. Not quite sure why, but it’s mostly the bottom error causing the actual issue.


#22

Thanks. I’ll start there.


#23

It seems like the definition for the “b” variable is missing. Do you know off the top of your head how that variable might need to be defined? Seems like an object that would need to be instantiated with something like this:

b = new OBJECTNAME

Is this a normal instantiation in the “void setup()” function? If so, how and where are these usually defined?

Toby


#24

D’oh! I still had the path wrong. I needed the preceding slash. :slight_smile: This gets rid of the errors:

#include "/InternetButton.h"

#25

This or rather that

OBJECTNAME* b = new OBJECTNAME();

would be the way to instantiate an object constructed by calling the default constructor and store an instance pointer in b.
Subsequently you’d need to do all instance access like b->whatever().

But that

OBJECTNAME b = OBJECTNAME();
// or even better
OBJECTNAME b;

instantiates an object as instance variable and calls the default constructor for it.
And subsequent access would be done like b.whatever()

And if you are using Particle Build (Web IDE), you want to have that exactly like this

#include "InternetButton/InternetButton.h"

// InternetButton b = InternetButton(); // this will first create an instance b, and a temporary instance and then replace b with the temporary one (cumbersome to say the least)
InternetButton b;

#26

Stephanie;
I want to try this with a Photon, what code do I need to replace to use a button connected to D0 or D1 as a digital read ?
Is the code in the library ? I tried your “firmware” link and it went to a page other than the code library (or did I miss something ?)
Thanks for an interesting app !


#27

If you are not using the InternetButton kit but only the Photon, you can choose whatever pin you want, but have to replace all the b.xxxxx() instructions with native digitalRead() statements an set the pinMode() accordingly.
The firmware link doesn’t lead to the actual code but to a description of what firmware means and how to build an flash it.

The actual code is shown in the post :wink:


#28

Just sent two bits of information to two columns in a Google Drive spreadsheet using this code. Now I can graph time verses analogRead() using IFTTT. Code works great, just thought I should share.

void setup() {

}

int myCount = 0; // seconds since start

void loop() {

myCount += 10;

String stringOne = String(analogRead(A0), DEC);
String stringTwo = String(myCount, DEC);
String stringThree = String("{{" + stringTwo + “}}|||{{” + stringOne + “}}”);

Particle.publish(“my-chart-04”, stringThree);
delay(10000); // 10 second delay

}