• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Display different Roomtemperature on MagicMirror

Scheduled Pinned Locked Moved General Discussion
31 Posts 4 Posters 9.0k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    wishmaster270 Module Developer @Xilef
    last edited by wishmaster270 Nov 26, 2022, 9:28 PM Nov 26, 2022, 9:26 PM

    @Xilef
    ESP8266 is a good choice. I prefer ESP32 cause it has more power but does not need that much more energy. You have a lot more GPIOs with a ESP32 than a with the ESP8266.

    I can provide you a ESP32 sketch which is ready to flash and only needs the Wifi-SSID, Wifi-Password and the MQTT parameters configured.
    I use the Arduino IDE to flash the boards.

    X 1 Reply Last reply Nov 26, 2022, 10:41 PM Reply Quote 0
    • X Offline
      Xilef @wishmaster270
      last edited by Nov 26, 2022, 10:41 PM

      @wishmaster270 thanks

      As I understand it, something like this is my target:
      a6d84a5f-2102-41ac-9e30-c5d3bfc07b02-grafik.png

      And i would need:

      • ESP32
      • DHT11-Sensor Problem with this Sensor is the accuracy i think, but if it works I can swap them out I guess
      • BreadBoard

      And as Powersupply something with 5V and 1-1,5A right?

      I would probably do it like this guy on youtube https://www.youtube.com/watch?v=ebJpXs2-WgM&list=PLUwa0e4GQGhS6KCSbLAQGog4_Z7eIWOm3&index=3

      And from the ESP32-Website the MagicMirror should be able to read the data and display it

      W 1 Reply Last reply Nov 26, 2022, 10:46 PM Reply Quote 0
      • W Offline
        wishmaster270 Module Developer @Xilef
        last edited by wishmaster270 Nov 26, 2022, 10:51 PM Nov 26, 2022, 10:46 PM

        @Xilef
        You need a ESP32 ( I use a D1 Mini but nearly everyone should be fine)
        You need a Temperature and Humidity Sensor (BME280 and HTU21 are a lot more accurate and use I2c to communicate with the controller.
        A Power supply with 5V 1A should be more than enough.

        That’s how I display my values…
        Screenshot_20221126_234807_bVNC Pro.jpg

        The first three are ESP32 the others my thermostats.

        J X 2 Replies Last reply Nov 27, 2022, 8:16 AM Reply Quote 0
        • J Offline
          JerryP @wishmaster270
          last edited by Nov 27, 2022, 8:16 AM

          @wishmaster270

          nice…

          1 Reply Last reply Reply Quote 0
          • X Offline
            Xilef @wishmaster270
            last edited by Nov 27, 2022, 9:21 AM

            @wishmaster270 Thats exactly what i had in mind

            The BME280 sensors on amazon are a litte expensive so Im think Im order 3 form this shop They have 5 Pins but I think this will work to, on Aliexpress its even cheaper but i have no experience with the shop, and 1-3€ difference is ok i guess

            And I wanted to ask what power supply you use e.g. just a cell phone charger?
            I think im gona go with this one and hope that it doesnt explode

            So if I have everything right this is my shopping list:
            ESP32
            BME280
            Power Supply
            BreadBoard

            And then I just have to figure out the programming

            X W 2 Replies Last reply Nov 27, 2022, 10:25 AM Reply Quote 0
            • X Offline
              Xilef @Xilef
              last edited by Nov 27, 2022, 10:25 AM

              Edit: With Power Supply i mean this one: https://www.amazon.de/gp/product/B08LMFBV55/ref=ox_sc_act_title_2?smid=A1XVC08L2WVJCV&psc=1

              1 Reply Last reply Reply Quote 0
              • W Offline
                wishmaster270 Module Developer @Xilef
                last edited by Nov 27, 2022, 10:36 AM

                @Xilef Hi, the list sounds good. I use old mobile chargers to power the boards. I have heard that some had problems with mobile chargers but I had no problems for years now.

                1 Reply Last reply Reply Quote 0
                • X Offline
                  Xilef
                  last edited by Dec 1, 2022, 5:57 PM

                  Hey im back @wishmaster270

                  my parts arrived, and after 5 hours of Troubleshooting i was able to achieve this: (with the help of this tutorial)
                  70a039b8-932a-412c-8365-5ccfd77ccd60-image.png

                  Now i need just a little bit help to display the Temperature and Humidity on my mirror

                  W 1 Reply Last reply Dec 1, 2022, 6:27 PM Reply Quote 0
                  • W Offline
                    wishmaster270 Module Developer @Xilef
                    last edited by wishmaster270 Dec 1, 2022, 6:43 PM Dec 1, 2022, 6:27 PM

                    @Xilef
                    Hi,
                    thats great news.
                    The screenshot shows that you setup the ESP32 and the sensor correctly.
                    The main problem is that the ESP now displays a webpage.
                    There are two possible ways now. Either you embed the webpage (as it is) into the mirror with a module like MMM-EmbedURL or to get the ESP to display the data machine readable.
                    Maybe the sketch you flashed to the ESP already contains a way to read the data in a different format? Which one did you use?

                    Edit: I think it is this one, am i right? Then there is no easy way.
                    I think i can provide a sketch that is more “mirror friendly” but you will need to set a static IP for the ESP. Is this ok for you?

                    You will need to change to your needs:

                    • ##ADD_WIFI_SSID_HERE
                    • ##ADD_WIFI_PASSWORD_HERE
                    • IPAddress local_IP(192, 168, 0, 2);
                    • IPAddress gateway(192, 168, 0, 1);
                    • IPAddress subnet(255, 255, 255, 0);
                    • IPAddress primaryDNS(192, 168, 0, 1);
                    #include <WiFi.h>
                    #include <Wire.h>
                    #include <Adafruit_Sensor.h>
                    #include <Adafruit_BME280.h>
                    
                    const char* ssid     = "##ADD_WIFI_SSID_HERE";
                    const char* password = "##ADD_WIFI_PASSWORD_HERE";
                    
                    //ENTER STATIC IP OF THE ESP32 BOARD HERE
                    IPAddress local_IP(192, 168, 0, 2);
                    IPAddress gateway(192, 168, 0, 1);
                    IPAddress subnet(255, 255, 255, 0);
                    IPAddress primaryDNS(192, 168, 0, 1);
                    IPAddress secondaryDNS(8, 8, 8, 8);
                    
                    Adafruit_BME280 bme;
                    
                    WiFiServer server(80);
                    
                    void setup()
                    {
                      Wire.begin();
                      Serial.begin(115200);
                    
                      if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
                        Serial.println("STA Failed to configure");
                      }
                    
                      Serial.print("Connecting to ");
                      Serial.println(ssid);
                    
                      WiFi.begin(ssid, password);
                    
                      while (WiFi.status() != WL_CONNECTED) {
                        delay(500);
                        Serial.print(".");
                      }
                    
                      Serial.println("");
                      Serial.println("WiFi connected!");
                      Serial.print("IP address: ");
                      Serial.println(WiFi.localIP());
                      Serial.print("ESP Mac Address: ");
                      Serial.println(WiFi.macAddress());
                      Serial.print("Subnet Mask: ");
                      Serial.println(WiFi.subnetMask());
                      Serial.print("Gateway IP: ");
                      Serial.println(WiFi.gatewayIP());
                      Serial.print("DNS: ");
                      Serial.println(WiFi.dnsIP());
                    
                      if (!bme.begin(0x76);) {
                        Serial.println("Couldn't find sensor!");
                        while (1);
                      }
                    
                      server.begin();
                    }
                    
                    void loop()
                    {
                      float temp = bme.readTemperature();
                      float tempf = temp * 1.8 + 32;
                      float rel_hum = bme.readHumidity();
                    
                      WiFiClient client = server.available();
                      if (client) {
                        Serial.println("New Client."); 
                        client.println("{");
                        client.print("  \"temperature_c\": ");
                        client.print(temp);
                        client.println(",");
                        client.print("  \"temperature_f\": ");
                        client.print(tempf);
                        client.println(",");
                        client.print("  \"humidity\": ");
                        client.print(rel_hum);
                        client.println(",");
                        client.println("  \"error\": false");
                        client.println("}");
                        client.stop();
                        Serial.println("Client disconnected.");
                        Serial.println("");
                      }
                      delay(100);
                    }
                    

                    You can use netcat to fetch the data:

                    /bin/nc -w3 THE_IP_OF_THE_ESP 80
                    

                    And the result will be something like:

                    {
                       "humidity": 32.61236572265625,
                       "temperature_c": 25.50150878906249, 
                       "temperature_f": 77.9027158203125, 
                       "error": false
                    }
                    

                    This kind of JSON object then can be read by my MMM-Temperature module.

                    S X 2 Replies Last reply Dec 1, 2022, 6:43 PM Reply Quote 1
                    • S Away
                      sdetweil @wishmaster270
                      last edited by sdetweil Dec 1, 2022, 6:45 PM Dec 1, 2022, 6:43 PM

                      @wishmaster270 I created a sketch for my 8266, which is a json get. returns current temp and humidity.

                      then I just fetch it when I want, similar to what u did

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      W 1 Reply Last reply Dec 1, 2022, 6:45 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 2 / 4
                      2 / 4
                      • First post
                        12/31
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy