Reporting wifi signal strength Topic is solved

Moderator: leecollings

Post Reply
djdehaan
Posts: 46
Joined: Thursday 11 June 2015 23:36
Target OS: Windows
Domoticz version: 2023.2
Location: Utrecht, NL
Contact:

Reporting wifi signal strength

Post by djdehaan »

I am trying to report from an Arduino ESP8266 using MySensors (2.0.0) to Domoticz (3.4834) the wifi strength. So this is what I added to the sketch:

Code: Select all

MyMessage Msg_DB(Sensor_DB, V_VAR1);

Code: Select all

present(Sensor_DB,S_CUSTOM, "Wifi dB");  //wifi db

Code: Select all

void Sync_DB() {
  int i = WiFi.RSSI();
  send(Msg_DB.set(i));
}
The Sync routine is called every minute, but never appears as a device in Domoticz. It does appear in the hardware section as one of the children of the MySensors gateway. But it seems like it never gets any data.

I also tried using: V_LEVEL and S_SOUND, but also no device did appear.

Can anyone help me how to solve this?

The entire Sketch (the includes are in the main sketch).

Code: Select all

const byte Sensor_HEART = 1;
const byte Sensor_Relais[] = {2,3,4,5,6,7,8};  // 7 totaal
const byte Sensor_VIN = 9;
const byte Sensor_VBATT = 10;
const byte Sensor_VOUT = 11;
const byte Sensor_PWR = 15;
const byte Sensor_TEMP = 13; 
//const byte Sensor_TEMPHUM = 16;
const byte Sensor_ESP = 20;
const byte Sensor_DB = 19;


MyMessage Msg_HEART(Sensor_HEART, V_STATUS);
MyMessage Msg_Relais[7];
MyMessage Msg_VIN_V(Sensor_VIN,V_VOLTAGE);
MyMessage Msg_VIN_A(Sensor_VIN,V_CURRENT);
MyMessage Msg_VBATT_V(Sensor_VBATT,V_VOLTAGE);
MyMessage Msg_VOUT_V(Sensor_VOUT,V_VOLTAGE);
MyMessage Msg_VOUT_A(Sensor_VOUT,V_CURRENT);

MyMessage Msg_PWR_WTT(Sensor_PWR, V_WATT);
MyMessage Msg_PWR_KWH(Sensor_PWR, V_KWH);
MyMessage Msg_PWR_VAR(Sensor_PWR, V_VAR1);

MyMessage Msg_TEMP(Sensor_TEMP, V_TEMP);
MyMessage Msg_HUM(Sensor_TEMP, V_HUM);

MyMessage Msg_ESP(Sensor_ESP, V_CUSTOM);
MyMessage Msg_DB(Sensor_DB, V_VAR1);

//MyMessage Msg_TEMP(Sensor_TEMPHUM, V_TEMP);
//MyMessage Msg_HUM(Sensor_TEMPHUM, V_HUM);





void setupMySensor() {
  for (byte i=0;i<7;i++) {
    Msg_Relais[i].sensor = Sensor_Relais[i];
    Msg_Relais[i].type = V_STATUS;
  }
}

void requestConnectDetection() {
  request(Sensor_HEART,V_STATUS);  //S_BINARY  
  DuurReqAnsTnul=millis();
}
void requestAfterReconnect() {
  for (byte i=0;i<7;i++) {
    request(Sensor_Relais[i],V_STATUS);
  }
  request(Sensor_PWR, V_VAR1);
}




