Announcement

Collapse
No announcement yet.

DS18B20 and uLCD43-PT

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DS18B20 and uLCD43-PT

    I am trying to display the temp from a DS18B20 to my uLCD43-PT.I used ViziGenie to create the LCD program. I am using an Arduino Mega 2560 Rev 3 and an adapter shield R2. I have looked at the app notes and found there is one that uses the DS18B20 connected directly to the display and the other app is an LM35 connected to the Arduino and displaying the temp on the LCD. I would like to connect the DS18B20 to the Arduino and display the temp on the LCD. I have compiled a sketch and I can read the temp just fine via the serial monitor, however the temp does not display correctly (at all really) on the LCD.
    What I am seeing on the display is 32. Which is the last set of numbers in this line of code
    tempF = tempC * 9 / 5 + 32; No matter what I change that number to, that is what I read on the LCD display. I only have one set of leddigits in my program and have confirmed that it is set to leddigits0. I have my sensor wired as shown in the picture and I have attached my sketch and here is a link to the sensor http://www.adafruit.com/datasheets/DS18B20.pdf Click image for larger version

Name:	ds18b20 image.jpg
Views:	154
Size:	68.3 KB
ID:	43193

  • #2
    Here is a screen print of the serial monitor running the sketch from my post above.

    Thanks Click image for larger version

