Device with multiple properties?

Question is simple, is it possible to create a device with multiple properties?

Yes, of course! Are you building your own web thing with one of our libraries?

Hi, yes I am using Arduino IDE to build a webthing with multiple temperature sensors, but I am having trouble getting them recognized by the gateway. I can run one sensor but I am unable to run two.

#include <Thing.h>
#include <WebThingAdapter.h>

Do I need to add another sensor here?
const char* sensorTypes[] = {"TemperatureSensor", nullptr};

and another line of this?
ThingProperty sensorTemp("temperature", "", NUMBER, "TemperatureProperty");

Btw.: I think the mozilla WebThing is a marvelous project with great potential!

This example will give you a good idea of how to add multiple sensors/properties to your device:

Thank you mrstegeman, this answers my question. I will do some testing. Btw, what is the preferred way to program WebThings?

However you want! We provide a wide variety of libraries in different languages to fit all kinds of use cases.

I’m trying and trying and I don’t get why my device shows only 2 properties in the gateway. I have commented “addProperty” lines and only shows the 2 lasts.

I beg you some help because I don’t know how to program and this is driving me crazy.

At the beginning of the code I wrote:

const char *AulaTypes[] = {“Sensor de aula”, nullptr};
ThingDevice SensorAula(“SensorAula_01”, “Aula 1.99”, AulaTypes);
WebThingAdapter *adapter;

// consultar
ThingProperty iluminacion(“Iluminacion”, “”, NUMBER, “LevelProperty”);
ThingProperty Temp(“Temperatura”, “”, NUMBER, “TemperatureProperty”);
ThingProperty HR(“Humedad Relativa”, “”, NUMBER, “HumidityProperty”);
ThingProperty Presion(“Presión barométrica”, “”, INTEGER, “BarometricPressureProperty”);
ThingProperty CO2(“CO2”, “”, INTEGER, “ConcentrationProperty”);
ThingProperty TVOC(“TVOC”, “”, INTEGER, “ConcentrationProperty”);

In the setup i wrote:

  adapter = new WebThingAdapter("SensorAula_99", WiFi.localIP());
  iluminacion.unit = "lux";        

Thank you very much!!


I forgot to define the Json_buffer


1 Like

Thank you for sharing! I made the same mistake :slight_smile: