Hello.
I'm trying to connect my Arduino Uno with rf433 receiver and some data received from another Uno and push this data to raspberry pi (open hab - for example). I've used this tutorial http://forum.mysensors.org/topic/1194/tutorial-openhab-with-serial-gateway
So far my readings in serial monitor looks like this:
±'Ú˘ţ0;255;3;0;9;Starting gateway (R-NGA-, 2.0.0-beta)
0;255;3;0;14;Gateway startup complete.
0;255;3;0;11;Weather Station Sensor
0;255;3;0;12;1.0
0;0;0;0;8;
0;2;0;0;7;
0;1;0;0;6;
0;4;0;0;7;
0;3;0;0;6;
0;5;0;0;6;
0;255;3;0;9;Init complete, id=0, parent=0, distance=0
0;0;1;0;4;0.0
0;3;1;0;0;0.0
0;3;1;0;0;24.0
0;4;1;0;1;59.0
0;5;1;0;0;15.5
0;0;1;0;4;1004.0
0;3;1;0;0;24.0
0;4;1;0;1;59.0
0;5;1;0;0;15.5
0;0;1;0;4;1004.0
Unfortunatelly I can't see enything in raspberry pi and openhab.
My Arduino Code:
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// FLash leds on rx/tx/err
#define MY_LEDS_BLINKING_FEATURE
// Set blinking priod
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Set Node Id number
#define MY_NODE_ID 101
#include <Wire.h> // use Wire library for protocol i2c (A4 = SDA & A5 = SCL)
#include <VirtualWire.h> // use Virtual library for decode signal from Rx module
#include <SPI.h>
#include <MySensor.h>
#include <DHT.h>
// ---------------------------------------------------------------------------------------------------
// Child sensor ids
#define CHILD_ID_BARO 0
#define CHILD_ID_TEMP1 1
#define CHILD_ID_HUM1 2
#define CHILD_ID_TEMP2 3
#define CHILD_ID_HUM2 4
#define CHILD_ID_TEMP3 5 //Dew Point
// ----------------------------------------------------------------------------------------------------
// DHT-11/22
//#define HUMIDITY_SENSOR_DIGITAL_PIN 3
//DHT dht;
//float lastTemp;
//float lastHum;
//boolean metric = true;
MyMessage msgPressure(CHILD_ID_BARO, V_PRESSURE);
MyMessage msgHum1(CHILD_ID_HUM1, V_HUM);
MyMessage msgTemp1(CHILD_ID_TEMP1, V_TEMP);
MyMessage msgHum2(CHILD_ID_HUM2, V_HUM);
MyMessage msgTemp2(CHILD_ID_TEMP2, V_TEMP);
MyMessage msgTemp3(CHILD_ID_TEMP3, V_TEMP);
// Sensors
int humidity;
int temp;
int tempf;
int pres;
int rain;
char MsgReceived[21];
//int led = 8; //pin for LED
float tF;
float dP;
float dPF;
float hT;
void setup()
{
//Serial.begin(115200); //Starting serial communication
//Serial.println("Program started");
//Serial.print(" WS :");
//Serial.print("\t");
//Serial.print("Rain Drop\t");
//Serial.print("Pressure \t");
//Serial.print("Air Hum\t");
//Serial.print("\t");
//Serial.print("Temp \t");
//Serial.print("Dew Point\t");
//Serial.println("Heat Index: ");
// VirtualWire
// Bits per sec
vw_setup(2000);
// set pin for connect receiver module
vw_set_rx_pin(9);
// Start the receiver PLL running
vw_rx_start();
//dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
} // END void setup
void presentation()
{
// Send the sketch Version Information to the Gateway
sendSketchInfo("Weather Station Sensor", "1.0");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_BARO, S_BARO);
present(CHILD_ID_HUM1, S_HUM);
present(CHILD_ID_TEMP1, S_TEMP);
present(CHILD_ID_HUM2, S_HUM);
present(CHILD_ID_TEMP2, S_TEMP);
present(CHILD_ID_TEMP3, S_TEMP);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
//Taking the data from the control base
if (vw_get_message(buf, &buflen)) //Non-blocking
{
//digitalWrite(led, HIGH);
//delay(100);
int i;
// Message with a good checksum received, dump it.
for (i = 0; i < buflen; i++)
{
// Fill Msg Char array with corresponding
// chars from buffer.
MsgReceived[i] = char(buf[i]);
//Serial.print(MsgReceived[i]);
}
sscanf(MsgReceived, "%d,%d,%d",&pres, &humidity, &temp, &rain); // Converts a string to an array
//digitalWrite(led, LOW);
//Serial.print(" WS : ");
//Serial.print(rain);
//Serial.print(" %\t");
//Serial.print("\t");
//Serial.print(pres);
//Serial.print(" hPa \t");
//Serial.print(humidity);
//Serial.print(" %\t");
//Serial.print("\t");
//Serial.print(temp);
//Serial.print("*C \t");
dP = dewPointFast(temp, humidity);
//Serial.print(dP);
//Serial.print("*C \t");
//Serial.print(" \t");
hT = heatIndex(temp,humidity);
//Serial.print(hT);
//Serial.println(" *C");
//Serial.println((char*)buf);
memset( MsgReceived, 0, sizeof(MsgReceived));// This line is for reset the StringReceived
}
send(msgPressure.set(pres, 1));
send(msgTemp2.set(temp, 1));
send(msgHum2.set(humidity, 1));
send(msgTemp3.set(dP, 1));
}
// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
double Td = (b * temp) / (a - temp);
return Td;
}
double heatIndex(double temp, double humidity)
{
double c1 = -42.38, c2 = 2.049, c3 = 10.14, c4 = -0.2248, c5= -6.838e-3, c6=-5.482e-2, c7=1.228e-3, c8=8.528e-4, c9=-1.99e-6 ;
tempf = (temp*1.8 + 32); // Celsius to Fahrenheit
double T = tempf;
double R = humidity;
double A = ((c5 * T) + c2) * T + c1;
double B = ((c7 * T) + c4) * T + c3;
double C = ((c9 * T) + c8) * T + c6;
double rv = (C * R + B) * R + A;
rv = ((((rv)-32)*5)/9); // converting to C
return rv;
}
What I'm missing???
FYI I'm quite new in arduino and programming.
Thank you in advance for help.
All the best
Robert