This is my Main code
#include <stdio.h>
#include <stdint.h>
#include "tm4c123gh6pm.h"
#include "ST7735.h"
#include "PLL.h"
#include "SysTick.h"
#include <stdbool.h>
#include "CO2_Sensor.h"
#include "Temp_Header.h"
#include "Bluetooth.h"
void EnableInterrupts(void);
void WaitForInterrupt(void);
extern uint8_t rx_data[8];
extern uint8_t rx_index;
double co2_calculation;
int main(void){
PLL_Init(); //Initilize PLL to 80MHz
SysTick_Init(); //Initilize SysTick Timer
ST7735_InitR(INITR_REDTAB); //Initilize LCD Screen
EnableInterrupts();
CO2_UART_Init (1, 0,' ', 9600); // initialize co2 uart
tempSensor_Init();
Bluetooth_UART_Init(1, 0,' ', 9600);
while(1){
sendBytes();
WaitForInterrupt();
co2_calculation = rx_data[3]*256+rx_data[4];
//checksum = 256-(rx_data[0]+rx_data[1]+rx_data[2])
// ST7735_SetCursor(10,6);
// ST7735_DrawString(11, 6, " ", 0xFFFF);
// ST7735_OutUDec(co2_calculation);
// ST7735_DrawString(11,8,"ppm ", 0xF69F);
// ST7735_SetCursor(11,11); // Set location of temp read number in lCD
// ST7735_OutUDec(GetTemp()); // Display results
int8_t temp = GetTemp();
int16_t co2_concentration = co2_calculation;
// Split the 16-bit integer into two 8-bit integers
int8_t co2_high_byte = (co2_concentration >> 8) & 0xFF;
int8_t co2_low_byte = co2_concentration & 0xFF;
// Send the data over Bluetooth
UART_Tx(temp); // Send the temperature as an 8-bit integer
UART_Tx(co2_high_byte); // Send the high byte of the CO2 concentration as an 8-bit integer
UART_Tx(co2_low_byte); // Send the low byte of the CO2 concentration as an 8-bit integer
SysTick_Wait10ms(15);
}
}
For my Temperature and CO2 library, they all can be display reading number on the LCD screen, so i think we do not need to modify those codes.
It's best if you do this with the original source files.
try
Bluetooth_UART_Init(8, 1,' ', 9600);
ok, i have no idea for that. But these two are my main and Bluetooth library, do u need my CO2 and Temp library/

for this part, i am using a switch statement, when i initialize ''1', at there , which means i make the bit size for 8bit.
Oh, I didn't go any deeper. I think you should go to the forum dedicated to programming this module and ask them to check the code to see if addresses etc are correct for this module. Once your module sends data correctly, we'll help with the app code.
What does while(1) mean? Is this an infinite loop? Can the module send data once? I don't see any logical fallacies. Only there may be a problem with addressing the BT module. I don't know this module and I can't tell if it's correct.
yes, it is a infinite loop. I was trying to find some forum for helping on the coding, but i can not find some. Do u have any idea where i can seeking for help?
Did you find the library on the internet for this particular microcontroller? did I write it myself using the documentation of the microcontroller? Maybe download the documentation from the internet and check if the addressing is correct. Does this module have BT on board, or do you use an external module, e.g. hc-05? Maybe you swapped the RX and TX pins?
oh, i will check them, this might be a problem, i was using this Bluetooth code to control board LED turn on or off. i will check pin first
I checked the connection, i think there should be problems on the coding, i am using the extra blurtooth module TEL0026.
It's hard for me to advise anything why the module is not sending anything.
1 Like
Dear @Zhaonan_Liu,
as Patryk_F already said, it's hard to help you because the HW you are using isn't the typical Arduino series.
Anyway, as he already suggested, by searching the web, you could probably find some specific hints, like the following:
Maybe helped by reading this link you could implement a chunk of code that allows you verify if your HW is sending something to the BT terminal. Once you are done with that, to make the receiving app, will follow.
hi @Patryk_F i make transmit working but i get some point strange. when i run
it is showing CO2 reading, i think this reading is good. But when i reading temp, it just show 0,4,36, these three number, when i put these together, it will show like below
Maybe let's start like this:
In your code for the module, turn off co2 sending, leave only temperature.
UART_Tx(temp); // Send the temperature as an 8-bit integer
//UART_Tx(co2_high_byte); // Send the high byte of the CO2 concentration as an 8-bit integer
//UART_Tx(co2_low_byte); // Send the low byte of the CO2 concentration as an 8-bit integer
Blocks set like this:
And show what you recejved in app.
The temperature is measured from -127 to +127 degrees? Then use this:
I have already tried on that, maybe the problem is I am using temperature and Bluetooth modules in the same port E, it might have a conflict. I am changing Bluetooth to port D and I will try again.
The one UART port is used for communication with one devices only. You cannot connect 2 devices to one port.
yeah, I have changed that, i try it right now. I am not sure if after changing every register is correct. 
hi, i get these numbers finally, like the picture.
and for my app, actually, there should be another two functions, the one is when temperature over 35, and CO2 over 1200, there is alarm wil be ringing
. and i want to have another function is when bluetooth is disconnected
, alarm will ring.Could you help me on that?
