Triggering a scheduling for a device depending on a state of a GPIO pin

Hello world… I am currently building a small microgreen indoor greenhouse that will be automated with a Raspberry Pi 3. Microgreens consist of seeds germinating for 3 - 5 days then they are exposed to light for 5 to 8 days to be ready for harvesting. The Raspberry Pi is hooked up to a 5" HDMI Touch Screen. The microgreen indoor greenhouse consist of a 5 shelves unit where the top 4 shelves have individual solenoid valves to control the watering portion of the microgreens and also have LED Lights. The bottom shelf is for seeds germination that requires no lighting but requires watering by hand for the first 3 - 5 days. Seeds germination vary in time depending on what type of seeds they are. The touchscreen would have different icons depending on what seeds you are growing. What I would like to accomplish is that at a press of a button (physical or icon on touchscreen to change a GPIO pin State), a text message would inform me to move the germinating trays on the shelf above to be exposed to lights in the timely manner depending on the type of seeds they are(some seeds takes 3 days, some take 5 days…).

Also, I would like to trigger the schedule for watering when the trays are moved on the shelves above. The Cayenne community have asked for a timed event feature for a couple years now but it is still not available. What I am trying to accomplish is to trigger a scheduling via a GPIO State. I am aware of Cayenne Scheduling feature, but is it possible to turn on and off a scheduling for a device depending on a state of a GPIO pin? In other words, I would like to be able to start the watering schedule only when I change the state of a GPIO pin via an icon of physical switch on my greenhouse so that the watering doesn’t start on a shelf if they are not trays on it to accept the water…

Thanks for your help and ideas.

1 Like

First of all, you have got a great setup and a project over there.

you can control the GPIO state (ON/OFF) using cayenne button widget on the dashboard.

For this, what I can suggest is that you manually set the schedule for 3 or 5 days for a button widget depending on seed type. then add a notification trigger for this button when the state is changed.

same here, use another button widget to make the watering system true or false.

Thanks for your reply shramik_salgaonkar, however, I don’t think you understand what I am trying to accomplish. The Schedule option in Cayenne cannot be use as a timer as it is only for repeat events from a start date on either a daily, weekly, monthly or yearly basis. Let’s say for instance that I am planting seeds on Wednesday this week, how can I setup Cayenne to trigger an event on the forth day after germination? Same thing for the watering portion of my project, each shelf have a separate water solenoid valve that needs to run for say 6 days depending on the seeds used… How can I setup a button to turn on or off a schedule for a particular water solenoid valve??? Please explain what you mean by “use another button widget to make the watering system true or false.”

Right now, when I setup a water solenoid valve with schedules to turn it on and off at specific times during the night, it will fire as soon as I click on the icon for it, so, how can I create a button to only activate the schedule and not the device itself?



which event do you want to trigger here? is it an SMS notification you want to receive, informing you that you need to change the seed. you can try this:

  • Add a button widget to your dashboard.

  • Add an SMS notification to this button when it becomes ON.

  • Add a schedule to this button to turn ON the button on the 4th day.

so you have a button that is scheduled to turn ON/OFF the solenoid. say button **solenoid **. now add another button start.
in your code add this:

if (solenoid == 1 and start == 1):
  print("start motor")

so the solenoid will only work when both buttons are ON wherein the start button acts as a control to the solenoid button.

Thanks shramik_salgaonkar, so if I understand correctly, I have to incorporate some python coding into Cayenne for it to work… This is all new to me and doesn’t know much about coding. Could you be more specific on how to do this?

to start with add a new device to cayenne using GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API and add a custom button widget to control the solenoid.