ayatec logo
Home Store Blog Contact
unicontrol user guide by ayatec
Home Store Blog Contact

Topics

  1. Welcome
  2. Getting started
    1. What is unicontrol
    2. How it works
    3. Connectivity
    4. Integration options
    5. Default hardware
    6. Hardware extensions
    7. Special sensors
    8. RGB driver
    9. Audio driver
    10. Network API - HTTP
    11. Network API - MQTT
    12. Network security
    13. Downloads
  3. Web Interface
    1. Processes
      1. Process
      2. Name
      3. Main state
      4. Initial state
      5. Display
      6. Constraints
        1. Process timer
        2. Variable contraints
        3. Force output
      7. Input
        1. Input source
        2. Channel
        3. Control period
        4. Value
        5. Publish
        6. Frequency
        7. Subtopic
      8. Events
        1. On/Off event
        2. Condition
        3. Idle/running time
        4. Delay on/off
        5. Fade in/out
        6. High/low input
        7. Mid point/Tolerance
        8. Out on when
      9. Output
        1. Primary output
        2. Action
        3. Type
        4. Invert
        5. Duty cycle
        6. Mem value
        7. High/low output
        8. Folder/Track
        9. RGB mode
        10. RGB color
        11. RGB brightness
        12. RGB speed
        13. Publish
        14. Subtopic
        15. Secondary outputs
      10. Cycle
        1. Cycles
        2. High/Low phase
      11. On/Off button
    2. Peripheral
      1. Hardware
      2. Type
      3. Calibration
      4. Mapping (edit)
      5. IR remote (edit)
      6. Impulse_counter (edit)
      7. RGB driver (edit)
      8. DS18B20 (edit)
    3. Device
    4. Network
    5. System
    6. License
  4. Tutorials
    1. First boot
    2. First process
    3. Connect to MQTT
    4. Process sequencing

    5. DIY Project: Bath Fan

In this article

  • Introduction
advert
unicontrol > Tutorials > First process

First process

Hello world!

In the First boot tutorial, you succesfully accessed your unicontrol device through the Web Interface, which allows you to begin defining its behavior. For instance, you can start with a simple Blinky program.

Peripherals

The initial step in each application the first step is to determine the type of Hardware connected to the ESP8266 GPIO pins. In this tutotial, we will use D3 as a button input (Logical IN) and D4 as an LED output (General OUT).

The D4 pin (GPIO2) on every ESP8266 features an on-board LED, making it an excellent test output. It is connected through a pull-up resistor, causing the LED to glow when D4 is LOW and turn off otherwise. The D3 pin (except when using the NodeMCU board), needs to be connected to the GND via a push-button or a switch according to the scheme below:

Button wiring
Button wiring
You may notice that this button connection is identical to the System button. Moreover, it matches the Flash button on NodeMCU ESP8266 development boards, which means no additional wiring is necessary when using this type of board.

In the Peripheral menu, make the following selections and click Save:

  • D3: IN - Logical
  • D4: OUT - General
To gain a deeper understanding of the default setup and capabilities, you may want to see the following articles: Default hardware, Hardware extensions, and Special sensors.
Web Interface - Peripherals menu D3 and D4 peripherals re-assignment D3 and D4 peripherals re-assignment
Web Interface - Peripherals menu

Process

For this task, we only need a single process. To set it up, we can begin with the following configuration:

  • Name: my_test
  • Main state: Auto
  • Primary output: D4 (on-board LED)

To simplify testing, we'll initially exclude the input. Choose Timeout for both On event and Off event, set 15 x 1/10 Sec (1.5 seconds) for both Idle time and Running time, and click Save. This will make the on-board LED (D4) blink indefinitely at 1.5-second intervals:

Blinking the on-board LED Your browser does not support HTML video.
Blinking the on-board LED

Now that the LED is blinking consistently, we can incorporate user input. Select D3 in Input source, and the process will evaluate the button state. Choose Rising edge for the On event and Falling edge for the Off event, so that D4 turns ON when D3 is pulled HIGH and OFF when it is pulled LOW. Click Save to apply the changes:

It's important to note that both D3 and D4 have built-in, enabled pull-up resistors, affecting both the LED and the button. This may cause confusion in their behavior. As a result, when the button is pressed, D3 is pulled LOW, and when it is released, D3 is pulled HIGH. Similarly, the on-board LED glows when D4 is LOW and remains off when D4 is HIGH. So, in the current setup, pressing the button pulls D3 LOW, registering a Falling edge and turning D4 OFF, which in turn turns the LED ON. Releasing the button pulls D3 back HIGH, registering a Rising edge and turning D4 ON, which then turns the LED OFF. If needed, you can use the Invert output option to make the LED's logic more intuitive.
Adding interaction to the process Your browser does not support HTML video.
Adding interaction to the process

In this setup, the button turns the LED ON when pressed and OFF upon release. You can easily modify this behavior by selecting the Rising edge for both Events and clicking Save. Then the button will change its state and retain it on each separate button press.

If your button experiences significant contact bounce noise, consider increasing the Control period to one-tenth of a second or more. This adjustment will effectively debouce the switch, preventing unwanted triggers.
Changing the button's behavior Your browser does not support HTML video.
Changing the button's behavior

You might also notice that with Rising edge selected for both Switching events, the button responds to release rather than press-down due to the pull-up resistor connection explained earlier. To make the button responsive immediately upon pressing down, try changing both Events to Falling edge. Don't forget to click Save after making adjustments.

Changing the button's behavior Your browser does not support HTML video.
Making button respond to button press-down
© 2024 ayatec.eu • Found a mistake?  Let us know!