ah, thanks mfalkvidd, thats what i´m looking for!
vga
@vga
Best posts made by vga
-
RE: Arduino Pro mini 3,3V + NRF24L01+: Can i change Pins?
-
RE: Moisture Sensor - Payload problem
It is working! ;D ...thank you very much!
Now i understand a little bit more with MySensors
Latest posts made by vga
-
RE: WaterPulseMeter: onPulse gets called on rising AND falling !?
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!?
-
RE: WaterPulseMeter: onPulse gets called on rising AND falling !?
I connected the sensor to D3 pin.
-
RE: WaterPulseMeter: onPulse gets called on rising AND falling !?
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?
-
WaterPulseMeter: onPulse gets called on rising AND falling !?
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?
-
SaveState(): How to save and load bigger value
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 -
RE: first tries with MySensors v2.0: problem staring up.
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? -
RE: first tries with MySensors v2.0: problem staring up.
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?
-
RE: first tries with MySensors v2.0: problem staring up.
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
-
RE: first tries with MySensors v2.0: problem staring up.
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?
-
first tries with MySensors v2.0: problem staring up.
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?