need to use more than 20 TTL Serial sensor >> how?

Hi
I need to use more than 20 TTL Serial sensor with the arduino .. which means I need 20 RX and 20 TX pins??

is the shift register a feasible solution ?? :confused:

what are your suggestions?

Thanks in advance

Please provide a link to the sensors that you will be using

Well, you only have 1 (328P), 2 (1284P), or 4 (2560) serial ports to start with.
So you have some option: add some digital multiplexing, add some hardware to get more ports.
Do the ports all need to run at the same time & independently? Then extra hardware, such as 5 quad SPI/I2C to serial port chips.
Can the ports be selected and communicated with one at a time? Then 2 or 3 pairs of 8:1 switches can be used, such as DG408 (Tx on one chip, Rx on the other, 1 pair of chips for 8 lines).

UKHeliBob:
Please provide a link to the sensors that you will be using

it is pzem-004t

link in aliexpress:
https://goo.gl/YcQhBd

CrossRoads:
Well, you only have 1 (328P), 2 (1284P), or 4 (2560) serial ports to start with.
So you have some option: add some digital multiplexing, add some hardware to get more ports.
Do the ports all need to run at the same time & independently? Then extra hardware, such as 5 quad SPI/I2C to serial port chips.
Can the ports be selected and communicated with one at a time? Then 2 or 3 pairs of 8:1 switches can be used, such as DG408 (Tx on one chip, Rx on the other, 1 pair of chips for 8 lines).

you are awesome
i guess in my case for the pzem 004t it is prefarable to run at the same time but it is ok to run one at a time
what the easiest way do you suggest for the pzem-004t ?

Hi,
Welcome to the forum.

What is the application that uses 20 voltage, current, power sensors?

Thanks.. Tom.. :slight_smile:

Try to find modules with a bus interface (SPI, I2C...).

TomGeorge:
Hi,
Welcome to the forum.

What is the application that uses 20 voltage, current, power sensors?

Thanks.. Tom.. :slight_smile:

HI Tom :slight_smile: , thanks

it is for home power monitoring

i want to track every room how much it is consuming .. there are some companies sell their devices but i want to make my own

until now i feel i need a lot of guiding ::slight_smile:

what the easiest way do you suggest for the pzem-004t ?

As you say you can communicate with those parts, are you sure?

So switch the multiplexers to one sensor and send a request for one reading to the selected sensor. Then wait for the reply, and switch to the next sensor.

You do realise this involves you making two 20 channel multiplexers to connect between your sensors and the Arduino. One for the TX signal and the other for the RX signal?

Grumpy_Mike:
So switch the multiplexers to one sensor and send a request for one reading to the selected sensor. Then wait for the reply, and switch to the next sensor.

then for example if i have two DG409 multiplexers lets call them (DG409 A) and (DG409 B)

in the DG409 i have switches numbers S1 to S8

you mean i will switch to DG409 A S1 to send a request for the first sensor … then … wait for the replay from the same sensor through DG409 B S1 … after receiving the reply i should move to the DG409 A S2 for the second sensor and so on

what about the timing i guess i should move to the next switch when I’m sure the reply fully received… is there a common way

MANY THANKS FOR YOU ALL <3

What is the physical distance between those sensors? All placed next to each other, or far apart? If so how far?

I'm sure you can find alternative sensors that communicate over I2C or SPI. The second would probably be better as it's easier to select the desired sensor, with I2C you probably run out of addresses.

Or add an ATtiny to each of them to read the data of the sensor via Serial, then communicate with your master over an I2C bus. That's actually a quite easy to implement solution, code should be very simple and they're all the same, just have to set the I2C address so each has a different one.

wvmarle:
What is the physical distance between those sensors? All placed next to each other, or far apart? If so how far?

All placed next to each other
.
.

wvmarle:
I'm sure you can find alternative sensors that communicate over I2C or SPI. The second would probably be better as it's easier to select the desired sensor, with I2C you probably run out of addresses.

I will search more i hope i can find them
.
.

wvmarle:
Or add an ATtiny to each of them to read the data of the sensor via Serial, then communicate with your master over an I2C bus. That's actually a quite easy to implement solution, code should be very simple and they're all the same, just have to set the I2C address so each has a different one.

I guess this is exactly what i need .. i'm watching some tutorial about them now

many thanks

If going for the attiny you may also consider optoisolating the TX/RX lines like this:
PZEM-004T mod diagram.png
Got this from a Google Image search; not tested; circuit looks good to me. Only difference is that I'd do Vcc on pin 1, GND on pin 2, and Tx/Rx on pin 3/4. Less risk of damage if you connect it the wrong way.

wvmarle:
If going for the attiny you may also consider optoisolating the TX/RX lines like this:

Got this from a Google Image search; not tested; circuit looks good to me. Only difference is that I'd do Vcc on pin 1, GND on pin 2, and Tx/Rx on pin 3/4. Less risk of damage if you connect it the wrong way.

is this circuit for quality or protection??

Protection - completely electric separation of the high voltage sensor output from the Arduino size.

Do not buy these sensors. There are no instructions/manual about how to communicate with it and no example code, in any language. Knowing that the communication is serial is only the start of the information you need, you need lots more information to be able to use the sensors.

toOomy:
you mean i will switch to DG409 A S1 to send a request for the first sensor ... then ... wait for the replay from the same sensor through DG409 B S1 ... after receiving the reply i should move to the DG409 A S2 for the second sensor and so on

Yes basically that is it.

what about the timing i guess i should move to the next switch when I'm sure the reply fully received...

Yes

is there a common way

No, it all depends on the sensor.

PaulRB has a very valid point, if you don't know if you can command a single reading then these sensors are useless to you. But you lead me to believe that you knew how to command a single reading. Are you being over optimistic?

PaulRB:
Do not buy these sensors. There are no instructions/manual about how to communicate with it and no example code, in any language. Knowing that the communication is serial is only the start of the information you need, you need lots more information to be able to use the sensors.

Grumpy_Mike:
PaulRB has a very valid point, if you don't know if you can command a single reading then these sensors are useless to you. But you lead me to believe that you knew how to command a single reading. Are you being over optimistic?

I found this datasheet

i'm not familiar enough with the TTL serial protocol but i'm assuming i should find enough tutorials to guide me how to use the table provided in the datasheet

do you see this datasheet will be enough for me? :slight_smile:

do you see this datasheet will be enough for me?

Perhaps, yes. Maybe no. At this time I would recommend buying only one sensor and using it to test and learn. We will help as much as we can.

PaulRB:
Perhaps, yes. Maybe no. At this time I would recommend buying only one sensor and using it to test and learn. We will help as much as we can.

many thanks PaulRB <3

I will order one and try it

I’m now confused what to do about receiving from the 20 TTL Serial sensors … do you suggest the ATtiny85 that i program it to be something like UART TTL to I2C converter … or just use the DG409 multiplexer

do you suggest the ATtiny85 that i program it to be something like UART TTL to I2C converter

Well I wouldn’t do that. However for 20 sensors would you would need three DG409 multiplexers per channel, making a total of six chips. Because they are only 8 input multiplexers.