UART/ISR 2nd sensor getting the same reading as the first one | Cypress Semiconductor
UART/ISR 2nd sensor getting the same reading as the first one
I am pretty new to programming and PSoC so please excuse me if I don't use the correct vocabulary. I am having problem getting the correct output data from 2 sensors.
The 2 digital sensors works fine when they are plugged on their own power and ground pins. My goal is to plug several sensors to my board (space is limited) so I want to stack at least 2 sensors to the same power and ground (VSSD) pins (different signal pins).
I modified my code so that the second sensor is using the same power pin as the first one, but for some reason, the second sensor gets the reading of the first one.
Here is my code for the first sensor:
//Define function, sensor #1
//Declare variable 'reading' of type 'decagonReading' (see "decagon.h")
decagonSensorDataCount = 0;
sscanf(decagonSensorData, "%hu %hu %hu\r\n", &reading.raw_dielectric, &reading.raw_EC, &reading.raw_temp);
//Define ISR, sensor #1
char ch = UART_1_GetByte();
if (ch != 0)// ignore NULL characters
decagonSensorData[decagonSensorDataCount] = ch;//Read a byte
decagonSensorDataCount++;//add one to Data Count, so it will then read the next byte
To get the data from the second sensor, I basically copied and pasted those 2 functions, changed the name of the variable (UART_1 -> UART_2, decagonHandeler1 -> decagon Handeler2, ISR_Decagon_2, ...) but keep the same lines for Digital_Sensor_Power_1_Write because they are using the ground power pin as the first sensor.
I do not understand why the 2nd sensor is getting the data from the first one. I checked multiple times that all my variables are correct. Is it a problem with the ISR? I tried setting a delay in my main function between the times I call those 2 functions but it doesn't change anything...
Does anybody see what could be the problem ?
Please let me know if something is not clear in my setup. Thank you.