lpodkalicki / attiny-ds18b20-library

This is tinyAVR (ATtiny13, ATtiny25, ATtiny45, ATtiny85, etc.) library for DS18B20 temperature sensor.
https://blog.podkalicki.com
BSD 2-Clause "Simplified" License
17 stars 2 forks source link

Error arduino ide #2

Open Edumarek123 opened 1 year ago

Edumarek123 commented 1 year ago

ERROR: undefined reference to `DS18B20_read(unsigned char)'

my code:

include

include <avr/io.h>

include <util/delay.h>

include "ds18b20.h"

//Pinos

define PIN_SENSOR_TEMPERATURA PB2

define PIN_COMPRESSOR (0x08)

//Parametros const int8_t TEMPERATURA_MINIMA=17; const int8_t TEMPERATURA_MAXIMA=20;

//Funcoes void liga_compressor(); void desliga_compressor();

int main(){ //PORTAS DDRB|=(PIN_COMPRESSOR); //PB3 como saida - compressor

//VARIAVEIS int16_t ultima_temperatura;

while (true) { ultima_temperatura=DS18B20_read(PIN_SENSOR_TEMPERATURA);

if(ultima_temperatura>TEMPERATURA_MAXIMA)
  desliga_compressor();
if(ultima_temperatura<TEMPERATURA_MINIMA)
  liga_compressor();

_delay_ms(1000);

}

return 0; }

void liga_compressor(){ PORTB|=(PIN_COMPRESSOR); }

void desliga_compressor(){ PORTB&=~(PIN_COMPRESSOR); }

imayoda commented 1 year ago

if you want to "integrate" and compile in arduino IDE, best choice imho is to port inside the sketch the onewire.c and ds18b20.c code.. btw do NOT mix the plain C code (while forever) with arduino scheme of function based on a setup() and loop().