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

Why cripple yourself with the Attiny85? You have limited flash & SRAM. Start with a 328P at least.

Don't you have to send serial data before you get a reply back?
I guess then you don't need hardware serial ports, and SoftwareSerial could work.
Maybe try to switch SoftwareSerial in loop() to a different set of pins every time when you want to read one sensor.
A Mega has enough pins for that.
Leo..

Hi,
Have you googled

pzem-004t arduino library

Also try google mutli pzem-004t arduino and 3 phase pzem-004t arduino

Tom... :slight_smile:

Wonder what would happen if you just had 1 sensor board and 20 coils?

Might be able to common wire all the (black), then just use multiplex switch between the (red)wires.

Save yourself 19 boards and 19 arduinos...

and 19 arduinos..

No one is suggesting using one Arduino for each board.

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.

An attiny is not an Arduino indeed. Cheaper, smaller, simpler.

Just been looking more at images of the sensor, and description of how it works.

The host has to send a command to the device to read data. So it's bidirectional, can't share Tx or Rx.

In the board I also see two 4-pin ICs, that appears to be optoisolation of the output. Can't see part numbers but no Idea what else it could be. They're placed in opposite orientation, just as I'd expect for optoisolation.

To add to that, I see a capacitive supply.
The whole board could be powered from that, with only opto isolation for the RX/TX pins.
That means the whole board could be directly connected to mains power (live!).
I wouldn't use this board without having mains power experience and/or access to a proper circuit diagram.
Leo..

The board reportedly doesn't work without mains power connected so it seems it is properly isolated: mains power indeed powering the on board electronics, vcc and gnd used only for the optocouplers

Grumpy_Mike:
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.

CrossRoads:
Why cripple yourself with the Attiny85? You have limited flash & SRAM. Start with a 328P at least.

I guess i will use 2 of 16:1 mux per channel

Wawa:
Don't you have to send serial data before you get a reply back?
I guess then you don't need hardware serial ports, and SoftwareSerial could work.
Maybe try to switch SoftwareSerial in loop() to a different set of pins every time when you want to read one sensor.
A Mega has enough pins for that.
Leo..

isn't that the mega has 4 RX/TX pins only

TomGeorge:
Hi,
Have you googled

pzem-004t arduino library

Basic Setup · olehs/PZEM004T Wiki · GitHub

https://www.circuitspecialists.com/content/189799/ac004.pdf

Also try google mutli pzem-004t arduino and 3 phase pzem-004t arduino

Tom... :slight_smile:

thanks Tom :slight_smile:
very useful links for me

Slumpert:
Wonder what would happen if you just had 1 sensor board and 20 coils?

do you mean it would be unsafe??

isn't that the mega has 4 RX/TX pins only

Irrelevant he said:-

Maybe try to switch SoftwareSerial in loop() to a different set of pins every time when you want to read one sensor.

So you have 20 instances of software serial and they come out on different pairs of pins and then you switch which instance of software serial is working in software. Note only one instant of software serial can work at any one time.

Grumpy_Mike:
So you have 20 instances of software serial and they come out on different pairs of pins and then you switch which instance of software serial is working in software. Note only one instant of software serial can work at any one time.

aha good idea

this give me new idea to save pins ... since all the sensors are the same and i can choose what RX to listen from .. could i use one TX from the arduino to all the RXs on the sensors .. at the end i will listen from one RX only and the other RXs will not make a difference....
is this possible ??

1 output to 20 inputs is probably not going to work. You will need to buffer the TX signal to perhaps 3, 4 or 5 lines driving 4, 5, 6 or 7 inputs each. Many basic logic chips could be used for this, for example 74hc00, 74hc04...

For example if you use 74hc04 hex inverter, you can wire Arduino TX to the input of inverter #1, output of inverter #1 to inputs of inverters #2 to #6, creating 5 copies of the TX signal. Each copy can drive 4 RX inputs on the sensors.