kisa
Junior Member
Posts: 54
|
Post by kisa on Jun 17, 2018 6:30:22 GMT
Hi,
I encountered a few issues with using the DS18B20, Celsius and computourist_node_v2.2MhC_choices_pub.
First, when I choose to uncomment CELS as well as DS18 and DS18B and compile it I get a the following compile error:-
C:\Users\username\Documents\Arduino\computourist_node_v2\CURRENT_TEMP_NODE50_computourist_node_v2.ino: In function 'void sendMsg()':
computourist_node_v2:2201: error: 'TempFactor' was not declared in this scope
TempFactor = 1+((temp-20)*.00395); // temperature correcting multiplying factor for soil moisture
^
exit status 1 'TempFactor' was not declared in this scope
I corrected this by adding the float variable 'TempFactor".
After doing this it compiled fine, but it only returned a temp value of 85.00.
Following that I also found I was required to change "temp = sensors.getTempCByIndex(1);" to "temp = sensors.getTempCByIndex(0);" in this:-
#ifdef DS18B // Papa: DS18, 2nd position digitalWrite(DS18power, HIGH); // battery or not, power DS18 sensor DSdelay; // settle the sensor #ifdef CELS temp = sensors.getTempCByIndex(1); // Papa: Celsius TempFactor = 1+((temp-20)*.00395); // temperature correcting multiplying factor for soil moisture #endif
I'm also finding that I'm getting 85.00 reading when I use the power control line (D5), but after about 3 attempts (sometimes never) it finally gets the right temperature and keeps reading it correctly from then on. If I tie that line to high it shows the correct temperature straight away. I am using a 3.3v Moteino, so maybe the data lines are struggling to pull the DS power line high enough?
I'm not sure is this is an issue with computourist_node_v2.2MhC_choices_pub or if I've done something wrong, but certainly happy to hear either way.
|
|
|
Post by papa on Jun 17, 2018 14:49:29 GMT
kisa: exit status 1 'TempFactor' was not declared in this scope
Read this post AND the next post to the end before you do anything with them.
kisa, for the moment, I'll address this part of your post. You found an error, part of the risks of putting so many nodes in one sketch. Maybe I can do some teaching here to help you find & correct sketch errors in the future: Use the Arduino IDE's find function to search for all instances of TempFactor The first instance is line 337 float TempFactor = 1; which is where the TempFactor variable is declared BUT look at line 332 #ifdef SOILMOIST & line 338 #endif // ifdef SOILMOIST. 332 & 338 mean that TempFactor & the other variables are NOT declared unless one uncomments // #define SOILMOIST earlier in the sketch. You don't need the SOILMOIST functions except for the DS18 temp sensor & since SOILMOIST was not defined, you get the not declared error. One possible solution ( not the optimum) is to find other TempFactor lines AFTER 337 & make sure you have #ifdef SOILMOIST before those lines & #endif // ifdef SOILMOIST after them. For example ... Line 1153 has been TempFactor = 1+((temp-20)*.00395); // temperature correcting multiplying factor for soil moisture You could instead have 3 lines, 1153-1155: #ifdef SOILMOIST TempFactor = 1+((temp-20)*.00395); // temperature correcting multiplying factor for soil moisture #endif // ifdef SOILMOIST Next, ?? A Better Solution to the Sketch Error ??
|
|
|
Post by papa on Jun 17, 2018 19:32:49 GMT
?? A Better Solution for the Sketch Error ??
The solution in the last post would add much clutter for a variable that is only used at line 2328: mes.intVal = mes.intVal * TempFactor; // temperature correct the soil moisture I believe a better solution is to delete these TempFactor lines: 2152, 2157, 2200, 2205 & use their calculations near 2328 as controlled by some #defines. (The line 2328 area is already a SOILMOIST section.) Lines 2327-2329 have been: #ifdef DS18 // We have soil temp & can correct for it mes.intVal = mes.intVal * TempFactor; // temperature correct the soil moisture #endif But we could expand 2327-2329 to be: #ifdef DS18 // We have temp & can use it to correct data based on resistance #ifdef CELS TempFactor = 1+((temp-20)*.00395); // temperature correcting multiplying factor for soil moisture, CELS #endif // ifdef CELS #ifdef FAHR TempFactor = 1+((((temp-32)* .5556)-20)*.00395); // temperature correcting ..., FAHR #endif // ifdef FAHR mes.intVal = mes.intVal * TempFactor; // temperature correct the soil moisture #endif // ifdef DS18 computourist_node_v2.2MhD_choices_pub.ino (107.79 KB) << I believe I've made these changes in this new version of the Choices Sketch. Next: Test Results on Correcting the Sketch Error
|
|
|
Post by papa on Jun 17, 2018 19:42:16 GMT
Test Results on Correcting the Sketch Error
Testing compiles of the new sketch version:
With the sketch in the previous post, I customized radio frequency & NODEID 50. 1) I uncommented: #define DS18 & #define DS18B. I alternated uncommenting: #define FAHR & #define CELS << This all compiled without error.
2) I added uncommenting: #define HT << compiled without error.
I added uncommenting: #SOILMOIST << compiled without error.
=======================================
I uploaded the various versions of 1) & 2) above. The resulting nodes all compiled without error AND output expected temp data to the Arduino IDE Serial Monitor.
With the following OpenHAB config entries, the nodes reported temp data to an OpenHAB User Interface:
.items Number TempProbe_Node50 "Probe50 [%.1f °F]" <temperature> {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev50:state:default]"}
.sitemap
Text item=TempProbe_Node50 =====================================================================
Thanks kisa, for finding & reporting the error.
I will post the above Node Choices sketch with the thread on building one's first RFM69 network.
|
|
|
Post by papa on Jun 17, 2018 23:55:12 GMT
kisa: I'm also finding that I'm getting 85.00 reading when I use the power control line (D5), but after about 3 attempts (sometimes never) it finally gets the right temperature and keeps reading it correctly from then on. If I tie that line to high it shows the correct temperature straight away. I am using a 3.3v Moteino, so maybe the data lines are struggling to pull the DS power line high enough? I'm not sure is this is an issue with computourist_node_v2.2MhC_choices_pub or if I've done something wrong, but certainly happy to hear either way. =============================================== kisa: ... when I use the power control line (D5) ...
papa: What you describe is typical ...
(Line numbers refer to computourist_node_v2.2Mh D_choices_pub) Are you trying to use the SLEEPY functions (sleep & help save battery power) with the DS18 probe? Are you wiring the DS18 VCC line to Arduino pin D5 & then turning D5 off & on to power & unpower the temperature probe? I allowed for that possibility around lines 2193-2206, but in this post's schematic, I wired the DS18 VCC line straight to 3.3 volts so I may have found (I don't remember) that turning power on & off via D5 was not reliable. Typically in situations like this one turns on power & then uses a delay to let power stabilize before doing a temperature read. Line 656 [#define DSdelay delay(300);] sets a delay of .3 second. Line 2195 implements the delay before temperature is read. You could try increasing the DSdelay variable above 300 which may help temp reading reliability.
|
|
kisa
Junior Member
Posts: 54
|
Post by kisa on Jun 18, 2018 8:03:02 GMT
Thanks again papa. I did previously follow all the code you mentioned including the tie to #SOILMOIST and assumed using a standard DS18 by itself may have been missed. My solution was to simply declare TempFactor as a float with all the other variables. Is there any issue with just doing that? It compiled fine doing it that way. I haven't tested but there may be an issue with a double declaration if #SOILMOIST is used as well, but that could be easily fixed by not declaring it in there. I tries D5 with both SLEEPY and without SLEEPY and both cases gave the same issue. I also tried increasing DSdelay up to 1000, but that didn't make any difference either. I do intend to use SLEEPY on a number of my temperature sensors (not all of them), so I'll experiment further with them once I build them. I don't mind the delay in them working eventually, the plan is to do the measuring for over a year or more, so missing the first dozen or so readings wont hurt .
|
|
|
Post by papa on Jun 18, 2018 14:27:42 GMT
kisa: "My solution was to simply declare TempFactor as a float with all the other variables. Is there any issue with just doing that?"
papa: No big deal. Doing it your way gets the job done, but will use some variable memory that you don't need. I also believe my "better" solution will be easier to see what variables go with what node options.
kisa: "I tried D5 with both SLEEPY and without SLEEPY and both cases gave the same issue. I also tried increasing DSdelay up to 1000, but that didn't make any difference either. I do intend to use SLEEPY on a number of my temperature sensors (not all of them), so I'll experiment further with them once I build them. I don't mind the delay in them working eventually, the plan is to do the measuring for over a year or more, so missing the first dozen or so readings wont hurt"
papa: You're really diving into this DIY Home Automation stuff. Your perspective & approach on the DS18 & SLEEPY seems reasonable to me. What you said earlier ("I am using a 3.3v Moteino, so maybe the data lines are struggling to pull the DS power line high enough") may be a factor. I've used the DS18 sensor with a Buono Uno, not a Anarduino Miniwireless or a Moteino & the Buono typically provides more current than other compatibles.
|
|
kisa
Junior Member
Posts: 54
|
Post by kisa on Jun 18, 2018 23:48:46 GMT
Your way is more tidy and efficient, I'll go that way to keep it all consistent .
|
|