kopia lustrzana https://github.com/meshtastic/firmware
				
				
				
			MLX90632 IR temperature sensor support (#4019)
							rodzic
							
								
									97a5abbc82
								
							
						
					
					
						commit
						06c635eca0
					
				|  | @ -137,4 +137,5 @@ lib_deps = | ||||||
|   adafruit/Adafruit VEML7700 Library@^2.1.6 |   adafruit/Adafruit VEML7700 Library@^2.1.6 | ||||||
|   adafruit/Adafruit SHT4x Library@^1.0.4 |   adafruit/Adafruit SHT4x Library@^1.0.4 | ||||||
|   adafruit/Adafruit TSL2591 Library@^1.4.5 |   adafruit/Adafruit TSL2591 Library@^1.4.5 | ||||||
|   ClosedCube OPT3001@^1.1.2 |   ClosedCube OPT3001@^1.1.2 | ||||||
|  |   emotibit/EmotiBit MLX90632@^1.0.8 | ||||||
|  | @ -132,8 +132,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
| #define RCWL9620_ADDR 0x57 | #define RCWL9620_ADDR 0x57 | ||||||
| #define VEML7700_ADDR 0x10 | #define VEML7700_ADDR 0x10 | ||||||
| #define TSL25911_ADDR 0x29 | #define TSL25911_ADDR 0x29 | ||||||
| #define OPT3001_ADDRESS 0x45 | #define OPT3001_ADDR 0x45 | ||||||
| #define OPT3001_ADDRESS_ALT 0x44 | #define OPT3001_ADDR_ALT 0x44 | ||||||
|  | #define MLX90632_ADDR 0x3A | ||||||
| 
 | 
 | ||||||
| // -----------------------------------------------------------------------------
 | // -----------------------------------------------------------------------------
 | ||||||
| // ACCELEROMETER
 | // ACCELEROMETER
 | ||||||
|  |  | ||||||
|  | @ -47,6 +47,7 @@ class ScanI2C | ||||||
|         NCP5623, |         NCP5623, | ||||||
|         TSL2591, |         TSL2591, | ||||||
|         OPT3001, |         OPT3001, | ||||||
|  |         MLX90632, | ||||||
|         AHT10, |         AHT10, | ||||||
|     } DeviceType; |     } DeviceType; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -346,7 +346,8 @@ void ScanI2CTwoWire::scanPort(I2CPort port) | ||||||
|                 SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found\n"); |                 SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555 I2C expander found\n"); | ||||||
|                 SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700 light sensor found\n"); |                 SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700 light sensor found\n"); | ||||||
|                 SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591 light sensor found\n"); |                 SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591 light sensor found\n"); | ||||||
|                 SCAN_SIMPLE_CASE(OPT3001_ADDRESS, OPT3001, "OPT3001 light sensor found\n"); |                 SCAN_SIMPLE_CASE(OPT3001_ADDR, OPT3001, "OPT3001 light sensor found\n"); | ||||||
|  |                 SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632 IR temp sensor found\n"); | ||||||
| 
 | 
 | ||||||
|             default: |             default: | ||||||
|                 LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address); |                 LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address); | ||||||
|  |  | ||||||
|  | @ -535,6 +535,7 @@ void setup() | ||||||
|     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700) |     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700) | ||||||
|     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN) |     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN) | ||||||
|     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001) |     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001) | ||||||
|  |     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::MLX90632, meshtastic_TelemetrySensorType_MLX90632) | ||||||
|     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) |     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X) | ||||||
|     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10) |     SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ | ||||||
| #include "Sensor/BMP280Sensor.h" | #include "Sensor/BMP280Sensor.h" | ||||||
| #include "Sensor/LPS22HBSensor.h" | #include "Sensor/LPS22HBSensor.h" | ||||||
| #include "Sensor/MCP9808Sensor.h" | #include "Sensor/MCP9808Sensor.h" | ||||||
|  | #include "Sensor/MLX90632Sensor.h" | ||||||
| #include "Sensor/OPT3001Sensor.h" | #include "Sensor/OPT3001Sensor.h" | ||||||
| #include "Sensor/RCWL9620Sensor.h" | #include "Sensor/RCWL9620Sensor.h" | ||||||
| #include "Sensor/SHT31Sensor.h" | #include "Sensor/SHT31Sensor.h" | ||||||
|  | @ -47,6 +48,7 @@ OPT3001Sensor opt3001Sensor; | ||||||
| SHT4XSensor sht4xSensor; | SHT4XSensor sht4xSensor; | ||||||
| RCWL9620Sensor rcwl9620Sensor; | RCWL9620Sensor rcwl9620Sensor; | ||||||
| AHT10Sensor aht10Sensor; | AHT10Sensor aht10Sensor; | ||||||
|  | MLX90632Sensor mlx90632Sensor; | ||||||
| 
 | 
 | ||||||
