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

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?

This is a complete control system that will be controlling 9 water control valves, 110AC pump to supply both feed water and just plain osmosis water to flush out nutrients, Monitoring Ph levels in soil, Mixing nutrients for feeding automatically and controlling a mixer to keep feed water mixed. to start with. All controlled through a bluetooth app that she can use while sitting at the dining room table or watching tv. I thought about a micro-controller but I think one 16 Channel Bluetooth relay board will do everything that needs to be done.

Eventually I might want to go WIFI with it but for now just Bluetooth.

The only difference is that you must remember about the application and you must be at home to turn on the system. However, the microcontroller would control everything automatically. No household interference.

But now I get it. Tomorrow I will show you an easy way to countdown time.

Ya you know what Patryk. Early on, on another project I bought the emulator, Bluetooth modules, Ph sensors etc fully intending on doing just that from MIKROE. But once they came out with Bluetooth boards I found it easier to just use them and a phone app to do the same thing by eliminating the redundant interface. ,I've done two applications this way both seem to do the job. One with just a 2 channel relay board and one with an 8 channel which really came out nice.

I am absolutely digging the MIT APP INVENTOR Development system and tell everyone I know about you guys.

Thank you for the help Patryk

Hello Jay

I think I remember Trailer Mate from the old App Inventor Forum :grin:

Yes that was two years ago. I was just getting into phone apps back then. The Trailer Mate was my second project using Bluetooth. That was a project that was self contained. Ran off a battery. Replaced the jack on the camper and allowed you to drive the camper around without the need of a vehicle attached.

Sweet project. Lifts the tongue up to 3,500 lbs., goes forward/reverse and left/right using your phone. Can pull a 10,000 lb. camper.

Trying to get that out on the market later this year. Had some delays because of COVID.

You used 7 fields in your application. does that mean the user can make a maximum of 7 on and off combinations? But it can also do less? Then will the blanks be left out? What do you enter in the On / OFF fields? If the inscriptions "on" and "off", isn't it better to use "switch" components that will represent on or off?
Sorry for so many questions, but they will allow me to better understand the application to apply the best solution. Maybe they can help you improve the app.

No problem Patryk I appreciate the help.

  1. Yes 1 cycle will consist of the Relay "ON/OFF" or if it makes more sense "ON" for a specified number of seconds by the user. The Unit will then for a specified "DURATION" in second the relay would be "OFF". That would be one complete cycle.
  2. They have the option of setting up a total of 7 cycles.
  3. If the "ON/OFF" cycle is Blank then that cycle and all cycle after that will not be performed.

Does that make more sense Patryk? Maybe I should change the headers to "ON" and "OFF" instead of "ON/OFF" and "DURATION" that might make more sense. What do you think?

And maybe we could post part of this as a TUTORIAL if we submit a version with or without the Bluetooth! What do you think?

I made an example of an application that allows you to add an unlimited number of ON / OFF tasks. The app will use the ListView component instead of the text boxes. You can add, delete or modify tasks. You can save / load the list. After clicking on start, ON or OFF strings are sent by BLE at a specified time.

clock (4).aia (195.7 KB)

1 Like