Leeuwner Greyling
Published

Refrigerator Room Temperature

ESP32 combined with a water proof Temperature sensor. It takes a temperature reading every 10s and uploadeds it to the Arduino cloud.

IntermediateShowcase (no instructions)5 hours1,144
Refrigerator Room Temperature

Things used in this project

Story

Read more

Schematics

ESP32 temperature sensor back

Housing has large magnet on the back easily be attached to refrigerator Room walls

ESP32 in housing

App dashboard

When opening the app you can choose from all devices that are listed

In app status of sensor

This show the current temperature at the top in a gauge format as well as the temperature over the last 24h in the form of a graft

Code

Temperature sensor

C#
Uses pin 4 as signal pin from temperature sensor
#include <DallasTemperature.h>
#include <OneWire.h>
#include "thingProperties.h"
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
l
  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float tempSens2;
*/
  const int oneWireBus = 4;

// Setup a oneWire instance to communicate with any OneWire devices
  OneWire oneWire(oneWireBus);

// Pass our oneWire reference to Dallas Temperature sensor
  DallasTemperature sensors(&oneWire);

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(115200);
  // This delay gives the chance to wait for a Serial Monitor without          blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  sensors.begin();  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  // Your code here 
   delay(100);
  
    sensors.requestTemperatures();
    tempSens2 = sensors.getTempCByIndex(0);
    Serial.println(tempSens2);
    ArduinoCloud.update();
  
  delay(5000);
}

Thing project.h

C Header File
// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char DEVICE_LOGIN_NAME[]  = "a7662bc6-58a8-4416-8fa4-9edac5553e87";

const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password


float tempSens2;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.addProperty(tempSens2, READ, 3600 * SECONDS, NULL);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Credits

Leeuwner Greyling
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.