Navigation

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

    tsunami

    @tsunami

    0
    Reputation
    13
    Posts
    452
    Profile views
    1
    Followers
    1
    Following
    Joined Last Online

    tsunami Follow

    Best posts made by tsunami

    This user hasn't posted anything yet.

    Latest posts made by tsunami

    • RE: RFM69HW antenna

      @zboblamont thank you very much.
      I'll post my result after I done it.
      what was the best antenna you used for your project?

      posted in General Discussion
      tsunami
      tsunami
    • RE: RFM69HW antenna

      @sundberg84 thats nice, I will look into it

      posted in General Discussion
      tsunami
      tsunami
    • RE: RFM69HW antenna

      @zboblamont thank you for your reply
      how can I use box as a reflector?
      connecting GND to the box is enough?
      I'm going to design PCB but I don't know how is the schematic of the antenna connection to RFM which you have said above. do you have any schematic for this?
      0_1562487938054_00B48F41-99DD-4D82-89E8-EC0B5D0B3BD8.jpeg

      posted in General Discussion
      tsunami
      tsunami
    • RE: RFM69HW antenna

      @nagelc thank you, I need about 200m range for my project in the building.

      posted in General Discussion
      tsunami
      tsunami
    • RFM69HW antenna

      hello
      I'm going to build a gateway with RFM69HW and I want to put it in the metal box.
      but in the metal box connection will lost and I should have a SMA antenna on the outside of the box. but I could't find any PCB schematic for SMA antenna connected to the rfm69(915mhz)
      I have some questions...
      1.Should I connect GND pin to the SMA plug pins?
      2. does 915Mhz SMA Rubber antenna will increase the range of the RFM69HW?
      3.anybody know how much is the range of this board?

      and any idea for designing RFM69HW shield with SMA connector?
      thanks in advanced

      posted in General Discussion
      tsunami
      tsunami
    • RE: having trouble with water flow sensor + relay + moisture

      @mfalkvidd I've changed CHILD_ID for nodes but nothing changed and moisture data show up in DHT22's humidity!

      posted in Troubleshooting
      tsunami
      tsunami
    • having trouble with water flow sensor + relay + moisture

      Hi, I've build my own node with mqtt to send waterflow sensor and DHT22 and moisture data to Domoticz and have one Relay to control. but both relay and waterflow sketches has receive function and when I write both of them in one function, relay doesn't show up in domoticz devices or hardware(child node);
      here is my code:

      #include <DHT.h>
      #include <SPI.h>
      #define DHT_DATA_PIN 6
      #define SENSOR_TEMP_OFFSET 0
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      static const uint64_t UPDATE_INTERVAL = 5000;
      
      #define MY_RADIO_NRF24
      #define MY_RF24_PA_LEVEL RF24_PA_MAX
      #define MY_REPEATER_FEATURE
      #define MY_NODE_ID 1
      
      #include <MySensors.h>  
      
      
      #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      
      #define CHILD_ID_MOISTURE 2
      #define CHILD_ID_HUM 3
      #define CHILD_ID_TEMP 4
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgMoisture(CHILD_ID_MOISTURE, V_HUM);
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      static int sensorValue;
      int soilPin = A0;
      int soilPower = 5;
      
      
      #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
      
      #define PULSE_FACTOR 450000                       // Nummber of blinks per m3 of your meter (One rotation/liter)
      
      #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
      
      #define MAX_FLOW 30                             // Max flow (l/min) value to report. This filters outliers.
      
      #define CHILD_ID_WATER 1
      
      uint32_t SEND_FREQUENCY =
          5000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
          
      
      MyMessage flowMsg(CHILD_ID_WATER,V_FLOW);
      MyMessage volumeMsg(CHILD_ID_WATER,V_VOLUME);
      MyMessage lastCounterMsg(CHILD_ID_WATER,V_VAR1);
      
      double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter
      
      volatile uint32_t pulseCount = 0;
      volatile uint32_t lastBlink = 0;
      volatile double flow = 0;
      bool pcReceived = false;
      uint32_t oldPulseCount = 0;
      uint32_t newBlink = 0;
      double oldflow = 0;
      double volume =0;
      double oldvolume =0;
      uint32_t lastSend =0;
      uint32_t lastPulse =0;
      
      void before()
      {
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);
          // Set relay to last known state (using eeprom storage)
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void presentation()
      {
       sendSketchInfo("Smart Irrigation System", "1.0");
        present(CHILD_ID_MOISTURE, S_MOISTURE);
        present(CHILD_ID_WATER, S_WATER);
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      
        metric = getControllerConfig().isMetric;
        
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        present(sensor, S_BINARY);
        }
      
      }
      
      void setup()
      {
        pinMode(soilPower, OUTPUT);//Set D6 as an OUTPUT
        // initialize our digital pins internal pullup resistor so one pulse switches from high to low (less distortion)
        pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);
      
        pulseCount = oldPulseCount = 0;
      
        // Fetch last known pulse count value from gw
        request(CHILD_ID_WATER, V_VAR1);
      
        lastSend = lastPulse = millis();
      
        attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, FALLING);
      
         dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
        // Sleep for the time of the minimum sampling period to give the sensor time to power up
        // (otherwise, timeout errors might occure for the first reading)
        sleep(dht.getMinimumSamplingPeriod());
      }
      
      void loop()
      {
      
         // Force reading sensor, so it works also after sleep()
        dht.readSensor(true);
      
        // Get temperature from DHT library
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT!");
        } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
          // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          // Reset no updates counter
          nNoUpdatesTemp = 0;
          temperature += SENSOR_TEMP_OFFSET;
          send(msgTemp.set(temperature, 1));
      
          #ifdef MY_DEBUG
          Serial.print("T: ");
          Serial.println(temperature);
          #endif
        } else {
          // Increase no update counter if the temperature stayed the same
          nNoUpdatesTemp++;
        }
      
        // Get humidity from DHT library
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
          // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
          lastHum = humidity;
          // Reset no updates counter
          nNoUpdatesHum = 0;
          send(msgHum.set(humidity, 1));
      
          #ifdef MY_DEBUG
          Serial.print("H: ");
          Serial.println(humidity);
          #endif
        } else {
          // Increase no update counter if the humidity stayed the same
          nNoUpdatesHum++;
        }
      
        // Sleep for a while to save energy
        sleep(UPDATE_INTERVAL); 
       //......................................................
        uint32_t currentTime = millis();
      
        // Only send values at a maximum frequency or woken up from sleep
        if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY)) {
          lastSend=currentTime;
      
          if (!pcReceived) {
            //Last Pulsecount not yet received from controller, request it again
            request(CHILD_ID_WATER, V_VAR1);
            return;
          }
      
          if (!SLEEP_MODE && flow != oldflow) {
            oldflow = flow;
      
            Serial.print("l/min:");
            Serial.println(flow);
      
            // Check that we dont get unresonable large flow value.
            // could hapen when long wraps or false interrupt triggered
            if (flow<((uint32_t)MAX_FLOW)) {
              send(flowMsg.set(flow, 2));                   // Send flow value to gw
            }
          }
      
          // No Pulse count received in 2min
          if(currentTime - lastPulse > 120000) {
            flow = 0;
          }
      
          // Pulse count has changed
          if ((pulseCount != oldPulseCount)||(!SLEEP_MODE)) {
            oldPulseCount = pulseCount;
      
            Serial.print("pulsecount:");
            Serial.println(pulseCount);
      
            send(lastCounterMsg.set(pulseCount));                  // Send  pulsecount value to gw in VAR1
      
            double volume = ((double)pulseCount/((double)PULSE_FACTOR));
            if ((volume != oldvolume)||(!SLEEP_MODE)) {
              oldvolume = volume;
      
              Serial.print("volume:");
              Serial.println(volume, 3);
      
              send(volumeMsg.set(volume, 3));               // Send volume value to gw
            }
          }
        }
        if (SLEEP_MODE) {
          sleep(SEND_FREQUENCY);
        }
          soilmoisture();
      }
      
      void soilmoisture()
      {
        digitalWrite(soilPower, HIGH);
      delay(10);//wait 10 milliseconds
      sensorValue = analogRead(soilPin);
      digitalWrite(soilPower, LOW);
      sensorValue = map(sensorValue, 0, 680, 0, 100);
        send(msgMoisture.set(sensorValue));
          sleep(SEND_FREQUENCY);
      }
      
      void receive(const MyMessage &message)
      {
        if (message.type==V_VAR1) {
          uint32_t gwPulseCount=message.getULong();
          pulseCount += gwPulseCount;
          flow=oldflow=0;
          Serial.print("Received last pulse count from gw:");
          Serial.println(pulseCount);
          pcReceived = true;
        }
      
        if (message.type==V_STATUS) {
          // Change relay state
          digitalWrite(message.sensor-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          saveState(message.sensor, message.getBool());
      }
      }
      
      
      void onPulse()
      {
        if (!SLEEP_MODE) {
          uint32_t newBlink = micros();
          uint32_t interval = newBlink-lastBlink;
      
          if (interval!=0) {
            lastPulse = millis();
            if (interval<500000L) {
              // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
              return;
            }
            flow = (60000000.0 /interval) / ppl;
          }
          lastBlink = newBlink;
        }
        pulseCount++;
      }
      
      

      anyone can help me?
      and any suggestion to clean up my code?
      thanks in advanced.

      posted in Troubleshooting
      tsunami
      tsunami
    • RE: esp8266 gateway doesn't connect to mqtt broker

      @mfalkvidd said in esp8266 gateway doesn't connect to mqtt broker:

      https://forum.mysensors.org/topic/5618/domoticz-now-supports-the-mysensors-mqtt-gateway/ might be useful

      thank you I've done it and works great. but I found it if node is offline and I put switch on or off in controller it works but when node get connect to the controller it doesn't update switch state. how to fix it?

      posted in Troubleshooting
      tsunami
      tsunami
    • RE: esp8266 gateway doesn't connect to mqtt broker

      @mfalkvidd said in esp8266 gateway doesn't connect to mqtt broker:

      @tsunami see if removing

      #define MY_PORT 11262
      helps. I think this define is only meant to be used when not using MY_CONTROLLER_URL_ADDRESS (but I am not entirely sure).

      If that doesn't help, take a look at https://github.com/mysensors/MySensors/issues/926
      It seems like the ESP8266 gateway will be unable to use DNS when using static IP configuration. In my experimental branch I have added DNS support, but it is not reliable and needs more work. You could try to use an IP address instead of m21.cloudmqtt.com - not sure if it helps but it could be worth trying.

      thanks alot everything works good now and gatewat has connected to the mqtt broker. but i can't connect it to the domiticz. domoticz topics are: domoticz/in/mymqtt
      but for gateway is different and i can't change for domoticz.

      Eagle2373 created this issue in mysensors/MySensors

      open ESP8266: DNS server #926

      posted in Troubleshooting
      tsunami
      tsunami