Simulation SDI-12

Hi everybody.
I want to simulate SDI-12, but it seems that the SDI-12 library does not work with Proteus. Can you tell me whether it can work or not?

//MASTER CODE


#include <SDI12.h>

#define SERIAL_BAUD 9600 /*!< The baud rate for the output serial port */
#define DATA_PIN 2        /*!< The pin of the SDI-12 data bus */
#define POWER_PIN 3       /*!< The sensor power pin (or -1 if not switching power) */

String inputString = "";         // a String to hold incoming data
bool stringComplete = false;  // whether the string is complete
SDI12 mySDI12(DATA_PIN);

char   inByte      = 0;
String sdiResponse = "";
String myCommand   = "";

void setup() {
  // initialize serial:
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  inputString.reserve(200);
  mySDI12.begin();
  delay(500);  // allow things to settle

  // Power the sensors;
  if (POWER_PIN > 0) {
    Serial.println("Powering up sensors...");
    pinMode(POWER_PIN, OUTPUT);
    digitalWrite(POWER_PIN, HIGH);
    delay(200);
  }
}

void loop() {
  serialEvent1();
  if (stringComplete) {
    if(inputString =="?!\n")
     {
       digitalWrite(13, HIGH);
       Serial.println('1');  //Send Address
      }
      if(inputString =="0D0!\n")
     {
       digitalWrite(13, LOW);
       Serial.println("113EP100G-08 01151108151545");  //request probe ID
      } 
      
    Serial.println(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}
void serialEvent1() {
  while (mySDI12.available()) {
     digitalWrite(13, HIGH);
    char inChar = (char)mySDI12.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag so the main loop can
    // do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

//SLAVE CODE


#include <SDI12.h>
#define DATA_PIN 2        /*!< The pin of the SDI-12 data bus */
#define POWER_PIN 3       /*!< The sensor power pin (or -1 if not switching power) */

/** Define the SDI-12 bus */
SDI12 mySDI12(DATA_PIN);



void setup() {
 
  mySDI12.begin();
  delay(500);  // allow things to settle

  // Power the sensors;
  if (POWER_PIN > 0) {
 //   Serial.println("Powering up sensors...");
    pinMode(POWER_PIN, OUTPUT);
    digitalWrite(POWER_PIN, HIGH);
    delay(200);
  }
}

void loop() {
   mySDI12.sendCommand("?!");
   delay(1000);
   mySDI12.sendCommand("0D0!");
   delay(1000);
}

Is your question if your setup/code will work in real life or how to get it working in proteus? For proteus related questions, you're probably better of on a proteus forum.

You don't seem to have a problem with the IDE hence your topic has been moved.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.