You need to connect the 2 header pins (+ and -) to the YL-38 soil moisture sensor control board as shown by the 2 blue wires above. The board has 4 pins on the other side labeled VCC, GND, D0, A0.
VCC: Positive Voltage Power Supply GND: Ground D0: Digital Out /////here we are not connecting this pin...we only taking analog valueA0: Analog Out
In our case, we are going to be making the following connections: VCC on the YL-38 module to 3V3 on the ESP8266 Development board. (Red wire) GND on the YL-38 module to GND on the ESP8266 Development board. (Black wire) A0 on the YL-38 module to A0 on the ESP8266 Development board. (Yellow Wire)
Now onto the Arduino IDEHere we will only see the coding for sensor only. Full coding we will see in coding section.
////Create a new sketch in the Arduino IDE and paste the following code into the body: int sensor_pin = A0;
int output_value ;
void setup() {
Serial.begin(115200);
Serial.println("Reading From the Sensor ...");
delay(2000); }
void loop() {
output_value= analogRead(sensor_pin);
Serial.print("Moisture : ");
Serial.print(output_value);
Serial.print("\n");
delay(1000); }
Calibrating SensorNow that you have a functioning soil moisture sensor, how do you get some useful data out of it?
Take note of the number that flashes across the screen on your serial monitor inside of the Arduino IDE while your sensor is completely dry, it is usually 9XX if you have your soil moisture sensor plugged into 3V on your ESP8266 Development board. Next, completely submerge your soil moisture leads in a small cup of water. Be careful not to submerge the wires during this step as this could damage your electronic hardware.
As soon as you submerge your sensor in the water, keep an eye on the serial monitor. You will see the readings jump to a different value!!!!!
In mine (yours may be slightly different), a completely dry sensor gives a reading of about ~750, while a completely wet sensor reads consistently around ~180. Taking these numbers, we are going to add a few lines of code to our Arduino Sketch to map these values to a more familiar percentage (%).
First, we need to convert the values we are getting to a percentage, and we can do this using the map function.
output_value = map(output_value,750,180,0,100);
This simple function takes our 2 values and converts them from 0 - 100% based on their number between each other. The first number you put into the map function is the sensor value when it is completely dry, next comes the wet value. The following values are the map values, 0 being 0% and 100 being 100%.
Next, we an add a % symbol into the line being printed as shown.
Serial.print("%\n");
Your completely modified code should look like this before you push it to the development board:
int sensor_pin = A0;
int output_value ;
void setup() {
Serial.begin(115200);
Serial.println("Reading From the Sensor ...");
delay(2000); }
void loop() {
output_value = analogRead(sensor_pin);
output_value = map(output_value,750,180,0,100);
Serial.print("Moisture : ");
Serial.print(output_value);
Serial.print("%\n");
delay(1000); }
Tutorial on Connecting NodeMCU to ThingsIO.AI CloudNodeMCU is one of the most popular IoT Development platform use by the thousands of developers worldwide. What is more attractive is that it can run on the even more popular Arduino IDE.
NodeMCU alone is able to connect and send the data to cloud that makes it more preferable(no need to have bunch of boards, only one is enough).
The goal of this tutorial is to enable you to send capture and send data to cloud from your NodeMCU device. Before starting this tutorial make sure you have your NodeMCU and lm35 sensor handy.
Part I: Installation and Settings of Arduino IDEOnce you download and install the arduino ide, to get start with ide it is good to check this first (http://www.circuitbasics.com/arduino-basics-installing-software).
Part II: Setting Up Cloud Account on ThingsIO.AIThingsIO.AI is a IoT platform for developers. As a developer we understood the pain of not having a seamless place to connect, analyze and process device data. Many pure analytics platforms does not offer device management, which is core for the iot. That is the reason for ThingsIO.AI.
- Register the account in http://thingsio.ai/#/register.
- You will get the notification for sign up.
- Go in your email address and verify your account.
- After that, sign in your account with your email address and password
- Now, you will be on the project dashboard. Click on the new project option.
- Click on the add a new device option. You will get device ID.
- Enter the device name and click on the create and configure device.
- You will be on your device dashboard.
Some basic points (1-5) for analysing data on ThingsIO.AI
1. Track your device’s special parameters here. This can be set in device configuration(default to null).
2. You can see your real time and special parameter’s graph.
3. You can see your all data points.
4. You can see here your last 5 data points.
5. You can see here all the list of created graphs.
- Go in sample device code options and click on the NodeMCU.
- You will get the sample code from there copy and paste into your Arduino IDE.
Click on the “Send trial data” to send a trial data to the server:
Part III: Setting Up NodeMCUwe have already made hardware connection so just upload this code on nodemcu by using an usb. and open your serial monitor where you see the values of temperature in different units.
- one important thing while uploading the code, check the device id.
Part IV: Charting and Visualizations on ThingsIO.AIGo to your ThingsIO.AI account and go to your device ->
Click on the configuration device option:
- You can set the special parameters (this is tracked on the device dashboard) & transform it accordingly and add new parameters (Parameters are updated automatically as you send them from your device).
- Click on the update device option:
- To create a graph for your device click on the “create graph option."
You will see graph of data points something like this.....
Comments