One-wire thermometer is one of most popular application for advanced-beginner working with any embedded platforms. Of course, you can find similar example for IQRF in start-up package too.
I tried this example, but I was unsatisfied. This example periodicaly starts temperature conversion and transmition. But if you need more sensors, collision may occur. Fortunately, the improvement is not so complicated.
In following code, master request is required for temperature conversion and transmission. Source code originates from startup package DDC exmple DDC-SE-01-dallas.c. Changes are indicated in comments. Whole code is linked at the end of article.
uns16 temperature, tmp;
uns8 i, tenths;
uns8 go; // < -----my modification
// ************
void APPLICATION()
{
pulseLEDG();
waitDelay(10);
go = 0; // < -----my modification
while (1)
{
if (RFRXpacket()) // <----- start of my modification
{
if (DLEN < 4) continue;
if (bufferRF[0] != 'R') continue; // Read
if (bufferRF[1] != 'T') continue; // Temperature
if (bufferRF[2] != 'A') continue; // Address Hi
if (bufferRF[3] != '5') continue; // Address Lo
go = 1;
}
if (go)
{
go = 0; // <------ end of my modification
if (DS_GetTemperature())
{
bufferRF[0] = 'T';
bufferRF[1] = '=';
The source code above expects 4 bytes of incoming message. The first two bytes indicates the desired operation, the next two bytes the address of the device. If you do not match the number of bytes, operation code, or address, conversion and transmission is not executed.
I used UART-LINK example as the master for code testing. Of course you can use SPI interface and terminal in IQRF IDE, if you want. Following picture shows master simulation by UART-LINK loaded module and serial port terminal.
This example works only for LOS cases and for short ranges. If you have any obstacles in signal path, you may have problems. For this situations IQ mesh is better. In next article I am going to show you, how to use DPA for IQ mesh temperature measurement.