[SOLVED] Sending variables to ubidots using Particle

I am attempting to send data in the form of two variables from a Photon the ubidots. using the sample code from the tutorial I have succeeded in sending one variable but I don’t understand how to expand it to sending data for 2 variables.

This is my attempt

#include "application.h"
#include "spark-dallas-temperature/spark-dallas-temperature.h"
#include "OneWire/OneWire.h"
#include "HttpClient/HttpClient.h"
#include "HX711ADC/HX711ADC.h"

// HX711.DOUT	- pin #A1
// HX711.PD_SCK	- pin #A0
  HX711ADC scale(A2,A1); // parameter "gain" is ommited; the default value 128 is used by the library
  
 #define VARIABLE_ID "56df9e5976254226f4f4153d"
 #define VARIABLE_ID_TEMP "56e036537625422297f4413e"
 
 #define TOKEN "xxxxxxxxxxxxxx"

    HttpClient http;
    int lightLevel = 0;
    float SpecificGravity1 =0;
    float Temperature1 = 55;
    unsigned int nextTime = 0;    // Next time to contact the server

    // Headers currently need to be set at init, useful for API keys etc.
    http_header_t headers[] = {
        { "Content-Type", "application/json" },
        { NULL, NULL } // NOTE: Always terminate headers will NULL
    };

    http_request_t request;
    http_response_t response;


void setup() {
    request.hostname = "things.ubidots.com";
    request.port = 80;
    request.path = "/api/v1.6/variables/"VARIABLE_ID"/values?token="TOKEN;
    request.path = "/api/v1.6/variables/"VARIABLE_ID_TEMP"/values?token="TOKEN;
    
    
  Serial.begin(9600);
  Serial.println("HX711 Demo");

  Serial.println("Before setting up the scale:");
  Serial.print("read: \t\t");
  Serial.println(scale.read());			// print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));  	// print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));		// print the average of 5 readings from the ADC minus the tare weight (not set yet)

  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);	// print the average of 5 readings from the ADC minus tare weight (not set) divided 
						// by the SCALE parameter (not set yet)  

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();				        // reset the scale to 0

  Serial.println("After setting up the scale:");

  Serial.print("read: \t\t");
  Serial.println(scale.read());                 // print a raw reading from the ADC

  Serial.print("read average: \t\t");
  Serial.println(scale.read_average(20));       // print the average of 20 readings from the ADC

  Serial.print("get value: \t\t");
  Serial.println(scale.get_value(5));		// print the average of 5 readings from the ADC minus the tare weight, set with tare()
  //SpecificGravity =scale.get_value(5);
  Serial.print("get units: \t\t");
  Serial.println(scale.get_units(5), 1);        // print the average of 5 readings from the ADC minus tare weight, divided 
						// by the SCALE parameter set with set_scale

  Serial.println("Readings:");
}

void loop() {
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1);
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);
  
  if (nextTime > millis()) {
            return;
        }
        // Read sensor value
       
        SpecificGravity1 = scale.get_units(5);

       // Serial.println("Sending data ...");

        //request.body = "{\"value\":" + String(lightLevel) + "}";
request.body = "{\"value\":" + String(SpecificGravity1) + "}";
        // Post request
        http.post(request, response, headers);
        Serial.println(response.status);
        Serial.println(response.body);

        nextTime = millis() + 1000;
       

  scale.power_down();			        // put the ADC in sleep mode
  delay(5000);
  scale.power_up();
}

Don’t use http library, use Ubidots library from photon contributed libraries

does it use the same commands? I get compile errors now

You can show me a screen of that?

ok I got it to work using the http library. I still would like to know what the ubibots library and how it differs from the httpclient library.

thanks for your help steve

Hi @murmsk you can read more about our Particle library in this tutorial: http://ubidots.com/docs/devices/particlePhoton.html or in our Github page: https://github.com/ubidots/ubidots-particle