Hi there
Yes I made gateway without radio. I need connect hallefect flow sensor to Domoticz.
I use Arduino (as node) connected to RPi (controller) via USB cable.
I already have good working skatch - measure water flow with 5% accuracy. Now I need to add gatewy feature to that sketch.
I found similar skatch (TESTING SKATCH) in web https://forum.mysensors.org/topic/1282/water-flow-sensor/2
and I wanted to check this solution. I need only current flow, i don't need counter.
I checked and change positions of #define MY_GATEWAY_SERIAL and #include <MySensors.h>.
now MY_GATEWAY is before MySensors.h...............and I have new error
sketch_mar26a:17: error: 'MySensor' does not name a type
MySensor gw;
^
C:\Users\Jacek\Desktop\sketch_mar26a\sketch_mar26a.ino: In function 'void setup()':
sketch_mar26a:26: error: 'gw' was not declared in this scope
gw.begin();
^
C:\Users\Jacek\Desktop\sketch_mar26a\sketch_mar26a.ino: In function 'void loop()':
sketch_mar26a:56: error: 'gw' was not declared in this scope
gw.send(flowMsg.set(flow));
^
exit status 1
'MySensor' does not name a type```
And this is my TESTING sketch
Insert Code Here
```#define MY_GATEWAY_SERIAL
#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 SENSOR_INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
#define CHILD_ID 1 // Id of the sensor child
int READ_INTERVAL = 3; // Read interval to count the pulses (in seconds).
long lastReadStart;
int flow;
MySensor gw;
MyMessage flowMsg(CHILD_ID,V_FLOW);
int READ_INTERVAL_MILLIS=READ_INTERVAL * 1000; // Just to simple the math!
volatile unsigned long pulseCount = 0;
void setup()
{
gw.begin();
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Water Meter", "1.2");
// Register this device as Waterflow sensor
gw.present(CHILD_ID, S_WATER);
pulseCount = 0;
lastReadStart = millis();
attachInterrupt(SENSOR_INTERRUPT, onPulse, RISING);
}
void loop()
{
unsigned long currentTime = millis();
if (currentTime - lastReadStart > READ_INTERVAL_MILLIS)
{
flow = pulseCount*60/READ_INTERVAL; //Need to change here for the G type
lastReadStart=currentTime;
Serial.print("l/hour:");
Serial.println(flow);
gw.send(flowMsg.set(flow));
pulseCount = 0;
}
}
void onPulse()
{
pulseCount++;
}