File component issue (Using Bluetooth, TinyDB to control a Plant watering system)

Thank you!

#Off topic
Only PNG not gif right

1 Like

Yeah. I read the topic about gif and I just got crazy.

1 Like

Am I missing something Patryk?

So I think I have finished the Bluetooth "Connect", Disconnect", File "Save ", "Get" portions of this App All that's left is the "Start Timer". Here is what I have for the "TimerScreen" and "File" Code.

All I need to do now is to create a simple loop that takes the info from the text box, start the clock, turn on the relay, create a loop that counts down that text box data, Disables the clock, turns off the relay, and repeats this procedure for all 14 text boxes in sequence. Sounds simple enough. I have this code but it's not working as expected. Just to turn on relay one time for the first text box.

Nope not that easy. Can you give me an idea why. I worked on this little piece of code all weekend.

Thanks

You fell into the trap of trying to loop your way out of a timing feature.
Screen Shot 2021-02-01 at 7.30.49 AM

Here's the background on why that won't work:

Here's an app sample that shows how to code the solution, using multiple deadline variables and a single Clock Timer event...

1 Like

Sorry about not replying to your latest entering on my issue. I was exposed to COVID and have been dealing with that for the last couple of weeks.This example you sent me is confusing to me. I don't see the correlation between the buttons and the clock. Is there another approach I should be looking at to achieve a series of sequential countdown events?

All I am trying to do is take the text from each text box in sequence count down the value in that text box. When it reaches zero, move the counter to the next ext box value and count down to zero, Then move to the next text box take that value and count down to zero, etc. In between the countdowns I will trigger an event that requires talking to a relay board to turn a 110VAC relay on or off depending on the requirement.

I have been screwing with this CLOCK component for over a month now between working on it and dealing with a COVID infection and so far I CAN NOT get it to work for a lack of understanding of how it functions, I have tried several different ways to get this to work with no success. I could rally use some help in resolving this issue as it is just a small portion of this project and the customer is getting a little impatient with me. Can anyone offer a working solution to this issue I am having

Timer is suppose to read the text boxes in sequence from left to right from top to bottom. I turns a relay on for whatever value is in the "ON/OFF" column for the specified seconds. It then turns the relay off for the specified seconds in the "DURATION" column. This cycle repeats until it completes all 7 rows. That's it! Seems simple enough right.

This is my latest attempt

No errors but it drops through the first 3 boxes and performs the last textbox in the group when the "START" button is pressed Ha! Ha! Ha!

Could really use some constructive help.

why do you set the clock 5 times to enabled = true?
does this make sense?
also how does your RelayOn procedure look like?
you also call it several times...

it is important to understand, that the processing does not magically stop after setting timerEnabled to true the first time... the program code just runs through...

are you already familiar with The model of event processing in App Inventor by Lyn?

what you have to do after your first process is finished, then start the second process... and after the second process is finished, then start the 3rd, etc.
see this example https://puravidaapps.com/filebyfile.php, which is using anynchronous processing, it is about downloading files, which is different... just try to understand the logic...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Export your .aia file and upload it here.

Hi Taifun

Thanks for the response. Sorry if I seem a little off I am recovering from COVID and it messes with you brain. Can't smell, can't taste, and my brain function is off speech and thinking. They say it can last up to 6 weeks or may never come back in some cases.

  1. I just thought it made sense to do it that way because I do not understand completely how the CLOCK component works and I am an old school programmer from the 90's.

  1. Yes my mistake which I caught right after I posted this. When I Enable the CLOCK I want the relay either on or off depending on if I am running through a ON/OFF cycle or the DURATION between ON/OFF cycle.


3. So putting the "Clock.TimerEnable = False" in the Clock routine is not a good Idea?

  1. I am not at all familiar with Lyn model I will definitely check it out.

  2. Forgive me but I thought I was doing that. Old school when a Routine like a BUTTON.CLICK is called it runs through it in sequence. When a sub routine inside that routine was called it would jumps out do that routine then return to the first Routine at the next line. Am I wrong in thinking that way?

I will look at the two links you sent me. Hopefully it will give me so insite even with my scrambled brain function.

Thank you so much for your help Taifun.

P.S. Ths is just the first two rows there are 7 in all I just did the first two to test it to see if I could get it to work.

See this topic

The requirement is different, but it shows how you move from a "linear" procedure (as per your current blocks which just races through to the end) to a looping procedure, using a clock timer to effect the loop, which waits until each activity has finished before the next is started.

Can't stop my Illustrator CS5 from wanting to load it. Any other suggestions

Does your application control live relays? Works like a microcontroller? The loop must pass between the seven "Duration" fields and periodically turn the relay on and off? Does it do that all day?
It wouldn't be a better solution if the relays were to be controlled by a microcontroller, while the application would be used to configure the microcontroller?

This program writes and reads data from fourteen text boxes using the clock component. There are also defaults on first run. Maybe this will bring you closer to how the clock works.

clock.aia (4.6 KB)

Hi Parryk

No it does ot.

The application requires the AC pump to be turned on for 15-20 seconds. Then off for 10-15 minutes to allow feed water to soak into soil. Then on for 15-20 seconds. Then off again for 10-15 minutes again to allow feed water to soak in. This is repeat 3-4 times until the plant receive approx. 3/4 of a gallon of feed water. The process is repeated ever 3-4 days by user.

Also Patryk
the plants may require different watering timing based on pot size and type of plant and whether they are feeding the plant or Flushing them.

I'm not asking that. Do You need an application for the pump and other devices to work all the time? Is she just configuring a device? What is the heart of your system?

Does the app on the phone control it all the time? Do you have any microcontroller, e.g. arduino?