Hi there,
I'Ve got a problem - and I think I might be quite close to the solution.
So I have an Arduino Nano to whom a pressure sensor ist attached. This works and is not the issue. Just mentioning it for "completeness".
So my acutal problem is the readout of a SMT100 soil moisture sensor with the Nano.
The SMT100 can be accessed via RS485, so: SMT100 -> RS485-to-TTL -> Arduino Nano.
To read out I use the following code, below:
// Test File für SHT25 + MPL3115
#include <Wire.h>
#include <Adafruit_MPL3115A2.h>
#include <Sodaq_SHT2x.h>
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
#include <Arduino.h>
#include <SoftwareSerial.h>
#define TX 1
#define RX 2
#define CONTROL 13
boolean RCV_ready = LOW;
boolean SND_ready = HIGH;
SoftwareSerial mySerial(TX, RX);
String str;
void setup()
{
Wire.begin(); // for pressure sensor
Serial.begin(9600);
pinMode(CONTROL, OUTPUT); // Pin "Conrol" is in output mode, i.e. it will send to the RS485 module
digitalWrite(CONTROL, RCV_ready); // R485 module in recieve mode
mySerial.begin(9600);
}
void loop()
{
// Begin pressure sensor
if (! baro.begin()) {
Serial.println("Couldnt find sensor");
delay(500);
}
//READ MLP3115
float pascals = baro.getPressure();
float tempC = baro.getTemperature();
Serial.print(pascals/100);
Serial.print(" ");
Serial.print(SHT2x.GetHumidity());
Serial.print(" ");
Serial.print(tempC);
Serial.print(" ");
Serial.print(SHT2x.GetTemperature());
//End pressure sensor
// Begin SMT100 sensor
if(mySerial.available() > 0){
Serial.print(" myserial found ");
}
Serial.print(" * ");
str = mySerial.read();
Serial.print(str);
Serial.print(" ");
str = mySerial.read();
Serial.print(str);
Serial.print(" ");
str = mySerial.read();
Serial.print(str);
Serial.print(" ");
str = mySerial.read();
Serial.print(str);
Serial.print(" ");
str = mySerial.read();
Serial.print(str);
Serial.print(" ");
str = mySerial.read();
Serial.print(str);
Serial.print(" ");
Serial.println(" * ");
delay(250);
}
// Comment section
/*
Actual response
* 57 56 55 46 50 56 *
* 32 51 48 46 50 57 *
* 32 50 49 46 57 52 *
* 32 50 51 46 50 50 *
* 32 109 121 115 101 114 *
* 105 97 108 32 102 111 *
*/
Now I get a response, see the "comment section" in the code, but it does not make sense to me. Also, there is no difference in the output when setting the CONTROL pin to either HIGH or LOW.
Could you help me out here?