///////////////////////
// Presentation
//////////////////////
void presentation()
{
  sendSketchInfo(PROJECT,VERSION);
  present(Sensor_HEART, S_BINARY, "Heartbeat");
  char* rl="Rel @";
  for (byte i=0;i<7;i++) {
    rl[4]=48+i;
    present(Sensor_Relais[i], S_LIGHT, rl);
  }
  present(Sensor_VIN, S_MULTIMETER,"VA zonnecel");
  present(Sensor_VBATT, S_MULTIMETER, "V accu");
  present(Sensor_VOUT, S_MULTIMETER, "VA out");

  present(Sensor_PWR,S_POWER, "Vermogen Zonnecel");
  present(Sensor_TEMP,S_TEMP, "Temp Hum tuin");
//  present(Sensor_TEMPHUM,S_HUM);
  present(Sensor_ESP,S_INFO, "ESP Info");
  present(Sensor_DB,S_CUSTOM, "Wifi DB");  //wifi db
}

///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////

void receive(const MyMessage &message) {
 
  if (message.sensor == Sensor_HEART) { //MySensor connected detection
    isMySensorsConnected = true;
    DuurReqAns=(millis() - DuurReqAnsTnul);
  }

  if (message.sensor == Sensor_PWR) { //MySensor opvragen KWH stand
    SolarTotal = message.getFloat();
    myLog+=" KWH=" + String(SolarTotal,6);
  }
  
  for (byte i=0;i<7;i++) {
    if (message.sensor == Sensor_Relais[i]) {
      //PCF.write(i,waarde
      PCFwrite(i,message.getBool());

//      myLog+="Rls " + String(i) + ": ";
//      myLog+=String(message.getString());
//      if (message.getBool()) {
//        myLog+="=JA. ";
//      } else {
//        myLog+="=NEE. ";
//      }
    }
  }
}



///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////

void Sync_Relais(byte i, bool v) {
  send(Msg_Relais[i].set(v));
}

void Sync_HEART(bool v) {
  send(Msg_HEART.set(v));
}

void Sync_PWR(float pwr, float kwh) {
  send(Msg_PWR_WTT.set(pwr,2)); 
  send(Msg_PWR_KWH.set(kwh,6)); 
  send(Msg_PWR_VAR.set(kwh,6)); 
}

void Sync_TEMPHUM(float tmp, float hum) {
//  send(Msg_TEMP.set(tmp,2));
//  send(Msg_HUM.set(hum,2));

  send(Msg_TEMP.set(tmp,2));
  send(Msg_HUM.set(hum,2));
}

void Sync_VIN(float v, float a) {
  send(Msg_VIN_V.set(v,2));
  send(Msg_VIN_A.set(a,2));
}
void Sync_VBATT(float v) {
  send(Msg_VBATT_V.set(v,2));
}
void Sync_VOUT(float v, float a) {
  send(Msg_VOUT_V.set(v,2));
  send(Msg_VOUT_A.set(a,2));
}
void Sync_ESP(String s) {
  send(Msg_ESP.set(s)); //"WV1_c7_db-55"
  myLog+=s;
}
void Sync_DB() {
  int i = WiFi.RSSI();
  send(Msg_DB.set(i));
}
User avatar
gizmocuz
Posts: 2549
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Reporting wifi signal strength

Post by gizmocuz »

V_VAR are variables only used internally, for instance when you made a metering sketch, you can store/retrieve the last counter value

You want to use the V_TEXT
Quality outlives Quantity!
djdehaan
Posts: 46
Joined: Thursday 11 June 2015 23:36
Target OS: Windows
Domoticz version: 2023.2
Location: Utrecht, NL
Contact:

Re: Reporting wifi signal strength

Post by djdehaan »

Thanks Gizmocuz. It works now with V_TEXT en also with V_LEVEL and S_SOUND.

Also I found out that if you want to send a String from Arduino, you have to convert it to a chararray first, otherwise it will come through as a number.
The Sync_ESP is my original post did not work, but this does:

Code: Select all

void Sync_ESP(String s) {
  byte b = s.length()+1;
  char c[b+1];
  s.toCharArray(c,b);
  send(Msg_ESP.set(c)); //"WV1_c7_db-55"
  myLog+=s;
}
And finally, a great help indeed in understanding what happens, is the MYScontroller tool:
https://forum.mysensors.org/topic/838/w ... -mysensors
A must have for anyone playing around with MySensors.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest