Hello, This is my first time using the forum and I am not sure if this belongs here, but anyway.
I am trying to build a water flow "hub" where I can connect as many sensors as possible.
From what I have read online, Esp32 could use 15+ interrupts, which translates in using 15+ sensors at a time.
I would like to know if this is true and if there is any kind of issue when using basically all of the Esp32 GPIO pins for that, for example running out of memory.
I also need to connect a solenoid valve for each sensor so I can shut down the water when needed, can I use the same pin that I use for the water flow sensor?
I was thinking about this because of two reasons:
The water flow sensor should not have any problems if a HIGH signal is sent trough its GPIO pin.
Using fewer pins means that I can hook up more sensors
The project consists of:
RTC module
SD card module
Solenoid valve for each Water Flow sensor
Each piece will get the power from another source, not the Esp32 3v3 pin
jerryjiren:
Hello, This is my first time using the forum and I am not sure if this belongs here, but anyway.
I am trying to build a water flow "hub" where I can connect as many sensors as possible.
From what I have read online, Esp32 could use 15+ interrupts, which translates in using 15+ sensors at a time.
I would like to know if this is true and if there is any kind of issue when using basically all of the Esp32 GPIO pins for that, for example running out of memory.
I also need to connect a solenoid valve for each sensor so I can shut down the water when needed, can I use the same pin that I use for the water flow sensor?
I was thinking about this because of two reasons:
The water flow sensor should not have any problems if a HIGH signal is sent trough its GPIO pin.
Using fewer pins means that I can hook up more sensors
The project consists of:
RTC module
SD card module
Solenoid valve for each Water Flow sensor
Each piece will get the power from another source, not the Esp32 3v3 pin
Thanks for your help.
Welcome to the Arduino forum. You have chosen quite a complicated project!
First, what kind of water flow sensor do you have and what signal does it produce?
Second, no Arduino can power a solenoid of any kind. If the solenoid is a DC powered solenoid, you need a MOSFET to actually switch the power to the solenoid, with an Arduino pin controlling the MOSFET. If your solenoid is AC operated, then you need a relay to control the solenoid, with a MOSFET controlling the relay. There are relay modules with all that included, so they can be directly connected to an Arduino pin.
Sensor reading pins are input pins. Solenoid controlling pins are output pins. Your software will define input or output. They can't be mixed for your application.
Have you studied all the sample Arduino programs in the IDE? IF not, start there.
It all works fine, but my dad gave me the idea of connecting multiple sensors instead of one per Esp32, so I am trying to find out if that is possible.
So let's say I manage to control the valve with 1 pin and the sensor with another pin, then the max amount of sensors and solenoids valves is totalPins/2. Right?
I am trying to find out how many of them I could possibly fit into an Esp32, I believe that an SD card can hold all the data needed for them and still have plenty of space left.
I can provide more info on the subject if it is needed.
Why? The ESP32 can periodically get time from the internet (NTP), and keep time in between (like your laptop).
jerryjiren:
2) SD card module
Why? The ESP32 has 4MB of Flash build-in.
jerryjiren:
4) Each piece will get the power from another source, not the Esp32 3v3 pin
Could be safer for the ESP to 'power' the sensor from the ESP.
Are you sure you need (potentially problematic) interrupts.
Just polling, and see if a pin has changed could be enough.
Unless your sensors produce thousands of pulses per second :o
Port expanders are another way to get more pins.
Attack one problem at the time, before you combine them all.
This is an advanced project.
I would start with to experiment with a better documented processor, like the ESP8266 (WeMos D1 mini is easy).
The "A Beginner's Guide to the ESP8266" (Google it) shows you how to use NTP and Flash.
Leo..
Sorry but I am not sure how to quote like that so I will explain all here:
Basically my code for the water sensor is taken from the web, I have seen a lot of projects and all of them use interrupts so I am just following instructions. So far it seems to work well.
RTC Module will keep track of time even if the connection is lost.
For example, I would like to shut down the water at 23:00:00, if there is no WiFi and my Esp32 just lost connection, then It won't be able to get the time, and therefore, my solenoid valve won't be shut down.
Since the Esp32 will count pulses per second, it will write the total milliliters gathered during the last 60 seconds or so to the SD card, this will prevent losing data in case of a energy shut down.
I have heard that you can store information on Esp32 but it seems that it's likely to not last too much.
Again the SD card comes handy. At a certain time, I will do a POST request to my server and if there is no connection, I will store the data on the SD card and try later when the connection comes back so I can try once again so there won't be any data lost.
The point of the project its to make it "fail-proof", so if anything happens, you won't lose your data.
Now I am curious to know why not to use interrupts, as I told you before all of the water flow Esp32 projects I have seen, use them. Can you guide me on this subject?
I will be considering if the RTC module is actually needed since my project is relying a lot on having a connection to the internet.
Since the Esp32 will count pulses per second, it will write the total milliliters gathered during the last 60 seconds or so to the SD card, this will prevent losing data in case of a energy shut down.
Uuuuh, NO. the data written to the SD card is not written to the card until the 512 byte buffer has been filled or until you execute a "flush" command. And you are not there even yet, until you "close" the file. So, you need some backup power and an indicator that the mains power is gone. Expect problems when mains power bounces off and on.
Paul_KD7HB:
2) Since the Esp32 will count pulses per second, it will write the total milliliters gathered during the last 60 seconds or so to the SD card, this will prevent losing data in case of a energy shut down.
Uuuuh, NO. the data written to the SD card is not written to the card until the 512 byte buffer has been filled or until you execute a "flush" command. And you are not there even yet until you "close" the file. So, you need some backup power and an indicator that the mains power is gone. Expect problems when mains power bounces off and on.
Paul
I mean, I will create a method that stores data on an SD card, I will open a file and close it when needed. The amount it takes to do that is something I can't control, but that will make losing data less probable.
What I am trying to achieve is to have a place to read data from if the power goes down, not gonna use EEPROM because it will wear off way faster than a SD card, am I wrong?
RTC Module will keep track of time even if the connection is lost.
So does the ESP.
The ESP has Flash, an SD card is Flash, same difference.
But more memory means that a cell might be written to less frequent, so a larger SD card could last longer.
I think what you propose is reasonable and standard practice. The detail is not quite clear, as an "energy shutdown" probably means no data created, thereby absolving you from the need to save it, but you can be sure the SD would be a better choice than an EEPROM when it comes to saving data in the event of a loss of communications.
It is common practice to use interrupts with water meters. If have never heard of one that doesn't. I believe you are correct about the ESP32 having a swag of interrupt pins and using one ESP per sensor would be crazy. The Mega also has six. There are examples in this forum of using multiple flow sensors, and I guess that, if you can do two, it is fine to do as many as you have pins.