fody weather station, wind sensor

  • Anyone heard of this before?
    For 400 SEK(~€40) you get temp, hum, wind and rain on the outdoor unit and temp, hum and pressure on the indoor unit.
    Worth its price.
    I will open up the outdoor unit and try to connect to it with an Arduino.
    Other name for this is Alecto WS-48000

  • I have now opened the outdoor unit.
    Anyone that have a code for collection data from 8 IR receivers?
    I need to find out what voltage the IR emitter is using, so I don't burn it.
    EDIT: google says 1,4-1,6 volt
    For wind it is simple to use interrupt
    Temperature and Humidity I don't know what kind of sensor it is, that one I can easily change to e.g. si7021/SHT21

    For wind direction it is using IR.
    wheel to control where IR is pointing

    For wind speed it is reed switch

    Control board

  • Hero Member

    @flopp the Ir 'emitter' is probably a led so you need a current of a few milli amps. Start low (1 kOhm in series) and find out when it starts to function.

  • @AWI
    EDIT: give it 3,3 or 5 volt, use 512 ohm works.

  • EDIT: I use digital input with pullup to see what sensor that receives the light
    So far I have a code for reading the direction and sending it to Controller.
    I will continue to add code for WindSpeed, Temp, Hum and Rain

  • It was a HT-01D sensor for measuring temp/hum. It is I2C and address is 0x28.
    I found code for HYT 221 that worked fine.

  • Mod

  • For anyone interested, I am in the process of designing a fully 3D printable weather station. The plan for the 3D printable parts will be:

    • rain gauge
    • combined wind speed and wind direction sensors
    • radiation shield that will house sensors for temp, humidity, barometric pressure and possibly a lux sensor.
    • central brain box for holding the MySensors electronics to control everything.

    I am just finishing the wind speed and direction sensor parts today. I will post pics later. I have a post in this category for the rain gauge that will be part of the station. I am designing all the parts myself. I still need to figure out a few more parts plus the MySensors electronics and code. I'll post everything as I get the different parts done.

  • This post is deleted!

  • Mod

    @flopp are you still using old library version? Are you going to make it a battery powered node or else? I noticed you didn't use any sleep in the code

  • @gohan said in fody weather station, wind sensor:

    @flopp are you still using old library version?

    Yes, this is for 1.5

    Are you going to make it a battery powered node or else?I noticed you didn't use any sleep in the code

    This is powered from a PC, not battery. I want data very often that's why it is not battery powered. I can also change the code if something is wrong.

  • had problem with very high gust, up to 30-50 m/s
    new code again

    #include <SPI.h>
    #include <MySensor.h>  
    #include <Wire.h>
    #define WIND_CHILD 0
    #define TEMP_CHILD 1
    #define HUM_CHILD 2
    #define RAIN_CHILD 3
    MySensor gw;
    MyMessage WSMsg(WIND_CHILD, V_WIND);
    MyMessage WGMsg(WIND_CHILD, V_GUST);
    MyMessage TempMsg(TEMP_CHILD, V_TEMP);
    MyMessage HumMsg(HUM_CHILD, V_HUM);
    MyMessage RainMsg(RAIN_CHILD, V_RAIN);
    MyMessage RainCounterMsg(RAIN_CHILD,V_VAR1);
    //Wind Speed
    volatile unsigned long lastPulse = 0;
    float WS = 0;
    float WG = 0;
    float WScount = 0;
    //Wind Direction
    int WDarray[8] = {45,90,135,180,225,270,315,0};
    int WD;
    float hwRainVolume = 0;   // Current rainvolume calculated in hardware.
    float bucketSize = 0.4;   // mm per tip
    boolean pcReceived = false; 
    unsigned long lastSend =0;
    // Temperature/Humidity
    double hum = 0;
    double temp = 0;
    void setup() {
      Wire.begin();   //start i2c
      gw.begin(incomingMessage, AUTO, false);
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Wind test", "170421");
      gw.present(WIND_CHILD, S_WIND);
      gw.present(TEMP_CHILD, S_TEMP);
      gw.present(HUM_CHILD, S_HUM);
      gw.present(RAIN_CHILD, S_RAIN);
      gw.request(RAIN_CHILD, V_VAR1);
      //pin 2 is rain, pin 3 is wind speed
      //pin 4-8, 14-16 is wind direction
      //configure pin 2-8 as an input and enable the internal pull-up resistor
      for (int i=2 ; i < 9 ; i++) {
        pinMode(i, INPUT_PULLUP);
      //configure pin 14-16(A0-A2) as an input and enable the internal pull-up resistor
      for (int i=14 ; i < 17 ; i++) {
        pinMode(i, INPUT_PULLUP);
      attachInterrupt(0, Rain, FALLING);    //rain
      attachInterrupt(1, WindSpeed, FALLING);   //wind speed
    void loop()
      readTempHum();    //read temperature and humidity
      readWindDirection();    //read wind direction
      resend((WSMsg.set(WS, 1)),10);
      resend((WGMsg.set(WG, 1)),10);
      WG = 0;   //reset gust
      resend((WDMsg.set(WD, 1)),10);
      resend((TempMsg.set(temp, 1)),10);
      resend((HumMsg.set(hum, 1)),10);
    void readWindDirection()
      //check in what direction the wind is. First sensor that have light will be the direction
      int i = 4;
      for (i; i < 9 ; i++){
        if (!digitalRead(i)){
          WD = WDarray[i-4];
      i = 14;
      for (i; i < 17 ; i++){
        if (!digitalRead(i)){
          WD = WDarray[i-9];
    void Rain()
      unsigned long currentTime = millis();
      if (!pcReceived && (currentTime - lastSend > 5000)) {      
        gw.request(RAIN_CHILD, V_VAR1);
        Serial.println("Request rainCount");
      if (!pcReceived) {
      hwRainVolume = hwRainVolume + bucketSize;
    void WindSpeed()
      if (WScount >= 5) {
        WScount = 0.4775 * WScount;
        unsigned long newPulse = micros();  
        unsigned long interval2 = newPulse-lastPulse;
        if (interval2<(WScount*12000L)) { // Sometimes we get wrong interrupt
        WS = (WScount/(interval2/1000000.0));
        Serial.print("Wind Speed ");
        Serial.println(" m/s");
        lastPulse = newPulse;
        if (WS > WG) {
          WG = WS;
        Serial.print("Gust ");
        Serial.println(" m/s");
        attachInterrupt(1, WindSpeed, FALLING);
    void readTempHum()
      Wire.beginTransmission(0x28);   // Begin transmission with given device on I2C bus
      Wire.requestFrom(0x28, 4);      // Request 4 bytes 
      if(Wire.available() == 4) {                   
        int b1 =;
        int b2 =;
        int b3 =;
        int b4 =;
        Wire.endTransmission();           // End transmission and release I2C bus
        // combine humidity bytes and calculate humidity
        int rawHumidity = b1 << 8 | b2;
        // compound bitwise to get 14 bit measurement first two bits
        // are status/stall bit (see intro text)
        rawHumidity =  (rawHumidity &= 0x3FFF);
        hum = 100.0 / pow(2,14) * rawHumidity;
        // combine temperature bytes and calculate temperature
        b4 = (b4 >> 2); // Mask away 2 least significant bits see HYT 221 doc
        int rawTemperature = b3 << 6 | b4;
        temp = 165.0 / pow(2,14) * rawTemperature - 40;
        //Serial.print("% - Temperature: ");
    void incomingMessage(const MyMessage &message)
      if (message.type==V_VAR1) {
        hwRainVolume = message.getFloat();
        pcReceived = true;
        Serial.print("Received last pulse count from gw: ");
    void resend(MyMessage &msg, int repeats)
      int repeat = 1;
      int repeatdelay = 0;
      boolean sendOK = false;
      while ((sendOK == false) and (repeat < repeats)) {
        if (gw.send(msg)) {
          sendOK = true;
        else {
          sendOK = false;
          Serial.print("Error ");
          repeatdelay += 500;
        repeat++; delay(repeatdelay);

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