We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2019-03-26
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Temperature & humidity
Downloaded: 4183 times
Not followed.
License: MIT license
Thermostat 2 Click is a general-purpose thermostat Click board designed to be used with any temperature sensor based on the DS1820 sensor design: 3-pin package with 1-Wire® communication interface.
Do you want to subscribe in order to receive notifications regarding "Thermostat 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Thermostat 2 click" changes.
Do you want to report abuse regarding "Thermostat 2 click".
Library Description
The library contains the One Wire functions for full communication from MCU to one of the DS18k20 sensors. The user also has a relay management function available.
Key functions:
void thermostat2_relay(uint8_t state)
- Relay controlvoid thermostat2_oneWireReset()
- One Wire Resetvoid thermostat2_oneWireWrite(uint8_t dataIn)
- One Wire Writeuint8_t thermostat2_oneWireRead()
- One Wire ReadExamples description
The application is composed of the three sections :
Commands : '+' - Relay ON '-' - Relay OFF 't' - Reads and display Temperature
void applicationTask()
{
float Temperature;
char demoText[50];
uint8_t dataReady_;
char receivedData_;
dataReady_ = UART_Rdy_Ptr( );
if (dataReady_ != 0)
{
receivedData_ = UART_Rd_Ptr( );
switch (receivedData_)
{
case '+' :
{
mikrobus_logWrite(" Relay ON!!! ", _LOG_LINE);
thermostat2_relay(_THERMOSTAT2_RELAY_STATE_ON);
break;
}
case '-' :
{
mikrobus_logWrite(" Relay OFF!!! ", _LOG_LINE);
thermostat2_relay(_THERMOSTAT2_RELAY_STATE_OFF);
break;
}
case 't' :
{
Temperature = thermostat2_getTemperature();
FloatToStr(Temperature, demoText);
mikrobus_logWrite("Temperature : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_TEXT);
mikrobus_logWrite(" C ", _LOG_LINE);
break;
}
}
}
}
Additional Functions :
void thermostat2_getTemperature( )
- Reads Temperature (DS18S20)Other mikroE Libraries used in the example:
One_Wire
UART
Conversions
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.