Hallo,
ich möchte mit dem DC-SS500 von Sure Electronics per UART die relative Luftfeuchtigkeit + Temperatur auslesen.
Das Problem ist, das ich für die ersten fünf Abfragen Ergebnisse bekomme, dann bekomm ich nichts mehr. Läuft hier ein Puffer o.ä. voll?
023Centigrade
023Centigrade, 073Fahrenheit
test
023Centigrade
023Centigrade, 073Fahrenheit
test
023Centigrade
023Centigrade, 073Fahrenheit
test
023Centigrade
023Centigrade, 073Fahrenheit
test
023Centigrade
023Centigrade, 073Fahrenheit
test
023Centigrade
test
test
test
test
test
Datenblatt: http://www.sure-electronics.net/download/DC-SS500_Ver1.0_EN.pdf
Verkabelung:
Arduino 5v -> DC-SS500 5v
Arduino GND -> DC-SS500 5v
Arduino RX -> DC-SS500 TX
Arduino D2 -> DC-SS500 RX
Code:
#include <SoftwareSerial.h>
#define rxPin 12 // actually, I am not using a rxPin
#define txPin 2// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);int get_str(char *s, int ms);
int str_to_int(char *s);void setup()
{
// define pin modes for tx, rx, led pins:
pinMode(txPin, OUTPUT);
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
Serial.begin(9600);
}void loop()
{
char s[30];
int T, RH;// measure and display the temperature in degrees F
mySerial.println("$sure temp");
get_str(s, 100);
Serial.println("test");
delay (1000);
// Now the same for the relative humidity,
mySerial.println("$sure temp -c");
get_str(s, 100);
delay(1000);}
int get_str(char *s, int ms)
{
char ch;
int n=0;while(ms--)
{
while (Serial.available() > 0)
{
Serial.print(char(Serial.read()));
if ((ch == 0x0a) || (ch == 0x0d)) // CR or LF
{
s[n] = 0; // null terminate the string
return(n);
}}
}
}