ricaun / DuinoCoinI2C

This project design to mine Duino-Coin using an Esp8266 as a master and Arduino as a slave.
MIT License
168 stars 72 forks source link

Arduino Nano not recognized after power on with >6 devices. #49

Open fopinski opened 3 years ago

fopinski commented 3 years ago

As there is no reply I edited that issue:

Describe the bug When there are more than 6 slave devices the system will not recognize these in 1 out of 10 (or more) power on cycles. The device list is then just empty [ ]. There is a problem with the i2c initialization when such a large number of devices connects.

To Reproduce Steps to reproduce the behavior: I use an ESP8266-01S as Master device and 10 Arduino Nano as Slaves. Use more than 6 Arduinos. Check the device liste. If it stays empty reset the Arduinos one by one and all of them should connect after a few seconds. --Or-- Add a random delay to DoinoCoin_Arduino_Slave.ino before DuinoCoin_setup();

  randomSeed(analogRead(0));
  delay(8000+random(2000,3000)+random(2000,3000));
  DuinoCoin_setup();

The delay must be longer than the time it takes to get wifi and the pool.

Expected behavior While I had only 6 Nano the rig worked immediately after power on. When I added 4 additional Nano devices it should all work as with 6 of them.

Arduino (please complete the following information):

Additional context The wiring is correct. If it works it just works right after the power on, no issue then with the single Arduinos. I deactivated the pull-up resistors on the Arduinos as they are deactivated by default in this code on the ESP. The reason is that I use a bidirectional level shifter that already has 10k resistors on each line on each side.

fopinski commented 3 years ago

I managed to run 20 Arduino with the mentioned delay in the Arduino setup and a delay in the client_loop() code of the esp. There has to be at least a 5ms delay in the end of the for loop. ESP at 160MHz. i2c clock no faster than 100KHz.

fopinski commented 3 years ago

Reward is 1 Duco per AVR. Is it possible that the DuinoCoin library needs an update?

ricaun commented 3 years ago

Hello!

This random makes sense, I implement something like this on the DuinoCoin_setup function.

But sometimes causes some bug and block all the slaves... That's why I remove the automatic I2C and set it to the fixed number using the eeprom on the tiny code.

Reward is 1 Duco per AVR. Is it possible that the DuinoCoin library needs an update?

Probably the ESP is too slow to manage all the slaves at the same time and/or the code has some, some users report the rewards drop exponentially when having to many slaves on the same master.