Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. emme
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    emme

    @emme

    1
    Reputation
    3
    Posts
    297
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    emme Follow

    Best posts made by emme

    • RE: Noob problem with NodeMCU and OneWire

      still unsolved, but workaround by replacing the onewire with a DHT22 😛 😛

      this is my sketch:

      // Gateway MySensors on NodeMCU with some Devices 
      // OneWire for DS18B20 
      // Bounce for S_DOOR (Rain Sensor)
      #define MY_DEBUG
      #define MY_BAUD_RATE 115200
      #define MY_RADIO_NRF24
      
      // #define MY_GATEWAY_SERIAL
      #define MY_GATEWAY_ESP8266
      #define MY_ESP8266_SSID "myWiFi"
      #define MY_ESP8266_PASSWORD "******"
      #define MY_ESP8266_HOSTNAME "sensor-gateway"
      #define MY_PORT 5003
      #define MY_GATEWAY_MAX_CLIENTS 3
      #include <ESP8266WiFi.h>
      
      #define MY_INCLUSION_MODE_FEATURE
      
      #include <MySensors.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
      #define ONE_WIRE_BUS D1 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 5
      
      unsigned long temp_Sleep = 30000; // Sleep time between reads (in milliseconds)
      unsigned long temp_nTime;
      
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      bool receivedConfig = false;
      bool metric = true;
      // Initialize temperature message
      MyMessage msgTemp(0,V_TEMP);
      
      #include <Bounce2.h>
      // RAIN Sensor Definitions and settings
      #define CHILD_ID 10
      #define BUTTON_PIN D4  // Arduino Digital I/O pin for button/reed switch
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      MyMessage msgRain(CHILD_ID,V_TRIPPED);
      
      unsigned long cTime;  // Current Time
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()  
      { 
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      
        pinMode(BUTTON_PIN,INPUT);
        digitalWrite(BUTTON_PIN,HIGH);
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.1");
      
        // Fetch the number of attached temperature sensors  
        numSensors = sensors.getDeviceCount();
      
        // Present all sensors to controller
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
           present(i, S_TEMP);
        }
        
        present(CHILD_ID, S_DOOR);  
      }
      
      void loop()     
      {
        cTime = millis();  // Get current Timing
      
        if ((cTime - temp_nTime) >= temp_Sleep) {     // this is supposed to replace the sleep function 
          sensors.requestTemperatures();
          for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
            float temperature = static_cast<float>(static_cast<int>(sensors.getTempCByIndex(i)));
            #if COMPARE_TEMP == 1
            if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
            #else
            if (temperature != -127.00 && temperature != 85.00) {
            #endif
              send(msgTemp.setSensor(i).set(temperature,1));
              lastTemperature[i]=temperature;
            }
          }
          temp_nTime = millis();
        }
        
        debouncer.update();
        int value = debouncer.read();
        if (value != oldValue) {
           // Send in the new value
           send(msgRain.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
        
      }
      

      if I enter a

      Serial.print("Sensors Count over 1W bus: ");
      Serial.println(sensors.getDeviceCount()); 
      

      I got 0 😞

      wirings are ok... I checked with the tester and I get correct voltage (3,3) and impedence (4,7k)
      DHT works fine at first try on the same PIN

      thanks for the help
      ciao
      Marco

      posted in Troubleshooting
      emme
      emme

    Latest posts made by emme

    • RE: Noob problem with NodeMCU and OneWire

      still unsolved, but workaround by replacing the onewire with a DHT22 😛 😛

      this is my sketch:

      // Gateway MySensors on NodeMCU with some Devices 
      // OneWire for DS18B20 
      // Bounce for S_DOOR (Rain Sensor)
      #define MY_DEBUG
      #define MY_BAUD_RATE 115200
      #define MY_RADIO_NRF24
      
      // #define MY_GATEWAY_SERIAL
      #define MY_GATEWAY_ESP8266
      #define MY_ESP8266_SSID "myWiFi"
      #define MY_ESP8266_PASSWORD "******"
      #define MY_ESP8266_HOSTNAME "sensor-gateway"
      #define MY_PORT 5003
      #define MY_GATEWAY_MAX_CLIENTS 3
      #include <ESP8266WiFi.h>
      
      #define MY_INCLUSION_MODE_FEATURE
      
      #include <MySensors.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
      #define ONE_WIRE_BUS D1 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 5
      
      unsigned long temp_Sleep = 30000; // Sleep time between reads (in milliseconds)
      unsigned long temp_nTime;
      
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      bool receivedConfig = false;
      bool metric = true;
      // Initialize temperature message
      MyMessage msgTemp(0,V_TEMP);
      
      #include <Bounce2.h>
      // RAIN Sensor Definitions and settings
      #define CHILD_ID 10
      #define BUTTON_PIN D4  // Arduino Digital I/O pin for button/reed switch
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      MyMessage msgRain(CHILD_ID,V_TRIPPED);
      
      unsigned long cTime;  // Current Time
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()  
      { 
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      
        pinMode(BUTTON_PIN,INPUT);
        digitalWrite(BUTTON_PIN,HIGH);
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.1");
      
        // Fetch the number of attached temperature sensors  
        numSensors = sensors.getDeviceCount();
      
        // Present all sensors to controller
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
           present(i, S_TEMP);
        }
        
        present(CHILD_ID, S_DOOR);  
      }
      
      void loop()     
      {
        cTime = millis();  // Get current Timing
      
        if ((cTime - temp_nTime) >= temp_Sleep) {     // this is supposed to replace the sleep function 
          sensors.requestTemperatures();
          for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
            float temperature = static_cast<float>(static_cast<int>(sensors.getTempCByIndex(i)));
            #if COMPARE_TEMP == 1
            if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
            #else
            if (temperature != -127.00 && temperature != 85.00) {
            #endif
              send(msgTemp.setSensor(i).set(temperature,1));
              lastTemperature[i]=temperature;
            }
          }
          temp_nTime = millis();
        }
        
        debouncer.update();
        int value = debouncer.read();
        if (value != oldValue) {
           // Send in the new value
           send(msgRain.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
        
      }
      

      if I enter a

      Serial.print("Sensors Count over 1W bus: ");
      Serial.println(sensors.getDeviceCount()); 
      

      I got 0 😞

      wirings are ok... I checked with the tester and I get correct voltage (3,3) and impedence (4,7k)
      DHT works fine at first try on the same PIN

      thanks for the help
      ciao
      Marco

      posted in Troubleshooting
      emme
      emme
    • re-request presentation

      Hi..
      I'm developing my new sensors, and sometimes I would need to reload and check from the MySensor app if everyhing is fine...

      I'm looking for a code that would allow me to:

      • Re-present the slave node upon request
      • Eventually reboot the node upon request.

      I'm not a real coder, so far I have just copied and cut/adopt other users code... but I did not find how to do those 2 operation.
      thanks
      ciao
      M

      posted in Troubleshooting
      emme
      emme
    • Noob problem with NodeMCU and OneWire

      Ciao to all,
      I'm moving to MySensors network in my home to be used with Domoticz... after a first phase made by a gateway on a raspberry PI2, a rain (on/off), I'm now approaching to reorganize the entire network and move to a nodeMCU (12e) gateway which include the rain sensor and I would like to add a DS18B20 too (to gather external temp)
      While the gateway and the on/off switch works pretty fine, I'm having a bad problem with OneWire: even if the sketch is compiled with no error, I see no device, nr presented, nor updated, no device at all

      Wirings are ok: using D1 pin (no luck with other pins), with a 4k7 resistor... 3.3v are provided from an external 5v (2A) power supply and a AMS1117 3.3
      I checked the same sketch on a ATMega328p nano and it works... seems to be a NodeMCU device issue
      does anyone experienced the same?
      Is there a solution for this (which does not include to move to DHT22 😛 😛 )
      thanks
      ciao
      M

      posted in Troubleshooting
      emme
      emme