xrist100 0 Posted March 8, 2015 Share Posted March 8, 2015 Hi all. I'm using the GFDS18B20V2 sketch and code works with no problem on MSP-EXP430F5529LP and CC3100BP. I've added some code to read the mac address and print it in the serial monitor. After the call to sprintf i'm getting two results from the sensor. // StellarisOW // Have used arrays to hold retrieved information, so that it can be easily addressed by your code // This sketch plus StellarisDS18B20.h will run as is on 430 & Stellaris LaunchPads // Do a reset to view the One Wire ROM addresses. Have Fun. // Grant Forest 29 Jan 2013. // Had confusion with library names. Lib now called GFDS18B20 // GF 6 Feb 2913 cleaned up a bit of code. //#include <StellarisDS18B20.h> #include <GFDS18B20.h> #include <SPI.h> #include <WiFi.h> #define OWPIN P6_5 //11 #define MAXOW 1 //Max number of OW's used byte ROMarray[MAXOW][8]; byte ROMtype[MAXOW]; // 28 for temp', 12 for switch etc. byte ROMtemp[MAXOW]; byte result[MAXOW+5]; byte data[12]; byte i; byte addr[8]; uint8_t ROMmax=0; uint8_t ROMcount=0; boolean foundOW =false; char macAddr[6]; byte mac[6]; int test = 0; DS18B20 ds(OWPIN); // currently on PIN 11 void setup(void) { Serial.begin(9600); delay(500); Serial.print("G'day StellarisOW\n"); findOW(); displayOW(); } void loop(void) { tempCMD(); for (i=1; i<ROMmax+1;i++){ if (ROMtype[i]==0x28) { readOW(i); saveTemperature(i); } } for (i=1;i<ROMmax+1;i++){ if (ROMtype[i]==0x28) { foundOW=true; Serial.print("OW"); Serial.print(i); Serial.print("="); Serial.print(result[i]); Serial.print("C "); } } if (foundOW) Serial.println(); if ((test > 5) & (test < 15)) { WiFi.macAddress(mac); sprintf(macAddr, "%02x:%02x:%02x:%02x:%02x:%02x", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]); Serial.println(macAddr); } test++; delay(4000); } void tempCMD(void){ //Send a global temperature convert command ds.reset(); ds.write_byte(0xcc); // was ds.select(work); so request all OW's to do next command ds.write_byte(0x44); // start conversion, with parasite power on at the end delay(1000); } void saveTemperature(uint8_t ROMno){ int32_t newtemp32; uint8_t i; newtemp32=data[1]<<8; newtemp32=newtemp32+data[0]>>4; result[ROMno]=byte(newtemp32); i=(data[0] & 0x0F)* 625/1000; if (i>=5) result[ROMno]++; } void readOW(uint8_t ROMno) { uint8_t i; ds.reset(); ds.select(ROMarray[ROMno]); ds.write_byte(0xBE); // Read Scratchpad for ( i = 0; i < 9; i++) { // need 9 bytes data[i] = ds.read_byte(); #if TEST if (data[i]<16) Serial.print("0"); Serial.print(data[i], HEX); Serial.print(" "); #endif } } void findOW(void) { byte addr[8]; uint8_t i; ROMmax=0; /////////////////////////////////////////////////////// while (true){ //get all the OW addresses on the buss i= ds.search(addr); if ( i<10) { Serial.print("ret=("); Serial.print(i); Serial.print(") No more addresses.\n"); ds.reset_search(); delay(500); return; } Serial.print("R="); for( i = 0; i < 8; i++) { if (i==0) ROMtype[ROMmax+1]=addr[i]; // store the device type ROMarray[ROMmax+1][i]=addr[i]; if (addr[i]<16) Serial.print("0"); Serial.print(addr[i], HEX); Serial.print(" "); } ROMmax++; Serial.print ("\t(OW"); Serial.print (ROMmax,HEX); Serial.print (") Type="); Serial.println (ROMtype[ROMmax],HEX); } } void displayOW(void) { uint8_t i; Serial.println ("From array"); for (ROMcount=1; ROMcount<ROMmax+1; ROMcount++) { ds.reset(); for( i = 0; i < 8; i++) { if (ROMarray[ROMcount][i]<16) Serial.print("0"); Serial.print( ROMarray[ROMcount][i], HEX); Serial.print(" "); } Serial.println(""); } } Regards, Vasilis. Quote Link to post Share on other sites
Marvi 1 Posted March 20, 2015 Share Posted March 20, 2015 I built thermocouple measurement board with MAX31850. Anyone, who are programing library for 1-wire reading? Do you have any progress with it? I will be very happy, if you respond me. Thank you very much. Quote Link to post Share on other sites
zeke 693 Posted March 20, 2015 Share Posted March 20, 2015 @@Marvi, Have you started talking to the sensor yet? Have you gotten anything back from the sensor? It should be a simple matter of reading the data from the sensor then computing the corresponding result. I'm in the middle of designing the PCB for a MAX31850K device so I haven't written any code just yet. The family code is 0x3B. Here is the datasheet for the MAX31859. On page 13, it describes the temperature data format. This explains how to convert the hex value into a floating point number. On page 15, it describes the transaction sequence required to talk with the sensor. On page 22, Table 6 describes the steps to complete an example operation with the sensor. @bluehash: We should probably create a new thread for each new one wire sensor. Quote Link to post Share on other sites
lmaafternoon 0 Posted April 18, 2015 Share Posted April 18, 2015 I have noticed that temperatures below zero are shown as positive numbers e.g. 253 or 255. It is library's bug or I am doing something wrong ? Thank you. Sent from my iPhone using Tapatalk Quote Link to post Share on other sites
zeke 693 Posted April 18, 2015 Share Posted April 18, 2015 @@lmaafternoon, Yes, you are doing something wrong but we need more information to troubleshoot successfully. Please tell us: Which LaunchPad you are using? Which One Wire sensor you are using? ie: DS18B20, DS18S20, MAX31859, etc What code are you using? ie: Energia or C Have you read the datasheet for your sensor? Anything else you would like to share? In the meantime, here's my guess: If you are using a DS18B20 sensor then you will have to test to see if Bits[11..15] are positive. If they are then the temperature is a negative value and the conversion math is affected. This is explained on page 3 and 4 of the DS18B20 datasheet. Note: I an not an Energia user. I program in C and my answer comes from that point of view. By the way, I recommend starting a new thread for this troubleshooting exercise. Quote Link to post Share on other sites
lmaafternoon 0 Posted April 19, 2015 Share Posted April 19, 2015 Hello ! Sorry for not providing any information. I'm using Energia 14 and the example code provided with the library. The sensor is the DS18B20. The launchpad is the F5529. I'll read the datasheet and the library's code and post any update. Thank you for you help. Sent from my iPhone using Tapatalk Quote Link to post Share on other sites
johnrdorazio 0 Posted April 23, 2015 Share Posted April 23, 2015 I have just found this thread, I also am needing to use a DS18S20 sensor with the OneWire library. I can use the OneWire library by Paul Stoeffregen without any problem in Arduino. I tried to download the library attached here http://forum.43oh.com/topic/3314-energia-library-onewire-ds18b20-430-stellaris/#entry29813 But Energia 0015 will not start, I receive an error saying that the application cannot be launched. As soon as I delete the library, Energia launches again just fine. I believe there is some kind of incompatibility with the latest Energia version? EDIT: I see the problem was simply that the example folder cannot be included with the library as is, this will block the application. Removing the example folder let me use the library nicely on an MSP430G2553. Quote Link to post Share on other sites
MarkV 0 Posted July 30, 2015 Share Posted July 30, 2015 I tried the StellarisDS18B20 lib and example on a CC3200 launchPad and sometimes it does not find the type 28 device and hangs and the results have frequent 0's and some occational out of range high number. Is there a more accurate/robust lib i should use on the cc3200 launchpad? G'day StellarisOW ROM=11 00 00 00 70 00 00 00 (OW1) Type=11 ROM=28 1C 97 F1 05 00 00 15 (OW2) Type=28 No more addresses. From array 11 00 00 00 70 00 00 00 28 1C 97 F1 05 00 00 15 OW2=F OW2=F OW2=75F OW2=185F OW2=F OW2=75F OW2=F OW2=75F OW2=75F OW2=F Quote Link to post Share on other sites
cadrjr 0 Posted December 1, 2015 Share Posted December 1, 2015 Anybody got the DS18B20 working on CC3200 ? I tried the StellarisDS18B20 lib and example on a CC3200 launchPad and sometimes it does not find the type 28 device and hangs and the results have frequent 0's and some occational out of range high number. Is there a more accurate/robust lib i should use on the cc3200 launchpad? G'day StellarisOW ROM=11 00 00 00 70 00 00 00 (OW1) Type=11 ROM=28 1C 97 F1 05 00 00 15 (OW2) Type=28 No more addresses. From array 11 00 00 00 70 00 00 00 28 1C 97 F1 05 00 00 15 OW2=F OW2=F OW2=75F OW2=185F OW2=F OW2=75F OW2=F OW2=75F OW2=75F OW2=F Quote Link to post Share on other sites
bakey 3 Posted May 9, 2016 Share Posted May 9, 2016 Got the lib working on my tm4c 1294 launchpad. Tx for the library. Quote Link to post Share on other sites
grandholosin 0 Posted January 15, 2018 Share Posted January 15, 2018 On 1/13/2015 at 5:59 AM, OzGrant said: As I need an excuse to fire up my new CC3200, will check it out with a DS18. Will get back soon. Grant hello! have you got the code for the cc3200? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.