Trying to interface Oled display with MLX90614 IR Sensor










0














Hi i am working on a school project where I'm supposed to output temperature values on an Oled display.



i have managed to do it with Arduino Code so i know that the sensor and display works, but the code has to be written in Atmel studio in pure embedded C for the project.



I'm not sure what I'm doing wrong and what I'm am doing right.
I'm struggling with C code and the I2C protocol.



i have done a lot of research on the subject but evertime i seem to only find arduino tutorials, or theory related posts.



I'm totally new to programming.



anyway this is the code i have come up with so far.



the txt i have written for the display is displayed. everthing works as it should except for the temperatur values:



#define F_CPU 16000000UL

#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "OLED.h"
#include "ATmega_Init.h"
#include "i2c_master.h"

//From Arduino Adafruit_MLX90614 lib
// RAM
#define MLX90614_RAWIR1 0x04
#define MLX90614_RAWIR2 0x05 //Important for reading out
#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07
#define MLX90614_TOBJ2 0x08

// EEPROM
#define MLX90614_TOMAX 0x20
#define MLX90614_TOMIN 0x21
#define MLX90614_PWMCTRL 0x22
#define MLX90614_TARANGE 0x23
#define MLX90614_EMISS 0x24
#define MLX90614_CONFIG 0x25
#define MLX90614_ADDR 0x0E
#define MLX90614_ID1 0x3C
#define MLX90614_ID2 0x3D
#define MLX90614_ID3 0x3E
#define MLX90614_ID4 0x3F

#define SLAVE_ADDRESS 0x5A



int main(void)


//uint8_t test_recieve[2];

uint16_t test_recieve_high; //To receive the high byte

uint16_t test_recieve_low; //To receive the low byte


init_atmega_setup();

initDisplay();

i2c_init();

clsDisplay();

strFont5XY("Floor Unit",25,3);

_delay_ms(2000);

clsDisplay();

//uint8_t receive_command = 0x00; //Needs the receive command,
definitely not just 0x00

while(1)= i2c_read_ack();

i2c_stop();

intFont5XY(test_recieve_low,1,0);

intFont5XY(test_recieve_high,1,1);

_delay_ms(1000);
;
;









share|improve this question

















  • 1




    "everthing works as it should except for the temperatur values" What temperature values? Where are they and what isn't working? Also if everything else works, what makes you think this is related to I2C and not some algorithm?
    – Lundin
    Nov 12 at 12:08










  • the temperature values are suppose to be read from the sensor and then outputtet to the display. i think it is the I2C connection + my lack of programming skills which is the problem. the reason i think that the problem is related to the i2c connection. is that i can output any text i want. but i cant collect the data from the sensor to output on the display.
    – El_NooB
    Nov 12 at 12:26















0














Hi i am working on a school project where I'm supposed to output temperature values on an Oled display.



i have managed to do it with Arduino Code so i know that the sensor and display works, but the code has to be written in Atmel studio in pure embedded C for the project.



I'm not sure what I'm doing wrong and what I'm am doing right.
I'm struggling with C code and the I2C protocol.



i have done a lot of research on the subject but evertime i seem to only find arduino tutorials, or theory related posts.



I'm totally new to programming.



anyway this is the code i have come up with so far.



the txt i have written for the display is displayed. everthing works as it should except for the temperatur values:



#define F_CPU 16000000UL

#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "OLED.h"
#include "ATmega_Init.h"
#include "i2c_master.h"

//From Arduino Adafruit_MLX90614 lib
// RAM
#define MLX90614_RAWIR1 0x04
#define MLX90614_RAWIR2 0x05 //Important for reading out
#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07
#define MLX90614_TOBJ2 0x08

// EEPROM
#define MLX90614_TOMAX 0x20
#define MLX90614_TOMIN 0x21
#define MLX90614_PWMCTRL 0x22
#define MLX90614_TARANGE 0x23
#define MLX90614_EMISS 0x24
#define MLX90614_CONFIG 0x25
#define MLX90614_ADDR 0x0E
#define MLX90614_ID1 0x3C
#define MLX90614_ID2 0x3D
#define MLX90614_ID3 0x3E
#define MLX90614_ID4 0x3F

