Serial data through bluetooth HC-05 \ 06 to display

So I agree with Read, store, display but I don’t know the code to get this data from the SoftwareSerial input pin through the Arudino and to an output pin.

And, still, you haven’t read reply #17 or reply #5.

I’m not going to type up code for you when Robin2 has already gone to a great deal of trouble to do that already AND to explain the code line by line AND to explain when you’d want to use each piece of sample code.

PaulS: And, still, you haven't read reply #17 or reply #5.

I'm not going to type up code for you when Robin2 has already gone to a great deal of trouble to do that already AND to explain the code line by line AND to explain when you'd want to use each piece of sample code.

Ive went through all of Robins serial data post for a few hours. Im having a hard time translating that to my project considering my data is coming in from a SoftwareSerial & Im outputting to a LED. I dont know how to get the serial data to output to a pin I can code for. It appears to me that his code is to Serial.Print & that is working on my project just fine so Im stuck on how to utilize Robin2s help.

Im having a hard time translating that to my project considering my data is coming in from a SoftwareSerial

Whether the stream of data comes from a HardwareSerial instance (Serial, Serial1, etc.), a SoftwareSerial instance, a file, or some other stream does not matter.

I dont know how to get the serial data to output to a pin I can code for.

Serial data is not meant to be “output to a pin”. So, it’s hard to understand what you are trying to do.

PaulS: Serial data is not meant to be "output to a pin". So, it's hard to understand what you are trying to do.

Didnt know that, thanks. At this point, I'm able to get the data on a Serial 7 segment LED from Sparkfun here

Sparkfun Serial 7 Segment Display

But of course the data just scrolls on the screen when connecting it UART directly to the incoming bluetooth data. I need to figure out a way to do it like the 1st example Sparkfun uses which is to have my data from the RX pin go out the TX (They use pin eight). They write up a counter code from the Arduino to TX. If I could get the sensor data to the TX, this is done.

So yeah, i need to do what you said, Read, Store, Display

So yeah, i need to do what you said, Read, Store, Display

What is sending the data? What is it sending?

PaulS: What is sending the data? What is it sending?

So the Force resistor data is 0 to 3 digits, that comes through to the HC-06 to my 2nd circuit. That data is read fine by the serial monitor & the bluetooth app. I just cant re-transmit it out the Tx so I can use this screen.

tunaman4u2: Ive went through all of Robins serial data post for a few hours. Im having a hard time translating that to my project considering my data is coming in from a SoftwareSerial & Im outputting to a LED.

Rather than think about translating my code to your project start a new project using my example 2 - and get it working without any changes to the code - just send data from the Serial Monitor.

Then make a copy of that and modify the copy so it uses SoftwareSerial to receive the data and Serial to display the output on the Serial Monitor. That should display the data coming from your Bluetooth device.

When that is working we can consider what to do next.

...R

Robin2: Rather than think about translating my code to your project start a new project using my example 2 - and get it working without any changes to the code - just send data from the Serial Monitor.

Then make a copy of that and modify the copy so it uses SoftwareSerial to receive the data and Serial to display the output on the Serial Monitor. That should display the data coming from your Bluetooth device.

When that is working we can consider what to do next.

...R

I guess I dont know how to do that I'm already receiving data from Software Serial from the bluetooth & displaying it on the serial monitor just fine. Im just not able to then turn around & get the inputed data to output.

tunaman4u2: I guess I dont know how to do that

You are not making it easy to help you.

Exactly what part of my Reply #26 do you need help with?

...R

Robin2:
You are not making it easy to help you.

Exactly what part of my Reply #26 do you need help with?

…R

I see what you’re asking. For me to start the serial monitor output side of things, I can use your code to write on the serial monitor & that will show up on my screen through TX. Im pretty sure I can get that done, & have done so on a prior project NOT using SoftwareSerial. The data from the sensor goes directly to the Arduino, I name the A0 pin as the output & the TM1637 reads perfectly.
But I’ll try what you say… to start on the serial monitor to output type of thing

I still dont see how I get my incoming serial data to be processed by the arduino & sent out through a pin. This is ALL I need to do.

Heres my old project that works great, its a muscle tester, patients love it.

#include <TM1637Display.h>

const int CLK = 9; //Set the CLK pin connection to the display
const int DIO = 8; //Set the DIO pin connection to the display


int flexiForcePin = A0;

TM1637Display display(CLK, DIO);  //set up the 4-Digit Display.

void setup()
{
  
  display.setBrightness(0x0a);  //set the diplay to maximum brightness
}


void loop()
{
    int flexiForceReading = analogRead(flexiForcePin);
  
 
  {
    display.showNumberDec(flexiForceReading); //Display the Variable value;
    delay(500);  //A half second delay between steps.
  }
}

