Photon publishes ok to particle, but not to ubidots


#1

Hi

New to ubidots and to arduino coding, but trying to learn.

Making a simple temperature logger for a meat aging fridge. Data is published to particle (correctly) and to ubidots, but the values in ubidots is consistent -127. It worked for a couple of minutes the first time I set up the service, but has since not worked.

This is the code:

#include <spark-dallas-temperature.h>
#include <OneWire.h>
#include <Ubidots.h>


// Data wire is plugged into pin 2 on the Arduino 
#define ONE_WIRE_BUS D2 
#define TOKEN "TOKEN"  // Put here your Ubidots TOKEN

Ubidots ubidots(TOKEN);
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices  
// (not just Maxim/Dallas temperature ICs) 
OneWire oneWire(ONE_WIRE_BUS); 
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);
/********************************************************************/ 
void setup(void) 
{ 
    // start serial port 
    Serial.begin(115200); 
    sensors.begin(); 

} 
void loop(void) 
{ 
    // call sensors.requestTemperatures() to issue a global temperature 
    // request to all devices on the bus 
    sensors.requestTemperatures(); // Send the command to get temperature readings 

    float temp = sensors.getTempCByIndex(0);

    Particle.publish("Temperature", String(temp), 1, PRIVATE);
    ubidots.add("Temperature", temp);
    ubidots.sendAll();

    delay(30000); 
} 

Appreciate any help

BR

Jørgen


#2

Hello @jorgens,

Do you have the sensor already connected? If not, this can be the reason why are you getting the -127, this is what I have been able to experience using the OneWire library. If you have the sensor connected, please verify if the connections is right!

If you are new to Ubidos and Arduino coding I recommend you start with our sample code to send values to Ubidots, with it you will don’t have any issue. Once you’re able to received data to Ubidots and everything works properly you can initialize the sensor at the code to read the sensor values.

Best Regards.
Maria C.


#3

Hi Maria

That’s the strange thing, the sensor is connected, and I get accurate readings (not -127) from particle.publish(). I get occasional -127 readings in the particle console, which might be from not very thorough wiring job, but not the consistent -127 value I get in ubidots.

This is a screenshot from particle console:

BR

Jørgen


#4

Hello, I suspect that it can be the cast to the float value, please ensure that you are using the last version of our library, then please enable the debug method adding this line: ubidots.setDebug(true); on your Setup() function and put the output the output of the debug printed on your serial console.

Also please add a call to the print method Serial.println(temp); and put the output, in this way we can know if the issue comes from the casting of the value or if it is an issue of the way as particle interprets your value.

Regards