Program Runs Perfect on one Device but not the other

I made a program that works perfectly fine on my main computer and in the terminal it prints the output from my temperature sensors fine. However when i try to plug the board into my laptop with the same program it doesnt work. Any help or advice?

Hello Harry,

if it works on one PC then the problem probably is not in the target or its code. The problem probably comes from the laptop.

Check out and summarize the differences of both computers:

  • state of cable or USB port
  • drivers
  • same settings of VCP like baud rate and so on

BR, Jan

Heya Jan,
Ill try exaplin with more detail.
So when i plug the board i have (NucleoF401RE) into my main computer and run the program it builds and displays the correct output in the terminal. My program is essesntially reading temperature from a DS18B20 sensor and it will display all of the temperatures and even the average. No problems there.

However, once i simply just swap the USB cable to my laptop, without changing code or running/building again from there, in the terminal it no longer displays the right output but instead when displaying temperature it reads: “Temperature = nan”. The nan part should not be here.

AGain all i have done is swap the USB cable so i could just visualise the output on the computer. If theres a way we could talk faster on this either by direct email or another method thatd be greatly appreciated :slight_smile:
Many thanks,

Additional note, i have tried a different USB same result so it cannot be the USB. I have installed the latest STlink driver on my laptop and the baud rate etc. stays the same

So the program is running , you see an output in console, but the value is not what you expected when the board is connected to the Notebook.
There must be some other aspect, it can not be on PC side (when settings are same and ports are ok - power/data ). It occurs to me that it could be a wire or a contact point what can lose contact during moving between PCs.

Have you tried where the nan value comes from (in your code or library what you use)?

BR, Jan

So when i am switching them nothing is being touched except for the USB cable. My breadboard and STM board stay still on my table and then simply plug the USB-A end from my computer into my laptop.

As for the nan value, another strange thing is that in the version working on my computer it would print something like:
Temperature = 24.5 C
Temperature = 24.7 C
Avg Temperature = 24.6 C
(Insert dashed line here)

However on my laptop it would simply print:
Temperature = nanC
(insert dashed line here)

So it doesnt even print the other line of:
“Avg Temperature = …”
When it should?

Hopefully this helps clear some things up.

I still see nothing what can lead to issue on PC side.
Do you use same Serial terminal with same settings on both PCs?
What a library for for DS18b20 do you use?

BR, Jan