цифровая электроника
вычислительная техника
встраиваемые системы

 

Система полива растений на основе Arduino своими руками

Автор: Mike(admin) от 3-08-2017, 20:45

Система полива цветов и других растений позволяет автоматизировать процесс ухаживания за флорой как в домашних условиях, так и в условиях огородных и садовых участков. Благодаря такой системе может быть получен более качественный урожай и продлена жизнь растений за счет их своевременного полива.


Система полива растений на основе Arduino своими руками

Для тех, кто не профессионал в электронике и не хочет покупать дорогостоящее оборудование для полива растений, предлагается сделать такую систему самостоятельно с помощью платы Arduino.


Данный проект основан на Arduino-подобной плате под названием Bluno компании DFRobot. Она имеет возможности беспроводного подключения по Bluetooth, поэтому при желании Вы можете контролировать полив растений с помощью мобильного телефона с поддержкой Bluetooth. Для измерения количества влаги в почве используется трехпроводной датчик влажности. Также для активации насоса, который будет обеспечивать подачу воды растениям, следует подключить модуль реле на 5 В. Помимо этого для отображения информации здесь применяется модуль OLED дисплея 2.7" 128x64. Схема подключения электрической части системы полива растений на основе Arduino представлена ниже.


Схема подключения электрической части системы полива растений на основе Arduino

Значение H, отображаемое на OLED-дисплее, определяет количество влажности, обнаруженную датчиком в почве. Растение находится в нормальном состоянии, если значение H составляет от 300 до 800; растение испытывает недостаток воды, если значение H меньше 300. Датчик почвы измеряет и выдает результат в абсолютных единицах (от 0 до 800), а влажность, отображаемая в Bluno, выражается процентах, поэтому итоговая влажность равна ((влажность почвы) / 800 * 100%).


Ниже приведен код программы для работы системы автоматического полива растений на основе Arduino.



#include "Arduino.h"
#include "PlainProtocol.h"
#include "U8glib.h"

PlainProtocol myBLUNO(Serial,115200);

U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI: SCK = 13, MOSI = 11, CS = 10, A0 = 9

int Relay=2;      
int Humid=0;
uint8_t draw_state=0;

// для формирования изображения
const uint8_t rook_bitmap[] PROGMEM = {

0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xC0,0x00,0x00,0x00,
0x00,0x00,0x0F,0xC1,0xF0,0x00,0x00,0x00,
0x00,0x00,0x3E,0x00,0x78,0x06,0x00,0x00,
0x00,0x00,0x78,0x00,0x1C,0x1F,0x00,0x00,
0x00,0x00,0xF0,0x00,0x0E,0x7F,0xC0,0x00,
0x00,0x00,0xE0,0x00,0x06,0xF0,0xF8,0x00,
0x00,0x00,0xC0,0x00,0x07,0xE0,0x3C,0x00,
0x00,0x01,0xC0,0x00,0x07,0x80,0x0E,0x00,
0x00,0x01,0xC0,0x00,0x07,0x80,0x06,0x00,
0x00,0x01,0xC0,0x00,0x07,0x00,0x07,0x00,
0x00,0x01,0xC0,0x00,0x07,0x00,0x03,0x80,
0x0F,0xFF,0xC0,0x00,0x06,0x00,0x01,0x80,
0x1F,0x0F,0xE0,0x00,0x06,0x00,0x01,0xC0,
0x3C,0x00,0xF0,0x00,0x06,0x00,0x00,0xC0,
0x70,0x00,0x38,0x00,0x06,0x00,0x00,0xE0,
0x60,0x00,0x1C,0x00,0x0E,0x00,0x00,0x60,
0x60,0x00,0x0F,0x00,0x0C,0x00,0x00,0x60,
0x60,0x00,0x07,0x80,0x1C,0x00,0x00,0x60,
0xE0,0x00,0x03,0xFF,0xFE,0x00,0x00,0x60,
0xE0,0x00,0x01,0xFF,0xFF,0xE0,0x00,0x60,
0xE0,0x00,0x01,0xE0,0x0F,0xF0,0x00,0xE0,
0xE0,0x00,0x01,0xC0,0x00,0x78,0x01,0xE0,
0x60,0x00,0x01,0x9F,0x3E,0x3C,0x03,0xC0,
0x60,0x00,0x01,0x91,0x22,0x1E,0x1F,0x80,
0x70,0x00,0x01,0x80,0x00,0x1F,0xFE,0x00,
0x30,0x00,0x01,0x80,0x00,0x0F,0xFF,0xC0,
0x38,0x01,0xFF,0x80,0x00,0x0E,0x07,0xF0,
0x1C,0x1F,0xFF,0x8C,0x06,0x1E,0x00,0xF8,
0x1F,0xFC,0x07,0x8E,0x0E,0x3C,0x00,0x1C,
0x07,0xF0,0x03,0xC7,0xFC,0x78,0x00,0x1E,
0x01,0xC0,0x01,0xE1,0xF0,0xF0,0x00,0x0E,
0x03,0x80,0x01,0xF0,0x03,0xE0,0x00,0x0F,
0x07,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x07,
0x06,0x00,0x00,0x3F,0xFE,0xF0,0x00,0x03,
0x06,0x00,0x00,0x0F,0xC0,0x38,0x00,0x07,
0x06,0x00,0x00,0x07,0x00,0x1C,0x00,0x07,
0x06,0x00,0x00,0x0E,0x00,0x1C,0x00,0x0E,
0x06,0x00,0x00,0x1C,0x00,0x0E,0x00,0x1E,
0x06,0x00,0x00,0x1C,0x00,0x0E,0x00,0x3C,
0x06,0x00,0x00,0x38,0x00,0x06,0x00,0x78,
0x07,0x00,0x00,0x38,0x00,0x06,0x01,0xF0,
0x07,0x80,0x00,0x70,0x00,0x07,0x87,0xC0,
0x01,0xE0,0x00,0xE0,0x00,0x07,0xFF,0x00,
0x00,0xF8,0x01,0xE0,0x00,0x07,0xFC,0x00,
0x00,0x7F,0xC7,0xC0,0x00,0x07,0x10,0x00,
0x00,0x1F,0xFF,0xE0,0x00,0x07,0x00,0x00,
0x00,0x00,0xFF,0xF0,0x00,0x0E,0x00,0x00,
0x00,0x00,0x00,0x7C,0x00,0x1E,0x00,0x00,
0x00,0x00,0x00,0x1F,0x00,0x3E,0x00,0x00,
0x00,0x00,0x00,0x07,0xE1,0xFE,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xEE,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xB8,0x00,0x00,

};





