Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
E

emme

@emme
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Noob problem with NodeMCU and OneWire
    E emme

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

    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

    Troubleshooting
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular