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
vgaV

vga

@vga
About
Posts
50
Topics
11
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • WaterPulseMeter: onPulse gets called on rising AND falling !?
    vgaV vga

    thanks mfalkvidd and since!

    now i´ve added the following to the onPulse function:

    delay(150);
      if(digitalRead(DIGITAL_INPUT_SENSOR) == HIGH){
        Serial.println("onPulse called");
        pulseCount++; 
      }
    

    now it is working, thanks for the support to all of you! :)

    btw: is there a way to reset the volume value, without running the cleareeprom sketch, so that i can keep the sensors node id!? :)

    Troubleshooting

  • WaterPulseMeter: onPulse gets called on rising AND falling !?
    vgaV vga

    I connected the sensor to D3 pin.

    Troubleshooting

  • WaterPulseMeter: onPulse gets called on rising AND falling !?
    vgaV vga

    thx sundberg84 for your fast response.

    meanwhile i added Serial.println("onPulse called"); before pulseCount++ in onPulse-function.
    The Serial Monitor confirms, the above problem.

    I turn on the water tap, till the position of my water counter wheel is exactly in position to trigger the RISING interrupt of the sensor, then i close the water tap. So the signal is constantly high. the serialmonitor prints, onPulse called, everything seems ok. after a while (seconds or minutes, tried both) i turn on the water tap again, till the position of the water counter wheel lets FALLING the signal from sensor, and turn of the water tap again. So signal is constantly low. In this moment the monitor prints also "onPulse called".

    Due to the described behavior I do not think it is up to the interval time, or?

    Troubleshooting

  • WaterPulseMeter: onPulse gets called on rising AND falling !?
    vgaV vga

    Hi,
    I build up a WaterPulseMeterSensor as the original MySensors example:
    Controller:Arduino nano
    Sensor: TCRT5000 IR Barrier Line Track sensor
    Powered with USB-powersupply.
    Sketch: Original Sensor example sketch - only changed the Interrupt mode from "FALLING" to RISING", as you can see below.

    
    #define MY_DEBUG                              
    #define MY_RADIO_NRF24                          
    #define MY_RF24_PA_LEVEL RF24_PA_MAX          
    #define MY_PARENT_NODE_ID 0                     
    #define MY_PARENT_NODE_IS_STATIC                
    
    #include <SPI.h>
    #include <MySensors.h>  
    
    #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
    
    #define PULSE_FACTOR 1000                       // 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 40                             // Max flow (l/min) value to report. This filters outliers.
    
    #define CHILD_ID 1                              // Id of the sensor child
    
    unsigned long SEND_FREQUENCY = 30000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
    
    MyMessage flowMsg(CHILD_ID,V_FLOW);
    MyMessage volumeMsg(CHILD_ID,V_VOLUME);
    MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
    
    double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter
    
    volatile unsigned long pulseCount = 0;   
    volatile unsigned long lastBlink = 0;
    volatile double flow = 0;  
    boolean pcReceived = false;
    unsigned long oldPulseCount = 0;
    unsigned long newBlink = 0;   
    double oldflow = 0;
    double volume =0;                     
    double oldvolume =0;
    unsigned long lastSend =0;
    unsigned long lastPulse =0;
    
    void setup()  
    {  
      // 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, V_VAR1);
    
      lastSend = lastPulse = millis();
    
      attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING);
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Water Meter", "1.1");
    
      // Register this device as Waterflow sensor
      present(CHILD_ID, S_WATER);       
    }
    
    void loop()     
    { 
      unsigned long 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, 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<((unsigned long)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);
      }
    }
    
    void receive(const MyMessage &message) {
      if (message.type==V_VAR1) {
        unsigned long gwPulseCount=message.getULong();
        pulseCount += gwPulseCount;
        flow=oldflow=0;
        Serial.print("Received last pulse count from gw:");
        Serial.println(pulseCount);
        pcReceived = true;
      }
    }
    
    void onPulse()     
    {
      if (!SLEEP_MODE)
      {
        unsigned long newBlink = micros();   
        unsigned long 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++; 
    }
    

    Here is what happens:
    When DigitalSensorPIN is RISING, the onPulse function is called as expected, but when DigitalSensorPIN is FALLING, the onPulse function is called also, which should not happen, right!??
    So this gives me a wrong consumption of 2liters per rotation, instead of 1liter.

    Has someone any idea what is going wrong?

    Troubleshooting

  • SaveState(): How to save and load bigger value
    vgaV vga

    Hi,
    i have build an water flow sensor and want to save the total flow value in mL in the eeprom.
    Is there a way to use the saveState and loadState from MySensors v2.0? The value will grow a long number, so it´s not only a "state" like 0/1 from switch/relay.

    Thanks and best regards,
    vga

    Development

  • first tries with MySensors v2.0: problem staring up.
    vgaV vga

    ok, thank you Yveaux for your help!
    to understand the mechanism, when the sensor node starts to search for parent again, why doesn´t it find the parent node, which used before?

    Troubleshooting

  • first tries with MySensors v2.0: problem staring up.
    vgaV vga

    Ah, Thanks!

    So, i have do i have to set the NODE_ID at Gateway to (i.e. 0), to have a fixed ID, to which i connect the sensor node, if i want it static, right?

    Troubleshooting

  • first tries with MySensors v2.0: problem staring up.
    vgaV vga

    yes, for testing without controller i set the NODE_ID manual, and now it works.
    Transmit works now. But when sensor was out of range, transmit fails some times, and sensor comes back into range, the transmit doesn't works again.

    SP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=ok:0
    0
    !TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=fail:1
    1
    !TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=fail:0
    0
    !TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=2,st=fail:1
    1
    !TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=3,st=fail:0
    0
    !TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=4,st=fail:1
    1
    !TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=16,pt=2,l=2,sg=0,ft=5,st=fail:0
    !TSM:UPL FAIL, SNP
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    0
    !TSP:SEND:TNR
    1
    !TSP:SEND:TNR
    
    Troubleshooting

  • first tries with MySensors v2.0: problem staring up.
    vgaV vga

    i haven´t set a MY_NODE_ID, the myconfig is set to auto, so i thought this will set automatically. Or is this only, when gateway is connected to controller?

    Troubleshooting

  • first tries with MySensors v2.0: problem staring up.
    vgaV vga

    Hi,
    i have worked with MySensors v1.5 till now, but i started to begin working with v2.0.

    I have made a test SerialGateway (nearly example sketch) with an arduino nano, and a test sensor node with an arduino Pro Mini 3,3V.

    When starting both arduinos, on the Sensor node i get the following output:

    TSM:PDT
    TSM:INIT
    TSM:RADIO:OK
    TSM:FPAR
    TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-255 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    TSM:ID
    TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
    !TSM:CHKID:FAIL (ID=255)
    !TSM:FAILURE
    TSM:PDT
    

    What das that mean? (especially the "!TSM:CHKID_FAIL" and "...:FAILURE"
    My Gateway is not connected to any controller, just want to check, if my Sensor node with the sensor hardware works (serial outputs) but the only thing i get is this.

    Do i have to fully implement the mySensor Network, also the controller connection, or is there a way to test my Sensor node at first, then the communication with the gateway only, and at least put it on my controller?

    Troubleshooting

  • NRF24L01+PA+LNA SMD: anyone tried it?
    vgaV vga

    Hi,
    does anyone have made experience with the NRF24L01+PA+LNA ?

    looking for a better range but not with big antennas.
    Also tried the wire-mod, but does´t get really much more range with that.
    This module looks like a good idea to me, but want to ask id someone tested it already:

    http://www.ebay.de/itm/2-4G-NRF24L01-PA-LNA-Wireless-Module-with-Ceramic-Antenna-1-27mm-for-Arduino-d/251688770656?_trksid=p2141725.c100338.m3726&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20150313114020%26meid%3D86e3c14b5de64baebdbb4ceede9a6350%26pid%3D100338%26rk%3D7%26rkt%3D19%26sd%3D311428791815

    Hardware

  • Arduino Pro mini 3,3V + NRF24L01+: Can i change Pins?
    vgaV vga

    ah, thanks mfalkvidd, thats what i´m looking for!

    Hardware

  • Arduino Pro mini 3,3V + NRF24L01+: Can i change Pins?
    vgaV vga

    Hi together,
    just have a simple question:

    is it possible to change the Pins to connect the NRF24L01+ to my Arduino Pro Mini 3,3V, or is there maybe a special function on the configured Pins, so only these Pins are usable?

    Thanks and best regards!

    Hardware

  • NRF24L01+: bad range of few meters
    vgaV vga

    i´ve got the solution!

    in MyConfig.h i have set:

    #define RF24_PA_LEVEL_GW   RF24_PA_MAX
    

    befor it it was LOW! :smirk:

    Troubleshooting

  • NRF24L01+: bad range of few meters
    vgaV vga

    sure, as i said, i don´t use the radio.set methods.

    So are there any other hardware tipps?

    Troubleshooting

  • How to get RFM69H 868Mhz working?
    vgaV vga

    thanks alexsh1.

    One more thing:
    Gateway is a Arduino Pro Mini 3,3V and powered with a connected FTDI 3,3V Breakout to USB from Raspberry Pi 2.
    Sensor node is also a Arduino Pro Mini 3,3V but powered with a FTDI 5V Breakout (the only second one i have at moment) which is connected to my MacBooks´USB.

    Is this a acceptable way?

    So at the end i have to buy a "W" Module, and try it again?

    Troubleshooting

  • NRF24L01+: bad range of few meters
    vgaV vga

    @Yveaux said:

    @vga if you don't change the channel it will default to 76.
    Why are you configuring the nRF directly by calling the driver methods? Are you using the mysensors library at all?

    do you mean the radio.set lines?
    this is only a quote from another post. i don't do it this way.
    i´m using My Sensors library v2.0 beta.

    I´ve found 3 parameters in the MyConfig.h, and they all set by default, as i see.
    But ni can´t find the payload size. Can i set it anywhere, or see what value it is set to?

    Troubleshooting

  • NRF24L01+: bad range of few meters
    vgaV vga

    thanks, i would take channel 76, but how can i set these parameters, also the other ones?

    in MyConfig.h i see the following:

    #define MY_RF24_CHANNEL	76
    #define MY_RF24_DATARATE RF24_250KBPS
    #define MY_RF24_PA_LEVEL RF24_PA_MAX
    

    ...but what about the PayloadSize? can i set this too?

    Troubleshooting

  • NRF24L01+: bad range of few meters
    vgaV vga

    Hi everyone,

    i´m using the following setup:

    Controller:
    Raspberry Pi 2 B, powered with an USB- Power-Supply Max. 2A

    Serial Gateway (v1.5):
    Arduino Nano 5V directly connected via USB,
    NRF24L01+ with SMA Antenna direct soldered to the Arduino, capacitor 0,47uF between GND and Vin

    Sensor-Node (v1.5):
    Arduino Pro Mini 3,3V, powered with new a battery: (one "SAFT" AA-Format cell, 3,6V 2000mAh)
    NRF24L01+ without external Antenna (and also tried the mod with soldered 83,3mm wire antenna), capacitor 0,47uF between GND and Vin

    Environment:
    Controller and gateway indoor directly behind a window (double shielded), sensor outside:
    5m away from window: connection OK.
    7m away from window: connection FAIL.

    What can i do, for better range:?

    • Is there a better way for powering the gateway or the battery sensor (but sensor needs to by battery powered, and power efficient)?
    • Any other hardware mods?
    • I´ve read in another post something about NRF24-library settings:
      radio.setPALevel(RF24_PA_MAX);
      radio.setDataRate(RF24_250KBPS);
      radio.setPayloadSize(4);
      radio.setChannel(2);
      radio.setRetries(15, 15);
    

    Is there a way to set these parameters via MySensors Library?

    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