How do I turn on and off a solenoid every x days using ESP32 and Blynk? - arduino

I am building a sprinkler system using blynk and ESP32 wifi module. I have 6 solenoids that activate sprinklers, and I am looking to have them fire every x days, changing every month. So far, I have come up with code that: fires a relay at a specific time, and/or fires a relay for a given amount of time when a button is pressed in Blynk.
Where I am looking to go with this is having 6 solenoids fire back-to-back every x days, with x changing by month. I don't really know how to format the syntax for the 'every x days' part. Any tips?

The simplest way to use Blynk, is to put the generated Blynk sketch in the Arduino and set the widgets in Blynk App.
To make a time schedule, use the BlynkTimer and/or Eventor widgets. The Blynk cloud handles the schedule even if the application is not connected.

Related

Multiple sensor data in same page in qt/qml application

I am developing and Qt/ qml application which runs on a limited resource device. App displays instant data of multiple sensors. Every sensor sends data periodically with different frequencies. Their frequency is much frequency than device can refresh Frame. Currently I am registering every sensors data to qml side as q_property and reassign their value every time one of the sensor sends data which is more frequent that frame can be refreshed. What I want to do is assign properties onlu before refreshing Frame. What is the best way in this situation? I researched about before rendering function of qquickwindow, but couldnt handle it.
From my experience with sensor data i would suggest that you delay/time the input on the c++/sensor side rather than on the GUI side.
e.g. i had data from joysticks on an Arduino that would refresh faster than every 0.01 sec. i than implemented a delay of 0.1 or 0.2 seconds on the arduino/hardware side and send all data from all devices in the same interval. I am guessing from the type of data you are collecting that its not even necessary that it refreshes so fast? So maybe just give it a 5+ second delay? QML than can refresh every 5 seconds.
if thats not an option for you i would also suggest like folibis to use a timer thats sets the new values in an interval.

How to use QTimer to get data from an external peripheral device for a specific time interval only?

Aim:
I am working on Qt Creator and want to interface Modem with my main program
, for that, I need to fetch the data from the modem for a specific time interval (say 3 seconds) only and after that I have to stop receiving data.
My Work:
I tried to implement it using:
QTimer::singleShot(3000,this,SLOT(SLOT1()));
But the limitation with it:
It calls the SLOT1 after 3000 m sec, but this is not what I want.
My requirement:
is to use timer in order to fetch data for 3 seconds only and then stop.

Display time with push button interrupt Arduino

I need to write a code that contains an interval loop but contains a push button interrupt that displays RTC values when activated. I have found a way to individually do each task i.e change pushbutton state, loop in intervals, display RTC value but I cannot seem to combine them and create a working. If someone can provide links or an explanation on how to accomplish this I would be so grateful.
If you do not use delay(interval); in your main loop, you can run as many tasks in parallel as you want. Understand the BlinkWithoutDelay sample, and try to extend it to two leds blinking independently. Or read a button while blinking.
And push button and interrupt does not go together well, BTW.
You even might add a small delay(2); to slow down polling the button pin.
This is usually fine for the other parallel running tasks and implements a very simple debounce mechanism.

Arduino button interrupt triggered on high power switch on

I have a nearly finished prototype using an arduino uno. Basically its purpose is to switch a 2000w main AC heating load using a heavy relay on and off. The input of the relay is comming from the mains but is connected to the power company using a special meter that is only switched on between 23-07 hrs at night. The power for the arduino is continous by the way, so this stays on.
The whole thing is nicely build into a box with on the front an small lcd display and a button, connected using 20cm wires to the arduino board (I am using a protoshield).
The button is pulled up with a 10k resistor which is pulled to ground when pressed. I have put a 0.47 uF cap on the input pin = pin 2 to also debounce the circuit a bit. In software I am using an interupt on the falling edge to detect button presses. The whole thing works nicely... Except...:
When the load ac input is switched on by the power company this is sometimes recognized as a button press! I am thinking that the suddon power spike induces a voltage in the 20 cm button wires which is recognized as a falling edge. How can I avoid this?
I am equiped with multimeter, oscilloscope, soldering... so I can try out any suggestions in detail.
I am having a similar problem building a fuel injection flow bench. The button press starts a simulated engine run sequence that powers a relay. That relay then powers up to 6 injectors. What happens is as soon as I press the button the injectors closing induces a current and trips the whole system to start over again. The solution I've found that worked was using a battery to supply voltage to the injectors as opposed to the power supply itself. This isolates the arduino supply from the injector supply via my relay. The problem is of course now I need to keep the battery charged. I'm looking for a more elegant solution.
I tried to solve this issue in hardware, but unfortunately failed.
These are the options I tried, but that did NOT work
used a shielded cable for the button
implemented an XY denoise capacitor network on the AC of the load (input)
like this one : http://www.conrad.be/ce/nl/product/450571/K042201052-Ontstoringscondensator-XY-Radiaal-bedraad-01-F-250-VAC-1-stuks?ref=searchDetail
In the end I implemented the following software solution:
The first time the button is pressed, it must be pressed 1 second before the button actually becomes active. This will never happen due to the AC turning on because this is a very brief spike. I programmed this into the arduino using interrupt to detect button press and then micro delay (inside the ISR) to check that after 1 seconds the button is still pressed.
After the initial 1 second button press, the button stays lively for 1 minute

Find time difference between two pulses using PIC16F628

I want to find time difference between two pulses using PIC16F628.
I am using a 4MHz external oscillator, MikroC compiler.
As a simple example let's assume there is a push button. When we press it, it sends a high signal to a pin. We press this button twice with some delay in between, I want to find the time difference between these two button presses.
Thank you.
As mentioned in the comments, the simplest way to do this is to use a timer/counter combo. I found this quick tutorial on how to do this specifically for PIC: http://www.mikroe.com/chapters/view/17/chapter-4-examples/#c4v5.
Have a look at 4.5 and 4.6, they give you exactly the information you'll need to get the count of timer intervals between pulses. The basic technique is to start a timer, associate an interrupt handler (Read: function) with the timer, and then increment a counter everytime the interrupt handler is called. Next time you see the pulse, read what the counter value is.
After that, all you need to know is the timebase you've set the counter to (which will be some integer subdivision of your oscillator rate, and is selectable in code usually) and you can convert # of timer intervals to time in seconds/millis/nanos.

Resources