Not transferring the data

Recently I have started to work on a project. So I connected to the arduino DHT 11 and OLED(128x32) and I tried to show the data on the screen and it worked. When I connected the hc-06 and tried to send the data from dht11 to my phone it didn't work and even stopped showing the data on the screen

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4


#include "DHT.h"
#define dhtPin 7
#define dhtType DHT11
DHT dht(dhtPin, dhtType);
Adafruit_SSD1306 display(OLED_RESET);

#include<SoftwareSerial.h>
SoftwareSerial bt(10, 11);
#include <SPI.h>


void setup() {
Serial.begin(9600);
Wire.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
dht.begin();
bt.begin(9600);
Serial.println("Ready..");
}

void loop() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();

display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(0,10);
display.print("Temprature: ");
display.print(temp);
display.display();

if(bt.available() >0){
    inchar=bt.read();
    Serial.println(inchar);
    delay(20);
    if (inchar=='v'){
      delay(10);
      Serial.println(inchar);
      delay(2000);
      Serial.print("Temperature:");
      Serial.print(temp);
      Serial.print("C");
    }  
}

Hi!

There´s nothing in your code that sends data to your phone. The code expects a 'v' character incoming from the phone instead.

Besides the initial "Ready..." message, the code will not show anything on the Serial Monitor before receiving data from your phone.

There´s a bracket missing to close the void loop() function...

Unless you didn't post your entire code I believe the problem is right here. It looks like maybe you meant to use bt.print rather than Serial.print. And as Brazilino said, your code is expecting a 'v' from the phone before sending anything.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.