Remote configuration

I'm just looking for ideas here. My project is still in the conceptual stage. It will be a controller for a greenhouse. I will need to collect measurements from many different locations and control a number of fans, vents, valves, etc. There are way too many for a single controller, so I envisioned driving an array of Arduinos from a Raspberry Pi. I thought I would use I2C since that leaves the most pins available.

The RPi would send each Arduino its pin configuration at initialization time, and the Arduinos would configure themselves from that info. During operation, the Arduinos would relay all measurements to the RPi, and the RPi would do its calcs and send back control info which the Arduinos would execute.

Since the Arduinos would just be message passers, they could all run exactly the same sketch. Except for one problem. They each need a unique I2C address. I really don't want to have to modify the sketch for each one just for its address. I also don't want to tie up any more pins than the I2C ones. The RPi needs to know each Arduino's address, preferably by assigning it from the database.

My first thought was to have the RPi reset each Arduino one at a time. During the init, it could tell the Arduino (over I2C with an initial address) which address to use and it could change to that address. The problem with that is that it would have to call wire.begin() twice, and I'm not sure if that is allowed.

I also thought about multiplexing some of the digital pins and using them for config on startup, then switching them to their normal function for operation. I think this would restrict them for input only during operation, but I'm not sure about that.

I am open to any creative ways to do this. Any ideas?

You could maybe look into CANbus communication. Not sure how many pins it uses though.

You dont say what area you have to cover, or how many points you have to collect data from, or which media, but from my little bit of playing the wireless modules , it sounds like a job for a mesh network ? you could use Xbee or the cheaper RFM22B or SIM20 ??

Perhaps each Arduino can service its sensors and outputs in its immediate zone, and you could poll each in turn from the main unit?

I'm not familiar with mesh networking. I plan to co-locate all of the arduinos in the office where the environment is more electronics friendly. That puts them in close enough proximity to use I2C.

If I have to modify the arduino sketch for each individual, it's no major problem. I just wanted a way to mass produce and have some spares ready to go for additions and replacements.

I will probably have several dozen growing stations, each with monitors for soil moisture and incident light, and control for watering valve and grow-light intensity. The entire space will be monitored for temperature and humidity, and will control air vents, fans, misting systems, etc.

Do you plan to wire every sensor / solenoid / relay through to the office ?

Yes, they will all be wired through.

None of this is set in stone. I could possibly be persuaded to distribute the controllers throughout.

I am trying to choose a wireless module for my project, the RFM22B has 500m range but is rather confusing to set up and use, but I am now looking at the XRF module that works straight out of the box, but you can configure it as a network/mesh.
You could possibly use these combined Arduino ( variant ) and radio module at various places around your greenhouse :-

http://shop.ciseco.co.uk/radio-arduino-compatible-starter-kit-lowest-cost-in-the-world/

(I havnt tried one yet )

Thanks Boffin1. I'll check that out.

dgregory:
I thought I would use I2C since that leaves the most pins available.

RS-422, RS-485, CANBUS, LINBUS, and Ethernet are likely better choices. It's a question of your expertise, your time, and your money. If you have the knowledge and ability to get I2C working reliably over about 20 meters then it may be a good choice. Otherwise, pick something else.

They each need a unique I2C address.

Store the address in EEPROM.

I am open to any creative ways to do this. Any ideas?

You don't need anything particularly creative. People have been doing similar things for decades. Store the minimum configuration in EEPROM (the address in your case). Use an appropriate physical layer. The rest is just sitting down and doing it (or stealing it).