Connect a DHT11 sensor

If you’re using the non-MQTT Arduino connectivity, the process is a bit different. In that case widgets aren’t autocreated on your dashboard, you’d instead first create a widget through Add New > Device/Widget > Custom Widgets and then specify an I/O of “Virtual”, select a Virtual Pin number, and a data type/unit through the web UI. Then in your sketch code you’d just need a statement like:

Cayenne.virtualWrite(V13, myHum)

(where V13 is the virtual pin selected on the web dashboard)

There is no need to specify data and unit type this way since you’ve already done so on the web dashboard. Ultimately you have a choice here as we have Arduino libraries for both connectivity types, so having an Arduino/W5100 doesn’t preclude you from using the way I originally described.

https://github.com/myDevicesIoT/Cayenne-Arduino-Library

To answer your other question, rel_hum and p (and all the other items in that linked table) are keywords in the sense that they help the widget auto-creation process select the correct widget and facilitate data conversion in some cases (for example, if you pass a Celsius value to Cayenne and want us to be able to convert it to F within the web UI, you have to specifically use temp and c so we recognize it for conversion.)

But if you just want a text label on a generic Value widget, you can pass whatever you want here:

zoinks

This widget was created with client.virtualWrite(14, myValue, "zoinks", "hello!")

“zoinks” was discarded, our system doesn’t recognize it so it just falls back to a generic value widget, and then “hello!” is applied as a text label for units. It will display but you won’t see any conversion options since its an unknown unit.

2 Likes