Right to the point:
It's a "dummy-sketch" to test communication between sensor node and Domoticz. With the following sketch Domoticz updates the values when i change wind speed and gust WITHIN the sketch manually. But i can change the number of the wind direction as much i want. Domoticz always uses 20 NNE. Why?
Code: Select all
#define MY_RADIO_NRF24
#define MY_DEBUG
#include <MySensors.h>
#include <SPI.h>
#define CHILD_ID_WIND 1
unsigned int val_wspeed;
unsigned int val_wgust;
unsigned int val_wdirection;
unsigned int last_wspeed;
unsigned int last_wgust;
unsigned int last_wdirection;
MyMessage msgWSpeed(CHILD_ID_WIND, V_WIND);
MyMessage msgWGust(CHILD_ID_WIND, V_GUST);
MyMessage msgWDirection(CHILD_ID_WIND, V_DIRECTION);
void presentation()
{
present(CHILD_ID_WIND, S_WIND);
}
void loop()
{
unsigned int val_wspeed = 12;
if(last_wspeed != val_wspeed)
{
last_wspeed = val_wspeed;
send(msgWSpeed.set(val_wspeed, 1));
Serial.print("WS: ");
Serial.println(val_wspeed);
}
unsigned int val_wgust = 4;
if(last_wgust != val_wgust)
{
last_wgust = val_wgust;
send(msgWGust.set(val_wgust, 1));
Serial.print("WG: ");
Serial.println(val_wgust);
}
unsigned int val_wdirection = 15;
if(last_wdirection != val_wdirection)
{
last_wdirection = val_wdirection;
send(msgWDirection.set(val_wdirection, 1));
Serial.print("WD: ");
Serial.println(val_wdirection);
}
}
I am also wondering where the "Temp: 20C" come from...
Purpose:
I am building a wind sensor without moving parts. With only 5 dallas tempeature sensors on a black metal plate i can calculate speed and direction. Everything still experimental and my programming skills are low. But tests without Domoticz show promising results.
I am sure somebody will see my mistake quickly