HomeyDuino device with two temperature sensors registers only one

To monitor my central heating water flow temperature (floorheating) I assembled two DS18B20 temperature sensors on a ESP32 board to monitor the water temperature. The first measures the water temperature before passing through my Grundfos circulator. The second one measures the temperature after the water has passed through the heating system. The temperature sensors are placed on the pipes and are insulated.

I added the capabilities in my arduino sketch as follows:

Homey.setClass(“sensor”);
Homey.addCapability(“measure_temperature.in”);
Homey.addCapability(“measure_temperature.out”);

See documentation found here Driver Capabilities

After registering my device in Homey only the first sensor temperature is shown. The second one is ignored.

Is this a known feature? (aka bug?) Can I fix this some other way?

Or is there another method to register multiples capabilities using perhaps some other technique/device?

Any help appreciated,

Marlon

Anyone?

Maybe I should try the MySensor plugin and rewrite my code.

That’s still under development, you can not do it like this you can only use 1 capability.
I’m doing something similar with my fireplace water system but I’m sending the values like this:

Homey.trigger(“temperature1”, tempDev[0]);

And then reading it out in a flow

Maybe you can do something with this example:
http://huisvanvandaag.nl/multi-sensor-homeyduino/

Thanks Jan, nice article btw. What the article describes does work because Mike registers different types of sensors e.g
Homey.addCapability(“measure_humidity”); // DHT11
Homey.addCapability(“measure_temperature”);// DHT11
Homey.addCapability(“alarm_motion”); // PIR
Homey.addCapability(“measure_luminance”); // LDR
These are all different capabilities and these do work!

The issue at hand is the fact that if you repeat the same capability on your HomeyDuino device the other values are ignored. This is related to this bug Multiple capabilities is not possible

1 Like

Personally, I feel that it may take quite some time before Homeyduino will get fixed. From what I know, it was a project that was created by an intern as a graduation project, and he has moved on since.

I’ve used the MySensors app in the past which, although not perfect, worked better than HomeyDuino for me. It does require running an MQTT broker, but you can use the MQTT Broker app for that.

At some point in the future, my Sonoff app will be able to support generic (ESP8266, not ESP32) sensor modules.

Ok, thanks!

For now I’m monitoring the temperatures using two separate d1 mini’s (ESP8266).
I will be looking into the MySensors app to combine both temperature sensors in one device. While I’m at it I will check out if running the thing in combination with Node-RED is a viable option.

I have a similar problem as I want to enable all sensors from an old alarmsystem in Homey. Idea was to add all sensors to an AT Mega and use Homeyduino to send data for all sensors each using the “alarm_tamper” capability to Homey but as the properties for the capability (e.g. “title”, “insightsTamperTrue” etc.) are hardcoded this seems to be not possible. Would be great if capability properties can be overwritten (which means this needs to be supported by Homeyduino app as well).

At the moment the only solution I can think about is the use a NodeMCU for each sensor but as I have +/- 20 sensors in my house this is the best solution for me.

Anyone any idea where we can request such enhancements?

Because of this I decided to move over to MQTT based ESP8266 sensors instead.

Hi Magnus, as I am new with Arduino and newer did anything yet with MQTT, can you help me to get started? Curious which ESP8266 sensors you’re using, if MQTT can be done with Arduino, which app / apps you’re running on Homey to get the data in etc.

Thanks in advance.

Robert,
First of all you need to install 2 apps to the Homey, there are information in this forum how to use them
MQTT Client - https://apps.athom.com/app/nl.scanno.mqtt
MQTT Broker - https://apps.athom.com/app/nl.scanno.mqttbroker

An example of a ESP8266 sensor I have made is a multisensor (Lux, Temp, Hum)

Homeyduino_MultiSensor

OPEN ==> Arduino Code for MultiSensor

/*

*/

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
#include <DHTesp.h>

// Constants
const char *wifi_ssid = “Enter SSID”;
const char *wifi_pwd = “Enter PWD”;
const char wifi_hostname = “MultiSensor”;
const char
mqtt_server = “Enter IP adress”; //MQTT Server IP, your home MQTT server eg Mosquitto on RPi, or some public MQTT
const int mqtt_port = 1883; //MQTT Server PORT, default is 1883 but can be anything.
const char *mqtt_user = “Enter USER”; //User name in the Homey Broker app
const char *mqtt_pwd = “Enter PWD”; //Password in the Homey Broker app
String clientId = "MultiSensor : " + String(ESP.getChipId(), HEX);
const char *ota_hostname = “MultiSensor”;

// MQTT Constants
const char* mqtt_LuminanceStatus_set_topic = “MultiSensor/Luminance”;
const char* mqtt_TemperatureStatus_set_topic = “MultiSensor/Temperature”;
const char* mqtt_HumidityStatus_set_topic = “MultiSensor/Humidity”;

// Global
int currentLuminance;
int previousLuminance = 0;
float currentHumidity;
float previousHumidity = 0;
float currentTemperature;
float previousTemperature = 0;
unsigned long previousMillis = 0;
const unsigned long reportInterval = 600000; // Time in milliseconds between reports to MQTT broker (600000ms = 10min)
int thresholdLuminance = 100; // Treshold level in luminance (Lux) to send report to MQTT broker (current-previous > treshold)
float thresholdHumidity = 1; // Treshold level in humidity (H) to send report to MQTT broker
float thresholdTemperature = 0.5; // Treshold level in celsius (*C) to send report to MQTT broker

WiFiClient espClient;
PubSubClient client(espClient);

DHTesp dht;
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);

//
/* Setup WiFi connection */
/
/

