Request sensor data in MySensor

10 years 10 months ago - 10 years 10 months ago #740 by kwest
I have a LCD screen with nrf24l01 and weather board connected to the controller RPi.
Now it appears the time and sensor data.

Does anyone know how to make a request node-controller or node-node? B)
For example the sensor is installed in the street.

And second, how to send a command to controller "turn off lamp №3"?
Attachments:

Please Log in or Create an account to join the conversation.

10 years 10 months ago #747 by EasyIoT

kwest wrote: I have a LCD screen with nrf24l01 and weather board connected to the controller RPi.
Now it appears the time and sensor data.

Does anyone know how to make a request node-controller or node-node? B)
For example the sensor is installed in the street.

And second, how to send a command to controller "turn off lamp №3"?


See ESP8266 thermostat example. There you have automation script to send temperature value from sensor to thermostat.

Please Log in or Create an account to join the conversation.

10 years 10 months ago - 10 years 10 months ago #763 by kwest
I've tried. No results.
My code:

#include <MySensor.h>
#include <SPI.h>

MySensor gw;
unsigned long timer = 0;

void setup()
{
gw.begin(incomingMessage, AUTO, true);
gw.sendSketchInfo("Relay", "1.0");
}

void loop()
{
gw.process();
if ((millis() - timer > 5000))
{
timer = millis();
gw.request(1, V_TEMP);
gw.request(2, V_TEMP);
gw.request(3, V_TEMP);
gw.request(4, V_TEMP);
}
}

void incomingMessage(const MyMessage &message)
{
Serial.print("Received: ");
Serial.println(message.data);
}


send: 3-3-0-0 s=1,c=2,t=0,pt=0,l=0,sg=0,st=ok:
send: 3-3-0-0 s=2,c=2,t=0,pt=0,l=0,sg=0,st=ok:
send: 3-3-0-0 s=3,c=2,t=0,pt=0,l=0,sg=0,st=ok:
send: 3-3-0-0 s=4,c=2,t=0,pt=0,l=0,sg=0,st=ok:

Please Log in or Create an account to join the conversation.

10 years 10 months ago #766 by osalval

kwest wrote: I've tried. No results.
My code:

#include <MySensor.h>
#include <SPI.h>

MySensor gw;
unsigned long timer = 0;

void setup()
{
gw.begin(incomingMessage, AUTO, true);
gw.sendSketchInfo("Relay", "1.0");
}

void loop()
{
gw.process();
if ((millis() - timer > 5000))
{
timer = millis();
gw.request(1, V_TEMP);
gw.request(2, V_TEMP);
gw.request(3, V_TEMP);
gw.request(4, V_TEMP);
}
}

void incomingMessage(const MyMessage &message)
{
Serial.print("Received: ");
Serial.println(message.data);
}


send: 3-3-0-0 s=1,c=2,t=0,pt=0,l=0,sg=0,st=ok:
send: 3-3-0-0 s=2,c=2,t=0,pt=0,l=0,sg=0,st=ok:
send: 3-3-0-0 s=3,c=2,t=0,pt=0,l=0,sg=0,st=ok:
send: 3-3-0-0 s=4,c=2,t=0,pt=0,l=0,sg=0,st=ok:



I'd change
{
gw.request(1, V_TEMP);
gw.request(2, V_TEMP);
gw.request(3, V_TEMP);
gw.request(4, V_TEMP);
timer = millis();
}

Please Log in or Create an account to join the conversation.

10 years 6 months ago #1847 by greengo
Hello colleagues.

I also have a problem with this feature, the server does not return a value.

Please tell me what the problem is.

Here is my code

#include <SPI.h>
#include <MySensor.h>

#define Temp_CHILD_ID 0

MySensor gw (8,7);

float temp = 25;

MyMessage tempSensorMsg(Temp_CHILD_ID, V_TEMP);

void setup()
{

gw.begin(incomingMessage, 10);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("devDuino SNv1", "1.0");
gw.present(Temp_CHILD_ID, S_TEMP);



gw.process();
}

void loop()
{
gw.send(tempSensorMsg.set(temp, 1));
// Serial.print("Temp = ");
// Serial.println(temp);
delay(10000);

gw.request(Temp_CHILD_ID, V_TEMP);

}

