HM-10 - Reading Data Part 2

Hello,

I have recently purchased a HM-10 BLE module to connect to my IPhone for a project. I am currently programming a Plant monitoring system. I have managed to incorporate all sensors and outputs into a working code. However, I would like to send the LUX levels that print to the serial monitor over the HM-10 BLE module to my iPhone. I can connect to the module but it doesn't display the data. This makes me think its a code issue. Can anyone review my code and let me know where i am going wrong.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(6, 10); // RX, TX
// Connect HM10 Arduino Uno
// Pin 1/TXD Pin 6
// Pin 2/RXD Pin 10

// light
int sensorPin = A0; // select the input pin for the potentiometer
float rawRange = 1024; // 3.3v
float logRange = 5.0; // 3.3v = 10^5 lux

//heat
#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;
#define DHT11_PIN 7

// soil sensor
int led_pin = 9;
int sensor_pin = 8;

void setup()
{

//light
analogReference(EXTERNAL); //
Serial.begin(9600);
Serial.println("Adafruit Analog Light Sensor Test");

//bluetooth
mySerial.begin(9600);

//heat
lcd.begin(16, 2);

//soil

pinMode(led_pin, OUTPUT);
pinMode(sensor_pin, INPUT);
}

void loop()
{
// read the raw value from the sensor:
// light
int rawValue = analogRead(sensorPin);

Serial.print("Raw = ");
Serial.print(rawValue);
Serial.print(" - Lux = ");
Serial.println(RawToLux(rawValue));
delay(1000);

//bluetooth
char c;
if (Serial.available()) {
c = Serial.read();
mySerial.print(c);
}
if (mySerial.available()) {
c = mySerial.read();
Serial.print(c);
}

//heat
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(DHT.humidity);
lcd.print("%");
delay(1000);

//soil
{
if(digitalRead(sensor_pin) == HIGH)
{
digitalWrite(led_pin, HIGH);
}
else
{
digitalWrite(led_pin, LOW);
delay(1000);
}
}
}

float RawToLux(int raw)
{
float logLux = raw * logRange / rawRange;
return pow(10, logLux);
}

SoftwareSerial mySerial(6, 10); // RX, TX

Can you post a picture of this mySerial that you have connected to pins 6 and 10? If not, explain the stupid name for the instance.

Your code reads whatever comes in the Serial instance, and writes it to the mySerial instance. It reads whatever comes in the mySerial instance, and writes it to the Serial instance.

Can I suggest that you stop the group grope session, and intelligently determine what to write to the mySerial instance, and what to write to the Serial instance, and properly do something with what you read from the two instances?

Hello Paul, thank you for your welcoming reply. I ask for help being a newcomer to this and receive your helpful sarcastic response. Obviously, you have a very good understanding of code from your remarks. However, I do not have the same level as yourself and require guidance and some helpful assistance. If that’s something you’re prepared to do, without a downgrading response, it would be much appreciated, and also extremely helpful. I have thrown some code together (which I do not understanding completely what it means) and would like some help understanding it. Hence the thread. My goal is to print the lux level and raw light level through Bluetooth and onto my phone. Guidance would help a lot.