void setup_wifi() {

WiFi.hostname(wifi_hostname);
WiFi.setSleepMode(WIFI_NONE_SLEEP);
WiFi.mode(WIFI_STA);
WiFi.begin(wifi_ssid, wifi_pwd);

while (WiFi.status() != WL_CONNECTED) delay(500);
Serial.print("WiFi connected: ");
Serial.println(WiFi.localIP());
}

//
/* Setup OTA connection */
/
/

void setup_ota() {

// Set OTA Password, and change it in platformio.ini
ArduinoOTA.setHostname(ota_hostname);
//ArduinoOTA.setPassword(“ESP8266_PASSWORD”);
ArduinoOTA.onStart( {});
ArduinoOTA.onEnd( {});
ArduinoOTA.onProgress((unsigned int progress, unsigned int total) {});
ArduinoOTA.onError((ota_error_t error) {
if (error == OTA_AUTH_ERROR); // Auth failed
else if (error == OTA_BEGIN_ERROR); // Begin failed
else if (error == OTA_CONNECT_ERROR); // Connect failed
else if (error == OTA_RECEIVE_ERROR); // Receive failed
else if (error == OTA_END_ERROR); // End failed
});
ArduinoOTA.begin();

}

//
/* Setup MQTT connection */
/
/

void reconnect() {

// Loop until we’re reconnected
// Attempt to connect

if (!client.connected()) {
  client.setServer(mqtt_server, mqtt_port);
  Serial.print("Connecting to MQTT server "); Serial.print(mqtt_server);

  while (!client.connected()) {
    if (client.connect(clientId.c_str(), mqtt_user, mqtt_pwd ))
    {
      Serial.println("\tconnected");
    } else {
      delay(500); 
      Serial.print(".");
    }
  } 

}
}

//
/* Publish Luminance to MQTT broker */
/
/

void publishLuminance(){

client.publish(mqtt_LuminanceStatus_set_topic, String(currentLuminance).c_str(), true);

}

//
/* Publish Temperature to MQTT broker */
/
/

void publishTemperature(){

client.publish(mqtt_TemperatureStatus_set_topic, String(currentTemperature).c_str(), true);

}

//
/* Publish Humidity staus to MQTT broker */
/
/

void publishHumidity(){

client.publish(mqtt_HumidityStatus_set_topic, String(currentHumidity).c_str(), true);

}

//
/* Initialise the Light Sensor TSL2561 Light Sensor */
/
/

void initiateLightSensor(){
if(!tsl.begin())
{
/* There was a problem detecting the TSL2561 … check your connections */
Serial.print(“Ooops, no TSL2561 detected … Check your wiring or I2C ADDR!”);
while(1);
}
}

//
/* Configures the gain and integration time for the TSL2561 Light Sensor */
/
/

void configureLuminanceSensor(void)
{
/* You can also manually set the gain or enable auto-gain support */
tsl.setGain(TSL2561_GAIN_1X); // No gain … use in bright light to avoid sensor saturation
// tsl.setGain(TSL2561_GAIN_16X); // 16x gain … use in low light to boost sensitivity
// tsl.enableAutoRange(true); // Auto-gain … switches automatically between 1x and 16x

/* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); // fast but low resolution
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); // medium resolution and speed
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); // 16-bit data but slowest conversions
}

//
/* Get a new temperature sensor event */
/
/

void Temperature() {
currentTemperature = dht.getTemperature();
//Serial.print(currentTemperature); Serial.print(" *C, ");
}

//
/* Get a new humidity sensor event */
/
/

void Humidity(){
currentHumidity = dht.getHumidity();
//Serial.print(currentHumidity); Serial.print(" H, ");
}

//
/* Get a new luminance sensor event */
/
/

void Luminance(){
sensors_event_t event;
tsl.getEvent(&event);

// Filter out values larger than 65000, because 65353 value means saturned sensor, bad measurement…
// this may happen in direct sunlight to the sensor

if (event.light < 65000) { currentLuminance = event.light; }
//Serial.print(currentLuminance); Serial.println(" lux");
}

//
/* Arduino setup function (automatically called at startup) */
/
/

void setup(void)
{
Serial.begin(115200);
setup_wifi();
setup_ota();
initiateLightSensor(); // initiate the light sensor
configureLuminanceSensor(); // Setup the light sensor gain and integration time
dht.setup(D5, DHTesp::DHT22); // Setup the DHT22 sensor to pin D5
}

void loop(void)
{
if (!client.connected()) { reconnect(); }
client.loop();
ArduinoOTA.handle();

// Get fresh sensor values
Temperature();
Humidity();
Luminance();

// Report status to MQTT broker every reportInterval
unsigned long currentMillis = millis();

if(currentMillis - previousMillis > reportInterval) {
previousMillis = currentMillis;

 publishLuminance();
 publishTemperature();
 publishHumidity();
/*Serial.print(currentTemperature); Serial.print(" *C, ");
Serial.print(currentHumidity); Serial.print(" H, ");
Serial.print(currentLuminance); Serial.println(" lux");*/

}

Hi Magnus,

Thanks a lot, will have a look at this.

Robert.

Not sure if you solved this. But reading the tutorial on capabilities in apps. I stumbled over this

https://apps-sdk-v2.developer.athom.com/tutorial-Drivers-Capabilities.html

Under using capabilities more than once. You can use a “sub-capability”. While defining your capability. In my example sending a sensor value and a trigger value for a light sensor. Simply add a period and a name you like for your sub capabilty, like “measure_luminance.example”. Works like a charm for me.

Homey.setClass(“light”);
Homey.addCapability(“measure_luminance.is”);

Homey.setClass(“light”);
Homey.addCapability(“measure_luminance.trigger”);