letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.27k stars 2.21k forks source link

P024_MLX90614 uses ports=16 #2199

Open Grovkillen opened 5 years ago

Grovkillen commented 5 years ago

https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P024_MLX90614.ino

We shouldn't use the port setting for this hardware, it's set to 0x5A (90) and is not changeable (or is it?).

047: Device[deviceCount].Ports = 16;
...
112: byte unit = Settings.TaskDevicePort[event->TaskIndex];
113: uint8_t address = 0x5A + unit;

should be?

047: Device[deviceCount].Ports = 0;
...
112: uint8_t address = 0x5A;

I don't have this unit close by but will try to test my change this week.

We should also clean up the comments regarding mysensors etc.

EDIT: it might be that I'm wrong and it's possible to have up to 127 units in the same bus...? How should we go about that?

ironataerial commented 5 years ago

Datasheet shows no sign of multiple units in the same bus

https://www.sparkfun.com/datasheets/Sensors/Temperature/MLX90614_rev001.pdf

Also the device has only the 4 basic pins so I do not see how and address can be set.

BUT

A quick google search resulted into a : "how to assign different slave address other than the default 0x5A"

https://chrisramsay.co.uk/posts/2014/09/arduino-and-multiple-mlx90614-sensors/

So I guess one could have up to 127 units on the same bus if wanted to push the envelop.

-D

Domosapiens commented 5 years ago

Port is used as an offset to 0x5A (90). So in general ... leave it 0 (no offset) .. is my experience.

Grovkillen commented 5 years ago

So we should remove it until we have a better way of doing that (my opinion). It's not clear how to use that setting in current implementation.

By the way, if used as an offset the port number is wrong in the device page.

ironataerial commented 5 years ago

My vote is to remove it (anything else is just asking for trouble)

ShardanX commented 5 years ago

Address seems to be stored in an EEPROM, writeable. http://forum.arduino.cc/index.php?topic=54170.0 https://chrisramsay.co.uk/posts/2017/09/arduino-and-multiple-mlx90614-sensors-take-two/

Domosapiens commented 5 years ago

To any-one who can read the code ... Is P024_MLX90614.ino supporting the address change via the power cycle procedure? As explained here https://chrisramsay.co.uk/posts/2017/09/arduino-and-multiple-mlx90614-sensors-take-two/

Once the current address is read out, I start the process of setting a new slave address (NewMLXAddr)

Domosapiens commented 5 years ago

Address change ...something as seems possible (??) with _P047_i2c-soil-moisture-sensor.ino

// check if we want to change the sensor address
        if (Settings.TaskDevicePluginConfig[event->TaskIndex][4]) {
            addLog(LOG_LEVEL_INFO, String(F("SoilMoisture: Change Address: 0x")) + String(_i2caddrP47,HEX) + String(F("->0x")) +
                    String(Settings.TaskDevicePluginConfig[event->TaskIndex][3],HEX));
            if (Plugin_047_setAddress(Settings.TaskDevicePluginConfig[event->TaskIndex][3])) {
              Settings.TaskDevicePluginConfig[event->TaskIndex][0] = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
            }
            Settings.TaskDevicePluginConfig[event->TaskIndex][4] = false;
}