I would like to connect 2 modules to one serial port. Is it possible?

I have the same problem as the title. The board can only connect two modules to serial port 3. And serial ports 1 and 2 are already in use.

And now, in the photo, only the esp8266 module is connected to the Arduino Due using a bridge. Because Bluetooth also uses a bridge to connect to Arduino Due, an error occurs.

So I tried to disconnect or connect the electricity by connecting a switch to the two modules, but the module often doesn't work properly.

So I looked for a module that supports both Bluetooth and Wi-Fi, but couldn't find it.

Is there a good way? Or good module.....

ESP32 modules support Bluetooth classic, Bluetooth LE and WiFi.

The simple answer is no, you cannot connect 2 devices to 1 serial port and expect it to work. In some cases it can be made to work but only if you are really careful about which device you are communicating with and don't mind that only one will work at a time. You have to have some kind of switching in place to switch the data to and from the correct device. Simpler to use software serial for one of them, assuming you have 2 spare pins to use it on and that it's fast enough for what you are doing.

I don't know what you mean by a 'bridge', please explain, thanks.

groundFungus:
ESP32 modules support Bluetooth classic, Bluetooth LE and WiFi.

Is esp32 normally compatible with due?

If yes, what are the ports that must be connected between esp32 and due?

The green board currently only supports RX, TX, GND, 3V3, EN, RST, I01, I02, which are required for esp8266. ESP32 will be the best choice if you only need the above 8 items.

PerryBebbington:
The simple answer is no, you cannot connect 2 devices to 1 serial port and expect it to work. In some cases it can be made to work but only if you are really careful about which device you are communicating with and don't mind that only one will work at a time. You have to have some kind of switching in place to switch the data to and from the correct device. Simpler to use software serial for one of them, assuming you have 2 spare pins to use it on and that it's fast enough for what you are doing.

I don't know what you mean by a 'bridge', please explain, thanks.

The bridge is the red device in the white circle. It connects RX and TX.

I didn't know what to word that, so I wording it was a bridge. Sorry.

And only one module needs to work at a time. However, I am having a hard time writing the code because Arduino cannot determine whether the device currently connected to serial port 3 is ESP8266 or HC-05.

If there is a code or a way to determine which equipment is currently connected, I can fix this.

Hi,
Welcome to the forum.

What is you overall project?
How many controllers are you using and what data do you communicate between them?

We may be able to offer alternative solution with more information.

Can you post a basic diagram of your controller network so we can understand your project better?

Thanks.. Tom... :slight_smile:

If there is a code or a way to determine which equipment is currently connected, I can fix this.

I don't really know how to answer that. Is it fair to say that you only have limited experience writing code an with electronics? I get the feeling you are working on a project more complex than you know how to deal with, is this a fair comment? Not to put you off, by all means keep going but you are going to have to play around and learn to get your answer. One way is to have the Due control which device it is talking to over serial, then it already knows as it is in control. You need to switch the serial port between the 2 devices, something like a 4052 or 4053 can do this.

I think the idea of using an ESP32 is better than playing around switching serial ports.

TomGeorge:
Hi,
Welcome to the forum.

What is you overall project?
How many controllers are you using and what data do you communicate between them?

We may be able to offer alternative solution with more information.

Can you post a basic diagram of your controller network so we can understand your project better?

Thanks.. Tom... :slight_smile:

First of all, I apologize to all of my friends who answered. I am using Google Translator because I have bad English skills. So there may be a bad translation.

The project I'm working on is creating a module that measures air quality.

Except for WiFi and Bluetooth, it has 8 sensors.

Data is collected from 8 sensors and sent to my database server.

We saved wifi information (SSID, Password, collection speed, database server address) on the sd card in a text file and transmitted the data with that information.

However, since the case box of this module is not a structure in which the sd card can be freely pulled out, I felt the need to modify the text file with Bluetooth.

So now I am trying to connect an additional bluetooth module.

PerryBebbington:
I don't really know how to answer that. Is it fair to say that you only have limited experience writing code an with electronics? I get the feeling you are working on a project more complex than you know how to deal with, is this a fair comment? Not to put you off, by all means keep going but you are going to have to play around and learn to get your answer. One way is to have the Due control which device it is talking to over serial, then it already knows as it is in control. You need to switch the serial port between the 2 devices, something like a 4052 or 4053 can do this.

I think the idea of using an ESP32 is better than playing around switching serial ports.

Thank you so much for your kindness.

But because of my bad English skills, I couldn't figure out exactly what you were saying to me.

Since I understood that it is better to use the esp32 module, I am looking for information on the ESP-32S NodeMCU Lua WiFi.

This is my first time developing Arduino, so I do not know much information. It just collects and transmits data from various sensors...

Thank you very much.

Hi,
Fine with Google translate.

What are the 8 sensors?
How far apart are the controllers?

Why do you need more than one controller?

Can you connect the 8 sensors to one controller?

Thanks.. Tom.... :slight_smile:

Sounds to me like another application for quad tri-state buffers. Search this site for my tutorial about 74HC126 and 74HC125 Quad Tri-state buffers. It's not a sticky unfortunately.

Here it is: Arduino Forum

TomGeorge:
Hi,
Fine with Google translate.

What are the 8 sensors?
How far apart are the controllers?

Why do you need more than one controller?

Can you connect the 8 sensors to one controller?

Thanks.. Tom.... :slight_smile:

Pm2008
Seeed
CCS811+HDC1080
MH-Z19
MQ-131
MQ-2
ZE80
SO2

As you can see in the picture, the distances between the sensors are very close.

Put these two green boards in a black case box and install them in a place to measure air quality.

The reason both bluetooth and wifi are needed is to make maintenance convenient by modifying the SD card information.