Wireless Temp Monitoring UNO/MLX90614/NRF24L01/OLED

Hello! Very Happy to be here!

I currently have a functioning circuit consisting of an Uno, SSD1306 .96" OLED, and a MLX90614
temp sensor. Both the OLED and Temp Sensor is connected to ports A4 and A5 on the UNO, with VCC on the OLED to 3.3v and 5V to the sensor. I am finding that when I have a foot or more wire length the OLED will not illuminate and the temp sensor will not function (process wont initiate), however, when the wire length is less than a foot it boots up and displays temperature accurately. I tried various gauges of wire as well as solid copper thinking CCA could the issue to no avail.

This will not work in my application because the OLED display needs to be at least 12ft. from the Arduino and the temp sensor needs to be around 4 or 5ft. from the Arduino. Any ideas what may be causing this? Is the current just not there, or does it have something to do with the shared ports (A4/A5) and causing resistance. Would putting the sensor on different ports eliminate this problem, and if so, how would I activate (for lack of a better word) those alternative ports in the sketch to do exactly what they are doing now when using less than a foot of wire?

Beyond that, I came up with the idea to incorporate wireless functionality from the sensor to the OLED display. Of course I will need a second UNO to achieve this and I have already purchased the

NRF24L01 modules to facilitate this. I really need assistance here with modifying my existing sketch to enable this functionality. Essentially, what sketch would I use on the sensor side Arduino (transmitter) and what sketch would I use on the OLED display side Arduino (receiver) , with the current configuration as a example in mind. I will paste a copy of my current sketch below.

This has been a three week process and I'm at a loss at this point, and my deadline is this coming weekend so any assistance or input is tremendously appreciated!

/*

  • MLX90614 Infrared Temperature Sensor and SSD1306 Oled display Module with Arduino
  • Non-Contact Thermometer
    */
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #include <Adafruit_MLX90614.h>

// For the SSD1306 I2C supported Oled Display Module
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

double temp_amb;
double temp_obj;
void setup()
{
Serial.begin(9600);
mlx.begin(); //Initialize MLX90614
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)

Serial.println("MLX90614 Infrared Temperature and Oled display with Arduino");

display.clearDisplay();
display.setCursor(5,20);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("NELO MEDIA:");
display.setCursor(25,35);
display.setTextSize(2);
display.print("NMCS");
display.display();
delay(5000);
}

void loop()
{

temp_amb = mlx.readAmbientTempF();
temp_obj = mlx.readObjectTempF();

display.clearDisplay();
display.setCursor(25,5);
display.setTextSize(1);
display.setTextColor(WHITE);
display.println("Temp :");
display.setCursor(10,20);
display.setTextSize(3);
display.print(temp_obj);
display.print((char)247);
display.print("F");
display.display();

delay(1000);

}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Please post the schematics. Several possible reasons for failure.

I am honestly having trouble figuring out which parts in the sketch need "highlighted". My apologies

I will do my best to draw up a depiction. Thank you for the reply

Don't worry. A working end result is what every helper aims for. Being nosy and just serve You a low level, part, reply to get You off is not what I've seen here.

please forgive me and don't laugh :slight_smile: I have limited resources as I'm out in the field at the moment. Desperation! This is what I have at the moment. As indicated in the original message, if the wiring connecting the devices to the Arduino exceed 12" in length it will not work, less than 12" it works perfect. I also tried moving VIN on the sensor to 5 volts thinking it was due to a lack of voltage but this did not help. Last thing I tried was adding 4.7k resistors to SCL and SDA on the sensor, that did not help either. Please refer to my original post. Thanks so much!

Oopps. You want to connect a 5 volt UNO to a 3.3 volt temp sensor, SCL and SDA.
That needs help. You need level shifters between the two guys.
5 volt into a 3.3 volt device is not according to specs. It might damage the 3.3 volt device.

I'm up for suggestions, I'm all ears (eyes)! I am currently running 3.3v into the temp sensor and 5v into the OLED display. If I understand correctly, are you saying that because SDA and SCL on both devices are sharing A4 and A5 this is conflicting because they are on different voltages? You mention a level shift, what would a component like that be, and how would I connect it in this circuit? Would supplying the OLED with 3.3v work, since it would allow both components to be supplied the same power (if this is indeed a conflict)? I there a way to put either the OLED or temp sensor on different pots on the Arduino, and if so, how would I "activate" those pots in ,y existing sketch? Maybe moving the temp sensor to a digital output and keep the OLED on A4/A5? I'm open to try anything, I just have limitations on my knowledge and how far I can experiment. I've exhausted all my brain will offer me in this situation :slight_smile:

I do understand the part where you mentioned that supplying the temp sensor with 5v can damage it.

If you are going to put code tags on code previously posted without them then surely it is obvious that you select all of the code then click on the </> icon above the message composer/editor window

The easiest way to post code with code tags is to have the sketch open in the IDE with none of it selected then right click and select "Copy for forum". This copies the entire sketch to the clipboard and adds the code tags automatically ready for you to simply paste it into a reply here with no further action required

/*
 * MLX90614 Infrared Temperature Sensor and SSD1306 Oled display Module with Arduino
 * Non-Contact Thermometer
 */
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MLX90614.h>

 // For the SSD1306 I2C supported Oled Display Module
#define SCREEN_WIDTH 128    // OLED display width, in pixels
#define SCREEN_HEIGHT 64    // OLED display height, in pixels
#define OLED_RESET -1       // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 

Adafruit_MLX90614 mlx = Adafruit_MLX90614();
 
double temp_amb;
double temp_obj; 
void setup()
{
  Serial.begin(9600);
  mlx.begin();         //Initialize MLX90614
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
 
  Serial.println("MLX90614 Infrared Temperature and Oled display with Arduino");
 
  display.clearDisplay();
  display.setCursor(5,20);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("NELO MEDIA:");
  display.setCursor(25,35);
  display.setTextSize(2);
  display.print("NMCS");
  display.display();
  delay(5000);
}
 
void loop()
{

  temp_amb = mlx.readAmbientTempF();
  temp_obj = mlx.readObjectTempF();

 
  display.clearDisplay();
  display.setCursor(25,5);  
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println("Temp :");
  display.setCursor(10,20);
  display.setTextSize(3);
  display.print(temp_obj);
  display.print((char)247);
  display.print("F");
  display.display();
 
  delay(1000);


}

Got it I believe. Thank you

No, not supplying the tempsor with 5 volt but connecting their SCL and SDA.

Ok, I follow you. Where should I be connecting SCL and SCA on the temp sensor (and possibly the OLED?) and how would I modify the sketch to enable this new configuration?

To avoid me from creating another thread and "spamming", could you also offer some insight on how to incorporate the wireless device into the circuit/sketch? I know its important to get the wired circuit functioning properly then proceed from there.

One thing at a time I know. I appreciate your engagement.

You should connect SCL and SDA at the same place but put a 5.0 to 3.3 volt logic level converter between them.
No modifications to the sketch.

Gotcha! Let me seek out this module. Thank you so very much.

That looks like an 8 channel level shifter. It will work but You only need a 2 channel version.

1 Like

I have in hand a 2 channel logic level converter. Is it true that this module will only work on the digital pins and not the analog ones? I n my case I am using pins A4 and A5 on the Uno...