Hello everyone, I'm trying to read two temperatures using LM35 and send them to a phone or computer using HC05 in order to control them. I want to send setpoints to the MCU. I tried to send different numbers ( 2 digit numbers) to the MCU and echo them, however I managed to recieve only the first digit of the numbers I was trying to send. I thought maybe I have problems in sending back the numbers and I tried to use the recieved temperature in my code as a setpoint, but it didn't work.
Here is my code. I also added the C file.
Thanks in advance, Alex
Code:
#include <stdio.h>
#include "lpc17xx_gpio.h"
#include "lpc17xx_pinsel.h"
#include "lpc17XX_uart.h"
#include "lpc17XX_adc.h"
#include "Hardware.h"
#include "Delay_RIT.h"
int main()
{
uint8_t buffstr [20];
uint8_t Temprec [1];
uint8_t temprec;
GPIO_SetDir(2,(1<<2),1);
HW_Init();
while(1)
{
uint16_t temp1 = HW_ADC_Read1();
uint16_t temp2 = HW_ADC_Read2();
uint8_t len= sprintf( (char*)buffstr," %u\n %u\n ",temp1,temp2);
UART_Send(LPC_UART3,buffstr,len,NONE_BLOCKING);
UART_Receive(LPC_UART3,Temprec,1,NONE_BLOCKING);
temprec= Temprec[0];
Delay_RIT_ms(1000);
if(temp1>=(temprec+1))
GPIO_ClearValue(2,(1<<2)) ;
else if ( temp1<=temprec)
GPIO_SetValue(2,(1<<2));
}
}