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
Bert RamselaarB

Bert Ramselaar

@Bert Ramselaar
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • MyWindSensor
    Bert RamselaarB Bert Ramselaar

    Made een Windsensor for MySensors, Works well!
    used an adafruit https://www.adafruit.com/product/1733 windmeter.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * versie 1.1 bert ramselaar  
     * Used an UNO with a NRF24+ with external antenna
     *
     * DESCRIPTION
     * Arduino Wind Sensor
     * Adafruit Anemometer Wind Speed Sensor -> https://www.adafruit.com/product/1733
     * connect the sensor as follows :
     *   VCC  (brown)      >>> 5V
     *   A    (blue)      >>> A0 or any other analog pin
     *   GND  (black)      >>> GND
     *
    
     *
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <MySensors.h>
    
    #define CHILD_ID_WIND 0
    #define WIND_SENSOR_ANALOG_PIN 0
    
    unsigned long SLEEP_TIME = 2000; // Sleep time between reads (in milliseconds)
    
    // VARIABLES
    float W_Raw_A0 = 0; // stores the RAW value coming from the sensor 0 to 1023
    float W_Volt = 0; // stores voltage calculated form A0
    float W_WindSpeed = 0; // Windspeed in meters per second (m/s)
    float W_WindSpeed_last = 0; // previus Windspeed sended
    float W_Voltage_Conversion = .004882814; //This constant maps the value provided from the analog read function, which ranges from 0 to 1023, to actual voltage, which ranges from 0V to 5V
    float W_voltageMin = .4; // Mininum output voltage from anemometer in mV.
    float W_voltageMax = 2.0; // Maximum output voltage from anemometer in mV.
    float W_windSpeedMin = 0; // Wind speed in meters/sec corresponding to minimum voltage
    float W_windSpeedMax = 32; // Wind speed in meters/sec corresponding to maximum voltage
    int W_beaufort = 0; // Calculated beaufort scale
    
    MyMessage windMsg(CHILD_ID_WIND, V_WIND);
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Wind Sensor", "1.1");
    
      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID_WIND, S_WIND);
    }
    
    void loop()
    {
      W_Raw_A0 = analogRead(WIND_SENSOR_ANALOG_PIN); // Get WIND value from A0
      W_Volt = W_Raw_A0 * W_Voltage_Conversion; //Convert sensor value to actual voltage
    
    //Convert voltage value to wind speed using range of max and min voltages and wind speed for the anemometer
    if (W_Volt <= W_voltageMin)
    {
     W_WindSpeed = 0; //Check if voltage is below minimum value. If so, set wind speed to zero.
    }
    else 
    {
      // calculate winspeed in Meters per Second 
      W_WindSpeed = (W_Volt - W_voltageMin) * W_windSpeedMax / (W_voltageMax - W_voltageMin); //For voltages above minimum value, use the linear relationship to calculate wind speed.
      // corrected // ~~W_WindSpeed = W_WindSpeed * 3.6 // convert from m/s to km/h~~
    }
    
      Serial.print("Raw Signal Value (0-1023): ");
      Serial.print(W_Raw_A0);
    
      Serial.print(" - Voltage: ");
      Serial.print(W_Volt);
    
      Serial.print(" - Windspeed M/S: ");
      Serial.print(W_WindSpeed); // unit: M/S
    
      Serial.print(" - Beaufort: ");
      Serial.println(beaufort()); // unit: beaufort scale
    
      if (ceil(W_WindSpeed) != W_WindSpeed_last) 
      {
    **/// CHANGED convert float to de nearest integer and converted (W_WindSpeed * 3.6) to km/h ///**
    send(windMsg.set((int16_t)ceil(W_WindSpeed * 3.6))); 
     W_WindSpeed_last = ceil(W_WindSpeed);
    
        //beaufort(); // option windspeed in beafort
        //send(windMsg.set(W_beaufort)); // option windspeed in beafort
      }
    
      sleep(SLEEP_TIME);
    }
    
    int beaufort(void)
    { 
        if (W_WindSpeed < 0.39)
        {
        W_beaufort = 0;
        return W_beaufort;
        } 
        else if (W_WindSpeed >= 0.3 & W_WindSpeed <= 1.5)
        {
        W_beaufort = 1;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 1.6 & W_WindSpeed <= 3.3)
        {
        W_beaufort = 2;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 3.4 & W_WindSpeed <= 5.4)
        {
        W_beaufort = 3;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 5.5 & W_WindSpeed <= 7.9)
        {
        W_beaufort = 4;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 8.0 & W_WindSpeed <= 10.7)
        {
        W_beaufort = 5;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 10.8 & W_WindSpeed <= 13.8)
        {
        W_beaufort = 6;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 13.9 & W_WindSpeed <= 17.1)
        {
        W_beaufort = 7;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 17.2 & W_WindSpeed <= 20.7)
        {
        W_beaufort = 8;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 20.8 & W_WindSpeed <= 24.4)
        {
        W_beaufort = 9;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 24.5 & W_WindSpeed <= 28.4)
        {
        W_beaufort = 10;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 28.5 & W_WindSpeed <= 32.6)
        {
        W_beaufort = 11;
        return W_beaufort;
        }
        else if (W_WindSpeed >= 32.7)
        {
        W_beaufort = 12;
        return W_beaufort;
        }
     }
    
    My Project

  • [SOLVED] Hi scalz: How did jou define the NRF24+ in the sketch for de arduino zero. can't get it working.
    Bert RamselaarB Bert Ramselaar

    Just minutes ago i got it working on the ZERO/M0

    MO, MI and SCK connect to the ICSP pin header: https://www.arduino.cc/en/uploads/Reference/ICSPHeader.jpg

    the CE and CS on defined pins example:
    #define MY_RF24_CE_PIN 9 // specific for my arduino zero
    #define MY_RF24_CS_PIN 10 // specific for my arduino zero

    Thanks

    Hardware
  • Login

  • Don't have an account? Register

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