Dear all,
I would like to add to my greenhouse some automation using an arduino uno.
What I would like to achieve in the first stage of the project is reading sensors values such as environmental temperature, humidity and soil moisture.
The idea is to realize some easy moisture sensors as discussed here: http://forum.arduino.cc/index.php/topic,37975.0.html.
Following the model described, I would need 2 digital and 1 analog pin for each plant.
Since I wish to monitor different plants, my idea is to connect one (or more) mcp23017 to expand the digital ports of arduino uno, as described here: Tutorial: Maximising your Arduino’s I/O ports with MCP23017 | tronixstuff.com
Doing so I would use 2 analog ports, and still have 4 free. Now, I thought expanding analog ports using a mcp3008, but I was not able to find any information on how to connect it to the arduino neither how to read analog values.
Do you have any suggestions, ideas or advices?
Is this the right way to proceed?
It appears that the MCP3008 is a SPI device which is a different method than the I2C MCP23017 to interconnect multiple chips. You will need to use the SPI pins to connect these devices (pins 10-13 on the UNO, other pin assignments on other chips). A quick glance at the datasheet does not show that you can connect multiple MCP3008's. http://www.adafruit.com/datasheets/MCP3008.pdf.
It might be simpler to use an I2C extender for analog inputs. You can find these at various places, such as Adafruit: ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier [STEMMA QT / Qwiic] : ID 1085 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits. Like the MCP23017, you can have multiple chips on the same bus (8 total, but check whether it uses the same addresses as the MCP23017). Adafruit provides a library for this chip (as well as the MCP23017 that they also sell). You don't have to buy the chips from Adafruit to use their library, but I tend to view it as an incentive to buy their chips, to fund providing the libraries.
Hello Michael, thank you for your reply.
Well yes, actually the idea was expanding digital ports using i2c and analog with spi.
Hum.. the fact that cannot connect multiple MCP3008 was one of the questions in my mind as also the one on how to connect it and make it work...
Anyway, if really cannot use multiple of them, one only should give me 8 channel to use and can be a good start.
I already saw the adafruit converter, but to be sincere, it costs too much for me..
The patch shield instead is interesting and could be useful for having things around.
Anyone tried to use MCP3008 or MCP3208 with arduino?
Thank you!
dk
Since you want 2 digital sensors and 1 analog sensor in multiple locations, it might make sense to use something like a Digispark, Trinket, or build your own chip using ATmega chips with the bootloader, and the sensor at each location with the sensors attached directly to the chip. They would communicate back to the host Arduino via i2c or other serial protocol. The advantage would be if you have to worry about noise due to the length of the wires, you can add some check-summing to the protocol, and if you decide you want a 3rd sensor, you don't have to change the wiring. This way you can eventually expand to 110 or so sensor groups (if you use i2c).
Hello!
Thank you for your suggestions.. well one moisture sensor has 2 digital and 1 analog, plus I can add whatever I want, following your advice. So it can be the idea to build 3 arduinos and attach 4/5 moisture sensors, and have the arduino uno as a master for reading values from the others.
What I miss is the i2c communication between arduinos, what would be best have a master that triggers data from each slave once in a while?
I will search the web to see if there are some example of multiple arduino connection via i2c.
I think I would need 4 cables (5V, GND, SDA, SCL), any ideas on how long these can be?
Thank you for your kind advices,
Have a nice day,
dk
d82k:
Hello!
Thank you for your suggestions.. well one moisture sensor has 2 digital and 1 analog, plus I can add whatever I want, following your advice. So it can be the idea to build 3 arduinos and attach 4/5 moisture sensors, and have the arduino uno as a master for reading values from the others.
What I miss is the i2c communication between arduinos, what would be best have a master that triggers data from each slave once in a while?
I will search the web to see if there are some example of multiple arduino connection via i2c.
I think I would need 4 cables (5V, GND, SDA, SCL), any ideas on how long these can be?
Thank you for your kind advices,
Have a nice day,
dk
hi,
i'm new with this staff,
but it is sounds very intresting and chalanging.
i have 2 questions about this solution:
what is the budget for this solution?
is their any idea of logging all the sensors's samples? that you can look on history of any sensor's samples.
Hello,
well right now still gathering information.. as soon as I have some time I will build a couple of arduinos with atmega8 or 168 (one of the possible ideas is to make them run at 3.3V).
The budget is really low.
Regarding the communication is to have a master that queries slaves to read sensors data.. but this is still in my mind and I have to understand which is better if trigger update from master or receive data directly every x minutes or hours..
Ciao
Paolo
Off hand, I would say it it better for the master to trigger the slaves to send the data, rather than the slaves sending the data on their own. If you have the master do the triggering, you don't have to worry about getting data from multiple slaves at the same time. Sure, you can do this (networking protocols like ethernet have to deal with this, and they have have to ack packets and resend them if two hosts collide sending a packet at the same time). However, if you have the master doing the polling, it can do each slave in turn. Of course, you still have to worry about hosts that go dead before/in the middle of transmission.