Project 2: R1BBIT + ESP32 (Wi-Fi) + Widgets

1. Configure the ESP32 Wi-Fi module (detailed instructions are available here).

    2. Use the code from Project 1 as a base.

    3. Add functionality to send variables to the cloud server.

    VAR T, H, F                 
    // Declare variables:
    // T – temperature in Celsius
    // H – humidity in percent
    // F – temperature in Fahrenheit
    
    DHT_INIT(T, H, 300)        
    // Initialize DHT temperature & humidity sensor
    // T will store temperature (°C)
    // H will store humidity (%)
    // 300 ms – sensor measurement interval
    
    DISPLAY_INIT(I2C, HD44780, 20, 2)  
    // Initialize LCD display
    // I2C – communication interface
    // HD44780 – display controller
    // 20 columns, 2 rows
    
    VARS_READ(F,H)   // Sends the values of variables F and H to the server via a Wi-Fi connection
    
    WHILE(1)                  
    // Infinite loop for continuous measurements
        F = T * 9 / 5 + 32     
        // Convert temperature from Celsius to Fahrenheit
        DISPLAY_TEXT(0, 0, "Temp: ", F.0, "F", Font_7x10, 1, 0x0000)  
        // Display temperature on row 0 of the LCD
    
        DISPLAY_TEXT(0, 1, "Hum : ", H.0, "%", Font_7x10, 1, 0x0000)  
        // Display humidity on row 1 of the LCD
    
        PAUSE 1000             
        // Wait 1000 ms (1 second) before the next measurement
    WEND                      
    // End of infinite loop

    Upload and run the program on the device.

    Open the mobile app on your phone and go to the Widgets tab.

    Add widgets to the dashboard: 2× Label and 1× Graph.

    Label widgets can dynamically change text color based on user-defined value ranges, while the Graph widget visualizes data in real time.

    TemperatureMeaningHEX ColorRGB
    32–50°FCold / Freezing#1E90FF🔵 Blue — cold
    50–68°FCool#00BFFF🔷 Light Blue — cool
    68–86°FMild / Comfortable#3CB371🟢 Green — comfortable
    86–104°FWarm#FFD700🟡 Yellow — warm
    104–122°FHot#FF8C00🟠 Orange — hot
    122–140°FVery Hot / Danger#DC143C🔴 Red — dangerously hot

    We can also add the Lamp widget, which can change its color depending on defined conditions and values.