Hello,
I’m trying to configure a MySensors ESP8266 Gateway as a Wifi Sensor (without Radio).
MySensors 2.0 now allows to have sensors attached directly to the gateway. This is what I want!
In my case the gateway will really act as a Sensor so I don’t need the radio module/library to be loaded.
The hardware (ESP8266 + DS18B20 temperature sensor) is working fine. I can connect to it with MYSController and the controller can see the sensor and the temperature readings.
But when I try to get it added into the HA controller, I get this error:
16-09-07 22:06:02 ERROR (Thread-3) [mysensors.mysensors] Node 0 is unknown, will not add child sensor.
This is the code:
#include <EEPROM.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define MY_DEBUG
#define MY_BAUD_RATE 9600
// Enables and select radio type (if attached)
//#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#define MY_GATEWAY_ESP8266
#define MY_ESP8266_SSID "WRT"
#define MY_ESP8266_PASSWORD "WRTpass"
#define MY_ESP8266_HOSTNAME "sensor-gateway"
#define MY_IP_GATEWAY_ADDRESS 192,168,1,1
#define MY_IP_SUBNET_ADDRESS 255,255,255,0
#define MY_PORT 5003
#define MY_GATEWAY_MAX_CLIENTS 2
#define MY_INCLUSION_MODE_FEATURE
#define MY_INCLUSION_MODE_DURATION 60
#define MY_INCLUSION_MODE_BUTTON_PIN 3
#define MY_DEFAULT_ERR_LED_PIN 16 // Error led
#define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin
#define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED
#if defined(MY_USE_UDP)
#include <WiFiUDP.h>
#else
#include <ESP8266WiFi.h>
#endif
#define MY_NODE_ID 5
#include <MySensors.h>
#define CHILD_D4 2 // Temperature D4 is Internal GPIO2
#define TEMP_D4 2
OneWire ourWire(TEMP_D4);
DallasTemperature sensors(&ourWire);
MyMessage msgTemperature1(CHILD_D4, V_TEMP);
void setup() {
present(255, 18); //The number 18 signifies S_ARDUINO_REPEATER_NODE. This is suggested in some forums.
delay(1000);
Serial.begin(9600);
sensors.begin(); //Se inician los sensore
}
void presentation() {
// Present locally attached sensors here
sendSketchInfo("Cuartito", "1.0");
present(CHILD_D4, S_TEMP); //Temperature
sleep(100);
}
void loop() {
sensors.requestTemperatures();
Serial.print(sensors.getTempCByIndex(0));
Serial.println(" grados Centigrados");
float temperature = static_cast<float>(static_cast<int>(sensors.getTempCByIndex(0) * 10.)) / 10.;
send(msgTemperature1.set(temperature,1));
delay(1000); //Se provoca un lapso de 1 segundo antes de la próxima lectura
}
I already tried to add the present(255, 18);
in the Setup but it doesn’t work…
And this is what I see when I connect through telnet to the ESP8266 gateway:
0;255;3;0;14;Gateway startup complete.
0;255;3;0;11;Cuartito
0;255;3;0;12;1.0
0;2;0;0;6;
0;2;1;0;0;26.0
0;2;1;0;0;26.0
0;2;1;0;0;26.7
0;2;1;0;0;26.5
And this is what I see in the Arduino IDE Console:
connected with WRT, channel 6
dhcp client start...
chg_B1:-40
.....ip:192.168.1.85,mask:255.255.255.0,gw:192.168.1.1
.IP: 192.168.1.85
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;Client 0 connected
Result from MYSController:
Any idea?
Thank you!