Temperature Control: NUCLEO-F334R8 + DS18B20 + LCD1602 shield + RELAY and see the results on the PC and on the LCD1602. For more info see here: http://www.emcu.it/NUCLEOevaBoards/mBed/QSG-Mbed-Library.pdf

Dependencies:   DS1820 mbed TextLCD

Fork of F334andDS18B20 by Enrico Marinoni

main.cpp

Committer:
emcu
Date:
2015-12-25
Revision:
1:5c2c3c1e5093
Parent:
0:b6b929b7764c
Child:
2:54ef8b27cbaa

File content as of revision 1:5c2c3c1e5093:

/**

By:       www.emcu.it
Date:     Dec.2015
Version:  1.0
Name:     F334andDS18B20

THE SOFTWARE AND HARDWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

UART Configuration (It is necessary for see the results, we suggest to use TeraTerm on PC)  
    Baud Rate:    9600 
    Data Bit:     8
    Parity:       NONE
    Stop Bit:     1
    Flow Control: NONE
    
This SW is ready to use on the NUCLEO-F334R8.
Connect to the NUCLEO-F334R8, the DS18B20 sensor, see the schematic below.

 DS18B20 front view
    __________
   |          |
   |    DS    |
   |   18B20  |   
   |          |
   |__________|
     |   |   |
     1   2   3
    GND  DQ VCC (3,3V)
     |   |   |______________ to VCC (3,3V on the NUCLEO-F334R8)  
     |   |  _|_
     |   |  | |
     |   |  | | 4K7
     |   |  | |
     |   |  -|-
     |   |___|______________ to A1 (on the NUCLEO-F334R8) 
     |
     |
     |______________________ to GND (on the NUCLEO-F334R8)   

This SW is just for only one DS18B20
This SW is a derivative of:: https://developer.mbed.org/users/Sissors/code/DS1820_HelloWorld/
On the: https://developer.mbed.org/users/Sissors/code/DS1820_HelloWorld/ there is a multi sensor (DS18B20) example.

*/


// Below there is the Data Pin where is connected the: 
// pin.2 (DQ) of the DS18B20
#define DATA_PIN  A1

#include "mbed.h"
#include "DS1820.h"

// Define the PC serial Port
Serial pc(SERIAL_TX, SERIAL_RX);

// Specify the pin of the NUCLEO-F334R8 where is connected 
// the pin.2 (DQ) of the DS18B20.
DS1820 probe(DATA_PIN);
 
int main() 
{
    pc.printf("\r\n\nTemperature measurement made using an NUCLEO-F334R8 and DS18B20 (input on A1). \n\rby: www.emcu.it\n\r\n\r");
    while(1) 
    {
        probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
        pc.printf("The Temperature is %3.3f Celsius/Centigradi\r\n", probe.temperature());
        wait(1);
    }
}