Hello
I’m using ESP8266 to create a simple temperature and humidity sensor pretty much following various examples available
WebThingAdapter* adapter;
const char* sensorTypes[] = {“MultiLevelSensor”, nullptr};
ThingDevice environmentalSensor(“TemperaturHumiditySensor”, “Temperature & Humidity Sensor”, sensorTypes);
ThingProperty temperature(“temperature”, “Temperature”, NUMBER, “TemperatureProperty”);
ThingProperty humidity(“humidity”, “Humidity”, NUMBER, “LevelProperty”);
I then initialize the sensors in my setup() routine
setup() {
…
adapter = new WebThingAdapter(“Temperature Humidity Sensor”, WiFi.localIP());
temperature.unit = “°C”;
temperature.readOnly = true;
humidity.unit = “%”;
humidity.readOnly = true;
environmentalSensor.title = thingLocationName;
environmentalSensor.addProperty(&temperature);
environmentalSensor.addProperty(&humidity);
adapter->addDevice(&environmentalSensor);
adapter->begin();
}
However, only the second sensor I “addProperty” gets updated. In the example above only humidity gets updated, if I flip the lines and add temperature last, only temperature gets updated. The other value stays, I believe, at the first value reported.
The sensor is providing correct values when looking at http://11.22.33.44/things/TemperaturHumiditySensor/properties/temperature
The internal log only shows getValue for humidity too. After a reboot of the gateway I see temperature value exactly one time followed by only humidity.
2019-11-30 10:45:19.010 INFO : thing-url: getValue for property humidity for: Bedroom returning 44.08316
2019-11-30 10:45:23.326 INFO : getValue for property humidity for: Bedroom returning 44.29678
2019-11-30 10:45:23.329 INFO : getValue for property temperature for: Bedroom returning 23.97854
2019-11-30 10:45:49.009 INFO : thing-url: getValue for property humidity for: Bedroom returning 44.29678
2019-11-30 10:46:19.014 INFO : thing-url: getValue for property humidity for: Bedroom returning 44.64774
2019-11-30 10:46:49.007 INFO : thing-url: getValue for property humidity for: Bedroom returning 45.12076
2019-11-30 10:47:19.012 INFO : thing-url: getValue for property humidity for: Bedroom returning 45.58615
2019-11-30 10:47:49.011 INFO : thing-url: getValue for property humidity for: Bedroom returning 46.21176
2019-11-30 10:48:19.013 INFO : thing-url: getValue for property humidity for: Bedroom returning 46.77634
The problem also exists if I just replace MultiLevelSensor by TemperatureSensor, which I would prefer because of the nicer look in the web interface.
I’m using webthing-arduino_ID5397, ArduinoJson_ID64 and mozilla-iot 0.10.0 on a raspberry pi 3.
Minor question. How do I set the title for the humidity. In the web-view it only shows as “<level>
”.
Another question. Is there any way to purge the database of Things on my gateway? I see that during startup the gateway tries to connect to at least one Thing I just used for debugging
2019-11-30 10:44:55.741 INFO : thing-url: Failed to connect to http://10.0.0.140/things/EnvSensor: FetchError: request to http://10.0.0.140/things/EnvSensor failed, reason: connect EHOSTUNREACH 10.0.0.140:80
Thanks