Notifications
Clear all

Multiple MLX sensors on one Arduino

32 Posts
5 Users
11 Likes
4,047 Views
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

Hey Everyone,

I am working on a project where I need to see the readings of two separate MLX90614 IR temp sensors running from one Arduino UNO.  This sensor has a fixed I2C address.  I am trying to figure out a way to run them both so their readings appear on the same display.  Ideally this would be a constant, but if I needed to switch between them every 20 seconds or so that would work as well.  Sparkfun has this sensor on a dev board that includes a small Arduino chip but I couldn't find how to get the data from that small AT328 chip to my main board. If each sensor has its own TinyPro AT328, how would I connect them to my UNO to get their data?

Hopefully I haven't confused everyone too much.

Thanks!


   
Quote
(@lydara)
Member
Joined: 3 years ago
Posts: 90
 

Since there are multiple TX/RX Interrupt-enabled pins on some Arduinos, could you put them on separate buses?


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@davemorris

You could put both sensors on the same bus easily. You would control your addresses in the sketch for the sensors(you need an FTDI programmer but I believe you could use the Uno for that it need be). In 20 seconds you should be able to read both and print the results multiple times. It would technically be one after the other but it would be so quick that it might not matter.

 

The sensors sketch would be waiting for request to the address you assign it, poll the sensor and reply.(or poll the sensor and save the variable and periodically check I2C, but this wouldn't be my choice, unless you need to filter out errors) Then the sketch on the Uno would just poll those addresses and update the display(or a variable first).

Bill made a video that addressed setting this up. Bills article/video here!

 

It does not have to be I2C. UART is also an option.

 

What display are you looking at? Most screens have cursors so you can write data form whatever sensor it gets data from, it can just rewrite that part of the screen only.

 

If you really need them at the same time then maybe an ESP32 is more suitable since you can run a task on each of the cores at the same time. This usually isn't the case since a few milliseconds won't matter.


   
ReplyQuote
(@lydara)
Member
Joined: 3 years ago
Posts: 90
 

@madmisha  You can poll two devices which have identical addresses on the same bus???


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1641
 

@davemorris  Hi, re: your statement 'This sensor has a fixed I2C address.'

Just glancing at the data sheets, the address seemed to be a 7-bit value in writeable EEPROM within the MLX device. Whilst this is set to a default value, both the Melexis's own demo board manual and the Sparkfun demo manual mention changing it. e.g.

The SparkFun MLX90614 Arduino includes a handful examples, which demonstrate everything from reading the sensor's values to adjusting emissivity, to modifying the 7-bit address.

And the MLX device datasheet shows:

from MLX90614 datasheet rev 13

I am guessing you would temporarily connect each device, one at a time, to change its preset address, before incorporating into your circuit with 2 (or more) on the same bus.

How this interfaces with the arduino sketches  (and maybe the software on the Melexis website), I don't know, but at first glance this could be an approach to consider.

Of course, as @madmisha has already mentioned, this assumes your project can cope with taking the measurements sequentially, as you can obviously only 'talk' to one MLX device at any one moment.

Good luck with your project!


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1073
 

If you're not married to the Arduino Uno you could also use another microcontroller that has multiple I2C busses.

Both the ESP32 and RP2040 (i.e Raspberry Pi Pico) have two I2C buses.

Otherwise, the TCA9548A I2C Multiplexer can turn your one Arduino Uno I2C bus into eight independent ones, I did a video on it a while back:

😎

Bill

 

 

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 
Posted by: @lydara

@madmisha  You can poll two devices which have identical addresses on the same bus???

No, but it can be changed(I imagine you could but they would just be talking over each other). The bare MLX sensor can be can be programmed through it's EEPROM but since he has the evaluation board, it has an ATmega328 and he can make it whatever he wants within it's program.

 

@davemorris

The evaluation board comes preprogramed with UART based example code, so if you don't want to make separate sketches for them or don't have the ability to reprogram it, you would need to be looking into UART.

 

And here is a link to use and Uno as an FTDI to program the sensors.

If you are just displaying the 2 sensors readings on a display, you could always just link them to use the 2 evaluation boards together without the additional Uno. On would be the master and drive the display and the other the slave that reports back to the master.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1641
 

@madmisha and @davemorris

Hi both,

  I wasn't clear if Dave had actually bought the Sparkfun evaluation board or just considered it. If the latter, then I hoped my input provided some options to look at -- and not too many confusions.

 Also in the hope of providing options, looking at the schematic of that board, the I2C connections to the MLX device are available, and hence presumably could be connected to an external master, providing the onboard processor was programmed to not drive those pins.

Of course, as previously mentioned, if the measurements must be synchronously timed, two separate data streams is the only option.

BTW The Sparkfun website says their board processor is 3.3V, so driving from a 5V 'FTDI-like' source, as the Arduino board referred to in the article referenced previously describes, may not work out well.

I note Adafruit also list the sensor (different price - is it the same?) and further info. Try https://learn.adafruit.com/using-melexis-mlx90614-non-contact-sensors/wiring-and-test

I also note there are a number of Chinese suppliers offering cheaper options, labelled GY-906, including just the sensor, regulator and four passives on a small board ... whether they work as well or even at all, I have no idea. (See https://protosupplies.com/product/gy-906-mlx90614-non-contact-precision-thermometer-module/ )

Hopefully you now have a number of options and can choose the best for your situation.

 


   
ReplyQuote
(@lydara)
Member
Joined: 3 years ago
Posts: 90
 

Ahhhhh!  That makes much more sense.  I took the OP at his word that he needed to connect two devices on identical addresses....which obviously should _not_ work.  Your details on the components proposed are better.  To my question, we _could_ run multiple I2C buses on an Arduino though, right?


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@lydara

If the Arduino is capable of multiple lines, then yes. So if readdressing was not an option, that would work. Otherwise, I don't think it makes much sense. It takes the same amount of time to poll one address on 2 lines as it does 2 addresses on one line(with exception of things like ESP32). Although I will note that there may be a buffer that could allow you to poll both and then get their responses. I'm not sure about that. I doubt it would speed it up enough to matter.

If you can't tell, I'm a huge fan of esp32s. They're my goto Arduino. Way more capable and I found they are more stable/reliable and for not that much more money.


   
LydaRA reacted
ReplyQuote
(@lydara)
Member
Joined: 3 years ago
Posts: 90
 

@madmisha I haven't studied the ESP32 much.  Maybe I should consider it for my rocket launch system?  It has really been pushing the pin counts & ADC resolution.  Also concerned about the RS485/Modbus load.  Actually had me wondering if I should consider an Arduino with built-in Ethernet?


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 
Posted by: @davee

BTW The Sparkfun website says their board processor is 3.3V, so driving from a 5V 'FTDI-like' source, as the Arduino board referred to in the article referenced previously describes, may not work out well.

Nice catch. Their evaluation board uses the ATmega328p and that is the same chip that the Uno uses(it's probably 3.3V because there is no power regulation for the sensor?). It can accept 2.7V-5.5V. You could provide power from the 3.3V pin but I actually don't know if it is acceptable to send 5V logic if the receiving device runs on 3.3V.

 

Posted by: @davee

I note Adafruit also list the sensor (different price - is it the same?) and further info. Try > https://learn.adafruit.com/using-melexis-mlx90614-non-contact-sensors/wiring-and-test

They have one more, too. https://www.sparkfun.com/products/17522

It looks like they just put the sensor on a PBC and added their weird connectors(they don't need to be used). Seems to be a handy in-between. You get it on a PCB but if you don't need the micro, this'll work.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@lydara

I would consider it. If you need things to happen at the same time(like something monitoring for safety conditions) it seems the way to go. I have not experimented with it yet but I am told that MicroPython is more stable on it as well. I believe there is a third option but I can't think of it.

 

Of all the things I have built on the Arduino platform, ESP32 is one that I trust running for months without having to force a restart. Sleep modes come in handy as well for saving power.


   
ReplyQuote
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

Thanks for all of the replies.  The information has been very helpful.  I am looking at either using the TCA9548A to add more I2C addresses or I may use an Arduino sketch that I found that will reprogram the address of the sensor directly.  Either way it looks like I can do what I am trying to accomplish.

In a nutshell since there was a little confusion on what I had and what I am trying to do, I am making a control center or sorts for the audio system in my truck.  This is an elaborate system and I want to build a monitoring setup that will do the following:

1. Monitor external temp of two different amplifiers and turn on 12v fans when temps exceed limits.

2. Monitor incoming voltage on each amplifier.

3. Control 12v LEDs that will light up some elements inside the truck.

4. Show results from all of these on a 128x128 OLED display.

It is sort of gimmicky, but I am also using this as an exercise to learn how to plan the project and do the programming.  So, thanks for the help and tips.  It is helping a lot!


   
ReplyQuote
(@lydara)
Member
Joined: 3 years ago
Posts: 90
 

@davemorris  "Life-long learning" is good!


   
ReplyQuote
Page 1 / 3