const uint8_t rook_bitmap1[] PROGMEM = {



0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x00,0x0F,0x83,0xF0,0x00,0x00,
0x00,0x00,0x60,0x1E,0x00,0x7C,0x00,0x00,
0x00,0x00,0xF8,0x38,0x00,0x1E,0x00,0x00,
0x00,0x03,0xFE,0x70,0x00,0x0F,0x00,0x00,
0x00,0x1F,0x0F,0x60,0x00,0x07,0x00,0x00,
0x00,0x3C,0x07,0xE0,0x00,0x03,0x00,0x00,
0x00,0x70,0x01,0xE0,0x00,0x03,0x80,0x00,
0x00,0x60,0x01,0xE0,0x00,0x03,0x80,0x00,
0x00,0xE0,0x00,0xE0,0x00,0x03,0x80,0x00,
0x01,0xC0,0x00,0xE0,0x00,0x03,0x80,0x00,
0x01,0x80,0x00,0x60,0x00,0x03,0xFF,0xF0,
0x03,0x80,0x00,0x60,0x00,0x07,0xF0,0xF8,
0x03,0x00,0x00,0x60,0x00,0x0F,0x00,0x3C,
0x07,0x00,0x00,0x60,0x00,0x1C,0x00,0x0E,
0x06,0x00,0x00,0x70,0x00,0x38,0x00,0x06,
0x06,0x00,0x00,0x30,0x00,0xF0,0x00,0x06,
0x06,0x00,0x00,0x38,0x01,0xE0,0x00,0x06,
0x06,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x07,
0x06,0x00,0x07,0xFF,0xFF,0x80,0x00,0x07,
0x07,0x00,0x0F,0xF0,0x01,0x80,0x00,0x07,
0x07,0x80,0x1E,0x00,0x01,0x80,0x00,0x07,
0x03,0xC0,0x3C,0xE0,0x71,0x80,0x00,0x06,
0x01,0xF8,0x79,0x10,0x89,0x80,0x00,0x06,
0x00,0x7F,0xF8,0x00,0x01,0x80,0x00,0x0E,
0x03,0xFF,0xF0,0x00,0x01,0x80,0x00,0x0C,
0x0F,0xE0,0x70,0x00,0x01,0xFF,0x80,0x1C,
0x1F,0x00,0x78,0xC0,0x19,0xFF,0xF8,0x38,
0x38,0x00,0x3C,0x60,0x31,0xE0,0x3F,0xF8,
0x78,0x00,0x1E,0x1F,0xE3,0xC0,0x0F,0xE0,
0x70,0x00,0x0F,0x00,0x07,0x80,0x03,0x80,
0xF0,0x00,0x07,0xC0,0x0F,0x80,0x01,0xC0,
0xE0,0x00,0x0F,0xFE,0x7F,0x00,0x00,0xE0,
0xC0,0x00,0x0F,0x7F,0xFC,0x00,0x00,0x60,
0xE0,0x00,0x1C,0x03,0xF0,0x00,0x00,0x60,
0xE0,0x00,0x38,0x00,0xE0,0x00,0x00,0x60,
0x70,0x00,0x38,0x00,0x70,0x00,0x00,0x60,
0x78,0x00,0x70,0x00,0x38,0x00,0x00,0x60,
0x3C,0x00,0x70,0x00,0x38,0x00,0x00,0x60,
0x1E,0x00,0x60,0x00,0x1C,0x00,0x00,0x60,
0x0F,0x80,0x60,0x00,0x1C,0x00,0x00,0xE0,
0x03,0xE1,0xE0,0x00,0x0E,0x00,0x01,0xE0,
0x00,0xFF,0xE0,0x00,0x07,0x00,0x07,0x80,
0x00,0x3F,0xE0,0x00,0x07,0x80,0x1F,0x00,
0x00,0x08,0xE0,0x00,0x03,0xE3,0xFE,0x00,
0x00,0x00,0xE0,0x00,0x07,0xFF,0xF8,0x00,
0x00,0x00,0x70,0x00,0x0F,0xFF,0x00,0x00,
0x00,0x00,0x78,0x00,0x3E,0x00,0x00,0x00,
0x00,0x00,0x7C,0x00,0xF8,0x00,0x00,0x00,
0x00,0x00,0x7F,0x87,0xE0,0x00,0x00,0x00,
0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x77,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x1D,0xC0,0x00,0x00,0x00,0x00,



};



