Gohan
Thanks very much for that pointer. You have been very helpful. All working now.
Gohan
Thanks very much for that pointer. You have been very helpful. All working now.
I have built an Mqtt gateway as you suggested. from the arduino serial monitor I can see it working, as below.
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.5
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.0
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.5
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.0
0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
0;255;3;0;9;TSF:MSG:READ,67-67-0,s=5,c=1,t=0,ptto=7,l=5,sg=0:16.5
0;255;3;0;9;Sending message on topic: mygateway1-out/67/5/1/0/0
I have mosquitto broker running on my pi 3. Node-red shows connected to the mqqt broker, yet no data is shown passing.
any ideas how best to fault find this issue
@gohan I am just thinking about the implications of moving to mqqt. This will break my home assistant setup. I also have over 30 sensors I would have to change the setup of.
If you see this as an example, "67;0;1;0;0;62.5↵" which is my data from a sensor showing in node-red debug. The 67 is the nodeId, the next 0 is the childSensor Id and the 62.5 is the temperature.
This the code I am using in a function of node-red to try and extract the temp value.
if (msg.payload.nodeId == 67 && msg.payload.childSensorId === 0) {
var msg;
msg.payload = msg.payload.value;
msg.topic = "Temperature";
return msg;
}
Can anyone spot any reason why this may not work ?
@gohan Ok, thanks for the advise. Strange that I can't use what I have, especially seeing as I can see the data coming from the sensors in node-red.
@gohan Hi, Can you give me some pointers on what I need to do to change to MQQT Gateway. I am not overly sure on the difference.
@gohan Ethernet gateway. As you can see above I have data. Just can't seem to extract the temp value for each sensor to make it usable for a gauge and graph
Hi
Yes I have. They just seem to to reformat the whole data. I just want to extract the temp value from each sensor to display in a gauge and a graph.
Hi All
I am having a go with Node-red. I have several temp sensors which I know are working as they are on home assistant. I know I am getting the values into Node-red using the debug.
This is an example of the info coming in.
msg.payload : string[15]
"2;0;1;0;0;19.1↵"
29/10/2017, 09:51:23node: 4764cb04.8ff4a4
msg.payload : string[15]
"2;1;1;0;0;16.9↵"
29/10/2017, 09:51:23node: 4764cb04.8ff4a4
msg.payload : string[16]
"67;0;1;0;0;63.0↵"
29/10/2017, 09:51:23node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:51:26node: 4764cb04.8ff4a4
msg.payload : string[16]
"67;0;1;0;0;62.5↵"
29/10/2017, 09:51:33node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:51:41node: 4764cb04.8ff4a4
msg.payload : string[15]
"2;0;1;0;0;19.0↵"
29/10/2017, 09:51:43node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:51:53node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:51:54node: 4764cb04.8ff4a4
msg.payload : string[15]
"2;1;1;0;0;16.8↵"
29/10/2017, 09:52:03node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:52:13node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:52:23node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:52:31node: 4764cb04.8ff4a4
msg.payload : string[15]
"2;0;1;0;0;19.1↵"
29/10/2017, 09:52:34node: 4764cb04.8ff4a4
msg.payload : string[18]
"0;255;3;0;2;2.1.1↵"
29/10/2017, 09:52:39node: 4764cb04.8ff4a4
msg.payload : string[16]
"67;5;1;0;0;27.0↵"
29/10/2017, 09:52:41node: 4764cb04.8ff4a4
msg.payload : string[16]
"67;5;1;0;0;27.5↵"
So I want to separate the information so that I can show a gauge and graph and use in a thermostat. so nodeId 67 childSensorId 0 is a sensor I want the value for, and also nodeId 67 childSensorId 5. I have tried with this script in a function, but it does not output anything.
if (msg.payload.nodeId == 67 && msg.payload.childSensorId === 0) {
var msg;
msg.payload = msg.payload.value;
msg.topic = "Temperature";
return msg;
}
Could someone point me in the right direction to what i am doing wrong.
Instead of showing values it showed nan.
The node was connecting to the gateway, but no sensor values were available to send.
On the example sketch the sensor showed values without issue.
Thanks for the rely. Yes sorry for the sketchy info.
When using the mysensors sketch and looking at the serial info, no values from the sensor were being reported. At first I thought it maybe the sensors being faulty. So I thought I would just test the sensors on their own to make sure it was not hardware. When using the example sketch the sensors outputs temp and humidity, but not on the mysensors sketch.
Thanks for your help, Laurie
Hi
Purchased a few DHT11's off ebay. I Know they work as when I test them with this code from exmples, below they work. When I test with the mysensor code they do not. Can someone help me out with the changes required. I think it is to do with the library being used.
Example code
#include <SimpleDHT.h>
// for DHT11,
// VCC: 5V or 3V
// GND: GND
// DATA: 2
int pinDHT11 = 3;
SimpleDHT11 dht11;
void setup() {
Serial.begin(115200);
}
void loop() {
// start working...
Serial.println("=================================");
Serial.println("Sample DHT11...");
// read without samples.
byte temperature = 0;
byte humidity = 0;
if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
Serial.print("Read DHT11 failed.");
return;
}
Serial.print("Sample OK: ");
Serial.print((int)temperature); Serial.print(" *C, ");
Serial.print((int)humidity); Serial.println(" %");
// DHT11 sampling rate is 1HZ.
delay(1000);
}
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0: Henrik EKblad
* Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
*
* DESCRIPTION
* This sketch provides an example of how to implement a humidity/temperature
* sensor using a DHT11/DHT-22.
*
* For more information, please visit:
* http://www.mysensors.org/build/humidity
*
*/
// Enable debug prints
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
// Set this to the pin you connected the DHT's data pin to
#define DHT_DATA_PIN 3
// Set this offset if the sensor has a permanent small offset to the real temperatures
#define SENSOR_TEMP_OFFSET 0
// Sleep time between sensor updates (in milliseconds)
// Must be >1000ms for DHT22 and >2000ms for DHT11
static const uint64_t UPDATE_INTERVAL = 60000;
// Force sending an update of the temperature after n sensor reads, so a controller showing the
// timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
// the value didn't change since;
// i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
static const uint8_t FORCE_UPDATE_N_READS = 10;
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
float lastTemp;
float lastHum;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
bool metric = true;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
DHT dht;
void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("TemperatureAndHumidity", "1.1");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
metric = getControllerConfig().isMetric;
}
void setup()
{
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
}
// Sleep for the time of the minimum sampling period to give the sensor time to power up
// (otherwise, timeout errors might occure for the first reading)
sleep(dht.getMinimumSamplingPeriod());
}
void loop()
{
// Force reading sensor, so it works also after sleep()
dht.readSensor(true);
// Get temperature from DHT library
float temperature = dht.getTemperature();
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT!");
} else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
// Only send temperature if it changed since the last measurement or if we didn't send an update for n times
lastTemp = temperature;
if (!metric) {
temperature = dht.toFahrenheit(temperature);
}
// Reset no updates counter
nNoUpdatesTemp = 0;
temperature += SENSOR_TEMP_OFFSET;
send(msgTemp.set(temperature, 1));
#ifdef MY_DEBUG
Serial.print("T: ");
Serial.println(temperature);
#endif
} else {
// Increase no update counter if the temperature stayed the same
nNoUpdatesTemp++;
}
// Get humidity from DHT library
float humidity = dht.getHumidity();
if (isnan(humidity)) {
Serial.println("Failed reading humidity from DHT");
} else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
// Only send humidity if it changed since the last measurement or if we didn't send an update for n times
lastHum = humidity;
// Reset no updates counter
nNoUpdatesHum = 0;
send(msgHum.set(humidity, 1));
#ifdef MY_DEBUG
Serial.print("H: ");
Serial.println(humidity);
#endif
} else {
// Increase no update counter if the humidity stayed the same
nNoUpdatesHum++;
}
// Sleep for a while to save energy
sleep(UPDATE_INTERVAL);
}
Well I don't get this. Today both temp sensors are showing. Yesterday only one showed all day. Anyone any ideas why it would take so long for the second sensor to be detected.
Hi
I have a problem with a nano board with multiple onewire sensors on it, using Home Assistant. Only one sensor is picked up in Home assistant. I think it is to do with the presentation part of the sketch, and have tried a few different things, but no luck. Could someone help me out please with the mods required.
Here is my code
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* DESCRIPTION
*
* Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
* http://www.mysensors.org/build/temp
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#include <SPI.h>
#include <MySensors.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 16
unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors=0;
bool receivedConfig = false;
bool metric = true;
// Initialize temperature message
MyMessage msg(0,V_TEMP);
void before()
{
// Startup up the OneWire library
sensors.begin();
}
void setup()
{
// requestTemperatures() will not block current thread
sensors.setWaitForConversion(false);
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Temperature Sensor", "1.1");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
// Present all sensors to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
present(i, S_TEMP);
}
}
void loop()
{
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// query conversion time and sleep until conversion completed
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
sleep(conversionTime);
// Read temperatures and send them to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
#if COMPARE_TEMP == 1
if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
#else
if (temperature != -127.00 && temperature != 85.00) {
#endif
// Send in the new temperature
send(msg.setSensor(i).set(temperature,1));
// Save new temperatures for next compare
lastTemperature[i]=temperature;
}
}
sleep(SLEEP_TIME);
}
Insert Code Here
Hi
I have read through this thread fully and the concept look great. I am confused as to the hardware that is required thought. I have a mysensors gateway connetcted to wifi and some sensors setup and working on Home Assistant. What do I need to build to implement this solution, and what would I have to install in HA.
Thanks for any help
Laurie
To the person that commented on the build instructions. Check your wiring. I now have it working on 2.1 library with no code changes.
I have built and installed this.
https://www.mysensors.org/build/humidity
But have same issue as in comment with 2.1 library.
!TSM:INIT:TSP FAIL, all hardware tested, and gateway working with other sensors.
Finally bottomed out the issues on this. Radios purchased from ebay were sub standard quality. Purchased some that had the proper IC and components on the board. Plugged in and worked straight away. Thank you for all your assistance.
Regards
Laurie
Ok I have proven radios work, but not on the NodeMCU. I have put all gateway code back in and sensor code. I have attached as much information as I can. Anyone that can help would be much appreciated. Please see read me first file for extra details. I have run out of ideas, after 7 days of trying to resolve. Thanks to anyone's help6_1483727101339_serial sent from sensor.txt 5_1483727101339_serial from nodemcu 0.9.txt 4_1483727101339_sensor sketch nano V3.txt 3_1483727101338_PLEASE READ FIRST.txt 2_1483727101338_Nodemcu 0.9 eps8266 sketch.txt 1_1483727101338_mysensors_json in home assistant.txt 0_1483727101337_Home assistant log.txt
Hi mfalkvidd I really appreciate your time with this. Really strange whats happening here. I have loaded blink in both nano and Nodemcu. Both work. Modifications above compile and upload, but when looking at serial it looks like old sketches running. NodeMCU shows connection to my wifi for example. IDE says it loaded. Very frustrating.
Thanks again. . I want to go right back to basics here. I need to prove the hardware.
Can someone confirm the connections to a Nano V3 board and also to a Nodemcu 0.9. Having researched this it looks like different libraries have different pinouts. Not sure which one mysensors use. Also I have 22 microF caps. Is this right on the supply.
0_1483628888879_Compile error.txt
Not sure what happened there. Anyway installed on Nano V3 ok, but on nodemcu 0.9 would not compile with this call of overloaded 'set(long unsigned int)' is ambiguous. I have attached full compile error report generated
Thanks for the reply. I have been through the fault finding. added capacitors forst 4.7s then changed for 22's. Put Transceivers on seperate supply. Still no change. Now trying pingpong but will not compile on nanoV3 or nodemcu 0.9. both error on #include <MySensor.h> What am I missing here
Hi All, this is my first post, so before I start I would just like to say thank you to the mysensors team. Once I get this working I am sure it will be a great system.
I have built a wifi gateway as per instructions, which works with HA and a local sensor, but not with a radio node. Radio node sends but gets no reply from gateway. Is there an easy way to test the NRF24LO1+ transceivers. Thanks Laurie