💬 Temperature Sensor
-
This thread contains comments for the article "Temperature Sensor" posted on MySensors.org.
-
Hi there, I'm new to Mysensors and I thought I'd start with a simple DS Temp sensor. However, I'm getting compile errors when I try compile it. Can someone please point me in the right direction?
Arduino: 1.6.11 (Windows 7), Board: "Arduino Nano, ATmega328" WARNING: Category 'Sensor' in library DallasTemperature is not valid. Setting to 'Uncategorized' In file included from C:\Users\Admin\Documents\Arduino\Projects\MS Temp sensor node\DallasTemperatureSensor\DallasTemperatureSensor.ino:37:0: C:\Users\Admin\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h: In function 'void loop()': C:\Users\Admin\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h:249:13: error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is private int16_t millisToWaitForConversion(uint8_t); ^ DallasTemperatureSensor:85: error: within this context int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); ^ Multiple libraries were found for "DallasTemperature.h" Used: C:\Users\Admin\Documents\Arduino\libraries\DallasTemperature Not used: C:\Users\Admin\Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master exit status 1 within this context This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. -
Ah, never mind! Managed to resolve it after all. For the benefit of others who may hit the same issue: the code depends on a very particular version of the DallasTemperature library, the versions downloaded via the Arduino IDE don't work and give the errors above. I had to download the library from the examples on github here: https://github.com/mysensors/MySensorsArduinoExamples
-
Ah, never mind! Managed to resolve it after all. For the benefit of others who may hit the same issue: the code depends on a very particular version of the DallasTemperature library, the versions downloaded via the Arduino IDE don't work and give the errors above. I had to download the library from the examples on github here: https://github.com/mysensors/MySensorsArduinoExamples
-
I have trouble with this on a NodeMCU 0.9.
#error "Please define I/O register types here"Anyone who can help?
-
I have trouble with this on a NodeMCU 0.9.
#error "Please define I/O register types here"Anyone who can help?
@Patrik-Söderström could you give us some more context about the problem?
Which line does the error occur on? Does the error message say anything more? (we are not magicians :-) )
Have you modified the example sketch in any way? if so, what changes? -
I use the following code, I have added the GW support for ESP board.
/** * 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 // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "TP54C10" #define MY_ESP8266_PASSWORD "blarretp54c10" // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 #include <ESP8266WiFi.h> #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 = 30000; // 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); }the exakt error I get in Arduino IDE is
In file included from C:\Users\xxxxx\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h:22:0, from Z:\MySensors\NodeMCU-Water meter\NodeMCU-Water_meter\NodeMCU-Water_meter.ino:51: C:\Users\xxxxxx\Documents\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here" #error "Please define I/O register types here" ^ exit status 1 Error compiling for board NodeMCU 0.9 (ESP-12 Module).``` -
I use the following code, I have added the GW support for ESP board.
/** * 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 // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "TP54C10" #define MY_ESP8266_PASSWORD "blarretp54c10" // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 #include <ESP8266WiFi.h> #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 = 30000; // 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); }the exakt error I get in Arduino IDE is
In file included from C:\Users\xxxxx\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h:22:0, from Z:\MySensors\NodeMCU-Water meter\NodeMCU-Water_meter\NodeMCU-Water_meter.ino:51: C:\Users\xxxxxx\Documents\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here" #error "Please define I/O register types here" ^ exit status 1 Error compiling for board NodeMCU 0.9 (ESP-12 Module).```@Patrik-Söderström according to http://www.esp8266.com/viewtopic.php?f=12&t=9430 you need a newer version of the onewire library.
-
Can anyone tell me what these errors say?
DallasTemperature.cpp:433: error: no 'int16_t DallasTemperature::calculateTemperature(const uint8_t*, uint8_t*)' member function declared in class 'DallasTemperature'
int16_t DallasTemperature::calculateTemperature(const uint8_t* deviceAddress, uint8_t* scratchPad){^sketch/DallasTemperature.cpp: In member function 'int16_t DallasTemperature::getTemp(const uint8_t*)':
DallasTemperature.cpp:484: error: 'calculateTemperature' was not declared in this scope
if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad);^sketch/DallasTemperature.cpp: In member function 'bool DallasTemperature::hasAlarm(const uint8_t*)':
DallasTemperature.cpp:764: error: 'calculateTemperature' was not declared in this scope
char temp = calculateTemperature(deviceAddress, scratchPad) >> 7;^exit status 1
no 'int16_t DallasTemperature::calculateTemperature(const uint8_t*, uint8_t*)' member function declared in class 'DallasTemperature' -
Hello mrwomble.
Could you detail the file you have use to compile OK ? Do we need to use the full library? I plan to use local file with
#include "filename.h"
instead of
#include <filename.h>
ThanksI confirm that i can suppress the compilation error but nothing append on serial port...
Could somebody write here the typical serial port output with debug available?
This example is not working. What is the good solution to use this temperature sensor ?
thanks
-
Why don't we use an internal pull-up resistor available within an arduino board? Why additional external one?
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors -
Why don't we use an internal pull-up resistor available within an arduino board? Why additional external one?
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors@Alex-B-Goode the datasheet says "The 1-Wire bus requires an external pullup resistor of approximately 5kΩ"
The internal pull-up of most Arduinos are 20-50kΩSo my guess is that the reason is that the person who created the instructions read the datasheet and chose to follow its recommendation. But accounding to http://electronics.stackexchange.com/a/62096/107155 the exact size might not be important, so it might be possible to use the internal pull up. Try it and let us know if it works.
-
Does this example compile for anyone??? I get this error:
In file included from /Users/Documents/Arduino/tas_temp/tas_temp.ino:37:0:
/Users/Documents/Arduino/libraries/DallasTemperature/DallasTemperature.h: In function 'void loop()':
/Users/Documents/Arduino/libraries/DallasTemperature/DallasTemperature.h:252:13: error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is private
int16_t millisToWaitForConversion(uint8_t);^tas_temp:85: error: within this context
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
^
exit status 1
within this context -
Does this example compile for anyone??? I get this error:
In file included from /Users/Documents/Arduino/tas_temp/tas_temp.ino:37:0:
/Users/Documents/Arduino/libraries/DallasTemperature/DallasTemperature.h: In function 'void loop()':
/Users/Documents/Arduino/libraries/DallasTemperature/DallasTemperature.h:252:13: error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is private
int16_t millisToWaitForConversion(uint8_t);^tas_temp:85: error: within this context
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
^
exit status 1
within this context -
@toddsantoro see post 2 and 3 in this thread or read the instructions on the build page, just under the "Example" heading.
@mfalkvidd said:
@toddsantoro see post 2 and 3 in this thread or read the instructions on the build page, just under the "Example" heading.
^ What he said 😁
-
@toddsantoro see post 2 and 3 in this thread or read the instructions on the build page, just under the "Example" heading.
@mfalkvidd OK. I have it compiling and uploaded to the nano. My config file looks like this now:
sensor 6: -platform: onewire names: some_id: outside mount_dir: "/mnt/1wire"I get an error when I restart HASS on the Pi.
ERROR (Thread-6) [homeassistant.components.sensor.onewire] No onewire sensor found. Check if dtoverlay=w1-gpio is in your /boot/config.txt. Check the mount_dir parameter if it's defined.I guess my question is do I need to define the mount_dir variable and if so is the one I have correct? And if it is correct do I need to create that directory on my Pi?
I also do not get any output in the Arduino Serial Monitor window. Not sure if I even should...
Thanks in advance for any help...
-
@mfalkvidd OK. I have it compiling and uploaded to the nano. My config file looks like this now:
sensor 6: -platform: onewire names: some_id: outside mount_dir: "/mnt/1wire"I get an error when I restart HASS on the Pi.
ERROR (Thread-6) [homeassistant.components.sensor.onewire] No onewire sensor found. Check if dtoverlay=w1-gpio is in your /boot/config.txt. Check the mount_dir parameter if it's defined.I guess my question is do I need to define the mount_dir variable and if so is the one I have correct? And if it is correct do I need to create that directory on my Pi?
I also do not get any output in the Arduino Serial Monitor window. Not sure if I even should...
Thanks in advance for any help...
@toddsantoro I am not familiar with homeassistant so I have no clue unfortunately.
About debug output on the serial monitor: Debug needs to be enabled first. See instructions at https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help and https://www.mysensors.org/build/debug
Debug output is often essential when troubleshooting.
-
@toddsantoro I am not familiar with homeassistant so I have no clue unfortunately.
About debug output on the serial monitor: Debug needs to be enabled first. See instructions at https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help and https://www.mysensors.org/build/debug
Debug output is often essential when troubleshooting.
@mfalkvidd Thank you!!! I get this output in the serial monitor
TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=2) TSM:FPAR TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:PAR OK (ID=0, dist=1) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=2) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:MSG:READ 0-0-2 s=255,c=3,t=25,pt=1,l=1,sg=0:1 TSP:MSG:PONG RECV (hops=1) TSP:CHKUPL:OK TSM:UPL:OK TSM:READY TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100 TSP:MSG:SEND 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0 TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0 TSP:MSG:READ 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:I TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=11,pt=0,l=18,sg=0,ft=0,st=ok:Temperature Sensor TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.1 Request registration... TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2 TSP:MSG:READ 0-0-2 s=255,c=3,t=27,pt=1,l=1,sg=0:1 Node registration=1 Init complete, id=2, parent=0, distance=1, registration=1Does this look OK? If so I will ask my previous question on the Home Assistant forum. You have been a great help and once I get one of these things down I will be able to help others:)
-
@mfalkvidd Thank you!!! I get this output in the serial monitor
TSM:INIT TSM:RADIO:OK TSP:ASSIGNID:OK (ID=2) TSM:FPAR TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSM:FPAR TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSP:MSG:FPAR RES (ID=0, dist=0) TSP:MSG:PAR OK (ID=0, dist=1) TSM:FPAR:OK TSM:ID TSM:CHKID:OK (ID=2) TSM:UPL TSP:PING:SEND (dest=0) TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1 TSP:MSG:READ 0-0-2 s=255,c=3,t=25,pt=1,l=1,sg=0:1 TSP:MSG:PONG RECV (hops=1) TSP:CHKUPL:OK TSM:UPL:OK TSM:READY TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100 TSP:MSG:SEND 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0 TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0 TSP:MSG:READ 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:I TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=11,pt=0,l=18,sg=0,ft=0,st=ok:Temperature Sensor TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.1 Request registration... TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2 TSP:MSG:READ 0-0-2 s=255,c=3,t=27,pt=1,l=1,sg=0:1 Node registration=1 Init complete, id=2, parent=0, distance=1, registration=1Does this look OK? If so I will ask my previous question on the Home Assistant forum. You have been a great help and once I get one of these things down I will be able to help others:)