const uint8_t rook_bitmap2[] PROGMEM = {


0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xC0,0x00,0x00,0x00,
0x00,0x00,0x0F,0xC1,0xF0,0x00,0x00,0x00,
0x00,0x00,0x3E,0x00,0x78,0x06,0x00,0x00,
0x00,0x00,0x78,0x00,0x1C,0x1F,0x00,0x00,
0x00,0x00,0xF0,0x00,0x0E,0x7F,0xC0,0x00,
0x00,0x00,0xE0,0x00,0x06,0xF0,0xF8,0x00,
0x00,0x00,0xC0,0x00,0x07,0xE0,0x3C,0x00,
0x00,0x01,0xC0,0x00,0x07,0x80,0x0E,0x00,
0x00,0x01,0xC0,0x00,0x07,0x80,0x06,0x00,
0x00,0x01,0xC0,0x00,0x07,0x00,0x07,0x00,
0x00,0x01,0xC0,0x00,0x07,0x00,0x03,0x80,
0x0F,0xFF,0xC0,0x00,0x06,0x00,0x01,0x80,
0x1F,0x0F,0xE0,0x00,0x06,0x00,0x01,0xC0,
0x3C,0x00,0xF0,0x00,0x06,0x00,0x00,0xC0,
0x70,0x00,0x38,0x00,0x06,0x00,0x00,0xE0,
0x60,0x00,0x1C,0x00,0x0E,0x00,0x00,0x60,
0x60,0x00,0x0F,0x00,0x0C,0x00,0x00,0x60,
0x60,0x00,0x07,0x80,0x1C,0x00,0x00,0x60,
0xE0,0x00,0x03,0xFF,0xFE,0x00,0x00,0x60,
0xE0,0x00,0x01,0xFF,0xFF,0xE0,0x00,0x60,
0xE0,0x00,0x01,0xE0,0x00,0xF0,0x00,0xE0,
0xE0,0x00,0x01,0xC0,0x00,0x78,0x01,0xE0,
0x60,0x00,0x01,0x91,0x11,0x3C,0x03,0xC0,
0x60,0x00,0x01,0x8A,0x0A,0x1E,0x1F,0x80,
0x70,0x00,0x01,0x84,0x04,0x1F,0xFE,0x00,
0x30,0x00,0x01,0x8A,0x0A,0x0F,0xFF,0xC0,
0x38,0x01,0xFF,0x91,0x11,0x0E,0x07,0xF0,
0x1C,0x1F,0xFF,0x80,0x00,0x1E,0x00,0xF8,
0x1F,0xFC,0x07,0x81,0xF0,0x3C,0x00,0x1C,
0x07,0xF0,0x03,0xC2,0x08,0x78,0x00,0x1E,
0x01,0xC0,0x01,0xE4,0x04,0xF0,0x00,0x0E,
0x03,0x80,0x01,0xF0,0x03,0xE0,0x00,0x0F,
0x07,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x07,
0x06,0x00,0x00,0x3F,0xFE,0xF0,0x00,0x03,
0x06,0x00,0x00,0x0F,0xC0,0x38,0x00,0x07,
0x06,0x00,0x00,0x07,0x00,0x1C,0x00,0x07,
0x06,0x00,0x00,0x0E,0x00,0x1C,0x00,0x0E,
0x06,0x00,0x00,0x1C,0x00,0x0E,0x00,0x1E,
0x06,0x00,0x00,0x1C,0x00,0x0E,0x00,0x3C,
0x06,0x00,0x00,0x38,0x00,0x06,0x00,0x78,
0x07,0x00,0x00,0x38,0x00,0x06,0x01,0xF0,
0x07,0x80,0x00,0x70,0x00,0x07,0x87,0xC0,
0x01,0xE0,0x00,0xE0,0x00,0x07,0xFF,0x00,
0x00,0xF8,0x01,0xE0,0x00,0x07,0xFC,0x00,
0x00,0x7F,0xC7,0xC0,0x00,0x07,0x10,0x00,
0x00,0x1F,0xFF,0xE0,0x00,0x07,0x00,0x00,
0x00,0x00,0xFF,0xF0,0x00,0x0E,0x00,0x00,
0x00,0x00,0x00,0x7C,0x00,0x1E,0x00,0x00,
0x00,0x00,0x00,0x1F,0x00,0x3E,0x00,0x00,
0x00,0x00,0x00,0x07,0xE1,0xFE,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFE,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xEE,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xB8,0x00,0x00, 
};


