I have a problem with Arduino with temperature measure. When testing it in Arduino IDE Serial monitor i have responses like:

23.37
23.37
23.37

But quick reconnect by c# .net core app, with console output gives me:

23. 
44
23.
44
23.4
4 

My Arduino code is very short and looks like:

#include <OneWire.h> 
#include <DallasTemperature.h> 
#define ONE_WIRE_BUS 2 

OneWire oneWire(ONE_WIRE_BUS);  
DallasTemperature sensors(&oneWire);

void setup(void) 
{ 
 // start serial port 
 Serial.begin(9600); 
 // Start up the library 
 sensors.begin(); 
} 
void loop(void) 
{ 
 sensors.requestTemperatures(); 
  delay(1500);
 Serial.println(sensors.getTempCByIndex(0)); 
   delay(100); 
} 

C# code part with receiving:

soc.ReceiveMessage(port.ReadExisting());

where ReceiveMessage method just

public void ReceiveMessage(string msg)
{
  Console.WriteLine(msg);
  soc.WebSocketServices.Broadcast(msg); 
}

What am i doing wrong?

1 Answers

0
Kamil On

Change Serial.begin(9600) to Serial.begin(115200) and change this value in baud in C# code helped me. There is about 90% messages received good. But i don't have an idea why it helped.