Hi, I am trying to read a ds1820 and send it with virtualwire, I have this working with a 328 but with the attiny85, It always reads -16.19 ? I have a 4.7k resistor from 5v to data on the ds1820
any ideas? thanks
#include<stdlib.h>
#include <VirtualWire.h>
#include <OneWire.h>
byte addr[8];
float celsius;
OneWire ds(1); // on pin 10
String tempstr[10];
int RF_TX_PIN = 2;
void setup()
{
vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
vw_setup(2000); // Transmission speed in bits per second.
}
void loop()
{
const char *msg = "hello";
char cc1[10];
vw_send((uint8_t *)msg, strlen(msg)); // Send 'hello' every 400ms.
delay(400);
byte i,present =0, data[12];
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1500); // maybe 750ms is enough, maybe not
ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
int16_t raw = (data[1] << 8) | data[0];
raw = raw << 3; // 9 bit resolution default
raw = (raw & 0xFFF0) + 12 - data[6];
celsius = (float)raw / 16.0;
dtostrf(celsius,5,2,cc1);
vw_send((uint8_t *)cc1, strlen(cc1));
vw_send((uint8_t *)"t", 1); //send a t after the temp
delay(1000); // wait for a second
}