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
  1. Home
  2. Hardware
  3. Wind speed sensor node

Wind speed sensor node

Scheduled Pinned Locked Moved Hardware
21 Posts 5 Posters 11.0k Views 4 Watching
  • 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.
  • JohanRCJ Offline
    JohanRCJ Offline
    JohanRC
    wrote on last edited by JohanRC
    #21

    Yesterday I found some example code on the Domoticz forum.

    With some modifications I get numbers in wind :smiley:

    As below my current sketch that sends values, I will modify it untill it is what I like and will post it here.

    #include <SPI.h>
    #include <MySensor.h>  
    
    #define CHILD_ID_WIND 20
    
    #define LED_PIN 8
    
    #define ID_WIND 170
    
    #define WIND_SENSOR_ANALOG_PIN 1
    
    MySensor gw;
    unsigned int val_wspeed;
    unsigned int val_wgust;
    unsigned int val_wdirection;
    
    
    unsigned int last_wspeed;
    unsigned int last_wgust;
    unsigned int last_wdirection;
    
    
    boolean metric = true; 
    
    unsigned long currentTime;
    unsigned long SEND_FREQUENCY = 10000;
    unsigned long lastSend;
    
    MyMessage msgWSpeed(CHILD_ID_WIND, V_WIND);
    MyMessage msgWGust(CHILD_ID_WIND, V_GUST);
    MyMessage msgWDirection(CHILD_ID_WIND, V_DIRECTION);
    
    //Setup routine
    void setup()  
    { 
      
        // Initialize library and add callback for incoming messages
      gw.begin();
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Windsensor", "0.1");
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_WIND, S_WIND);
    
      metric = gw.getConfig().isMetric;
      lastSend = 0;
    
      pinMode(LED_PIN, OUTPUT); 
      digitalWrite(LED_PIN,1);
    }
    
    //Main loop
    void loop()      
    {  
      gw.process();
     
      currentTime = millis();
      
      unsigned int val_wspeed = (analogRead(WIND_SENSOR_ANALOG_PIN))/31.605; 
      
        if(last_wspeed != val_wspeed)
        { 
           last_wspeed = val_wspeed;
           gw.send(msgWSpeed.set(val_wspeed, 1));
           Serial.print("WS: ");
           Serial.println(val_wspeed);
        }
        
        unsigned int val_wgust = (analogRead(WIND_SENSOR_ANALOG_PIN))/31.605; 
        if(last_wgust != val_wgust)
        { 
           last_wgust = val_wgust;
           gw.send(msgWGust.set(val_wgust, 1));
           Serial.print("WG: ");
           Serial.println(val_wgust);
        }
        
        unsigned int val_wdirection = (analogRead(WIND_SENSOR_ANALOG_PIN))/2.842; 
        if(last_wdirection != val_wdirection)
        { 
           last_wdirection = val_wdirection;
           gw.send(msgWDirection.set(val_wdirection, 1));
           Serial.print("WD: ");
           Serial.println(val_wdirection);
        }
    }
    

    RaspberryPi Domoticz - Serial gateway - 12 nodes and counting

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    19

    Online

    11.7k

    Users

    11.2k

    Topics

    113.1k

    Posts


    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
    • Login

    • Don't have an account? Register

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