Need help with code dht22 and hx711

I can’t seem to get my code to compile: Any help would be great.

#include "PietteTech_DHT.h"
#include "Adafruit_DHT.h"
#include "HX711ADC.h"

HX711ADC scale(A1, A0);		// parameter "gain" is ommited; the default value 128 is used by the library

// Variables
int temperature1;
int humidity1;
int temperature2;
int humidity2;
int calibration_factor = -7050;

DHT dht1(2, DHTTYPE);
DHT dht2(3, DHTTYPE);

void setup() {

void loop() {
    temperature1 = dht1.getTempCelcius();
    temperature2 = dht2.getTempCelcius();
    humidity1 = dht1.getHumidity();
    humidity2 = dht2.getHumidity();
float weight1 = scale.get_units();
 Spark.publish("Hive 1 temperature", String(temperature1) + " °C");
    Spark.publish("Hive 1 humidity", String(humidity1) + "%");
    Spark.publish("Hive 2 temperature", String(temperature2) + " °C");
    Spark.publish("Hive 2 humidity", String(humidity2) + "%");
    Spark.publish("weight", weight1+"lbs");

You should post any error messages that you’re getting. For sure, your include statements need a # in front of them if what you’re showing isn’t just a typo. Also, DHTTYPE doesn’t name a type, you need to define that with something like,

#define DHTTYPE DHT22; // or DHT11 or DHT21

BTW, why are you using both the Adafruit library and the PietteTech one. You should only need one or the other.

The only error I get is: “error could not compile. please check your code”

My include statements do have a # but it just didn’t show up.

good catch on the #define. I missed that in my copy and paste. I can get the code for the DHT22 to compile (using both libraries). I can also get the code for the hx711 to compile. The problem I have is when I try to combine them together it just give me the could not compile error.

This is my 1st attempt to program with particle.

Thank you for your response

You need to replace Spark with Particle everywhere it appears. Also this,

Spark.publish("weight", weight1+"lbs");

needs to be,

Particle.publish("weight", String(weight1) + "lbs");

For that reason you should post your code wrapped in a set of these

 // your code
I've edited your original post accordingly and for mor hints look at


You also need to state what dev env you are using, how you have imported or included your libraries, what device and system version you are targeting.