Hey guys...
need some help figuring out an issue with receiving 6 temp readings using DS18B20 sensors connected via an UNO and send over bluetooth to an MIT inventor created app.
I do get all readings to display but they shift a lot between the designated locations.
I have to play with clock timer in the app and delay in the arduino sketch to make it somewhat acceptable but still shifts but you really have to look for them. Downside is that the refreshrate takes to long for my liking.
any help would really be appreciated
Arduino sketch;
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
#define ONE_WIRE_BUS A0
SoftwareSerial mySerial(11, 12);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
uint8_t sensor1[8] = { 0x28, 0x67, 0xF4, 0x0D, 0x00, 0x00, 0x00, 0x7C };
uint8_t sensor2[8] = { 0x28, 0x1E, 0x4D, 0x0F, 0x00, 0x00, 0x00, 0xC9 };
uint8_t sensor3[8] = { 0x28, 0xFF, 0xB8, 0x0F, 0x00, 0x00, 0x00, 0xA3 };
uint8_t sensor4[8] = { 0x28, 0xFA, 0x46, 0x0B, 0x00, 0x00, 0x00, 0x42 };
uint8_t sensor5[8] = { 0x28, 0x09, 0xD9, 0x0A, 0x00, 0x00, 0x00, 0x3E };
uint8_t sensor6[8] = { 0x28, 0x98, 0x15, 0x49, 0x0C, 0x00, 0x00, 0x68 };
const byte auxPin [] {3, 4, 5, 6, 7, 8, 9, 10};
void setup(void)
{
for (auto& pin : auxPin) {
pinMode(pin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
mySerial.begin(9600);
Serial.begin(9600);
sensors.begin();
}
void loop(void)
{
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}
if (mySerial.available()) {
int i = mySerial.read();
if (i >= '1' && i <= '8') {
int index = i - '1';
Serial.println ((char)i);
digitalWrite(auxPin [index], HIGH);
delay(500);
digitalWrite(auxPin [index], LOW);
delay(100);
}
}
sensors.requestTemperatures();
printTemperature(sensor1);
Serial.print(",");
printTemperature(sensor2);
Serial.print(",");
printTemperature(sensor3);
Serial.print(",");
printTemperature(sensor4);
Serial.print(",");
printTemperature(sensor5);
Serial.print(",");
printTemperature(sensor6);
Serial.println();
delay(500);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print(tempC, 1);
}