EnviroDIY / Arduino-SDI-12

An Arduino library for SDI-12 communication with a wide variety of environmental sensors. This library provides a general software solution, without requiring any additional hardware.
https://github.com/EnviroDIY/Arduino-SDI-12/wiki
BSD 3-Clause "New" or "Revised" License
158 stars 100 forks source link

NodeMCU Compatibility #73

Closed KareemWaheed closed 3 years ago

KareemWaheed commented 3 years ago

Hi,

first of all thank you for the great work put inside this library.

I'm trying to use the library with NodeMCU module I successfully read from a sensor using arduino uno, but while connecting the nodemcu to the sensor and flash this code :

the serial log return : console log

could someone help with this

Thank you



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

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

/**
  '?' is a wildcard character which asks any and all sensors to respond
  'I' indicates that the command wants information about the sensor
  '!' finishes the command
*/
String myCommand = "?I!";

void setup() {
  Serial.begin(SERIAL_BAUD);
  while (!Serial)
    ;

  Serial.println("Opening SDI-12 bus...");
  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(myCommand);
  delay(300);                    // wait a while for a response
  while (mySDI12.available()) {  // write the response to the screen
    Serial.write(mySDI12.read());
  }
  delay(3000);  // print again in three seconds
}```
SRGDamia1 commented 3 years ago

Hm. Exactly the same program works on the Uno, right? The code looks right.

Are you shifting voltage? The Uno is 5V but NodeMCU (ESP8266) is only 3.3V. SDI-12 standard is 12V, but manufacturers use other voltages as well. Voltage shifters themselves can also cause issues if they don't have a fast or clean enough response. Are you sure you have the right pins?

What kind of sensor is it?

KareemWaheed commented 3 years ago

Hm. Exactly the same program works on the Uno, right? The code looks right.

Are you shifting voltage? The Uno is 5V but NodeMCU (ESP8266) is only 3.3V. SDI-12 standard is 12V, but manufacturers use other voltages as well. Voltage shifters themselves can also cause issues if they don't have a fast or clean enough response. Are you sure you have the right pins?

What kind of sensor is it?

I'm using Teros sensors from metergroup actually, they are working right now sorry for the delay in response I think it was wiring problem

Thank you for your contribution to making this library

SRGDamia1 commented 3 years ago

Ok. I'm glad it's working!