Outils pour utilisateurs

Outils du site


divers_elec:mlx90614:mlx90614

liens

cablage

mlx90614

  • Part No. MLX90614 datasheet
  • Temperature Code E (-40°C…85°C) K (-40°C…125°C)
  • Package Code SF (TO-39)
  • Option Code - X X X (1) (2) (3)
    • (1) Supply Voltage/ Accuracy
      • A - 5V
      • B - 3V
      • C - Reserved
      • D - 3V medical accuracy
    • (2) Number of thermopiles:
      • A – single zone
      • B – dual zone
      • C – gradient compensated*
    • (3) Package options:
      • A – Standard package
      • B – Reserved
      • C – 35° FOV
      • D/E – Reserved
      • F – 10° FOV
      • G – Reserved
      • H – 12° FOV (refractive lens)
      • I – 5° FOV
  • Standard part -000
  • Packing form -TU

source

Pi

WiringPi Pin = WPP

Fonction WPP Name Header Name WPP Fonction
mlx90614 pwr 3.3v 1 2 5v
mlx90614 SDA (pull up on pi board) 8 SDA 3 4 5v
mlx90614 SCL (pull up on pi board) 9 SCL 5 6 0v
7 GPIO7 7 8 TxD 15
mlx90614 gnd 0v 9 10 RxD 16
0 GPIO0 11 12 GPIO1 1
2 GPIO2 13 14 0v
3 GPIO3 15 16 GPIO4 4
3.3v 17 18 GPIO5 5
12 MOSI 19 20 0v
13 MISO 21 22 GPIO6 6
14 SCLK 23 24 CE0 10
0v 25 26 CE1 11
    • Pi 3 Model B+ rev 1.0 : 1.8k pull on SDA SCL (R23 GPIO2) (R24 GPIO3)
    • Pi 3 Model B rev 1.2 : 1.8k pull on SDA SCL (R23 GPIO2) (R24 GPIO3)
    • Pi 2 Model B rev 1.2 : 1.8k pull on SDA SCL (R23 GPIO2) (R24 GPIO3)
    • Pi Model B+ rev 1.2 : 1.8k pull on SDA SCL (R23 GPIO2) (R24 GPIO3)
    • Pi Model A+ rev 1.1 : 1.8k pull on SDA SCL (R23 GPIO2) (R24 GPIO3)
    • Pi Zero rev 1.3 : 1.8k pull on SDA SCL (R23 GPIO2) (R24 GPIO3)
    • Pi Zero W rev1.1 : ? pas de BCM2835 sur le schéma ?

code

//gcc mlx90614.c -o mlx90614 -l bcm2835
#include <stdio.h>
#include <bcm2835.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#define AVG 1   //averaging samples
 
# include <termios.h>
	char getch(){
		char buf=0;
		fflush(stdout);
		if(read(0,&buf,1)<0)   perror("read()");
		return buf;
	} 
 
int main(int argc, char **argv)
{
    unsigned char buf[6];
    unsigned char i,reg;
    double temp=0,calc=0, skytemp,atemp,sky_temp_average_double,sky_temp_sum_double=0;
	unsigned int G_nb_sample_uint16=0;
	char c_command;
 
	//pas d'attente et pas d'echo sur getch
	struct termios old={0};
	if(tcgetattr(0, &old)<0) perror("tcsetattr()");
	old.c_lflag&=~ICANON;
	old.c_lflag&=~ECHO;
	old.c_cc[VMIN]=0;
	old.c_cc[VTIME]=0;
	if(tcsetattr(0, TCSANOW, &old)<0) perror("tcsetattr ICANON");
 
    bcm2835_init();
    bcm2835_i2c_begin();
    bcm2835_i2c_set_baudrate(25000);
    // set address
    bcm2835_i2c_setSlaveAddress(0x5a);
    printf("x : exit\nr : RAZ moyenne\nconnected to MLX90614 \n");
 
 while(c_command != 'x')
 { 
     calc=0;
     reg=7;
     for(i=0;i<AVG;i++)
     {
        bcm2835_i2c_begin();
        bcm2835_i2c_write (&reg, 1);
        bcm2835_i2c_read_register_rs(&reg,&buf[0],3);
        temp = (double) (((buf[1]) << 8) + buf[0]);
        temp = (temp * 0.02)-0.01;
        temp = temp - 273.15;
        calc+=temp;
     }
     skytemp=calc/AVG;
 
     calc=0;
     reg=6;
     for(i=0;i<AVG;i++){
        bcm2835_i2c_begin();
        bcm2835_i2c_write (&reg, 1);
        bcm2835_i2c_read_register_rs(&reg,&buf[0],3);
        temp = (double) (((buf[1]) << 8) + buf[0]);
        temp = (temp * 0.02)-0.01;
        temp = temp - 273.15;
        calc+=temp;
     }
    atemp=calc/AVG;
 
    if (c_command == 'r') {sky_temp_sum_double=0; G_nb_sample_uint16=0;}
    sky_temp_sum_double += skytemp;
    G_nb_sample_uint16++;
	sky_temp_average_double = sky_temp_sum_double/G_nb_sample_uint16;
 
    printf("Ambient Temp=%04.2f  Object Temp=%04.2f  Moyenne Object Temp=%04.2f\r", atemp,skytemp,sky_temp_average_double);
	c_command = getch();
    sleep(1);
 }
    //restore setting of getch
    old.c_lflag|=ICANON;
    old.c_lflag|=ECHO;
	if(tcsetattr(0, TCSADRAIN, &old)<0) perror ("tcsetattr ~ICANON");
    printf("\r\n");
    return 0;
}
divers_elec/mlx90614/mlx90614.txt · Dernière modification: 05/2018 par fred