Skip to main content

12 posts tagged with "tibbit_03_1"

View All Tags

Sprinkler Control 5: Web Dashboard

In this next iteration of the Sprinkler Control project, the ability to monitor the state of and control the sprinkler relay remotely is added. This is done through the dashboard, a page of your device's web interface that can host widgets. The dashboard is configured on the General subpage of the Web Dashboard page of the Features tab. Open this page to see the widget this project uses:

sprinkler_widgets

The widget is of the Switch type. The switch is "connected" to the manual_override variable:

sprinkler_dashboard_variable

This "connection" is bi-directional:

  • If you push the "ON" or "OFF" button on the TPS, the dashboard switch will reflect the current manual_override state.
  • If you flip the switch on the dashboard, the manual_override variable will be updated.
sprinkler_control_5

To react to the dashboard switch flips, an On Variable Changed event block has been added to the application. This event triggers when the corresponding variable value changes.

The On Variable Changed block was first introduced in the Settings project.

This, and many other projects, takes advantage of the LUIS interface. The application makes two settings -- Ethernet DHCP and Ethernet IP -- accessible from the LUIS smartphone app.

Sprinkler Control 6: Multiple Zones

In the final version of the Sprinkler Control project, we go multi-zone. The application only controls two relays (to save the slot space inside your TPS), but you can easily extend it to individually control many more watering zones.

The first step in adding the multi-zone support was to add the sprinkler_num field to the sprinkler_schedule table. Notice how the field's Minimum and Maximum properties come in handy here: the minimum sprinkler number is 1, and the maximum is 2:

sprinkler_table_config_2

The second step was adding the For-Next Loop block to the diagram. This is the first project where we do "loops." Click on the For-Next Loop block to open its properties. As you can see, the block iterates from 0 to 1 (inclusive). The block runs twice, first, with the value of 0, and second, with the value of 1.

sprinkler_for

When a block chain is connected to the Iterate output of the For-Next Loop block, this entire chain runs once for each for-next loop. This means the application will perform the Table Lookup and everything behind it twice.

sprinkler_table_lookup

Record Offsets

Now it is time to look inside the Table Lookup block. The element interesting to us right now is the Record Offset property. The current_iteration parameter of the For-Next Block is there. The Table Lookup will first run with the Record Offset of zero and then with the Record Offset of one.

When at zero, the Record Offset instructs the Table Lookup block to search from the beginning of the table and find the first data table record matching the search criteria. Setting the Record Offset to one will make the Table Lookup block search for the second record matching the search criteria.

If you fix the record offset at zero, this application won't work correctly when both sprinkler relays are to be activated simultaneously. The following example illustrates why. Let's say that you have this watering schedule:

sprinkler_numwatering_timeduration
108:00 AM300
208:30 AM300
106:00 PM600
206:00 PM600

At 08:00 AM, the first record will be fetched. At 08:30 AM, the second record will be fetched. Now, what will happen at 06:00 PM? At the first for-next loop iteration, the third record will be fetched. When the loop runs for the second time, the same third record will be fetched again -- that is, if the Record Offset parameter is always at 0. If this parameter is set to match current_iteration, then the first matching record (the third record) will be ignored, and the second matching record (the fourth record) will be found!

This, and many other projects, takes advantage of the LUIS interface. The application makes two settings -- Ethernet DHCP and Ethernet IP -- accessible from the LUIS smartphone app.

Monitoring the Sprinkler Relay State

On the AppBlocks Demo Kit (ADK), the first "sprinkler" relay is connected to the green LED marked "RL1." The second "sprinkler" relay is connected to the red LED "RL2." Either LED is on when the corresponding relay is on.