## 5. Example 2 with Slider

### Goal

Now we want to connect a sliding Potentiometer to the IoT Cube. Whenever the slider is moved, a value is to be transmitted via LoRaWAN. The value can be used for various scenarios, e.g. to dim a remote smart light. The value is also shown on the OLED display.

### Hardware

- Connect the display to J5 (I2C 5V)
- Connect the Sliding Potentiometer to the IoT Cube. You can use J3 (Pin P2 3.3V). Pin P2 can be used to read analog values.
- Connect the Y USB Cable to the IoT Cube
  - the plug marked red on the back of the housing (only power)
  - the other one to the micro:bit on the top of the housing (power + data)

- Connect the USB-A Connector with your computer

Be careful when connecting other sensors to J5, J6 and J7. J5 to J7 have a 5V supply voltage. 3.3V devices can be damaged. Use J3, if you are using analog sensors, like the UV- Sensor in the box.

### Software for the IoT Cube

Try to recreate this example. You will need nodes from the following categories. The colors help you to choose the right category:

Before you despair, you can also use this ready-made example: Shared Example 2

#### Explanations

In the current configuration of the IoT Cubes, transmission is only possible approx. every 6 seconds. Shorter intervals are therefore prevented with a simple timer. When moving the slider, the system first checks whether the value has changed. If so, the program attempts to send the data. However, this is only possible if the IoT Cube has joined the network and nothing has been sent in the last six seconds. Compared to the first example, the edge device acts more intelligently here. Data is only sent if something has changed. This saves energy and extends the battery life.

Intelligent edge devices in IoT (Internet of Things) are crucial components for modern smart systems. These devices have several key features that make them “intelligent” and efficient for various applications.

- Energy Efficiency: Think about when it is really necessary to send data. Every transmission costs energy.
- Data Processing Capabilities: Unlike traditional IoT devices that rely solely on cloud servers for data processing, intelligent edge devices have the capability to process data locally. This reduces latency, as data doesn't need to travel to a central server and back, and it can also operate in environments with limited or no connectivity.

### Integration on things board

Proceed in the same way as in example 1: Go to the website againClavis Cloud (ThingsBoard) and create a suitable dashboard!

## Exercise

Try to combine the two examples so that the light measurement and the potentiometer measurement are made on the same IoT cube.

Tipp: You can add more than one sensor value to the buffer and transmit them together. Like this:

If you use Channel 2 instead of Channel 1, the data key looks like the one in the Clavis Cloud (ThingsBoard):

Fabian Reifler | Copyright © 2024