Close

Measuring Plant Moisture in analog.io

A project log for analog.io - A full stack IoT platform

A full stack project dedicated to easily collecting, analyzing and sharing IoT sensor data.

luke-benoLuke Beno 08/30/2015 at 06:250 Comments

As mentioned in the project description, analog.io is a powerful tool that could be used to solve a variety of world problems. Today there are two challenges that are very important for humanity, the first is improvement of the food supply and the second is water conservation. A lot of water is used to irrigate crops but there is the fundamental question of what the optimal amount of water necessary.

Here is a quick and easy IoT water sensor system that I setup using a Sensor from Elecrow, myMSP430 Sensor Node and it is connected using the nRF24 - ESP8266 Hub that I wrote about.

Here's the code:

#include <analog_io.h>
#include <SPI.h>

#define SENSOR_PWR P2_4

uint8_t x = 0;
analog_io radio(P3_5, P3_6, P2_5);

const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };

void setup()
{
  Serial.begin(9600);
  analogReference(INTERNAL2V5);
  pinMode(SENSOR_PWR, OUTPUT);
  digitalWrite(SENSOR_PWR, LOW);
  
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power

  radio.setTXaddress((void*)txaddr);
}

void loop()
{
  
  digitalWrite(SENSOR_PWR, HIGH);
  sleep(500);
  long data = map(analogRead(A4), 0, 1023, 0, 500);
  digitalWrite(SENSOR_PWR, LOW);
  radio.print("{\"soil\":");
  radio.print (data/100);
  radio.print (".");
  radio.print (data%100+5); // this is wrong if the tens are 0
  radio.print ("}");
  
  radio.flush();
  
  delay(100);
  
  radio.print (data/100);
  radio.print (".");
  radio.print (data%100+5); // this is wrong if the tens are 0
  radio.flushBle();

  radio.deepsleep();
  sleep(10000);
}

And the data so far:

I will update more as time goes on :)

Discussions