| #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 | #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 | ||||||
| #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true | #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true | ||||||
|  | @ -117,6 +119,8 @@ int32_t EnvironmentTelemetryModule::runOnce() | ||||||
|                 result = rcwl9620Sensor.runOnce(); |                 result = rcwl9620Sensor.runOnce(); | ||||||
|             if (aht10Sensor.hasSensor()) |             if (aht10Sensor.hasSensor()) | ||||||
|                 result = aht10Sensor.runOnce(); |                 result = aht10Sensor.runOnce(); | ||||||
|  |             if (mlx90632Sensor.hasSensor()) | ||||||
|  |                 result = mlx90632Sensor.runOnce(); | ||||||
|         } |         } | ||||||
|         return result; |         return result; | ||||||
|     } else { |     } else { | ||||||
|  | @ -307,6 +311,10 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) | ||||||
|         valid = valid && opt3001Sensor.getMetrics(&m); |         valid = valid && opt3001Sensor.getMetrics(&m); | ||||||
|         hasSensor = true; |         hasSensor = true; | ||||||
|     } |     } | ||||||
|  |     if (mlx90632Sensor.hasSensor()) { | ||||||
|  |         valid = valid && mlx90632Sensor.getMetrics(&m); | ||||||
|  |         hasSensor = true; | ||||||
|  |     } | ||||||
|     if (rcwl9620Sensor.hasSensor()) { |     if (rcwl9620Sensor.hasSensor()) { | ||||||
|         valid = valid && rcwl9620Sensor.getMetrics(&m); |         valid = valid && rcwl9620Sensor.getMetrics(&m); | ||||||
|         hasSensor = true; |         hasSensor = true; | ||||||
|  |  | ||||||
|  | @ -0,0 +1,40 @@ | ||||||
|  | #include "configuration.h" | ||||||
|  | 
 | ||||||
|  | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR | ||||||
|  | 
 | ||||||
|  | #include "../mesh/generated/meshtastic/telemetry.pb.h" | ||||||
|  | #include "MLX90632Sensor.h" | ||||||
|  | #include "TelemetrySensor.h" | ||||||
|  | 
 | ||||||
|  | MLX90632Sensor::MLX90632Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MLX90632, "MLX90632") {} | ||||||
|  | 
 | ||||||
|  | int32_t MLX90632Sensor::runOnce() | ||||||
|  | { | ||||||
|  |     LOG_INFO("Init sensor: %s\n", sensorName); | ||||||
|  |     if (!hasSensor()) { | ||||||
|  |         return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     MLX90632::status returnError; | ||||||
|  |     if (mlx.begin(nodeTelemetrySensorsMap[sensorType].first, *nodeTelemetrySensorsMap[sensorType].second, returnError) == | ||||||
|  |         true) // MLX90632 init
 | ||||||
|  |     { | ||||||
|  |         LOG_DEBUG("MLX90632 Init Succeed\n"); | ||||||
|  |         status = true; | ||||||
|  |     } else { | ||||||
|  |         LOG_ERROR("MLX90632 Init Failed\n"); | ||||||
|  |         status = false; | ||||||
|  |     } | ||||||
|  |     return initI2CSensor(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void MLX90632Sensor::setup() {} | ||||||
|  | 
 | ||||||
|  | bool MLX90632Sensor::getMetrics(meshtastic_Telemetry *measurement) | ||||||
|  | { | ||||||
|  |     measurement->variant.environment_metrics.temperature = mlx.getObjectTemp(); // Get the object temperature in Fahrenheit
 | ||||||
|  | 
 | ||||||
|  |     return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | #include "configuration.h" | ||||||
|  | 
 | ||||||
|  | #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR | ||||||
|  | 
 | ||||||
|  | #include "../mesh/generated/meshtastic/telemetry.pb.h" | ||||||
|  | #include "TelemetrySensor.h" | ||||||
|  | #include <SparkFun_MLX90632_Arduino_Library.h> | ||||||
|  | 
 | ||||||
|  | class MLX90632Sensor : public TelemetrySensor | ||||||
|  | { | ||||||
|  |   private: | ||||||
|  |     MLX90632 mlx = MLX90632(); | ||||||
|  | 
 | ||||||
|  |   protected: | ||||||
|  |     virtual void setup() override; | ||||||
|  | 
 | ||||||
|  |   public: | ||||||
|  |     MLX90632Sensor(); | ||||||
|  |     virtual int32_t runOnce() override; | ||||||
|  |     virtual bool getMetrics(meshtastic_Telemetry *measurement) override; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Ben Meadors
						Ben Meadors