@Digdogger it can depend on a lot of things. The best way to know is to look at the debug logs from the node and the gateway from the time when it happened. There could be a problem with the communication, with the radios, with the power supply, with the sketch, etc.

1-That's the only sketch behaving this way
2-Even the "IDE-automatic-opening-bracket-finder" (shows which bracket is open when placing cursor on closing bracket) can NOT find the right bracket for loop()...

Only one of these if statements will be active. The Arduino IDE probably doesn't evaluate preprocessing directives, so it sees two if statements and therefore thinks it should see two end braces. A way to "fix" this could be to move the starting curly brace to after the preprocessing directives:

There was a rather small note in the 2.0.0 changelog about the introduction of before().

Btw: Another functional routine (preHwInit() (?)) may have been introduced also with 2.1.1 (?). But until now, all of my sketches and tests got along without this preHwInit() functionality. But imo the new structure is pretty good: before() is helpfull to initialise SPI devices on same bus as nRF24 and to collect relevant info like the number of DS18x20, setup() is now also good to send info you only need once (e.g. the Dallas-Chip-ID).

The rest is - at least afaik - not really documented well, but most examples (if you use the updated ones) will work (apart from the DS18x20 example, where other - external - code changes made some parts tricky to use.

I made some working sketches for the Dallas Sensors some time ago based on some ideas I found here in the MySensors forum; they mostly should still work (exept for the change of getConfig() to getControllerConfig()). If you are interested: here .

The sketches in my repo have been updated yesterday for complete compability with the new structure and syntax. They compile fine and should work, but I didn't have the time to make functional tests also.
If anyone is interested, I could also add a multibus example with several Sensors at each bus and different timings for each bus. One of my nodes is working on this concept for several days now (Heizung, RS485 version), so I'm pretty confident this will reliably work for longer periods. But it's rather special .

Additionally: There is also a multibus version included that uses different timings for reading each of the buses.
For using this sketch, I'm not sure wheter some changes in the DallasTemperature-lib also is required (it is based on an very recent example of the maintainer's guthub version; should be linked in the Arduino Library Manager; I myself applied some changes wrt. this in my local libs).
I may aslo post this in case anyone's interested (and these mods are necessary).

@mfalkvidd Thx for your observation, I didn't realise that. Did you try to use this sketch also?
As FHEM is the controller sw I use, I am not able to really test this kind of behaviour, that more seemed to be related to domoticz (or other trouble wrt. to this individual MySensors-installation).

@Dick Imo, the node at least when trying to register behaves as necessary: it presents itself to the controller (but the chosen ID seems to be already bound to a different node). In FHEM - not for the node itself but for individual readings - it is necessary to reload the page to see updated readings, if it's the very first time they are sent from node's side (hope, you can follow my thoughts). Maybe domoticz shows a similar behaviour?

Imo, the only thing that is not standard is to also use a comment when presenting the individual temp-sensors:

present(i + DS_First_Child_ID, S_TEMP, charAddr);

FHEM doesn't care about that (just ignores this comment), but maybe other controllers don't like that at all. (I added this as it is a possible feature and may be helpful for others), but @Dick , you could try to delete the last argument.

@Dick Besides the inclusion mode, in FHEM one also has to activate a feature called "autocreate". Is there a comparable routine, and in case if: did you turn it on?
If you have a look in your domoticz log, there most likely appear further trials to register, or not?

@mfalkvidd For your info, I started the sketch cleareeprom to clear my Nano, loaded the script mentioned already and the log I posted is the same so the log must fit the sketch for the DallasTemperatureSimple. The repeater is activated or is it better to turn it off?

@mfalkvidd I changed the dalles lib with an older one, because in a disussion a wile ago it was advised to get it working. Now this modified Sketch is available I replaced the dalles lib again the latest one. For the rest nothing.

of the initial log you posted says that the node cannot sleep because it is a repeater.

This part of the sketch:

// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
sleep(conversionTime);

explains that if the node is a repeater, the sleep call must be replaced by wait. If it is not replaced, the temperature sensors will not be ready when getTemp... is called, so the node will not send any values. Domoticz only lists sensors that have sent a value.

Very strange.
I just mad the test and copied the code (out of your post above) to my IDE, compiled and uploaded: No problem, worked fine. Node gets registered by FHEM, sends ID once and Temp regularly as expected. For testing, I used just one DS18B20, but that shouldn't make any difference. (And MySensors lib version 2.2-beta, but that also shouldn't be an issue).

Btw: what kind of a GW you are using?
Recently, I came across a situation with a WiFi-GW that absolutely refused to accept new nodes. Using a serial one, everything was fine... Strange thing, too. (The GW itself was ok, there were several other nodes working without any communication problems. the new HW was also ok. Last, the channel was also correct, as all the existing nodes just switched over to the serial GW.... Reflashing that nasty thing also was no solution.)

I have been frustrated with this for weeks now. Today I notice that void loop is not closed with a curly brace and if I add one it does not compile.
So what black magic is going on here?

I have been trying to get sensor readings every 2 mins and battery every half hour. But whatever I try it still gives temp every minute and battery at once a minute too. No wonder my batteries are draining so fast.

@mfalkvidd said in Temperature Sensor:
Thank you very much for helping out with this! - I will try it today if I can. I guess I could use the same principle to send sensor data every 2 minutes instead of every 1 minute and further reduce battery draw. I know the DS18B20 sensors are correctly going into sleep mode, but the node itself is still using too much juice.

@skywatch doing what you want is a bit hard since millis won't update while the node is in power save mode (sleeping).

There is nothing in the API about this, would be nice if it were added as I don't think I will be the only person with such requirements. Also, what does sleep actually do and are there further things I could do to reduce the power use?

I don't understand why you're using interrupt to sleep though.

That is because I haven't finished this node yet.... I am working on it systematically and in future a water leak detector will be added. But only when this part is working correctly and I have good battery life from the node.

Also, what does sleep actually do and are there further things I could do to reduce the power use?

It does a lot of things, but basically it puts the radio and the Arduino in power save mode and uses the Arduino's watchdog timer to roughly keep track of time (exact timing is not possible because exact timing requires power, and power save mode is all about saving power).

I am using a pro mini 3.3v 8MHz. I would ideally like to get a 1MHZ bootloader onto it but the last try stopped the temperature sensors sending data (although battery levels were still sent!)..... Hope it helps.

Sorry for the dealy, I have had a week of plumbing problems at home - yuck!

So, I came back fresh to this and noticed that I had put the interrupt into the code ready for the water leak sensor (apt considering this weeks activities!) - BUT, I had not assigned the pin nor initialised it in the code. So maybe it was floating and giving random triggers?
I tested by changing from int8_t sleep(1, FALLING, SLEEP_TIME); to int8_t sleep(SLEEP_TIME); but now I get battery level sent every single second! - This is making me crazy......

is there any known problem / bug with version 2.1.* and the Dallas temp sensor? (I found non in the bug tracker and/or forum)

I updated several nodes from 1.5 to 2.1.1 and now no temp sensor is working. No temp sensor DS18B20 is found by the node, therefore -127.0 is returned to the controller. I checked the wiring - as illustrated in this manual, everything seems right; incl. the pull-up with 4,7 k. I use the modified version of the Dallas-Library included in the examples package, as stated out in this manual.

I am not a programmer, but trying to learn by making small projects.
I am trying to build a arduino/ESP8266 with temp sensor so that at a particular set temp it sends a single to another arduino/ESP8266 with relay to turn on a cooler/heater. if there is a thread on this, please help me find it.

Hi, I have few in wall nodes mounted under the light switches. I have two relays and one DS18B20 in each node. When i'm turning light on, switching the relay, the DS18B20 readings jumping about 0.8 degrees celsius up. When I switch off the relay readings back to normal. Anyone have similar problems ? Sensors are away from from node board, relays etc. so it's not about the heat from atmega or relays.

It's probably a voltage drop from the psu when the relay is engaged and drawing current. That will cause the output voltage to dip slightly.

If it is only momentary you can add a beefy capacitor across the power supply, but if the readings change for the whole time the relay is on, you really need to replace the relay with something that uses less power (triac/mosfet??) - Or get a more stable power supply with good regulation.

A final thing might be more noise on the power line with the psu sending more current with the relay on. again a smoothing capacitor would help if this were the case.

You could also try looking into the wiring and see if the relay cables and the ds18b20 cables are far enough apart, some induction might be going on there between the cables. Also, make sure everything goes back to a single ground point. I can't imagine how an earth loop would cause what you describe, but it's always a good thing to do.....

Another thought to think about is matbe the magnetic field from the relap power cables are inducing into the sensor cables.

Hi
Can we talk about redundancy please? What if one or more sensor fail on a one-wire bus? Would it make the whole line unusable?
As part of a central heating MySensorization i would like to have groups of 3 sensors and have some sort of redundancy check.
Would i be allowed to run multiple one-wire busses on a single arduino?
Thanks a lot foryour help

@mfalkvidd thanks a lot. Yes, that looks good to me. I will have a go.

The real big question now is about what happens when one or more sensor fails on the line.
I am not talking about removing a sensor, which doesn't produce any fault.
My concern is how does a DS18 ends its life under normal operation? Complete shortcut?

@ben999 I cannot remember WHERE I read it, but if a DS18B20 fails it will either send impossible results when addressed or fail to be addressed at all as it is digitally addressed. Only cable short circuits can pull the entire chain down, as I found out when two socket pins had crossed over (sensor crimped into telephone plugs).

And a "dead" sensor looses its bus address (next sensor on the chain takes its address and so on)

That's not exactly right. Each of the 1-wire devices uses a hardcoded, unique address that can not be changed.
So if you use the standard sketch with multiple DS18B20, in case of detached or replaced sensors you may get reported the measured temperatures comming from the same physical DS18B20 device under a different ChildID (after node reboot). To avoid effects like that, one has to take additional measures as described here . In short:

Use an array with the physical ID's to address them

Store a hash-array (done automatically) to identify "known" physical ID's that have once been attached to the bus as well as the ChildID used for MySensors.

Hi, I'm having a hard time getting this Temperatursensor to work with Home Assistant. When i start it it doesn't register with the HA. If I use the same hardware and switch out the sensor to a DHT sensor (new sketch of course) then it works out of the box, HA sees the sensor. I've tried changing the Dallas DS18B20, but nothing. If i look at the logs the gateway have no problem with the sensor. Is there something in the code for the sensor that doesn't add up to it being presented to HA in the right way? I'm quite the newbie when it comes to programming.

@gohan No I have not. I have a RF-Link also connected to the HA and it's working great. As I said, if I use the same hardware that I used to control the Dallas sensor and change the sensor to a DHT sensor the DHT sensor is accepted by HA and shows up as a sensor. That's why I was asking if there is something in the code for the Temperature sensor sketch that has to be changed to be able to present it to HA.