Software apps and online services
My dear followers - I've noticed your feedback that you need more ideas related to a relay: today I'm going to point it out and show how you can control the relay either by your room humidity or with the help of your smartphone and the free Blynk services. This switches another 12V DC circuit together and the water pump for the fountain becomes active until the threshold is reached or you switch off the relay with your smartphone.
Here is what you need to do: 1. Download Blynk app here 2. Scan this QR code 3. Enjoy my app!
You'll fall into a trap if you're using a low-level relay to postpone the build-up: this will respond to LOW and have cost me some time to understand that. So far I thought that there are only high-level relays, which switch to HIGH, but I have a better instruction. So if you have a high-level relay, only a few code interventions are necessary to edit the changeover from LOW to HIGH.
The red LED is always on; the green LED when activated:
I assume that you have a Blynk account and install the smartphone app on a device of your choice.
Follow the pin assignment in the sketch and combine the DHT22 with the resistor, the relay and the photon on the breadboard.
Do not forget to link the two libraries within the Particle WebIDE or Particle Dev to the sketch before flipping the sketches.
#include <Adafruit_DHT.h> #include <blynk.h>
About Blynk.run(); Blynk-functions are available outside loop & setup, which are controlled via the Blynk app, namely BLYNK_WRITE () which is used 2x. This is used to control the button widget, which has been set as a switch and the slider widget. Here you can also turn on the water pump, even if the threshold has already been exceeded. A slider is a fine thing: you can influence the value specified in the sketch by using the Blynk app, without having to re-adjust the sketch and flash again. But beware: do not come to the idea within a loop values to the Blynk app to transfer: this leads very quickly to a flood error and your Blynk app goes offline.
// Blynk.virtualWrite (V4, humidity_threshold); // !!! http://docs.blynk.cc/#troubleshooting-flood-error // DO NEVER in LOOP!
I have solved this with a call to a function.
In the following, the humidity is measured over the DTH22 at a distance of at least 2 seconds, monitored via the serial interface and then evaluated accordingly: if the threshold value is less than or equal to the threshold, the relay is activated and the internal photon LED is lit. And moistened until the moisture has reached the threshold.Serial interface
Good to know the commands for the serial interface:
- Windows: execute CMD - "
particle serial monitor --follow"
- MAC: execute Terminal - "
ls /dev/tty.*" - "screen /dev/tty.usbmodem1411" as example
Note that I am still going to pass a test, namely with the global variable check the state of the button: If the variable "vRelayStatus" is not equal to != 1, the test should only be carried out in this case. This means that the manual activation via the button is given priority.
Here again a favorable 12V water pump, which pumps the water in a closed water circuit over a short piece of silicone hose and also illuminates the 4 LEDs. This looks very nice in the dark.
A possible extension would be that the Particle Photon enters a sleep mode in a time window to be adjusted via the Blynk app (for example at night between 11 and 8 o'clock in the morning in order not to make sleep-robbing noises from the pump) and thus additionally saves some current and then resumes the measurement. Who wants to contribute with a code suggestion? Any ideas? system.sleep and time.hour-functions are suggested.
Like my description? You will find more under my account. Follow me to be notified when I publish new projects!
Here is my Paypal link. You can also send me sensors, which I then like to look at times.