Its seems to be working with this last sketch
https://github.com/paolo-rendano/MySensors/blob/c01e14d0942de68126d67325a0687b1a6ce4fa16/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
need some time to test it
thanks
Its seems to be working with this last sketch
https://github.com/paolo-rendano/MySensors/blob/c01e14d0942de68126d67325a0687b1a6ce4fa16/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
need some time to test it
thanks
Thanks, i tried but it has no effect
Hello,
i am working on an adruino-Pro 5V mini with jeedom.
My water meter already have a pulse output, its a simple NO/NC contact, directly wired to pin 3 and GND
I tried and succeed to read this output with this simple sketch :
https://github.com/mysensors/MySensorsArduinoExamples/blob/master/examples/BinarySwitchSensor/BinarySwitchSensor.ino
But with the same hardware, when i tried this sketch
https://github.com/mysensors/MySensors/blob/master/examples/WaterMeterPulseSensor/WaterMeterPulseSensor.ino
i have no signal on jeedom.
Do you know what is happening ?
thanks
here is my serial monitor
16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
26 TSM:INIT
28 TSF:WUR:MS=0
34 TSM:INIT:TSP OK
36 TSF:SID:OK,ID=9
37 TSM:FPAR
41 ?TSF:MSG:SEND,9-9-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
540 TSF:MSG:READ,0-0-9,s=255,c=3,t=8,pt=1,l=1,sg=0:0
545 TSF:MSG:FPAR OK,ID=0,D=1
2050 TSM:FPAR:OK
2051 TSM:ID
2052 TSM:ID:OK
2054 TSM:UPL
2057 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2068 TSF:MSG:READ,0-0-9,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2073 TSF:MSG:PONG RECV,HP=1
2075 TSM:UPL:OK
2077 TSM:READY:ID=9,PAR=0,DIS=1
2081 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2089 TSF:MSG:READ,0-0-9,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2097 TSF:MSG:SEND,9-9-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
2105 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
4113 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=OK:Water Meter
4122 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.1
4130 TSF:MSG:SEND,9-9-0-0,s=1,c=0,t=21,pt=0,l=0,sg=0,ft=0,st=OK:
4135 MCO:REG:REQ
4140 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
4147 TSF:MSG:READ,0-0-9,s=255,c=3,t=27,pt=1,l=1,sg=0:1
4152 MCO:PIM:NODE REG=1
4154 MCO:BGN:STP
4157 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
4163 MCO:BGN:INIT OK,TSP=1
34165 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
64168 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
94167 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
124168 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
154169 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
184170 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
214171 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
244172 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
248990 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
248995 TSF:MSG:BC
249164 TSF:MSG:SEND,9-9-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
274173 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
304174 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
334175 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
364176 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
394177 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
424178 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
454179 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
484180 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
514181 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
544182 TSF:MSG:SEND,9-9-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
@Boots33 , Thanks i have compiled your example and its working good !
Thanks for your answers, i will try it
Hi,
I made a multisensor node with latest library :
2x Relay + 2x Dallas+ Sonar Distance + 2x Button
The node is working but :
Is it possible to send dallas information every minute without a wait ?
For the moment my solution is to convert FLOAT temperature to INT.
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <NewPing.h>
//-------------------RELAY-----------------------------//
#define RELAY_1 A1 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define RELAY_2 A2 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 2 // Total number of attached relays
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay
//-------------------DALLAS----------------------------//
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 2
//unsigned long WAIT_TIME = 5000; // Sleep time between reads (in milliseconds)
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
int lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors=0;
bool receivedConfig = false;
bool metric = true;
// Initialize temperature message
MyMessage msg(0,V_TEMP);
//-------------------SONAR----------------------------//
#define CHILD_ID 5
#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 1000 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
MyMessage msg1(CHILD_ID, V_DISTANCE);
int lastDist;
//-------------------BUTTON----------------------------//
#define CHILD_ID_6 6
#define CHILD_ID_7 7
#define BUTTON_PIN_6 4 // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN_7 8 // Arduino Digital I/O pin for button/reed switch
Bounce debouncer1 = Bounce();
Bounce debouncer2 = Bounce();
int oldValue1=-1;
int oldValue2=-1;
MyMessage msg6(CHILD_ID_6,V_TRIPPED);
MyMessage msg7(CHILD_ID_7,V_TRIPPED);
//=======================BEFORE==========================================//
void before() {
//-------------------DALLAS----------------------------//
//Startup up the OneWire library
sensors.begin();
//-------------------RELAY-----------------------------//
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to OFF
digitalWrite(pin, RELAY_OFF);
}
}
//=======================SETUP============================================//
void setup() {
//-------------------DALLAS----------------------------//
//requestTemperatures() will not block current thread
sensors.setWaitForConversion(false);
//-------------------SONAR----------------------------//
metric = getConfig().isMetric;
//-------------------BUTTON----------------------------//
// Setup the button
pinMode(BUTTON_PIN_6,INPUT);
pinMode(BUTTON_PIN_7,INPUT);
// Activate internal pull-up
digitalWrite(BUTTON_PIN_6,HIGH);
digitalWrite(BUTTON_PIN_7,HIGH);
// After setting up the button, setup debouncer
debouncer1.attach(BUTTON_PIN_6);
debouncer1.interval(5);
debouncer2.attach(BUTTON_PIN_7);
debouncer2.interval(5);
}
//=======================PRESENTATION======================================//
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Poele", "1.0");
//-------------------RELAY-----------------------------//
// Register all sensors to gw (they will be created as child devices)
present(1, S_BINARY);
present(2, S_BINARY);
//-------------------DALLAS----------------------------//
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
//Present all sensors to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
present(i+3, S_TEMP);
}
//-------------------SONAR----------------------------//
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID, S_DISTANCE);
//-------------------BUTTON----------------------------//
present(CHILD_ID_6, S_DOOR);
present(CHILD_ID_7, S_DOOR);
}
//=======================LOOP==============================================//
void loop()
{
//-------------------BUTTON----------------------------//
debouncer1.update();
// Get the update value
int value1 = debouncer1.read();
if (value1 != oldValue1) {
// Send in the new value
send(msg6.set(value1==HIGH ? 1 : 0));
oldValue1 = value1;
}
debouncer2.update();
// Get the update value
int value2 = debouncer2.read();
if (value2 != oldValue2) {
// Send in the new value
send(msg7.set(value2==HIGH ? 1 : 0));
oldValue2 = value2;
}
//-------------------SONAR----------------------------//
int dist = metric?sonar.ping_cm():sonar.ping_in();
Serial.print("Ping: ");
Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println(metric?" cm":" in");
if (dist != lastDist && dist != lastDist+1 && dist != lastDist-1) {
send(msg1.set(dist));
lastDist = dist;
}
//-------------------DALLAS----------------------------//
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// query conversion time and sleep until conversion completed
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
wait(conversionTime);
// Read temperatures and send them to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
int temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
#if COMPARE_TEMP == 1
if (lastTemperature[i+3] != temperature && temperature != -127.00 && temperature != 85.00) {
#else
if (temperature != -127.00 && temperature != 85.00) {
#endif
send(msg.setSensor(i+3).set(temperature,1));
// Save new temperatures for next compare
lastTemperature[i+3]=temperature;
}
}
}
//=======================RECEIVE==============================================//
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_STATUS) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}```
Thanks