Hi guys, sorry this is a bit of a long one but I have a lot of questions and I am trying to provide as much detail as possible to make it easier to understand.
TLDR: Trying to make a v2 of a modular smart pot I made. First one wasn't very modular. V2 should connect with magnets and pogo pin like connectors and use a protocol like I2C or CAN or something like that to control each pot, but IDK how to use them. Preferably run off a single esp32 but not required (Trying to keep costs down).
So, I am making my second generation of a modular smart pot system I made. The way v1 worked is there was a control module that housed a esp32 and a screen for data viewing and then each pot contained its own water, pump and moisture sensor, with the wires running through holes in the sides of the pots to the control module. I don't like this since for each pot I have to run 2 wires from the control module through each pot to the new pot plus the power for each of them but I daisy chained those. (1 for the moisture sensor and 1 for the relay for the 12v pump per pot plus 12v and 3v and ground). The reason I didn't put a esp32 in each pot is to keep it cheaper and so I can display data of all the pots on the screen without having to deal with connecting all the esp32 over wifi or bluetooth. Recently I did get serveral esp32 for cheap so I would be kinda ok with putting a esp32 in each pot if its easier.
With the 2nd gen I want to make the electronics smaller and make the pots "hot swappable" by having then connect with magnets and something like pogo pins, but I don't know how to make it where it is the same number of pins per pot. Also, it doesn't have to be pogo pins, I just don't know about any other connector where you don't have to plug/unplug it. The reason I want them to be hot swapable is because it makes it more user friendly and I plan to send these for my mother and she isn't very techy so that way all she has to do is put the pots next to each other and the magnets would snap them together and they would just work. As I said I have to run 6 wires through all the pots so making the wires the same amount per pot is required for making them hot swapable. I read about using communication protocols like I2C and CAN but I don't really know how they work and how to control my components in each pot with these protocols but I think that would be the way to do it.
Also to make it easier for the user, on my v1 I would have to refill each pot with water individually, is there a connector that would work in this scenario that would connect all the pots together?
You have not told how you identify one pot from the other.
You have not told us how you will water an individual pot and keep a second pot from also being watered.
You have not told us how you intend to hold a magnet to the pot surface so it is not pulled out if the pots are separated.
4, You have not told us how you will make a water tight connection from pot to pot.
5, Are you also molding.making the custom pots
Currently I manually update the code to add in a new pot by making a new variable for the moisture sensor and the pin for the relay and then put that into a function to detect if the sensor is at a level then put the relay pin to high.
Same as in question 1. each relay is set in the code like relayPot1 or relayPot2.
and 5. I am 3d printing the pots and I will put the magnets into the print so that they are fully encased inside.
That is what I was asking how to do, I was asking if there was a way to make a water tight connection between the pots that can be disconnect because currently the water is fully contained within each pot and each pot has to be refilled independently.
That is likely already being done with drip irrigation systems.
But the problem for your meditation today is: How to water pot#2 and not also water pot#1,pot#3 and pot#4.
Ok, let me rephrase my question. I need to control an indefinite number of 12-volt pumps and receive data from the same number of either a capacitive moisture sensor or digital moisture sensor. I need to be able to add or remove a set of pump/sensor without having to change the wiring. How would I go about doing this?
Can you post a complete sketch that waters and senses one pot?
Or better, one that currently does a few? I for one would like to see how you went from one to several instances of sensor/pump pot combos.
If you had a maximum number, you could just make the sketch handle that many, and only hook stuff up to the extent you have stuff to hook up.
Let all the pots go for the same ride - sensing, watering and whatever; the sensors that aren't attached might report nonsense, and the pumps that are not attached won't mind getting nonsense control indications.
I say indefinite but really the max it would be is probably like 10 pot module
I wiped my os again when trying to install a new linux distro so I don't have it anymore but heres some psuedo code of how it kinda works (this is for a 3 pot system, currently each time I want to add a pot I have to rewire and change the code:
pump1 = PUMP1PIN
pump2 = PUMP2PIN
pump3 = PUMP3PIN
moisture1 = MOISTURESENSOR1PIN
moisture2 = MOISTURESENSOR2PIN
moisture3 = MOISTURESENSOR3PIN
drySoil = SOMEVALUE
loop() {
while (analogRead(moisture1) > drySoil ) {
digitalWrite(pump1, HIGH)
}
while (analogRead(moisture2) > drySoil ) {
digitalWrite(pump2, HIGH)
}
while (analogRead(moisture3) > drySoil ) {
digitalWrite(pump3, HIGH)
}
//Code to display moisture levels of each pot on screen here
}
Also here is a wiring diagram for the 3 pot system, this isn't a good diagram its mainly just for me to remember what wires go where when wiring it.
OK, this can work, but it would be a good time to stop making progress and learn a bit more.
Any time you find yourself making new names by appending a differentiating character to a base name, you should think about using an array variable.
Any time you find yourself growing the sketch by copy/paste/editing existing working code, you should think about writing a function based on that code.
Such a function could have arguments that generalize it so one code block could handle any pot/sensor/pump.
And once you know about array variables and functions, you will see how nicely they match up with using loops like the for loop.
I don't know where or how you are learning about coding, but adding arduino to anything and googling will provide a wealth of hits. The nice thing is there are opinions, but no subjectivity, so just about anything you read about
arduino array variables
will not be wasted.
A benefit is that with but one block of code, there is only one place to perfect, modify or enhance your process for sensing and dispensing.
Thank You! I think this is what I was looking for in terms of between pot communication. Is there anything specific I should know about using serial for communication and is there a specific module that works best?
You start by looking at the ASCII table and study the use of all the communication control characters. This is the beginning of a long learning exercise.