Since you have to count and transmit the total, I insist on using the tranceiver method. You can leave every of the 40 pic as Steve stated in a polling state and when the address is valid for each station, then this station report back. No collisions this way.

From the PC side you have to implement a way to address each one of the 40 pics in circle.

For example in a loop:

for i=0 to 39
send address i
gosub receive from station i
next i

Ioannis