Add support for MLX90640

Add support for MLX90640 IR array temperature sensor by Christian Baars
This commit is contained in:
Theo Arends 2020-09-14 11:49:33 +02:00
parent 18639730f0
commit 9aa18c23f0
5 changed files with 17 additions and 13 deletions

View File

@ -47,7 +47,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- **tasmota-zbbridge.bin** = The dedicated Sonoff Zigbee Bridge version. - **tasmota-zbbridge.bin** = The dedicated Sonoff Zigbee Bridge version.
- **tasmota-minimal.bin** = The Minimal version allows intermediate OTA uploads to support larger versions and does NOT change any persistent parameter. This version **should NOT be used for initial installation**. - **tasmota-minimal.bin** = The Minimal version allows intermediate OTA uploads to support larger versions and does NOT change any persistent parameter. This version **should NOT be used for initial installation**.
Binaries for ESP8266 based devices can be downloaded from http://ota.tasmota.com/tasmota/release. Binaries for ESP32 based devices can be downloaded from http://ota.tasmota.com/tasmota32/release. The base links can be used for OTA upgrades like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin`` The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota/release for ESP8266 or http://ota.tasmota.com/tasmota32/release for ESP32. The links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin``
[List](MODULES.md) of embedded modules. [List](MODULES.md) of embedded modules.
@ -61,3 +61,5 @@ Binaries for ESP8266 based devices can be downloaded from http://ota.tasmota.com
- Fix crash in ``ZbRestore`` - Fix crash in ``ZbRestore``
- Add new shutter modes (#9244) - Add new shutter modes (#9244)
- Add ``#define USE_MQTT_AWS_IOT_LIGHT`` for password based AWS IoT authentication - Add ``#define USE_MQTT_AWS_IOT_LIGHT`` for password based AWS IoT authentication
- Add Zigbee auto-config when pairing
- Add support for MLX90640 IR array temperature sensor by Christian Baars

View File

@ -9,6 +9,7 @@
- Add new shutter modes (#9244) - Add new shutter modes (#9244)
- Add ``#define USE_MQTT_AWS_IOT_LIGHT`` for password based AWS IoT authentication - Add ``#define USE_MQTT_AWS_IOT_LIGHT`` for password based AWS IoT authentication
- Add Zigbee auto-config when pairing - Add Zigbee auto-config when pairing
- Add support for MLX90640 IR array temperature sensor by Christian Baars
### 8.5.0 20200907 ### 8.5.0 20200907

View File

@ -558,7 +558,7 @@
// #define USE_VEML7700 // [I2cDriver50] Enable VEML7700 Ambient Light sensor (I2C addresses 0x10) (+4k5 code) // #define USE_VEML7700 // [I2cDriver50] Enable VEML7700 Ambient Light sensor (I2C addresses 0x10) (+4k5 code)
// #define USE_MCP9808 // [I2cDriver51] Enable MCP9808 temperature sensor (I2C addresses 0x18 - 0x1F) (+0k9 code) // #define USE_MCP9808 // [I2cDriver51] Enable MCP9808 temperature sensor (I2C addresses 0x18 - 0x1F) (+0k9 code)
// #define USE_HP303B // [I2cDriver52] Enable HP303B temperature and pressure sensor (I2C address 0x76 or 0x77) (+6k2 code) // #define USE_HP303B // [I2cDriver52] Enable HP303B temperature and pressure sensor (I2C address 0x76 or 0x77) (+6k2 code)
// #define USE_MLX90640 // [I2cDriver53] Enable MLX90640 IR array temperature sensor (I2C address 0x33) (+4k9 code) // #define USE_MLX90640 // [I2cDriver53] Enable MLX90640 IR array temperature sensor (I2C address 0x33) (+20k code)
// #define USE_DISPLAY // Add I2C Display Support (+2k code) // #define USE_DISPLAY // Add I2C Display Support (+2k code)
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0 #define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0

View File

@ -601,8 +601,9 @@ void GetFeatures(void)
#ifdef USE_I2S_AUDIO #ifdef USE_I2S_AUDIO
feature6 |= 0x00800000; // xdrv_42_i2s_audio.ino feature6 |= 0x00800000; // xdrv_42_i2s_audio.ino
#endif #endif
#ifdef USE_MLX90640
// feature6 |= 0x01000000; feature6 |= 0x01000000; // xdrv_43_mlx90640.ino
#endif
// feature6 |= 0x02000000; // feature6 |= 0x02000000;
// feature6 |= 0x04000000; // feature6 |= 0x04000000;
// feature6 |= 0x08000000; // feature6 |= 0x08000000;

View File

@ -1,5 +1,5 @@
/* /*
xdrv_84_MLX90640.ino - MLX90640 support for Tasmota xdrv_43_mlx90640.ino - MLX90640 support for Tasmota
Copyright (C) 2020 Christian Baars and Theo Arends Copyright (C) 2020 Christian Baars and Theo Arends
@ -33,7 +33,7 @@
* MLX90640 * MLX90640
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_84 84 #define XDRV_43 43
#define XI2C_53 53 // See I2CDEVICES.md #define XI2C_53 53 // See I2CDEVICES.md
#include <MLX90640_API.h> #include <MLX90640_API.h>
@ -144,7 +144,7 @@ const char HTTP_MLX90640_2a_SNS_COMPRESSED[] PROGMEM = "\x33\xBF\xA0\xB7\x9A\x3E
#else #else
const char HTTP_MLX90640_2a_SNS[] PROGMEM = const char HTTP_MLX90640_2a_SNS[] PROGMEM =
"var line = 0;" "var line = 0;"
"setInterval(function() {" "setInterval(function() {"
"rl('ul',line);" // 0 = do NOT force refresh "rl('ul',line);" // 0 = do NOT force refresh
"},200);" "},200);"
"function rl(s,v){" //source, value "function rl(s,v){" //source, value
@ -209,7 +209,7 @@ const char HTTP_MLX90640_2b_SNS[] PROGMEM =
"for (var j=0;j<32;j++){" "for (var j=0;j<32;j++){"
"var y = 239 - Math.floor(map(rA[(i*32)+j],0,40,0,239));" // 40 is max. temp for heat map "var y = 239 - Math.floor(map(rA[(i*32)+j],0,40,0,239));" // 40 is max. temp for heat map
// console.log(gPx.data[y],gPx.data[y+1],gPx.data[y+2]); // console.log(gPx.data[y],gPx.data[y+1],gPx.data[y+2]);
"octx.fillStyle = 'rgb(' + gPx.data[(y*4)] + ',' + gPx.data[(y*4)+1] +',' + gPx.data[(y*4)+2] + ')';" "octx.fillStyle = 'rgb(' + gPx.data[(y*4)] + ',' + gPx.data[(y*4)+1] +',' + gPx.data[(y*4)+2] + ')';"
"octx.fillRect(j*1,i*1,1,1);" "octx.fillRect(j*1,i*1,1,1);"
"}" "}"
"}" "}"
@ -254,7 +254,7 @@ const char HTTP_MLX90640_3a_SNS[] PROGMEM =
"rO.deleteContents();" "rO.deleteContents();"
"for(var p in poi){" "for(var p in poi){"
//"console.log('poi:'+ poi[p][0]);" //"console.log('poi:'+ poi[p][0]);"
"var c=150;" "var c=150;"
"if(eb('poiL').value==p){c=255;}" "if(eb('poiL').value==p){c=255;}"
// "console.log(c);" // "console.log(c);"
"ctx.fillStyle = 'rgba('+c+','+c+','+c+',0.6)';" "ctx.fillStyle = 'rgba('+c+','+c+','+c+',0.6)';"
@ -411,18 +411,18 @@ void MLX90640UpdateGUI(void){
void MLX90640HandleWebGuiResponse(void){ void MLX90640HandleWebGuiResponse(void){
char tmp[(MLX90640_POI_NUM*2)+4]; char tmp[(MLX90640_POI_NUM*2)+4];
WebGetArg("ul", tmp, sizeof(tmp)); // update line WebGetArg("ul", tmp, sizeof(tmp)); // update line
if (strlen(tmp)) { if (strlen(tmp)) {
uint8_t _line = atoi(tmp); uint8_t _line = atoi(tmp);
// AddLog_P2(LOG_LEVEL_DEBUG, "MLX90640: send line %u", _line); // AddLog_P2(LOG_LEVEL_DEBUG, "MLX90640: send line %u", _line);
float _buf[65]; float _buf[65];
if(_line==0){_buf[0]=1000+MLX90640.Ta;} //ambient temperature modulation hack if(_line==0){_buf[0]=1000+MLX90640.Ta;} //ambient temperature modulation hack
else{_buf[0]=(float)_line;} else{_buf[0]=(float)_line;}
memcpy((char*)&_buf[1],(char*)&MLX90640.To[_line*64],64*4); memcpy((char*)&_buf[1],(char*)&MLX90640.To[_line*64],64*4);
Webserver->send(200,PSTR("application/octet-stream"),(const char*)&_buf,65*4); Webserver->send(200,PSTR("application/octet-stream"),(const char*)&_buf,65*4);
return; return;
} }
WebGetArg("up", tmp, sizeof(tmp)); // update POI to browser WebGetArg("up", tmp, sizeof(tmp)); // update POI to browser
if (strlen(tmp)==1) { if (strlen(tmp)==1) {
Webserver->send(200,PSTR("application/octet-stream"),(const char*)&MLX90640.pois,MLX90640_POI_NUM*2); Webserver->send(200,PSTR("application/octet-stream"),(const char*)&MLX90640.pois,MLX90640_POI_NUM*2);
return; return;
} }
@ -591,7 +591,7 @@ void MLX90640Show(uint8_t json)
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
bool Xdrv84(uint8_t function) bool Xdrv43(uint8_t function)
{ {
bool result = false; bool result = false;