aymen ammari
DIIDevHeads IoT Integration Server
•Created by aymen ammari on 7/25/2024 in #edge-networking
MLX90640 Sensor Fails After 3-5 Minutes When Using ArduinoBLE Library
switch (res) {
case MLX90640_ADC_16BIT: Serial.println("16 bit"); break;
case MLX90640_ADC_17BIT: Serial.println("17 bit"); break;
case MLX90640_ADC_18BIT: Serial.println("18 bit"); break;
case MLX90640_ADC_19BIT: Serial.println("19 bit"); break;
}
mlx.setRefreshRate(MLX90640_2_HZ);
Serial.print("Current frame rate: ");
mlx90640_refreshrate_t rate = mlx.getRefreshRate();
switch (rate) {
case MLX90640_0_5_HZ: Serial.println("0.5 Hz"); break;
case MLX90640_1_HZ: Serial.println("1 Hz"); break;
case MLX90640_2_HZ: Serial.println("2 Hz"); break;
case MLX90640_4_HZ: Serial.println("4 Hz"); break;
case MLX90640_8_HZ: Serial.println("8 Hz"); break;
case MLX90640_16_HZ: Serial.println("16 Hz"); break;
case MLX90640_32_HZ: Serial.println("32 Hz"); break;
case MLX90640_64_HZ: Serial.println("64 Hz"); break;
}
/* Initialiser BLE */
BLE.setDeviceName("ArduinoMLX");
BLE.setLocalName("ArduinoMLX");
if (!BLE.begin()) {
Serial.println(F("- Starting Bluetooth® Low Energy module failed!"));
while (1);
}
BLE.setAdvertisedService(ArduinoMLXService);
ArduinoMLXService.addCharacteristic(ArduinoMLXRequestCharacteristic);
ArduinoMLXService.addCharacteristic(ArduinoMLXResponseCharacteristic);
BLE.addService(ArduinoMLXService);
ArduinoMLXResponseCharacteristic.writeValue((uint8_t*)"0", 1);
BLE.advertise();
Serial.println(F("Arduino R4 WiFi BLE (Peripheral Device)"));
Serial.println(" ");
}
switch (res) {
case MLX90640_ADC_16BIT: Serial.println("16 bit"); break;
case MLX90640_ADC_17BIT: Serial.println("17 bit"); break;
case MLX90640_ADC_18BIT: Serial.println("18 bit"); break;
case MLX90640_ADC_19BIT: Serial.println("19 bit"); break;
}
mlx.setRefreshRate(MLX90640_2_HZ);
Serial.print("Current frame rate: ");
mlx90640_refreshrate_t rate = mlx.getRefreshRate();
switch (rate) {
case MLX90640_0_5_HZ: Serial.println("0.5 Hz"); break;
case MLX90640_1_HZ: Serial.println("1 Hz"); break;
case MLX90640_2_HZ: Serial.println("2 Hz"); break;
case MLX90640_4_HZ: Serial.println("4 Hz"); break;
case MLX90640_8_HZ: Serial.println("8 Hz"); break;
case MLX90640_16_HZ: Serial.println("16 Hz"); break;
case MLX90640_32_HZ: Serial.println("32 Hz"); break;
case MLX90640_64_HZ: Serial.println("64 Hz"); break;
}
/* Initialiser BLE */
BLE.setDeviceName("ArduinoMLX");
BLE.setLocalName("ArduinoMLX");
if (!BLE.begin()) {
Serial.println(F("- Starting Bluetooth® Low Energy module failed!"));
while (1);
}
BLE.setAdvertisedService(ArduinoMLXService);
ArduinoMLXService.addCharacteristic(ArduinoMLXRequestCharacteristic);
ArduinoMLXService.addCharacteristic(ArduinoMLXResponseCharacteristic);
BLE.addService(ArduinoMLXService);
ArduinoMLXResponseCharacteristic.writeValue((uint8_t*)"0", 1);
BLE.advertise();
Serial.println(F("Arduino R4 WiFi BLE (Peripheral Device)"));
Serial.println(" ");
}
7 replies
DIIDevHeads IoT Integration Server
•Created by aymen ammari on 7/25/2024 in #edge-networking
MLX90640 Sensor Fails After 3-5 Minutes When Using ArduinoBLE Library
#include <Adafruit_MLX90640.h>
#include <ArduinoBLE.h>
Adafruit_MLX90640 mlx;
float frame[32*24]; // buffer for full frame of temperatures
uint8_t frame_ble[32*24];
// Définir les UUIDs des services et caractéristiques
const char * deviceServiceUuid = "1523";
const char * deviceServiceRequestCharacteristicUuid = "1526";
const char * deviceServiceResponseCharacteristicUuid = "1527";
BLEService ArduinoMLXService(deviceServiceUuid);
BLECharacteristic ArduinoMLXRequestCharacteristic(deviceServiceRequestCharacteristicUuid, BLEWrite, 4);
BLECharacteristic ArduinoMLXResponseCharacteristic(deviceServiceResponseCharacteristicUuid, BLENotify, 768);
void setup() {
while (!Serial) delay(10);
Serial.begin(115200);
delay(100);
Serial.println("Adafruit MLX90640 Simple Test");
if (! mlx.begin(MLX90640_I2CADDR_DEFAULT, &Wire)) {
Serial.println("MLX90640 not found!");
while (1) delay(10);
}
Serial.println("Found Adafruit MLX90640");
Serial.print("Serial number: ");
Serial.print(mlx.serialNumber[0], HEX);
Serial.print(mlx.serialNumber[1], HEX);
Serial.println(mlx.serialNumber[2], HEX);
//mlx.setMode(MLX90640_INTERLEAVED);
mlx.setMode(MLX90640_CHESS);
Serial.print("Current mode: ");
if (mlx.getMode() == MLX90640_CHESS) {
Serial.println("Chess");
} else {
Serial.println("Interleave");
}
mlx.setResolution(MLX90640_ADC_18BIT);
Serial.print("Current resolution: ");
mlx90640_resolution_t res = mlx.getResolution();
#include <Adafruit_MLX90640.h>
#include <ArduinoBLE.h>
Adafruit_MLX90640 mlx;
float frame[32*24]; // buffer for full frame of temperatures
uint8_t frame_ble[32*24];
// Définir les UUIDs des services et caractéristiques
const char * deviceServiceUuid = "1523";
const char * deviceServiceRequestCharacteristicUuid = "1526";
const char * deviceServiceResponseCharacteristicUuid = "1527";
BLEService ArduinoMLXService(deviceServiceUuid);
BLECharacteristic ArduinoMLXRequestCharacteristic(deviceServiceRequestCharacteristicUuid, BLEWrite, 4);
BLECharacteristic ArduinoMLXResponseCharacteristic(deviceServiceResponseCharacteristicUuid, BLENotify, 768);
void setup() {
while (!Serial) delay(10);
Serial.begin(115200);
delay(100);
Serial.println("Adafruit MLX90640 Simple Test");
if (! mlx.begin(MLX90640_I2CADDR_DEFAULT, &Wire)) {
Serial.println("MLX90640 not found!");
while (1) delay(10);
}
Serial.println("Found Adafruit MLX90640");
Serial.print("Serial number: ");
Serial.print(mlx.serialNumber[0], HEX);
Serial.print(mlx.serialNumber[1], HEX);
Serial.println(mlx.serialNumber[2], HEX);
//mlx.setMode(MLX90640_INTERLEAVED);
mlx.setMode(MLX90640_CHESS);
Serial.print("Current mode: ");
if (mlx.getMode() == MLX90640_CHESS) {
Serial.println("Chess");
} else {
Serial.println("Interleave");
}
mlx.setResolution(MLX90640_ADC_18BIT);
Serial.print("Current resolution: ");
mlx90640_resolution_t res = mlx.getResolution();
7 replies