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?
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.
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,…).
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");
}
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.
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.