As well as trying what I suggested in Reply #26 please post some examples of the data that are being sent using Bluetooth.

...R

Robin2: As well as trying what I suggested in Reply #26 please post some examples of the data that are being sent using Bluetooth.

...R

Spent a few hours trying to modify the code. I can get the serial monitor to put data I type in to the Serial monitor go to the screen. I cannot get my serial data to be an outputted, I cant get it to a pin. That's what I have to figure out... how to get Softwareserial input data to an output.

The data is 0 to 300 depending on how hard the force sensor is pushed. I'm not using Serial monitors in this project, its battery operated Arduino with a force sensor to HC-05 to the HC-06 to the Arduino to a screen

tunaman4u2: Spent a few hours trying to modify the code. I can get the serial monitor to put data I type in to the Serial monitor go to the screen. I cannot get my serial data to be an outputted, I cant get it to a pin. That's what I have to figure out... how to get Softwareserial input data to an output.

PLEASE ... help us to help you. Post the programs without me having to ask you.

...R

Robin2:
PLEASE … help us to help you. Post the programs without me having to ask you.

…R

Robin, you really are trying here I appreciate that so much. I spent 4 hours last night alone trying to change up all sorts of code & my wife is upset that I’m not spending time with her or the kids this week so believe me I’m giving it all I have.

So I tried 3 different codes to get my data to a screen. My question is which one of these is the most likely to work when I integrate into your code?

1st this is the code that works transmitting to the app & the serial monitor, heres what perfect data looks like to those outputs. The numbers change based on how hard I press the sensor. In this code I have no outputs to a display however.

0;0;136;147;0;0;18;18;25;28;26;45;345;464;512;511;487;464;0;

Code to App & Serial Monitor that works

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup() 
{
  Serial.begin(9600);
  BTSerial.begin(9600);
}
 
void loop()
{
  if (BTSerial.available())
Serial.write(BTSerial.read());
 
  if (Serial.available())
  BTSerial.write(Serial.read());
  
}

Serial Segment display attempt 1: Try to read the sensor data through softwareserial Rx & then write it out the Tx. The data is not received properly if I do that, but it does show up on the display. If I add a serial monitor to this code the data looks like this.

072;61;84;711161775;775;2664476666600;34455;0;;0;;;99;9;600;00;0;0;0;0;;0

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
 
void setup() 
{
  BTSerial.begin(9600);
}
 
void loop()
{
if (BTSerial.available())
BTSerial.write(BTSerial.read());
}

Serial Segment Display attempt 2: I tried to send the data to the A0 pin. No luck, nothing comes out

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
int ForceData = A0;
 
void setup() 
{
  BTSerial.begin(9600);
}
 
void loop()
{
if (BTSerial.available())
int ForceData = BTSerial.read();
}

4 bit Tube LED attempt 1: I try to put the data directly into A0 pin like I was doing in the past straight off the sensor from the past project. The screen just gives me numbers in the 600s that keep changing without any effect from the sensor

#include <TM1637Display.h>

const int CLK = 9; //Set the CLK pin connection to the display
const int DIO = 8; //Set the DIO pin connection to the display

int flexiForcePin = A0;
TM1637Display display(CLK, DIO);  //set up the 4-Digit Display.

void setup()
{
  
  display.setBrightness(0x0a);  //set the diplay to maximum brightness
}
void loop()
{
    int flexiForceReading = analogRead(flexiForcePin);
  {
    display.showNumberDec(flexiForceReading); //Display the Variable value;
    delay(500);  //A half second delay between steps.
  }
}

REWARD IS NOW $100 Amazon Gift Card, its a lot cheaper than divorce at this point! :slight_smile:

I have zero interest in a reward. If you want someone to write a program for you for money then ask in Gigs and Collaborations section.

NONE of the programs you have posted in Reply #33 bears the slightest resemblance to what I asked you to do in Reply #26. If you don't want my help then please tell me and I will use my time to help someone else.

And it has just occurred to me that (AFAIK) you have never posted the code for the program that is sending the data. Please do so.

...R

Robin2:
I have zero interest in a reward. If you want someone to write a program for you for money then ask in Gigs and Collaborations section.

NONE of the programs you have posted in Reply #33 bears the slightest resemblance to what I asked you to do in Reply #26. If you don’t want my help then please tell me and I will use my time to help someone else.

And it has just occurred to me that (AFAIK) you have never posted the code for the program that is sending the data. Please do so.

…R

Sorry for the miscommunication Robin, I was trying to figure out which of those 3 codes you thought I should attempt to modify your code with. I just went with the basic SoftwareSerial & BTserial code.