void setup() {
  
    myBLUNO.init();
    pinMode(Relay, OUTPUT);
    
}


void draw0 (void)
{
  
   // команды для перерисовки изображения на экране
  u8g.drawBitmapP( 0,1, 8, 63, rook_bitmap);

  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(72,24);
  u8g.print("H:");
  u8g.print(Humid);    // считывание значения влажности 
  u8g.drawStr(72,40,"I'm ");
  u8g.drawStr(84,56,"happy");

 }
 
 void draw1 (void)
{
  
   // команды для перерисовки изображения на экране
  u8g.drawBitmapP( 0,1, 8, 63, rook_bitmap1);
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(72,24);
  u8g.print("H:");
  u8g.print(Humid);    //Read Moisure Sensor Value 
  u8g.drawStr(72,40,"I'm ");
  u8g.drawStr(84,56,"happy");
 }
  void draw2 (void)
{
  
   // команды для перерисовки изображения на экране
  u8g.drawBitmapP( 0,1, 8, 63, rook_bitmap2);
  u8g.setFont(u8g_font_unifont);
  u8g.setPrintPos(72,24);
  u8g.print("H:");
  u8g.print(Humid);    //Read Moisure Sensor Value 
  u8g.drawStr(72,40,"I'm ");
  u8g.drawStr(72,56,"thirsty");
 }
 
 void draw(void)
 {
   switch(draw_state)
   {
     case 0:draw0();break;
     case 1:draw1();break;
     case 2:draw2();break;
      default:
     draw0();
     break;
   }
 }
 

void loop()
{
    if (myBLUNO.available()) {
        if (myBLUNO.equals("RELAY")){
          digitalWrite(Relay,myBLUNO.read());
          
        }     
         else if(myBLUNO.equals("HUMID")){
         myBLUNO.write("HUMID", Humid/8); 
        }      
    }    
      
   static unsigned long HUMIDTimer=millis();
    if (millis() - HUMIDTimer >= 500) {
        HUMIDTimer=millis();
        Humid=analogRead(0);
      if(Humid>300)
      {
          draw_state++;
          if(draw_state>1)
          draw_state=0;
      }
      else if(Humid<300)
      {
        draw_state=2;
      }
      
    }
        static unsigned long OledTimer=millis();       
    if (millis() - OledTimer >= 500) {
        OledTimer=millis();
    
       u8g.firstPage();                         
        do{
            draw();
        }
       while(u8g.nextPage());
     
    }
}



Теги: Arduino, Bluetooth



Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь.
Мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем.

Комментарии:

Оставить комментарий