Valve Monitor
Monitor and control the open/closed state of a valve, and measure liquid flow state.
To run this project yourself you’ll need to:
- Configure Notehub.
- Purchase and assemble the necessary hardware.
- Flash the project’s firmware
- Run the project’s web application.
Notehub
The Valve Monitor project runs on top of Notehub. As such, to run this sample you’ll need to create a Notehub account, start a new Notehub project, and configure a handful of environment variables.
Creating a New Project
- Sign up for a free Notehub account, if you don’t have one already.
- Click the blue Create Project button in the top-right corner of the screen.
- Give the project a name, such as “ValveMonitor”, and then click the next Create Project button.
Configuring Environment Variables
The Valve Monitor project uses environment variables for storing project settings that need to be shared and synchronized across devices.
You can set this project’s environment variables at the fleet level or device level, where fleet-level variables affect all devices in the fleet, and device-level variables are specific to an individual device.
Notehub creates an initial fleet for you when you start a new project, and you can use that for setting your initial variables.
- Navigate to your fleet in the navigation menu, and then click the Settings link.
- Click the Environment tab.
- Scroll down to the Fleet environment variables heading, and define the
four variables below.
flow_rate_alarm_threshold_max
: (number) The maximum expected flow rate from your device, in mL / min. Flow-rate readings over this amount will trigger an alarm.flow_rate_alarm_threshold_min
: (number) The minimum expected flow rate from your device, in mL / min. Flow-rate readings under this amount will trigger an alarm.monitor_interval
: (integer) How often to take readings from the device’s flow-rate monitor, in seconds.
- With all three defined, click the blue Save button.
With this your Notehub backend is fully configured, and you’re ready to start setting up your hardware.
Hardware
The following hardware is required to run the Valve Monitor project.
- A Blues Starter Kit.
- A flow meter, such as this GREDIA Quick Connect Water Flow Sensor.
- A solenoid valve, such as this DIGITEN Inlet Feed Water Solenoid Valve.
- If you do get the DIGITEN valve, make sure you also have spade cables for connecting the valve to power.
- Tubing for moving liquid throughout your hardware, such as this 1/4 OD silicone tubing.
- A power breakout, such as this HiLetgo power breakout for supplying correct voltage to this project’s various components.
- An I2C level shifter, such as this one from HiLetgo, to translate the flow meter’s pulses from 5V logic to 3.3V logic for the Swan microcontroller.
- A MOSFET driver, such as this one from HiLetgo, is required to allow the Swan to switch on high-power devices such as the solenoid, without needing to send that power from the microcontroller. (The Swan can only send about 0.066 Watts (3.3V*20mA) out of a GPIO.)
Additionally you may wish to also use the following:
- (Optional) A manual valve such as this YZM Quick Connector to make it easier to start/stop the flow of liquid while testing.
- (Optional) An enclosure for your hardware such as this outdoor-friendly enclosure from Sixfab.
Once you have all of your hardware you’ll next need to assemble the pieces. To start, complete the Notecard and Notecarrier-F quickstart guide, which will help you connect your Notecard, Notecarrier, and Swan.
From there you’ll need to connect both your flow meter and solenoid valve to the Notecarrier. If you’re using this project’s recommended hardware, here’s a wiring diagram that shows how all the components connect.
Regardless of which hardware you use, you’ll need to have the following pins wired to your Notecarrier:
- The solenoid valve’s signal line must be connected to the Notecarrier’s
F_D10
pin. The Swan uses this pin to open and close the solenoid. - The flow meter’s signal line must be be connected to the Notecarrier’s
F_D6
pin. The Swan uses this pin to read the flow rate from the flow meter. - The Notecarrier’s
F_D13
pin must be wired to the Notecarrier’sATTN
pin. The Swan uses this to respond to interrupts whenever the Notecard receives a command to open or close the solenoid valve.
When everything is put together your build should look something like this.
If you’re also using a case like the recommended one from Sixfab, your build can look like this when placed within the enclosure.
With the hardware assembled, your next step is getting the project’s firmware running on your device.
Firmware
This project has firmware implemented with both Arduino and Zephyr. To get your firmware up and running on the Swan, you can follow the documentation for either implementation:
Web Application
The Valve Monitor project’s web application allows you to view flow rates, open and close solenoid valves, set alarm thresholds, and manage environment variables in a browser.
As a final step, complete the web app’s setup guide to get the app running on your development machine.