#define SLAVE_ADDRESS 0x5A



int main(void)


//uint8_t test_recieve[2];

uint16_t test_recieve_high; //To receive the high byte

uint16_t test_recieve_low; //To receive the low byte


init_atmega_setup();

initDisplay();

i2c_init();

clsDisplay();

strFont5XY("Floor Unit",25,3);

_delay_ms(2000);

clsDisplay();

//uint8_t receive_command = 0x00; //Needs the receive command,
definitely not just 0x00

while(1)= i2c_read_ack();

i2c_stop();

intFont5XY(test_recieve_low,1,0);

intFont5XY(test_recieve_high,1,1);

_delay_ms(1000);
;
;









share|improve this question

















  • 1




    "everthing works as it should except for the temperatur values" What temperature values? Where are they and what isn't working? Also if everything else works, what makes you think this is related to I2C and not some algorithm?
    – Lundin
    Nov 12 at 12:08










  • the temperature values are suppose to be read from the sensor and then outputtet to the display. i think it is the I2C connection + my lack of programming skills which is the problem. the reason i think that the problem is related to the i2c connection. is that i can output any text i want. but i cant collect the data from the sensor to output on the display.
    – El_NooB
    Nov 12 at 12:26













0












0








0







Hi i am working on a school project where I'm supposed to output temperature values on an Oled display.



i have managed to do it with Arduino Code so i know that the sensor and display works, but the code has to be written in Atmel studio in pure embedded C for the project.



I'm not sure what I'm doing wrong and what I'm am doing right.
I'm struggling with C code and the I2C protocol.



i have done a lot of research on the subject but evertime i seem to only find arduino tutorials, or theory related posts.



I'm totally new to programming.



anyway this is the code i have come up with so far.



the txt i have written for the display is displayed. everthing works as it should except for the temperatur values:



#define F_CPU 16000000UL

#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "OLED.h"
#include "ATmega_Init.h"
#include "i2c_master.h"

//From Arduino Adafruit_MLX90614 lib
// RAM
#define MLX90614_RAWIR1 0x04
#define MLX90614_RAWIR2 0x05 //Important for reading out
#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07
#define MLX90614_TOBJ2 0x08

// EEPROM
#define MLX90614_TOMAX 0x20
#define MLX90614_TOMIN 0x21
#define MLX90614_PWMCTRL 0x22
#define MLX90614_TARANGE 0x23
#define MLX90614_EMISS 0x24
#define MLX90614_CONFIG 0x25
#define MLX90614_ADDR 0x0E
#define MLX90614_ID1 0x3C
#define MLX90614_ID2 0x3D
#define MLX90614_ID3 0x3E
#define MLX90614_ID4 0x3F

#define SLAVE_ADDRESS 0x5A



int main(void)


//uint8_t test_recieve[2];

uint16_t test_recieve_high; //To receive the high byte

uint16_t test_recieve_low; //To receive the low byte


init_atmega_setup();

initDisplay();

i2c_init();

clsDisplay();

strFont5XY("Floor Unit",25,3);

_delay_ms(2000);

clsDisplay();

//uint8_t receive_command = 0x00; //Needs the receive command,
definitely not just 0x00

while(1)= i2c_read_ack();

i2c_stop();

intFont5XY(test_recieve_low,1,0);

intFont5XY(test_recieve_high,1,1);

_delay_ms(1000);
;
;









share|improve this question













Hi i am working on a school project where I'm supposed to output temperature values on an Oled display.



i have managed to do it with Arduino Code so i know that the sensor and display works, but the code has to be written in Atmel studio in pure embedded C for the project.



I'm not sure what I'm doing wrong and what I'm am doing right.
I'm struggling with C code and the I2C protocol.



i have done a lot of research on the subject but evertime i seem to only find arduino tutorials, or theory related posts.



I'm totally new to programming.