Heres my sad attempt to modify your code. If I use the BTserial, I get nothing out of pin 11. If I try to have both the BTserial & serial code running I get… ‘showNewData’ was not declared in this scope which is why I have // to some serial code. So I cant see or transmit through the serial monitor.

// Example 2 - Receive with an end-marker

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX

const byte numChars = 32;
char receivedChars[numChars];
// an array to store the received data

boolean newData = false;

void setup() {
//Serial.begin(9600);
//Serial.println("<Arduino is ready>");
BTSerial.begin(9600);
}

void loop() {
recvWithEndMarker();
showNewData();
}

void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;

//while (Serial.available() > 0 && newData == false) {
//rc = Serial.read();
 
while (BTSerial.available() > 0 && newData == false) {
 rc = BTSerial.read();

if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
 newData = true;
 }
  
}
}

void showNewData() {
if (newData == true) {
//BTSerial.print("This just in ... ");
 BTSerial.println(receivedChars);
 newData = false;
 }
}

If I use your code as is & hook up the display to the serial TX of the Arduino, I always have a “d” & an “A” on the screen in various places… and obviously none of my data in it at all.

Heres the code from the HC-05 that I needed to use for the Android app & kept using for this project. As I look through it, theres a BTSerial.read( ; ) that could be causing a problem

#include <SoftwareSerial.h>

SoftwareSerial BTserial(10, 11); // RX | TX

int sensorPin = A0;

int sensorValue = 0;

void setup() {

BTserial.begin(9600); }

void loop() {

sensorValue = analogRead(sensorPin);

BTserial.print(sensorValue);

BTserial.print(";");

//message to the receiving device

delay(1000);

}

Let me know how you want me to proceed & I’ll put more hours in, I’m trying.

tunaman4u2: Heres my sad attempt to modify your code.

Before I look at that can you confirm that you have tried my un-modified code and that it works - using the Serial Monitor for input. It is important to start from something that works.

It looks like your sending program is using ';' (semi-colon) as an end marker so my recvWithEndMarker() obviously needs to be modified to expect that rather than a '\n' (line-feed).

The sending and receiving programs must be able to work with each other.

...R

Robin2: Before I look at that can you confirm that you have tried my un-modified code and that it works - using the Serial Monitor for input. It is important to start from something that works.

It looks like your sending program is using ';' (semi-colon) as an end marker so my recvWithEndMarker() obviously needs to be modified to expect that rather than a '\n' (line-feed).

The sending and receiving programs must be able to work with each other.

...R

Yup, I can get your program to output digits to my serial 7 segment LED but it always has the "A" & "d" on the screen so if I put "12" for example in the serial monitor it looks like A12d.

I also tried to get your code to go to another Arduino & then read that on a serial monitor on another computer but was unable to. I tried the serial receive pin & the Software serial codes I've been using to receive sensor data but I still get nothing despite knowing that your program is transmitting the "12" I punched in. I'm not sure why I cant get that "12" to be received by the other Arduino when the same program receives my sensor data fine.

tunaman4u2: Yup, I can get your program to output digits to my serial 7 segment LED

I did NOT ask you to use my program to output digits on a 7 segment LED. I asked you to run it without any changes. There is no mention of a 7 segment LED in my Reply #26.

I think I am nearly tired of this.

I suggested a solution to you in Reply #5. You are now at Reply #37 with no sign of progress even though the code I suggested in Reply #5 still seems to be the solution.

...R

Robin2: I did NOT ask you to use my program to output digits on a 7 segment LED. I asked you to run it without any changes. There is no mention of a 7 segment LED in my Reply #26.

I think I am nearly tired of this.

I suggested a solution to you in Reply #5. You are now at Reply #37 with no sign of progress even though the code I suggested in Reply #5 still seems to be the solution.

...R

I did use your code exactly as it was written & described my results above. It worked on the serial monitor on my computer just fine. I entered "12" for example & the serial monitor said, This just in "12" (We both know your code works) but I could not get the serial to output to another Arduino through the TX-1 pin. You asked me to tell you if your code was working as written on my project.

SO...

I used the Serial Segment display to check to see if the TX-1 pin had information on it & it did, the "A" & "d" with the "12". So your code IS working sort of

SO....

I then tried an alternative to see if I could output your code through BTserial instead of the TX-1 pin & get it to be read by another serial monitor INSTEAD of my 7 segment screen and that didn't work. I thought you would like to know if your code worked on another serial monitor

AND...

If I tried to use your code with BTserial I had to // the serial monitor or I got 'showNewData' was not declared in this scope if I tried to integrate my code into yours

Robin- I spend HOURS trying many things and try to post the results in a succinct way that I believe you are asking for. Its my fault for trying to do too many things. I will simply try the one thing you ask & post that one result from now on. Don't give up me, I'm not giving up.