Adding sensors on raspberry

Dear All,

My name is Vuk and I am pretty new in this stuff. recently I needed a device to measure temperature and himidity in my rack installations and I’ve heard about thinger. I have a lot of raspberry pi devices and I would like to add a DHT temperature and humidity sensor on them. It went all good until adding resources showed up where I am stuck. Before You start criticizing me, I have searched a LOT and I didn’t find any tutorial which I can use. They are mostly for arduino. Is there any easy way to add a sensor in main.cpp and add a fan trigger (later if I ever make sensor ;(
).
Please help…

Best regards.

I have this in the main.cpp

int main(int argc, char *argv[])
{
thinger_device thing(USER_ID, DEVICE_ID, DEVICE_CREDENTIAL);

// define thing resources here. i.e, this is a sum example
    // define the resource just once in the setup
    thing["TempHum"] >> [](pson &out){
            out["temperature"] = dht.readTemperature();
            out["humidity"] = dht.readHumidity();
    };
thing.start();
return 0;

}

and I get this when I try to execute ./install.sh

root@thinger:/home/pi/Linux-Client/install/raspberry# ./install.sh
– OpenSSL Version: 1.1.1c
– Configuring done
– Generating done
– Build files have been written to: /home/pi/Linux-Client/install/raspberry/build
[ 50%] Building CXX object CMakeFiles/thinger.dir/src/main.cpp.o
/home/pi/Linux-Client/src/main.cpp: In lambda function:
/home/pi/Linux-Client/src/main.cpp:38:24: error: ‘dht’ was not declared in this scope
out[“temperature”] = dht.readTemperature();
^~~
/home/pi/Linux-Client/src/main.cpp:38:24: note: suggested alternative: ‘dh_st’
out[“temperature”] = dht.readTemperature();
^~~
dh_st
make[3]: *** [CMakeFiles/thinger.dir/build.make:63: CMakeFiles/thinger.dir/src/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/thinger.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/thinger.dir/rule] Error 2
make: *** [Makefile:164: thinger] Error 2
[ 50%] Building CXX object CMakeFiles/thinger.dir/src/main.cpp.o
/home/pi/Linux-Client/src/main.cpp: In lambda function:
/home/pi/Linux-Client/src/main.cpp:38:24: error: ‘dht’ was not declared in this scope
out[“temperature”] = dht.readTemperature();
^~~
/home/pi/Linux-Client/src/main.cpp:38:24: note: suggested alternative: ‘dh_st’
out[“temperature”] = dht.readTemperature();
^~~
dh_st
make[2]: *** [CMakeFiles/thinger.dir/build.make:63: CMakeFiles/thinger.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/thinger.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

My raspbian is Raspbian Buster Lite.

Someone knows whats wrong?

this is your problem, where is dht declared? is this the whole code?

Hello, thanks for reply. yes, that’s the whole code. I have no idea how to declare dht… ;(