It’s important to create a solderless breadboard prototype for projects like this, so you can make sure your sensor and code are working before making any permanent connections.

In this case, the soil sensor has stranded wires to it was necessary to temporarily attach solid headers to the ends of the sensor wires using solder, helping hands, and some heat shrink tubing.

Follow the circuit diagram to wire up the sensor's power, ground, clock, and data pins (data also gets a 10K pull-up resistor that comes with the soil sensor).

Sensor green wire to GND

Sensor red wire to 3.3V

Sensor yellow wire to NodeMCU pin D5 (GPIO 14)

Sensor blue wire to NodeMCU pin D6 (GPIO 12)

10K pull-up resistor between blue data pin and 3.3V

You can translate this to your preferred microcontroller. If you're using an Arduino Uno or similar, your board is already supported by the Arduino software. If you're using the ESP8266, please check out my Internet of Things Class for step-by-step help getting set up with ESP8266 in Arduino (by adding supplemental URLs to the Additional Boards Manager URLs field in Arduino's preferences, then searching for and selecting new boards from the boards manager). I tend to use the Adafruit ESP8266 Huzzah board type to program the NodeMCU ESP8266 board, but you can also install and use the Generic ESP8266 board support. You'll also need the SiLabs USB communications chip driver (available for Mac/Windows/Linux).

To get the sensor up and running with my Arduino-compatible board, I downloaded the SHT1x Arduino Library from Practical Arduino's github page, then unzipped the file and moved the library folder to my Arduino/libraries folder, then renamed it SHT1x. Open up the example sketch ReadSHT1xValues and change the pin numbers to 12 (dataPin) and 14 (clockPin), or copy the modified sketch here:

#include <SHT1x.h> #define dataPin 12 // NodeMCU pin D6 #define clockPin 14 // NodeMCU pin D5 SHT1x sht1x(dataPin, clockPin); // instantiate SHT1x object void setup() { Serial.begin(38400); // Open serial connection to report values to host Serial.println("Starting up"); } void loop() { float temp_c; float temp_f; float humidity; temp_c = sht1x.readTemperatureC(); // Read values from the sensor temp_f = sht1x.readTemperatureF(); humidity = sht1x.readHumidity(); Serial.print("Temperature: "); // Print the values to the serial port Serial.print(temp_c, DEC); Serial.print("C / "); Serial.print(temp_f, DEC); Serial.print("F. Humidity: "); Serial.print(humidity); Serial.println("%"); delay(2000); }

Upload this code to your board and open up the serial monitor to see the sensor data stream in.

If your code won't compile and complains about SHT1x.h not being found, you haven't got the required sensor library installed properly. Check your Arduino/libraries folder for one called SHT1x, and if it's somewhere else, like your downloads folder, move it to your Arduino libraries folder, and rename if it necessary.

If your code compiles but won't upload to your board, double check your board settings, be sure your board is plugged in, and select the correct port from the Tools menu.

If your code uploads but your serial monitor input is unrecognizable, double check your baud rate matches that specified in your sketch (38400 in this case).

If your serial monitor input doesn't seem correct, double check your wiring against the circuit diagram. Is your 10K pull-up resistor in place between the data pin and 3.3V? Are data and clock connected to the correct pins? Are power and ground connected as they should be throughout the circuit? Do not proceed until this simple sketch is working!

The next step is specific to the ESP8266 and configures the optional wireless sensor reporting portion of the sample project. If you're using a standard (non-wireless) Arduino-compatible microcontroller, continue to develop your final Arduino sketch and skip to Prepare Solar Charging Board.