anyway this is the code i have come up with so far.



the txt i have written for the display is displayed. everthing works as it should except for the temperatur values:



#define F_CPU 16000000UL

#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "OLED.h"
#include "ATmega_Init.h"
#include "i2c_master.h"

//From Arduino Adafruit_MLX90614 lib
// RAM
#define MLX90614_RAWIR1 0x04
#define MLX90614_RAWIR2 0x05 //Important for reading out
#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07
#define MLX90614_TOBJ2 0x08

// EEPROM
#define MLX90614_TOMAX 0x20
#define MLX90614_TOMIN 0x21
#define MLX90614_PWMCTRL 0x22
#define MLX90614_TARANGE 0x23
#define MLX90614_EMISS 0x24
#define MLX90614_CONFIG 0x25
#define MLX90614_ADDR 0x0E
#define MLX90614_ID1 0x3C
#define MLX90614_ID2 0x3D
#define MLX90614_ID3 0x3E
#define MLX90614_ID4 0x3F

#define SLAVE_ADDRESS 0x5A



int main(void)


//uint8_t test_recieve[2];

uint16_t test_recieve_high; //To receive the high byte

uint16_t test_recieve_low; //To receive the low byte


init_atmega_setup();

initDisplay();

i2c_init();

clsDisplay();

strFont5XY("Floor Unit",25,3);

_delay_ms(2000);

clsDisplay();

//uint8_t receive_command = 0x00; //Needs the receive command,
definitely not just 0x00

while(1)= i2c_read_ack();

i2c_stop();

intFont5XY(test_recieve_low,1,0);

intFont5XY(test_recieve_high,1,1);

_delay_ms(1000);
;
;






c






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 12:02









El_NooB

11




11







  • 1




    "everthing works as it should except for the temperatur values" What temperature values? Where are they and what isn't working? Also if everything else works, what makes you think this is related to I2C and not some algorithm?
    – Lundin
    Nov 12 at 12:08










  • the temperature values are suppose to be read from the sensor and then outputtet to the display. i think it is the I2C connection + my lack of programming skills which is the problem. the reason i think that the problem is related to the i2c connection. is that i can output any text i want. but i cant collect the data from the sensor to output on the display.
    – El_NooB
    Nov 12 at 12:26












  • 1




    "everthing works as it should except for the temperatur values" What temperature values? Where are they and what isn't working? Also if everything else works, what makes you think this is related to I2C and not some algorithm?
    – Lundin
    Nov 12 at 12:08










  • the temperature values are suppose to be read from the sensor and then outputtet to the display. i think it is the I2C connection + my lack of programming skills which is the problem. the reason i think that the problem is related to the i2c connection. is that i can output any text i want. but i cant collect the data from the sensor to output on the display.
    – El_NooB
    Nov 12 at 12:26







1




1




"everthing works as it should except for the temperatur values" What temperature values? Where are they and what isn't working? Also if everything else works, what makes you think this is related to I2C and not some algorithm?
– Lundin
Nov 12 at 12:08




"everthing works as it should except for the temperatur values" What temperature values? Where are they and what isn't working? Also if everything else works, what makes you think this is related to I2C and not some algorithm?
– Lundin
Nov 12 at 12:08












the temperature values are suppose to be read from the sensor and then outputtet to the display. i think it is the I2C connection + my lack of programming skills which is the problem. the reason i think that the problem is related to the i2c connection. is that i can output any text i want. but i cant collect the data from the sensor to output on the display.
– El_NooB
Nov 12 at 12:26




the temperature values are suppose to be read from the sensor and then outputtet to the display. i think it is the I2C connection + my lack of programming skills which is the problem. the reason i think that the problem is related to the i2c connection. is that i can output any text i want. but i cant collect the data from the sensor to output on the display.
– El_NooB
Nov 12 at 12:26

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261783%2ftrying-to-interface-oled-display-with-mlx90614-ir-sensor%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261783%2ftrying-to-interface-oled-display-with-mlx90614-ir-sensor%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto