DS18B20 Sketch from Examples doesn't brings Node to sleep.
-
Hi, the 1.1 Sketch doesn't brings the Node to sleep with 2.0.1-beta.
Anyone else is having this problem?I have two nodes and both having this issue
-
What type of hardware?
-
Arduino Pro Mini with NRF24L01+...
It Works great with the "old" 2.0.0 beta.
-
Any Ideas, why it is not working with new 2.0.1-beta?
-
Could you post more infos plz ?
- your sketch even if it's the original
- which lib you're using for onewire
- enable MY_DEBUG in sketch and post the logs
-
DEBUG: 0 MCO:BGN:INIT REPEATER,CP=RNNRA--,VER=2.0.1-beta 4 MCO:BGN:BFR 65 TSM:INIT 73 TSM:INIT:TSP OK 75 TSM:INIT:STATID=2 77 TSF:SID:OK,ID=2 79 TSM:FPAR 114 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 227 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0 233 TSF:MSG:FPAR OK,ID=0,D=1 2123 TSM:FPAR:OK 2123 TSM:ID 2125 TSM:ID:OK 2127 TSM:UPL 2134 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 2156 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1 2162 TSF:MSG:PONG RECV,HP=1 2164 TSM:UPL:OK 2166 TSM:READY 2170 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 2181 TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=18,pt=0,l=10,sg=0,ft=0,st=OK:2.0.1-beta 2191 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 2197 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 4208 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=11,pt=0,l=18,sg=0,ft=0,st=OK:Temperature Sensor 4225 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.1 4235 TSF:MSG:SEND,2-2-0-0,s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=OK: 4241 MCO:REG:REQ 4245 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 4263 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1 4270 MCO:PIM:NODE REG=1 4274 MCO:BGN:STP 4276 MCO:BGN:INIT OK,ID=2,PAR=0,DIS=1,REG=1 4282 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 4288 !MCO:SLP:REP 5070 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:19.0 5079 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 5085 !MCO:SLP:REP 65089 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 65095 !MCO:SLP:REP 65875 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:18.7 65884 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 65890 !MCO:SLP:REP``` SKETCH: /** * 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 #define MY_NODE_ID 2 #define MY_REPEATER_FEATURE Disabled // 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 2 unsigned long SLEEP_TIME = 60000; // 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>((getConfig().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); }
...and the Onewire Library from: Mysensors Libraries @GitHub
-
@Floca Your node is defined as repeater, and repeaters do not sleep by definition:
See log:
65890 !MCO:SLP:REP
To disable repeater mode, comment this line (writing "Disabled" won't work):
#define MY_REPEATER_FEATURE Disabled