Communication between O2 and CO2 sensors and laptop via bluetooth

Hi Team,

I am new to this forum and relatively new to electronics in general.

I am currently trying to set up a system where I can connect:

  • an O2 sensor (LuminOx - Supply V: 4.5 - 5.5 Vdc - communication protocol: 3.3v RS232)
  • and a CO2 sensor (MinIR - Supply V: 3.3 - 5Vdc - Communication protocol: UART)

to a microcontroller that would be able to communicate with a laptop via bluetooth.
I am trying to understand what my best microcontroller option would be. My setup will require the sensor/microcontroller assembly to be powered by an external battery pack.

My initial investigation led me to the Arduino Nano 33 BLE board but in my understanding, I would be able to communicate only to one sensor and not both at the same time as it only has one serial port. The other issue I see is that the board operates at 3.3V and one of the O2 sensor requires an input voltage of 4.5-5.5 V.

I may be wrong in my above statement and please feel free to correct me.
Any ideas of what microcontroller I could use to get my system working?

Any help is welcome. Thank you :slight_smile:

Hi Moana,

Welcome to the forum :slight_smile:

The Nano 33 BLE is certainly a good option. Just note that it is very limited in its ability to power other things, so you’re best to power everything externally (25mA total max current drain from V_DD and the GPIO pins).

You can get around the restriction of only 1 hardware serial interface by using the SoftwareSerial() library:

As for the voltage level difference, for bidirectional communication you’ll need a TTL logic level converter like this:

However, if your sensor doesn’t need to receive any instructions from your microcontroller, you can often get away with a simple resistor divider to drop the 5v down to 3.3v.

Regards,
Oliver
Support | Core Electronics

1 Like

Hi Oliver,

Thank you for your response.

If I understand well, one option for my setup could be:

  • Power both sensors from an external source and not via the Nano board
  • Connect both communicating pins (Rx and Tx) of both sensors to the logic level converter module
  • Connect the logic level converter module to the Nano 33 BLE board (Rx and Tx pins and 2 other pins)
  • Use the SoftwareSerial() library to add a second serial interface on the Nano board. As I would be using only one software serial port, I’d be able to communicate with both sensors simultaneously.

I would have to write an appropriate code in the IDE to set up the sensors and collect data from my sensors (e.g. ppO2, Temp, CO2 concentration,…).

Am I correct in my thinking?

thank you for your help.
Kind regards,
Moana

Hi Moana,

Yes that’s correct. You wouldn’t need the Level converter for any of your sensors running at 3.3V though. As for writing the code yes and no. Pretty much every sensor we sell (or that most other suppliers sell) will have existing software libraries so you don’t need to know the nitty-gritty of how they work.

For example, the NewPing.h library is a great library for use with Ultrasonic sensors. Once you #include the library in your code, all you need to obtain a distance reading is ask for the distance. Here’s the NewPing Example sketch:

// ---------------------------------------------------------------------------
// Example NewPing library sketch that does a ping about 20 times per second.
// ---------------------------------------------------------------------------

#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  delay(50);                     // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
  Serial.println("cm");
}

Regards,
Oliver
Support | Core Electronics

2 Likes

Hi Oliver,

Thank you for your response and for taking the time to educate me on this topic. I will give this a try in the near future and see if I can get it to work. :slight_smile:

Regards,
moana

2 Likes

Hi Moana,

I would also recommend grabbing one of these: https://core-electronics.com.au/bluefruit-le-sniffer-bluetooth-low-energy-ble-4-0-nrf51822-v1-0.html
if you are using a BLE device with Windows 7/8/10.

Let us know if you have any other questions!

Cheers,
Liam.

3 Likes

Thanks Liam - just had a look at the description of this little item and in fact it could make my life a bit easier. Thank you for the advice.

Cheers

1 Like

Hi All,

After digging into the specification sheets of my 2 gas sensors and the nano 33 BLE, I realised that the power consumption of the setup is relatively high (average supply current of 1.1+7.1+15.5 = 23.7mA) considering that I would like this setup to be autonomous for let’s say 60 days…

I have got a few questions to assess whether my project is feasible or not:

  • If I was to send data from the nano board to a laptop via bluetooth only once an hour, would the power requirements of the board be dropped considerably?
  • Can the nano board act as a data logger for e.g. 1h and then send the data on an hourly basis to save power?
  • Is there an alternative microprocessor that would be better for my project?

According to my calculation, the setup (2 gas sensors and Nano board) would need a battery pack of at least 35,000 mAh to run for 60 days… I would need power regulators to suit the different power requirements of the sensors and board (hence more losses and more power required in the first hand).

I am starting to think that this might just not be doable for now.

Any thoughts are welcome.

Thanks and have a good week end.

Moana

Hi @Oliver

The softwareSerial library is not not available for the nano33 ble. It is a samd21 based board, and has two serial ports available anyway.

Refer to this post:

3 Likes

Hi Moana,

These are some more complex questions that would probably be better answered with some testing.

To reduce the power consumption of the Nano you should have a look at the sleep function (or something similar) over on this topic here: https://forum.arduino.cc/index.php?topic=423790.0

For storing the data it might be worth having a look into using the EEPROM library to store your data in case of a lapse of power: https://www.arduino.cc/en/Tutorial/Foundations/Memory || https://www.arduino.cc/en/Reference/EEPROM

In terms of microprocessors, I would check out the Bluno Beetle: https://core-electronics.com.au/bluno-beetle.html

Let us know how you go!

Regards,
Liam.

2 Likes

Ah nice. Good pick-up Robin!

Hi Liam,

Thank you for sending through those links. I will look at them in more details when I get a chance and see what I can do.

I will let you know if this project gets somewhere. :slight_smile:

Thanks
moana

3 Likes