Photon with Ubidots - .ccp and .h files

Hi there!
Using the IDE Web I have an app that contains .ino, .cpp and .h files.
I would like to place all my “function definition” in .cpp files and my function prototypes in .h files.
In .ino files, I just want to have functions call only.
If I do this and among those functions, there are some that include Ubidots post and get request, the code does not compile despite including <Ubidots.h> in the h files.
The question is where besides on .ino file I should include <Ubidots.h> so that the code compile?
But consider that if all function that contains Ubidots Apis are located in .ino file, there is no issue and the code is currently running in that way.
Thanks for any help.

Are you including Particle.h in your .h file?
Are you including your .h file in your .cpp file?
Are you including your .h file in your .ino file?

If you post a SHARE THIS REVISION link these questions would not need to be asked but we could see by ourselves.

Sorry, I never used this feature to share a revision.
I know that web IDE include this feature but it seem to be that the link you get is public.
How proceed to share only with you?

Just send it to him as a PM here on the forum?

That said - unless you have authentication credentials in your file, I would presume it’s not exactly rocket science you’re doing either since you’re using the online IDE? :wink: Just remove the confidential credentials and then share that version? Then put them back?

This is how you want the code to look.
But it does not compile.
Thanks for your help.

// monitor-1.ino

// This #include statement was automatically added by the Particle IDE.

#include <Ubidots.h>
#include "utility.h"
#include <string.h>
#include <stdio.h>

/********************************MONITOR_1 **************************/

  External MCU send string type:   
  A78.04%81.09%80.20%36.75%78.40%111.13%78.35%81.66% '\n' 

Ubidots ubidots(TOKEN,"");

/***  Timer delay and associated function ***/

    Timer timer(10, dataTimeout1);//  for time out in while waiting for "A"
    Timer timer2(1000, dataTimeout2);  //  for time out in while waiting for "data"

 * Main Functions
