Dallas DS18B20 temperate sensor
-
Hello
This is my first project with a Ds18B20 an arduino mega as that is what I had to hand as a test as well as a nrf24l01 radio. This is all being transmitted to a raspberry pi gateway with a nrf24l01 with the eventual plan to link to hass io.
I am unfortunately stuck with making sure the value is transmitted to the raspberry pi. I am using the code detailed here [https://www.mysensors.org/build/temp] (https://www.mysensors.org/build/temp)
I have added the extra definitions needed for the mega and connected the radio as per [https://www.mysensors.org/build/connect_radio] (https://www.mysensors.org/build/connect_radio)
This is the debug message from my raspberry pi, I tried using the log parser but it was not clear what the sensor output was and if this was right. Please could someone help me as to if this is right?
TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:SRT:OK TSM:READY:NWD REQ ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: TSF:SAN:OK TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:PNG:SEND,TO=0 TSF:CKU:OK TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: TSF:MSG:BC TSF:MSG:FPAR REQ,ID=3 TSF:CKU:OK,FCTRL TSF:MSG:GWL OK !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
Thanks in advance
-
Welcome to the forum @Jenkins
Are you sure this log is from the Raspberry Pi gateway? It looks like a node log.
-
Hello @mfalkvidd
Thanks for the reply, I reread the instructions https://www.mysensors.org/build/raspberry and ran the following commands.
git clone https://github.com/mysensors/MySensors.git --branch development cd MySensors
The choice of these commands was based on wanting to use the raspberry py to recive information on the nrf24l01 chip and share it on an ethernet gateway.
./configure --my-transport=rf24 --my-gateway=ethernet --my-port=5003
make
sudo ./bin/mysgw
This was the output I got with the sensor on the arduio already on and running the code.
Apr 03 19:23:36 ERROR Failed to open log pipe. Apr 03 19:23:36 INFO Starting gateway... Apr 03 19:23:36 INFO Protocol version - 2.4.0-alpha Apr 03 19:23:36 DEBUG MCO:BGN:INIT GW,CP=RNNGL---,FQ=NA,REL=0,VER=2.4.0-alpha Apr 03 19:23:36 DEBUG TSF:LRT:OK Apr 03 19:23:36 DEBUG TSM:INIT Apr 03 19:23:36 DEBUG TSF:WUR:MS=0 Apr 03 19:23:36 DEBUG TSM:INIT:TSP OK Apr 03 19:23:36 DEBUG TSM:INIT:GW MODE Apr 03 19:23:36 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Apr 03 19:23:36 DEBUG MCO:REG:NOT NEEDED Apr 03 19:23:36 DEBUG Listening for connections on :5003 Apr 03 19:23:36 DEBUG MCO:BGN:STP Apr 03 19:23:36 DEBUG MCO:BGN:INIT OK,TSP=1 Apr 03 19:23:36 DEBUG TSM:READY:NWD REQ Apr 03 19:23:36 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Apr 03 19:23:57 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:23:57 DEBUG TSF:MSG:BC Apr 03 19:23:57 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:23:57 DEBUG TSF:PNG:SEND,TO=0 Apr 03 19:23:57 DEBUG TSF:CKU:OK Apr 03 19:23:57 DEBUG TSF:MSG:GWL OK Apr 03 19:23:58 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:23:59 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:23:59 DEBUG TSF:MSG:BC Apr 03 19:23:59 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:23:59 DEBUG TSF:CKU:OK,FCTRL Apr 03 19:23:59 DEBUG TSF:MSG:GWL OK Apr 03 19:24:00 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:24:53 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:24:53 DEBUG TSF:MSG:BC Apr 03 19:24:53 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:24:53 DEBUG TSF:PNG:SEND,TO=0 Apr 03 19:24:53 DEBUG TSF:CKU:OK Apr 03 19:24:53 DEBUG TSF:MSG:GWL OK Apr 03 19:24:53 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:24:53 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:24:53 DEBUG TSF:MSG:BC Apr 03 19:24:53 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:24:53 DEBUG TSF:CKU:OK,FCTRL Apr 03 19:24:53 DEBUG TSF:MSG:GWL OK Apr 03 19:24:54 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:25:18 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:25:18 DEBUG TSF:MSG:BC Apr 03 19:25:18 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:25:18 DEBUG TSF:PNG:SEND,TO=0 Apr 03 19:25:18 DEBUG TSF:CKU:OK Apr 03 19:25:18 DEBUG TSF:MSG:GWL OK Apr 03 19:25:19 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:25:19 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:25:19 DEBUG TSF:MSG:BC Apr 03 19:25:19 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:25:19 DEBUG TSF:CKU:OK,FCTRL Apr 03 19:25:19 DEBUG TSF:MSG:GWL OK Apr 03 19:25:20 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:25:43 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:25:43 DEBUG TSF:MSG:BC Apr 03 19:25:43 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:25:43 DEBUG TSF:PNG:SEND,TO=0 Apr 03 19:25:43 DEBUG TSF:CKU:OK Apr 03 19:25:43 DEBUG TSF:MSG:GWL OK Apr 03 19:25:43 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 03 19:26:08 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:26:08 DEBUG TSF:MSG:BC Apr 03 19:26:08 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:26:08 DEBUG TSF:PNG:SEND,TO=0 Apr 03 19:26:08 DEBUG TSF:CKU:OK Apr 03 19:26:08 DEBUG TSF:MSG:GWL OK Apr 03 19:26:08 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
The code on the arduino is as below
/** * 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_RF24 //#define MY_RADIO_RFM69 #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 #define MY_RF24_CE_PIN 49 #define MY_RF24_CS_PIN 53 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(); // start serial port //Serial.begin(9600); //Serial.println("Dallas Temperature IC Control Library Demo"); // 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); }
Does this all look ok? I feel like I missed something as the output above looks similar still. If it makes any difference I am using a raspberry PI 4 runnning buster.
I will continue to also read other posts to see if I can find my error. Thank you for your help.
-
Sorry, my bad. It is clearly a gateway log.
Apr 03 19:23:57 DEBUG TSF:MSG:READ,3-3-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 03 19:23:57 DEBUG TSF:MSG:BC Apr 03 19:23:57 DEBUG TSF:MSG:FPAR REQ,ID=3 Apr 03 19:23:57 DEBUG TSF:PNG:SEND,TO=0 Apr 03 19:23:57 DEBUG TSF:CKU:OK Apr 03 19:23:57 DEBUG TSF:MSG:GWL OK Apr 03 19:23:58 DEBUG !TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
The first line here shows that the gateway received a message from node 3.
The message is a Find Parent request, which means node 3 is asking for the gateway.
The last line is the gateway sending a response. The ! before TSF and the st=NACK means that the gateway sent the message, but the gateway did not receive acknowledgement from the node that the node received the reply.The most common cause is unstable power supply. What capacitor(s) are you using? (On the Raspberry and on the node). How is the nrf powered on the node?
If you haven't already, see https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help/ for the most common problems and how to troubleshoot them efficiently.
-
Hello
Before my post was approved last night I did realise I was missing capacitors on the rf24 modules. The node has the rf24 module powered from the 3.3v pin of the arduino mega. The raspberry pi gpio 3.3v is powering the other rf24. I have ordered some capacitors so will see if that helps when they arrive sometime next week.
Thanks for the help
-
Hello,
The Capacitors took a lot longer than they should due to the post being slow at the moment. But I think it now works, here is a trace do you agree?
pi@RASPINAS:~ $ sudo /usr/local/bin/mysgw Apr 14 14:01:03 INFO Starting gateway... Apr 14 14:01:03 INFO Protocol version - 2.4.0-alpha Apr 14 14:01:03 DEBUG MCO:BGN:INIT GW,CP=RNNGL---,FQ=NA,REL=0,VER=2.4.0-alpha Apr 14 14:01:03 DEBUG TSF:LRT:OK Apr 14 14:01:03 DEBUG TSM:INIT Apr 14 14:01:03 DEBUG TSF:WUR:MS=0 Apr 14 14:01:03 DEBUG TSM:INIT:TSP OK Apr 14 14:01:03 DEBUG TSM:INIT:GW MODE Apr 14 14:01:03 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Apr 14 14:01:03 DEBUG MCO:REG:NOT NEEDED Apr 14 14:01:03 DEBUG Listening for connections on ���:5003 Apr 14 14:01:03 DEBUG MCO:BGN:STP Apr 14 14:01:03 DEBUG MCO:BGN:INIT OK,TSP=1 Apr 14 14:01:03 DEBUG TSM:READY:NWD REQ Apr 14 14:01:03 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Apr 14 14:01:11 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 14 14:01:11 DEBUG TSF:MSG:BC Apr 14 14:01:11 DEBUG TSF:MSG:FPAR REQ,ID=2 Apr 14 14:01:11 DEBUG TSF:CKU:OK,FCTRL Apr 14 14:01:11 DEBUG TSF:MSG:GWL OK Apr 14 14:01:12 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Apr 14 14:01:13 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Apr 14 14:01:13 DEBUG TSF:MSG:BC Apr 14 14:01:13 DEBUG TSF:MSG:FPAR REQ,ID=2 Apr 14 14:01:13 DEBUG TSF:CKU:OK,FCTRL Apr 14 14:01:13 DEBUG TSF:MSG:GWL OK Apr 14 14:01:14 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0 Apr 14 14:01:15 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 Apr 14 14:01:15 DEBUG TSF:MSG:PINGED,ID=2,HP=1 Apr 14 14:01:15 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1 Apr 14 14:01:15 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 Apr 14 14:01:15 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 Apr 14 14:01:15 DEBUG TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2 Apr 14 14:01:15 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 Apr 14 14:01:17 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=18,sg=0:Temperature Sensor Apr 14 14:01:17 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.1 Apr 14 14:01:17 DEBUG TSF:MSG:READ,2-2-0,s=0,c=0,t=6,pt=0,l=0,sg=0: Apr 14 14:01:17 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 Apr 14 14:01:17 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1 Apr 14 14:01:18 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=0,pt=7,l=5,sg=0:25.0 Apr 14 14:01:48 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=0,pt=7,l=5,sg=0:21.5 Apr 14 14:16:03 DEBUG TSF:SAN:OK Apr 14 14:21:03 DEBUG TSM:READY:NWD REQ Apr 14 14:21:03 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
Thank you
-
@Jenkins yes that looks good. st=OK means the next node acknowledged the message.
-
@mfalkvidd thank you for all your help