void incomingMessage(const MyMessage &message) {

Serial.println("incoming message");
Serial.println(message.sensor);
Serial.println(message.data);

}


that's what gives the console

2015-06-29T10:02:08.7116890+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
2015-06-29T10:02:08.7582890+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=3,t=6,pt=1,l=1:0
2015-06-29T10:02:10.7172610+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=3,t=11,pt=0,l=13:devDuino SNv1
2015-06-29T10:02:10.7363330+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=3,t=12,pt=0,l=3:1.0
2015-06-29T10:02:10.7513120+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=0,t=6,pt=0,l=5:1.4.1
2015-06-29T10:02:10.7598390+02:00 DEBUG MySensors Rx: Sensor presentation NodeId:10,SensorId:0,type:S_TEMP,data:1.4.1
2015-06-29T10:02:10.9492790+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=1,t=0,pt=7,l=5:25.0
2015-06-29T10:02:11.0150280+02:00 INFO MySensors N10S0 Sensor.Temperature 25.0 -
2015-06-29T10:02:20.7672450+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=2,t=0,pt=0,l=0:
2015-06-29T10:02:20.7789450+02:00 ERROR MySensors Rx: Invalid data type:10 ,sensor:0, type:0
2015-06-29T10:02:20.7983180+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=1,t=0,pt=7,l=5:25.0
2015-06-29T10:02:20.8038520+02:00 INFO MySensors N10S0 Sensor.Temperature 25.0 -


Server version 0.8

Please Log in or Create an account to join the conversation.

10 years 6 months ago #1848 by EasyIoT

greengo wrote: Hello colleagues.

I also have a problem with this feature, the server does not return a value.

Please tell me what the problem is.

Here is my code

#include <SPI.h>
#include <MySensor.h>

#define Temp_CHILD_ID 0

MySensor gw (8,7);

float temp = 25;

MyMessage tempSensorMsg(Temp_CHILD_ID, V_TEMP);

void setup()
{

gw.begin(incomingMessage, 10);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("devDuino SNv1", "1.0");
gw.present(Temp_CHILD_ID, S_TEMP);



gw.process();
}

void loop()
{
gw.send(tempSensorMsg.set(temp, 1));
// Serial.print("Temp = ");
// Serial.println(temp);
delay(10000);

gw.request(Temp_CHILD_ID, V_TEMP);

}

void incomingMessage(const MyMessage &message) {

Serial.println("incoming message");
Serial.println(message.sensor);
Serial.println(message.data);

}


that's what gives the console

2015-06-29T10:02:08.7116890+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
2015-06-29T10:02:08.7582890+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=3,t=6,pt=1,l=1:0
2015-06-29T10:02:10.7172610+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=3,t=11,pt=0,l=13:devDuino SNv1
2015-06-29T10:02:10.7363330+02:00 DEBUG MySensors Read: 10-10-0 s=255,c=3,t=12,pt=0,l=3:1.0
2015-06-29T10:02:10.7513120+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=0,t=6,pt=0,l=5:1.4.1
2015-06-29T10:02:10.7598390+02:00 DEBUG MySensors Rx: Sensor presentation NodeId:10,SensorId:0,type:S_TEMP,data:1.4.1
2015-06-29T10:02:10.9492790+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=1,t=0,pt=7,l=5:25.0
2015-06-29T10:02:11.0150280+02:00 INFO MySensors N10S0 Sensor.Temperature 25.0 -
2015-06-29T10:02:20.7672450+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=2,t=0,pt=0,l=0:
2015-06-29T10:02:20.7789450+02:00 ERROR MySensors Rx: Invalid data type:10 ,sensor:0, type:0
2015-06-29T10:02:20.7983180+02:00 DEBUG MySensors Read: 10-10-0 s=0,c=1,t=0,pt=7,l=5:25.0
2015-06-29T10:02:20.8038520+02:00 INFO MySensors N10S0 Sensor.Temperature 25.0 -


Server version 0.8



I've checked - there is only implementation for V_TEMP request if module type is S_TEMP_AO. For now you can try and change module type in WEB UI. I will prepare new beta release this week and fix for this issue will be included. Please report if it works in new beta.
The following user(s) said Thank You: kwest

Please Log in or Create an account to join the conversation.

Time to create page: 0.229 seconds

Forum latest

  • No posts to display.