I'm using HC-05 bluetooth with Arduino and want to show values from sensors. Using this code on Arduino.
//#include <SPI.h>
#include <Wire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Addresses of 4 DS18B20s Change these to match temp sensors used
uint8_t sensor1[8] = { 0x28, 0x73, 0x7D, 0x7D, 0x08, 0x00, 0x00, 0x4E };//engine------------sensor #29
uint8_t sensor2[8] = { 0x28, 0x11, 0xAD, 0x6D, 0x08, 0x00, 0x00, 0x85 };//transmission #1----sensor #28
uint8_t sensor3[8] = { 0x28, 0xFF, 0x5F, 0x98, 0xA1, 0x15, 0x04, 0x60 };//transmission #2
uint8_t sensor4[8] = { 0x28, 0xFF, 0x11, 0x57, 0x73, 0x15, 0x01, 0xE1 };//outside
int lvl;
void setup() {
Serial.begin(9600);
#define TEMPERATURE_PRECISION 10
sensors.begin();
sensors.setResolution(sensor1, TEMPERATURE_PRECISION);
sensors.setResolution(sensor2, TEMPERATURE_PRECISION);
// void printTemperature(DeviceAddress deviceAddress)
}
void loop() {
//++++++++++++++++++++++++++++Temperature
float temperature1 = sensors.getTempF(sensor1);
float temperature2 = sensors.getTempF(sensor2);
float temperature3 = sensors.getTempF(sensor3);
float temperature4 = sensors.getTempF(sensor4);
//++++++++++++++++++++++++++++Pressure
int sensorVal1 = analogRead(A0);//air pressure 1
int sensorVal2 = analogRead(A1);//oil pressure
float voltage1 = (sensorVal1 * 5.0) / 1024.0;
float voltage2 = (sensorVal2 * 5.0) / 1024.0;
float pressure_pascal1 = (3.0 * ((float)voltage1 - 0.47)) * 1000000.0;
float pressure_pascal2 = (3.0 * ((float)voltage2 - 0.47)) * 1000000.0;
float pressure_psi1 = pressure_pascal1 * 0.00001450377;
float pressure_psi2 = pressure_pascal2 * 0.00001450377;
//++++++++++++++++++++++++++++Pressure Print
if (pressure_psi1 <= 1) {
Serial.print("0");
} else
Serial.print(pressure_psi1, 1);
//Serial.println(" psi 1");
//Serial.print("|");
Serial.print("|");
if (pressure_psi2 <= 1) {
Serial.print("0");
} else
Serial.print(pressure_psi2, 1);
Serial.print("|");
//Serial.println(" psi 2");
//++++++++++++++++++++++++++++Temperature Print
sensors.requestTemperatures();
Serial.print(temperature1, 0);
Serial.print("|");
Serial.print(temperature2, 0);
Serial.print("|");
Serial.print(temperature3, 0);
Serial.print("|");
Serial.println(temperature4, 0);
// Serial.println("|");
// Serial.println(lvl);
delay(2000);
}
Everything works as it should on the Arduino serial monitor. Values change according to sensor changes. I have no problem connecting to bluetooth, I've done it many times.
Using these blocks.
aia for above
From_2_sensorsWebsite.aia (8.3 KB)
When I open the app I get the readings, but only once, it doesn't change with the readings from the Arduino serial screen.
Sometimes I get this error.
Sometimes I get more readings than there are boxes for