void setup() {
   pinMode(serialStart , OUTPUT);

void loop() {
    unsigned long topLoop = millis(); 

if ( (topLoop - lastvalues) >= Sendvalues) {

    lastvalues = topLoop;
if ( counter==4)
  /*************** Request sen serial data to MCU**********************/    
    digitalWrite(serialStart, HIGH);
    digitalWrite(serialStart, LOW); 


/******* Temperature values ********************************************/
    ubidots.add("LP", value0,context0);  
    ubidots.add("HP", value1,context1);
    ubidots.add("RT", value2);
    ubidots.add("ST", value3);
    ubidots.setMethod(TYPE_TCP);  //Set to TCP the way to send data   
if(ubidots.isDirty()){  // There are stored values in buffer

/******* Temperature  & current values  ********************************************/
ubidots.add("OT", value4 );
ubidots.add("Icpr",value8); // Current
ubidots.add("Ifcm",value9); // Current
ubidots.setMethod(TYPE_TCP);  //Set to TCP the way to send data
       if(ubidots.isDirty()) {  // There are stored values in buffer

 }// end if counter++

}// end void loop

/*****************************END OF FILE*************************************
//  utility.cpp

// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>
#include <string.h>
#include <stdio.h>
#include "utility.h"

char Temp[200]={'\0'};  
char data;
unsigned long lastvalues;// Global initialize to 0
const unsigned long Sendvalues =5000L;
unsigned long tiempo1=0, tiempo2 = 0;

char *Temp0, *Temp1 , *Temp2, *Temp3, *Temp4, *Temp5, *Temp6,*Temp7,*Irms1, * Irms2;
double value0,value1,value2,value3,value4,value5,value6,value7,value8,value9;

char context0[100]; //  Low Pressure   
char context1[100]; //  high Pressure   

int serialStart=D0;
int counter=0;

 * Auxiliar Functions definition

/*  Check Temperature high limit       */

void waitForString(){
  //  store the string received for external MCU 
    int i=0;

    tiempo1=0;// Initialize counter when while starts
    while (Serial1.available( ) &&  data !='A')  // check for A

             if (tiempo1>1){ // 1 count=10ms
               tiempo1=0 ; break;  
             data =;

   tiempo2=0;// Initialize counter when while start
   while ( Serial1.available( )  && data!='\n' )
          if(tiempo2>1){// 1 count=1000ms
            tiempo2=0; break;
          Temp[i] =;

/*  A78.04%81.09%80.20%36.75%78.40%111.13%78.35%81.66% '\n' */


Temp0 = strtok (Temp,"%");
Temp1 = strtok (NULL, "%");
Temp2= strtok (NULL, "%");
Temp3= strtok (NULL, "%");
Temp4= strtok (NULL, "%");
Temp5= strtok (NULL, "%");
Temp6= strtok (NULL, "%");
Temp7= strtok (NULL, "%");         

Irms1=strtok (NULL ,"%");
Irms2=strtok (NULL ,"%");         


void dataTimeout1(){ // 

void dataTimeout2(){ // 

 void checkLimitHP(float value1){

 float HPL = ubidots.getValueWithDatasource(DEVICE_LABEL, VAR_LABEL1); /* get HPHL set by user */

    if (value1> HPL){ // 
        sprintf(context1, "Diagnostic1=\High Pressure Limit\""); 
    else {   sprintf(context1,"Diagnostic1=\Pressure In range\""); 

void checkLimitLP(float value0){

   float LPL = ubidots.getValueWithDatasource(DEVICE_LABEL, VAR_LABEL0); /* get HPHL set by user */
    if (value0 >LPL){
        sprintf(context0, "Diagnostic0=\Low Pressure in Range\""); 
    else {   sprintf(context0, "Diagnostic0=\Low Pressure Limit\""); 

// Set time delay and associated function

/*****************************END OF FILE*************************************
//  utility.h

#define __UTILITY_H__

#include "Particle.h"

 * Define Constants

    #ifndef TOKEN
    #define TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  // Put here your Ubidots TOKEN
    #ifndef VAR_ID1
    #define VAR_ID1 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  // Put here your data source name
    #ifndef VAR_LABEL1
    #define VAR_LABEL1 "hphl" // Put here your variable api label
    #ifndef VAR_ID0
    #define VAR_ID0 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  // Put here your data source name
    #ifndef VAR_LABEL0
    #define VAR_LABEL0 "lpll" // Put here your variable api label
    #ifndef DEVICE_LABEL
    #define DEVICE_LABEL"xxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Put here your device api label

extern char Temp[200];  
extern char data;
extern unsigned long lastvalues;// Global initialize to 0
extern const unsigned long Sendvalues;
extern unsigned long tiempo1, tiempo2;

extern char *Temp0, *Temp1 , *Temp2, *Temp3, *Temp4, *Temp5, *Temp6,*Temp7,*Irms1, * Irms2;
extern double value0,value1,value2,value3,value4,value5,value6,value7,value8,value9;

extern char context0[100]; //  Low Pressure   
extern char context1[100]; //  high Pressure   

extern int serialStart;
extern int counter; 

void waitForString(void);

void dataTimeout1(void);
void dataTimeout2(void);

void chekcLimitLP(float);
void chekcLimitHP(float);


/*****************************END OF FILE*************************************

If you can post the code publicly, why did you not just post the link I asked for?
And as @jenschr said, if you didn’t want it seen by the publick a PM (= Private Message) would have been the option.

Reading through your code and guessing what error messages you get and what the probable cause is would have been a lot easier for us.

Sorry but I am not familiar with this kind of stuff.

1 - “Share this revision” will exhibit publicly all the code I have on the web IDE ?
2 - I’m assuming that I need to erase the access token am I right?
3- How you sen a PM ?
Thank you.

  1. this will only be public when you post it publicly, but as said several times Private Messages are private between you and the messaged person. Also the link only exposes a link to a copy of your project and not your original - let alone any other code in your Web IDE. You can even invalidate a previously posted link by removing the original project from your Web IDE (to simply create a copy of your project, use your own link, hit the COPY THIS APP button, give it a new name, then remove the original - after that the link will be dead and you can rename your copy back to what the original name was too, if you wish).
  2. You should erase it, but if you send a PM to any of us moderators or Particle employees, we are under obligation to not share confidential information. We often even redact code that inadvertently exposes such information.
  3. You can click at the avatar of any post (e.g. mine image ) and will get a dialog box with a Message button

Thank you very much for you explanation.
But you now what? Ubidots updated the library for Particle and there are differences with the former one. So that the code I all ready posted currently not works. Once I modified the code I will send it to you in the way you explained me.
Thank you again.