• Hello first time user here, I have been trying to build a 4in1 light, motion, tem/hum using a nano, temt6000, dht22, and sr501 using the examples and already made sketches i can combine everything, but i am not sure if i am entering the info for the temt6000 correctly. Can someone take a look please```
    Insert Code Here

    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_MOTION 2
    #define CHILD_ID_LIGHT 3
    int lastLightLevel;
    #define DIGITAL_INPUT_SENSOR 2   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = false; 
    unsigned long interval= 3000;//dht.getMinimumSamplingPeriod(); // the time we need to wait
    unsigned long previousMillis=0; // millis() returns an unsigned long.
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgMot(CHILD_ID_MOTION, V_TRIPPED);
    uint16_t lastlux;
    void setup()  
     // metric = getConfig().isMetric;
     pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    void presentation()  
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("4-1 Sensor", "1.0");
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_MOTION, V_TRIPPED);
    void loop()      
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    // only run loop if time has passed. 
    unsigned long currentMillis = millis(); // grab current time       
     // check if "interval" time has passed
     if ((unsigned long)(currentMillis - previousMillis) >= interval) {
          #ifdef MY_DEBUG
           Serial.print("Motion: ");
      // Fetch temperatures from DHT sensor
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        if (!metric) {
          temperature = dht.toFahrenheit(temperature);
        send(msgTemp.set(temperature, 1));
        #ifdef MY_DEBUG
        Serial.print("T: ");
      // Fetch humidity from DHT sensor
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          send(msgHum.set(humidity, 1));
          #ifdef MY_DEBUG
          Serial.print("H: ");
     // Read lux from TEMT6000
      float lightLevel = analogRead(LIGHT_SENSOR_ANALOG_PIN) *  9.;  // 1000/1024
      if (int(lightLevel - lastLightLevel) > 10 || int(lastLightLevel - lightLevel) > 10) {
          lastLightLevel = lightLevel;
       // save the "current" time
       previousMillis = millis();
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      //sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);


  • @stress-nero do the v light levels values look good or am i missing something?

  • Mod

    Original post moved to https://forum.mysensors.org/topic/7150/temt6000/
    Locking this topic to avoid confusion and double work.

Log in to reply

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.