Name:	Temp Display from Serial Monitor.jpg
Views:	20
Size:	552.3 KB
ID:	43196

    Comment


    • rcbandwidth
      rcbandwidth commented
      Editing a comment
      You cannot use the Serial.Print statements,these conflict with the display ...comment out the Print statements and retest.....If you want both you can move the display to another Comm port since you are using a mega,then the Serial.print statements can be used without conflict.

      Bob

  • #3
    That is what I was leaning towards as a possible reason. I based that on the fact that I cannot load the sketch while the LCD is plugged in to the shield. I don't need the serial.print statements, I was only using it to confirm that the sensor was actually working. I will give it a try.

    Thank you for your help

    Brian

    Comment


    • #4
      I have commented out the serial.print lines and reloaded the sketch. I am still reading 40 on the LCD which is the same 40 that appears in the line of code below.
      tempF = tempC * 9 / 5 + 40;

      I did close out the sketch window, unplugged the USB and restarted everything to be sure that I had loaded the updated sketch. When I open the serial monitor now, I see (& repeating itself.

      Here is the updated sketch.

      Thanks
      Brian
      Attached Files

      Comment


      • rcbandwidth
        rcbandwidth commented
        Editing a comment
        I think you can use something like this,I think the math is already done in the library,declare as float not int....Just a guess on my part I have not used 1 wire.

        float Tc = sensors.getTempCByIndex(0); // for C

        float Tf = sensors.getTempFByIndex(0); // for F

    • #5
      Thanks for the reply. I unfortunately do not know where that should be incorporated in to the sketch? I think you are telling me to comment out int tempC, int tempF and int sensorPin = 2? Would the line of code you sent go in place of those int values? I apologize, I wish I understood more about this. I have been all over the web and the forum trying to diagnose this. Although I dont recall where I read it, I do remember what you have suggested in your response about the library doing the math.

      Thanks
      Brian

      Comment


      • #6
        The really frustrating part is that when I use this code, I can read the temp just fine via the serial monitor. But yet, no matter what I try, I cannot get that information to write to the leddigits0.
        Attached Files

        Comment


        • #7
          Brian this is just my guess,you said it works when printing to the serial monitor,I just substituted what I think it should be.
          perhaps James can answer more directly if this does not work. I left the Print statements in as a reference point.

          void loop(void)
          {
          // call sensors.requestTemperatures() to issue a global temperature
          // request to all devices on the bus
          //Serial.print("Requesting temperatures...");

          sensors.requestTemperatures(); // Send the command to get temperatures

          //Serial.println("DONE");

          // Try either one of these or use both for dual display
          // float Tc = sensors.getTempCByIndex(0); // for C
          // float Tf = sensors.getTempFByIndex(0); // for F

          //Serial.print("Temperature for Device 1 is: ");
          float Tc = sensors.getTempCByIndex(0); // change getTempCByIndex(0) to getTempFByIndex(0) for Farenheight
          genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, Tc); //Write to Leddigits0 the value of Tc
          delay(50);



          }
          Last edited by rcbandwidth; 23rd February 2015, 07:54 AM.

          Comment


          • #8
            Good guess Bob! That works like a charm! Where can I send the bottle of whiskey to?
            Thanks again!
            Brian

            Comment


            • rcbandwidth
              rcbandwidth commented
              Editing a comment
              That's good news.....I got lucky !...I am guessing you might have been close to getting the Hammer out.

              Regards
              Bob

          • #9
            Hell no, I was drinking your bottle of whiskey! Either way, its a one bottle job! Lol, stay tuned, I'm just getting started.

            Brian

            Comment


            • #10
              Here is another one for you. I am now trying to write to a tank. I am using an 8" milone etape (www.milonetech.com). Again, when I use the attached sketch Milone 8 inch etape and use the serial monitor, it works fine (Attached photo, tank prt scr). Then using the last example you helped me with, I tried to write the sketch (Temp-Tank). While it does seem like it is reading, it seems like it is reading backwards. So, the tank shows full when it should read empty. There are two tanks on this form, however I did confirm that the one I am trying to write to (tank0) is the one that appears to be getting the reading from the tape. I did keep in mind what you told me when you helped with the backlight slider and the max is 100 while the min is 0. So possibly the number 1023 in this line of code
              reading = (1023 / reading) - 1;
              should be 100?
              Anyway, this is where I become dangerous! I appreciate your thoughts

              Brian
              Attached Files

              Comment


              • rcbandwidth
                rcbandwidth commented
                Editing a comment
                Brian: I saved your files to have a look at.In the meantime I will introduce you to a very useful Arduino function called Map,this function allows you to rescale values to different ranges, have a look at it......http://arduino.cc/en/reference/map
                The Map function works with integer values and will truncate numbers.

                The 1023 number in the sketch is the full scale integer value for your Arduino A/D converter(10 bit),which can read a 0 to 5 volt signal from your sensor,The A/D translates this voltage to a number 0 to 1023. If you defined your tanks to have a min = 0 and a max = 100 then we can use the map function to scale 0 to 1023 to 0 to 100 or you can reverse the min max and flip the response......Don't alter the 1023 number.

                Bob
                Last edited by rcbandwidth; 23rd February 2015, 10:04 AM.

            • #11
              Thanks for the tip, I will certainly check that out. FYI, I did try flipping the min max values and it did not make any difference in how the LCD reads the etape. In other words, it is still reading backwards. I am still working on it and will let you know if I figure it out.
              Thanks again
              Brian

              Comment


              • #12
                Ah, so I did hook the etape back up to the sketch where I can read things via the serial monitor and here is what I found,
                With no water the analog reading is 126.00 and the sensor resistance is 78.66
                With 2" of water the analog reading is 97.00 and the resistance is 58.66
                With 4" of water the analog reading 75.00 and the resistance is 44.30
                With 6" of water the analog reading is 55.00 and the resistance is 31.82
                and with a full 8" of water the analog reading is 29.00 and the resistance is 16.34.

                So, it would appear that although this gives me the opposite result of how I want to read this sensor, the LCD is displaying the results correctly.

                Perhaps the mapping code is going to be the answer for this afterall. Time to read that over again and also re-read the milone spec sheet.

                Brian

                Comment


                • #13
                  Here is what I have found so far. Even though in the sketch I have defined the SERIESRESISTOR to 560, the current application seems to work best when I have it defined as 1000 and am using a 10k ohm resistor instead of the 560k. If I use a 560k the tank display does not read at all. As far as the display reading backwards (empty showing full) if I comment out either one of the lines
                  // convert the value to resistance
                  reading = (1023 / reading) - 1;
                  reading = SERIESRESISTOR / reading;
                  the display will read correctly (empty shows empty) however it is not to scale. Even if the sensor detects "full", the display reads about one quarter full.

                  Brian

                  Comment


                  • rcbandwidth
                    rcbandwidth commented
                    Editing a comment
                    Brian: The sensor you have does not have a linear response,so you will not get good correlation between fluid level and the 4D gauges,The company sells a board that is designed to linearize the response curve.this will give you a nice 0 to 5 volt response for the Arduino A/D converter.
                    I would recommend contacting your supplier and explain exactly what you want to accomplish,perhaps they can suggest a lower cost approach.

                    Bob

                • #14
                  Bob,
                  Thanks for the reply. So the issue really is with the eTape and the uLCD-43PT not playing nice together? I am only trying to give myself a way to monitor the water level in a bilge. I guess I should start looking for another solution. I had though about using a simple float switch but that just gives me "on" and "off". I had thought this would give me more of a tank gauge feel showing different levels etc. Back to the drawing board!
                  Brian

                  Comment


                  • #15
                    I looked at the boards you were talking about. They are only $25. If that makes these work, no big deal. I'll go ahead and order them.

                    Brian

                    Comment


                    • rcbandwidth
                      rcbandwidth commented
                      Editing a comment
                      I am not sure how you derived your resistor values but you should get a much better response than what you are providing in your posts,contact the manufacturer and tell them you want a response geared for 0 to 5 volts and let them calculate a better value for you,if all you want is a high low value you should be able too achieve that....
                      Bob
                  Working...
                  X