Maker Pro
Arduino

Make Your Plant SMART! By Arduino

December 05, 2018 by ElectroPeak Inc
Share
banner

With this cool project, you can make sure your lovely plants are always in their best condition.

So you have always wondered how to add technology to your plants? With this cool project, you can make sure your lovely plants are always in their good condition. After doing this project you will:

  • Learn how to use analog-output sensors
  • Learn how to display data on OLED displays
  • Make your plant smile if everything is fine and cry if there is something wrong.

Smart Plant; What’s the base of the idea?

Nowadays, We can increase the efficiency of jobs, hobbies, lifestyle, etc. by adding technology to our tools and stuff with basic electronics components. Adding artificial intelligence to things that we care about is very attractive and amazing. You might have seen the Green Houses that use smart control and supervision on plants, flowers, etc. They can control the timing and amount of water of plants, lighting, temperature, and many other important and effective parameters.

It’s a good start point to enter this exciting world and learn how to do it. In this project, we will get the necessary details about our plant’s condition; such as sand moisture, environment temperature, and the amount of light that plant can receive. Monitoring these data can help us to always keep our plant in its good condition. Reading data from sensors by Arduino is quite easy and monitoring that on a display is not so hard. So, what are you waiting for? Let’s make our plants smart!

Required Materials

1111_9JR5nj7P0T.jpg

Circuit

Circuit

cir-800x548.jpg

There are a few important points you should pay attention to. First, you need a power supply that can provide at least 5V and 20mA. If your power supply does not meet these conditions, you should connect modules to the 5V pin of Arduino (Don’t use 3v3). You should also note that an OLED display with SPI protocol is used. If your display is I2C, you must connect them to the A4 and A5 pins of Arduino. In addition, the moisture sensor used here has 2 pins and therefore an amplifier board with one analog output is necessary. The DHT11 sensor can measure both temperature and humidity, but we our code displays temperature only. You can add humidity by adding a few lines of code.

Assembling

24_bCVdvwL0BM.jpg
x1_4Qfum13iVG.jpg
x2_Y2280dyQlL.jpg
x3_02zogx7qnl.jpg

Since our flower pot is small and there is a space limit, we have used a thin ribbon wire which is suitable for our flower pot.

For connecting this wires, it’s better to separate the pin headers from the components. First, the OLED display pin header should be desoldered. To do this, you can use a soldering iron but heater soldering is preferable.

The OLED display is stuck to a board which provides the SPI communication. To have a better view of the display and hide wires, you can separate the display panel from the board. Use a sharp knife to do this.

Now its time to solder wires to the board. The board is going to be placed in a wet sand, so we must make all the connections and components waterproof. First, we cover it with a Plastic Wrap. Then we cover it by a shrink tube. You should heat it to stick to the board. Now fill the seams by hot glue.

The moisture sensor that we chose, needs to have a separate amplifier. First, separate the pin headers, then make them waterproof

For LDR sensor, You must connect a 10k ohm resistor between GND and sensor’s pin. This must also be made waterproof.

For Temperature sensor, You must connect a 10k ohm resistor between Vcc and Signal pin.

Now it is time to connect all sensors and display modules to Arduino Nano. After finishing the assembly, do not forget to also make Arduino waterproof.

22_ciq7iKfGY2.jpg

Now empty some sand from the pot (not all of that, its harmful for the plant) and put the board and sensors (except temperature sensor) inside. The temperature sensor must be out of the pot. Now fill the pot with removed sand.

23_9AQPDZCZKu.jpg

We are all done! Let’s upload the code.

x4_2zR9MOJ3pO.jpg

Code

In this code (at the end of the page), We use SSD1306 and DHT library for OLED display and DHT 11. You should first add these libraries, then compile and Upload the code to Arduino Nano. If its the first time you run an Arduino board, don’t worry. Just follow these steps:

  • Go to www.arduino.cc/en/Main/Software and download the software of your OS. Install the IDE software as instructed.
  • Run the Arduino IDE and clear the text editor and copy the following code in the text editor.
  • Navigate to sketch and include the libraries (Download libraries from the following links). Now click add ZIP library and add the libraries
  • Choose the board in tools and boards, select Arduino Nano.
  • Connect the Arduino to your PC and set the com port in tools and port.
  • Press the Upload (Arrow sign) button.
  • You are all set!
#include "ssd1306.h"
#include "DHT.h"

#define VCCSTATE SSD1306_SWITCHCAPVCC
#define WIDTH     128
#define HEIGHT     64
#define PAGES       8

#define OLED_RST    9 
#define OLED_DC     8
#define OLED_CS    10
#define SPI_MOSI   11    /* connect to the DIN pin of OLED */
#define SPI_SCK    13     /* connect to the CLK pin of OLED */

#define DHTPIN 2 
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

float LIGHT;
float MOISTURE;
float TEMP;
float HUMID;

int counter=0;
int scroll=23;


uint8_t oled_buf[WIDTH * HEIGHT / 8];

const uint8_t percent [] PROGMEM = {
    0x70, 0x20, 
    0xd8, 0x60, 
    0xcc, 0x40, 
    0x8c, 0xc0, 
    0xcd, 0x80, 
    0xd9, 0x00, 
    0x73, 0x38, 
    0x02, 0x6c, 
    0x06, 0xcc, 
    0x04, 0xc4, 
    0x08, 0xc4, 
    0x18, 0x4c, 
    0x10, 0x38, 
    0x00, 0x00
};

const uint8_t celsius [] PROGMEM = {
    0x00, 0x00, 
    0x00, 0x00, 
    0x30, 0xf0, 
    0x59, 0xf8, 
    0x4b, 0x00, 
    0x72, 0x00, 
    0x06, 0x00, 
    0x06, 0x00, 
    0x02, 0x00, 
    0x03, 0x00, 
    0x01, 0x98, 
    0x00, 0xf0, 
    0x00, 0x00, 
    0x00, 0x00
};

const uint8_t LOGO [] PROGMEM = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x22, 0x10, 0x00, 0x00, 
    0x00, 0x00, 0x42, 0x28, 0x00, 0x00, 
    0x00, 0x00, 0x81, 0x24, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 
    0x00, 0x01, 0x18, 0xc2, 0x00, 0x00, 
    0x00, 0x01, 0x18, 0x82, 0x00, 0x00, 
    0x00, 0x02, 0x24, 0xc1, 0x00, 0x00, 
    0x00, 0x02, 0x37, 0x21, 0x00, 0x00, 
    0x00, 0x04, 0x4b, 0x70, 0x80, 0x00, 
    0x00, 0x08, 0x51, 0x10, 0x40, 0x00, 
    0x00, 0x08, 0xae, 0xe8, 0x40, 0x00, 
    0x00, 0x10, 0xc1, 0x98, 0x20, 0x00, 
    0x00, 0x11, 0x3c, 0x4c, 0x00, 0x00, 
    0x00, 0x21, 0x83, 0xe4, 0x10, 0x00, 
    0x00, 0x42, 0x7c, 0x36, 0x10, 0x00, 
    0x00, 0x45, 0x22, 0xd2, 0x08, 0x00, 
    0x00, 0x86, 0xd9, 0x35, 0x04, 0x00, 
    0x00, 0x89, 0x66, 0x59, 0x84, 0x00, 
    0x01, 0x0c, 0x99, 0x8c, 0x82, 0x00, 
    0x01, 0x12, 0xc4, 0x77, 0x42, 0x00, 
    0x02, 0x2d, 0xb3, 0x08, 0xc1, 0x00, 
    0x04, 0x22, 0x4c, 0xd7, 0x20, 0x80, 
    0x04, 0x5b, 0x92, 0x24, 0xb0, 0x80, 
    0x08, 0x64, 0x65, 0x5b, 0x50, 0x40, 
    0x08, 0x8e, 0x9a, 0xa4, 0xa8, 0x00, 
    0x10, 0xb5, 0x41, 0x11, 0x14, 0x60, 
    0x23, 0xca, 0xbe, 0xee, 0xec, 0x00, 
    0x16, 0x39, 0x6b, 0x5b, 0xd0, 0x10, 
    0x02, 0x14, 0x94, 0xa4, 0x20, 0x10, 
    0x04, 0x2b, 0x49, 0x12, 0xd0, 0x08, 
    0x04, 0x3d, 0xbf, 0xff, 0x75, 0xb4, 
    0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 
    0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 
    0x3d, 0xdd, 0xfb, 0xbb, 0xda, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};


const uint8_t SAD [] PROGMEM = {
      0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x01, 0xff, 0xc0, 0x00, 
    0x00, 0x0f, 0xc1, 0xf8, 0x00, 
    0x00, 0x1c, 0x00, 0x1e, 0x00, 
    0x00, 0x70, 0x00, 0x07, 0x00, 
    0x00, 0xe0, 0x00, 0x01, 0x80, 
    0x01, 0x80, 0x00, 0x00, 0xc0, 
    0x03, 0x00, 0x00, 0x00, 0x60, 
    0x06, 0x00, 0x00, 0x00, 0x30, 
    0x06, 0x00, 0x00, 0x00, 0x18, 
    0x0c, 0x3f, 0x80, 0x7e, 0x18, 
    0x0c, 0x71, 0xc1, 0xc3, 0x8c, 
    0x18, 0x40, 0x41, 0x81, 0x8c, 
    0x18, 0x00, 0x00, 0x00, 0x04, 
    0x10, 0x00, 0x00, 0x00, 0x06, 
    0x30, 0x00, 0x00, 0x03, 0x86, 
    0x30, 0x00, 0x00, 0x03, 0xc2, 
    0x30, 0x00, 0x7f, 0x03, 0x62, 
    0x30, 0x01, 0xff, 0xc3, 0x22, 
    0x30, 0x03, 0x80, 0x63, 0x32, 
    0x33, 0x06, 0x00, 0x33, 0x32, 
    0x37, 0x06, 0x00, 0x1b, 0x32, 
    0x3f, 0x0c, 0x00, 0x19, 0xb6, 
    0x3b, 0x08, 0x00, 0x0c, 0xe6, 
    0x33, 0x18, 0x00, 0x0c, 0x06, 
    0x23, 0x1b, 0xff, 0xec, 0x04, 
    0x63, 0x1f, 0xff, 0xfc, 0x0c, 
    0x63, 0x00, 0x00, 0x00, 0x0c, 
    0x63, 0x00, 0x00, 0x00, 0x18, 
    0x66, 0x00, 0x00, 0x00, 0x30, 
    0x3f, 0x00, 0x00, 0x00, 0x30, 
    0x0b, 0x80, 0x00, 0x00, 0x60, 
    0x01, 0xc0, 0x00, 0x01, 0xc0, 
    0x00, 0xe0, 0x00, 0x03, 0x80, 
    0x00, 0x38, 0x00, 0x0f, 0x00, 
    0x00, 0x1e, 0x00, 0x3c, 0x00, 
    0x00, 0x07, 0xff, 0xf0, 0x00, 
    0x00, 0x00, 0xff, 0x80, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00
};
const uint8_t SMILE [] PROGMEM = {
    0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x03, 0xff, 0x00, 0x00, 
    0x00, 0x0f, 0xc7, 0xe0, 0x00, 
    0x00, 0x38, 0x00, 0x78, 0x00, 
    0x00, 0xe0, 0x00, 0x1c, 0x00, 
    0x01, 0xc0, 0x00, 0x07, 0x00, 
    0x03, 0x00, 0x00, 0x03, 0x80, 
    0x06, 0x00, 0x00, 0x01, 0xc0, 
    0x0c, 0x00, 0x00, 0x00, 0xc0, 
    0x0c, 0x00, 0x00, 0x00, 0x60, 
    0x18, 0x00, 0x00, 0x00, 0x30, 
    0x10, 0x00, 0x00, 0x00, 0x30, 
    0x30, 0x00, 0x00, 0x00, 0x18, 
    0x20, 0x00, 0x00, 0x00, 0x18, 
    0x60, 0x7e, 0x01, 0xfc, 0x08, 
    0x60, 0xe7, 0x83, 0x8e, 0x08, 
    0x61, 0x81, 0x83, 0x02, 0x0c, 
    0x60, 0x00, 0x00, 0x00, 0x0c, 
    0x40, 0x00, 0x00, 0x00, 0x0c, 
    0x40, 0x00, 0x00, 0x04, 0x0c, 
    0x40, 0xf0, 0x00, 0x3e, 0x0c, 
    0x60, 0xff, 0x83, 0xfc, 0x0c, 
    0x60, 0x67, 0xff, 0xcc, 0x0c, 
    0x60, 0x60, 0x10, 0x0c, 0x08, 
    0x20, 0x20, 0x00, 0x18, 0x18, 
    0x30, 0x30, 0x00, 0x18, 0x18, 
    0x30, 0x18, 0x00, 0x30, 0x10, 
    0x18, 0x0c, 0x00, 0x60, 0x30, 
    0x18, 0x0e, 0x00, 0xc0, 0x60, 
    0x0c, 0x03, 0x87, 0x80, 0x60, 
    0x06, 0x01, 0xff, 0x00, 0xc0, 
    0x07, 0x00, 0x30, 0x01, 0x80, 
    0x03, 0x80, 0x00, 0x03, 0x00, 
    0x01, 0xc0, 0x00, 0x0e, 0x00, 
    0x00, 0x70, 0x00, 0x1c, 0x00, 
    0x00, 0x3c, 0x00, 0xf0, 0x00, 
    0x00, 0x0f, 0xff, 0xc0, 0x00, 
    0x00, 0x00, 0xfe, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00
};

const uint8_t TEM [] PROGMEM = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 
    0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 
    0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 
    0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 
    0x00, 0x00, 0x10, 0x18, 0x00, 0x00, 
    0x00, 0x00, 0x1e, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1f, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x18, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x18, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1f, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1f, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x1c, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x18, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 
    0x00, 0x00, 0x11, 0x88, 0x00, 0x00, 
    0x00, 0x00, 0x11, 0x88, 0x00, 0x00, 
    0x00, 0x00, 0x11, 0x88, 0x00, 0x00, 
    0x00, 0x00, 0x11, 0x88, 0x00, 0x00, 
    0x00, 0x00, 0x11, 0x88, 0x00, 0x00, 
    0x00, 0x00, 0x31, 0x8c, 0x00, 0x00, 
    0x00, 0x00, 0x71, 0x8e, 0x00, 0x00, 
    0x00, 0x00, 0xc1, 0x83, 0x00, 0x00, 
    0x00, 0x01, 0x81, 0x81, 0x80, 0x00, 
    0x00, 0x01, 0x83, 0xc1, 0x80, 0x00, 
    0x00, 0x03, 0x0f, 0xf0, 0xc0, 0x00, 
    0x00, 0x03, 0x0f, 0xf0, 0xc0, 0x00, 
    0x00, 0x03, 0x1f, 0xf8, 0xc0, 0x00, 
    0x00, 0x03, 0x1f, 0xf8, 0xc0, 0x00, 
    0x00, 0x03, 0x0f, 0xf0, 0xc0, 0x00, 
    0x00, 0x03, 0x0f, 0xf0, 0xc0, 0x00, 
    0x00, 0x01, 0x87, 0xe1, 0x80, 0x00, 
    0x00, 0x01, 0x80, 0x01, 0x80, 0x00, 
    0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 
    0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 
    0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 
    0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 
    0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const uint8_t SAND [] PROGMEM = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x73, 0x80, 
    0x00, 0x00, 0x00, 0x00, 0xe1, 0xc0, 
    0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 
    0x00, 0x00, 0x00, 0x01, 0xc0, 0xe0, 
    0x00, 0xe0, 0x00, 0x03, 0x80, 0x70, 
    0x01, 0xf0, 0x00, 0x03, 0x00, 0x30, 
    0x03, 0xf8, 0x00, 0x07, 0x00, 0x38, 
    0x07, 0xfc, 0x00, 0x06, 0x00, 0x18, 
    0x0f, 0x9e, 0x00, 0x0e, 0x00, 0x1c, 
    0x0f, 0x0f, 0x00, 0x0e, 0x00, 0x1c, 
    0x1e, 0x07, 0x80, 0x0c, 0x00, 0x0c, 
    0x1c, 0x07, 0x80, 0x0c, 0xc0, 0x0c, 
    0x3c, 0x03, 0xc0, 0x0c, 0xe0, 0x0c, 
    0x7c, 0x03, 0xc0, 0x0e, 0xf0, 0x1c, 
    0x78, 0x01, 0xc0, 0x06, 0x78, 0x18, 
    0x78, 0x01, 0xc0, 0x07, 0x18, 0x38, 
    0x78, 0x01, 0xc0, 0x03, 0x80, 0x70, 
    0x79, 0xe1, 0xc0, 0x01, 0xe1, 0xe0, 
    0x79, 0xe1, 0xe0, 0x00, 0xff, 0xc0, 
    0x79, 0xe1, 0xff, 0xf8, 0x3f, 0x00, 
    0x79, 0xc3, 0xff, 0xff, 0x00, 0x00, 
    0x79, 0xc3, 0xff, 0xff, 0xc0, 0x00, 
    0x3d, 0xef, 0xc0, 0x0f, 0xf0, 0x00, 
    0x1f, 0xff, 0x00, 0x01, 0xfc, 0x00, 
    0x1f, 0xfe, 0x00, 0x00, 0x7e, 0x00, 
    0x0f, 0xfc, 0x00, 0x00, 0x1f, 0x00, 
    0x07, 0xf8, 0x00, 0x00, 0x0f, 0x80, 
    0x07, 0xf0, 0x0f, 0xf8, 0x0f, 0x80, 
    0x01, 0xf0, 0x7f, 0xfc, 0x0f, 0x00, 
    0x00, 0xe1, 0xff, 0xf8, 0x1e, 0x00, 
    0x00, 0x63, 0xf8, 0x00, 0x3e, 0x00, 
    0x00, 0x07, 0xe0, 0x00, 0x7c, 0x00, 
    0x00, 0x1f, 0x80, 0x01, 0xf8, 0x00, 
    0x00, 0x1f, 0x80, 0x07, 0xe0, 0x00, 
    0x00, 0x3f, 0xc0, 0x1f, 0xc0, 0x00, 
    0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 
    0x00, 0xff, 0xff, 0xfe, 0x00, 0x00, 
    0x00, 0xe0, 0xff, 0xf0, 0x00, 0x00, 
    0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 
    0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 
    0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 
    0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

const uint8_t SUN [512] PROGMEM = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x80, 0x03, 0x00, 0x02, 0x00, 
    0x00, 0xc0, 0x03, 0x00, 0x06, 0x00, 
    0x00, 0xe0, 0x01, 0x00, 0x0e, 0x00, 
    0x00, 0x70, 0x00, 0x00, 0x1c, 0x00, 
    0x00, 0x38, 0x00, 0x00, 0x38, 0x00, 
    0x00, 0x1c, 0x00, 0x00, 0x70, 0x00, 
    0x00, 0x0c, 0x0f, 0xe0, 0x60, 0x00, 
    0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 
    0x00, 0x00, 0xf0, 0x3c, 0x00, 0x00, 
    0x00, 0x01, 0xc0, 0x0e, 0x00, 0x00, 
    0x00, 0x01, 0x80, 0x07, 0x00, 0x00, 
    0x00, 0x03, 0x00, 0x03, 0x80, 0x00, 
    0x00, 0x03, 0x00, 0x01, 0x80, 0x00, 
    0x00, 0x06, 0x00, 0x01, 0x80, 0x00, 
    0x00, 0x06, 0x00, 0x01, 0xc0, 0x00, 
    0x3f, 0x86, 0x00, 0x00, 0xc3, 0xf8, 
    0x7f, 0xc6, 0x00, 0x00, 0xc7, 0xf8, 
    0x00, 0x06, 0x00, 0x00, 0xc0, 0x00, 
    0x00, 0x06, 0x00, 0x01, 0xc0, 0x00, 
    0x00, 0x07, 0x00, 0x01, 0x80, 0x00, 
    0x00, 0x03, 0x00, 0x01, 0x80, 0x00, 
    0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 
    0x00, 0x01, 0xc0, 0x07, 0x00, 0x00, 
    0x00, 0x00, 0xe0, 0x0e, 0x00, 0x00, 
    0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 
    0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 
    0x00, 0x0c, 0x07, 0xc0, 0x60, 0x00, 
    0x00, 0x1c, 0x00, 0x00, 0x70, 0x00, 
    0x00, 0x38, 0x00, 0x00, 0x38, 0x00, 
    0x00, 0x70, 0x00, 0x00, 0x1c, 0x00, 
    0x00, 0xe0, 0x03, 0x00, 0x0e, 0x00, 
    0x00, 0xc0, 0x03, 0x00, 0x06, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00


};

void SADD(void){
      SSD1306_clear(oled_buf);
while (counter<20){
  if ((counter%2)==0)
  { SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 20, SAD, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 19, SAD, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 18, SAD, 40, 40, oled_buf);
    SSD1306_display(oled_buf);}

  else  
  { SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 18, SAD, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 19, SAD, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 20, SAD, 40, 40, oled_buf);
    SSD1306_display(oled_buf);}

    counter++;}
    counter=0;}

void HAPPY(void){
  SSD1306_clear(oled_buf);
while (counter<20){
  if ((counter%2)==0)
  { SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 23, SMILE, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 19, SMILE, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 16, SMILE, 40, 40, oled_buf);
    SSD1306_display(oled_buf);}

  else  
  { SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 16, SMILE, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 19, SMILE, 40, 40, oled_buf);
    SSD1306_display(oled_buf);
    SSD1306_clear(oled_buf);
    SSD1306_bitmap(40, 23, SMILE, 40, 40, oled_buf);
    SSD1306_display(oled_buf);}

    counter++;}
    counter=0;}    
void dsply(int input){
  int n1,n2;
  if (input<10){ SSD1306_char3216(10, 25, '0', oled_buf); switch(input) { case 0 : SSD1306_char3216(26, 25, '0', oled_buf); break; case 1 : SSD1306_char3216(26, 25, '1', oled_buf); break; case 2 : SSD1306_char3216(26, 25, '2', oled_buf); break; case 3 : SSD1306_char3216(26, 25, '3', oled_buf); break; case 4 : SSD1306_char3216(26, 25, '4', oled_buf); break; case 5 : SSD1306_char3216(26, 25, '5', oled_buf); break; case 6 : SSD1306_char3216(26, 25, '6', oled_buf); break; case 7 : SSD1306_char3216(26, 25, '7', oled_buf); break; case 8 : SSD1306_char3216(26, 25, '8', oled_buf); break; case 9 : SSD1306_char3216(26, 25, '9', oled_buf); break; } } else{ n1=input/10; n2=input%10; switch(n1) { case 0 : SSD1306_char3216(10, 25, '0', oled_buf); break; case 1 : SSD1306_char3216(10, 25, '1', oled_buf); break; case 2 : SSD1306_char3216(10, 25, '2', oled_buf); break; case 3 : SSD1306_char3216(10, 25, '3', oled_buf); break; case 4 : SSD1306_char3216(10, 25, '4', oled_buf); break; case 5 : SSD1306_char3216(10, 25, '5', oled_buf); break; case 6 : SSD1306_char3216(10, 25, '6', oled_buf); break; case 7 : SSD1306_char3216(10, 25, '7', oled_buf); break; case 8 : SSD1306_char3216(10, 25, '8', oled_buf); break; case 9 : SSD1306_char3216(10, 25, '9', oled_buf); break; } switch(n2) { case 0 : SSD1306_char3216(26, 25, '0', oled_buf); break; case 1 : SSD1306_char3216(26, 25, '1', oled_buf); break; case 2 : SSD1306_char3216(26, 25, '2', oled_buf); break; case 3 : SSD1306_char3216(26, 25, '3', oled_buf); break; case 4 : SSD1306_char3216(26, 25, '4', oled_buf); break; case 5 : SSD1306_char3216(26, 25, '5', oled_buf); break; case 6 : SSD1306_char3216(26, 25, '6', oled_buf); break; case 7 : SSD1306_char3216(26, 25, '7', oled_buf); break; case 8 : SSD1306_char3216(26, 25, '8', oled_buf); break; case 9 : SSD1306_char3216(26, 25, '9', oled_buf); break; } } } void setup() { Serial.begin(9600); dht.begin(); SSD1306_begin(); SSD1306_clear(oled_buf); SSD1306_string(17, 0, "ELECTROPEAK", 16 ,1 ,oled_buf); SSD1306_bitmap(42, 16, LOGO, 48, 48, oled_buf); SSD1306_display(oled_buf); delay(4000); } void loop() { LIGHT=analogRead(A0); LIGHT=(LIGHT/1024)*100; Serial.print("LIGHT : "); Serial.print(LIGHT); Serial.println(" %"); SSD1306_clear(oled_buf); SSD1306_string(30, 0, "LIGHTING", 16 ,1 ,oled_buf); SSD1306_bitmap(80, 16, SUN, 48, 48, oled_buf); SSD1306_bitmap(45, 40, percent, 14, 14, oled_buf); dsply(LIGHT); SSD1306_display(oled_buf); delay(4000); MOISTURE=analogRead(A1); MOISTURE=(MOISTURE/1024)*100; MOISTURE=(MOISTURE-100)*(-1); Serial.print("MOISTURE : "); Serial.print(MOISTURE); Serial.println(" %"); SSD1306_clear(oled_buf); SSD1306_string(22, 0, " MOISTURE", 16 ,1 ,oled_buf); SSD1306_bitmap(80, 16, SAND, 48, 48, oled_buf); SSD1306_bitmap(45, 40, percent, 14, 14, oled_buf); dsply(MOISTURE); SSD1306_display(oled_buf); delay(4000); HUMID = dht.readHumidity(); TEMP = dht.readTemperature(); Serial.print("TEMPERATURE : "); Serial.print(TEMP); Serial.println(" C"); SSD1306_clear(oled_buf); SSD1306_string(21, 0, "TEMPERATURE", 16 ,1 ,oled_buf); SSD1306_bitmap(80, 16, TEM, 48, 48, oled_buf); SSD1306_bitmap(45, 40, celsius, 14, 14, oled_buf); dsply(TEMP); SSD1306_display(oled_buf); delay(4000); if (TEMP>50 || TEMP<5)
SADD();

if (MOISTURE<50)
SADD();

if (TEMP<50 && TEMP>5){
  if (MOISTURE>70){
    if (LIGHT>80)
    HAPPY();}
  }

}
100_3PJrlU0w8O.jpg

What’s Next?

Now you can develop this project to your interest. Here is some suggests that you can add them to the project :

  • You can have a clock on display and measuring the time of different conditions and predict the time of conditions that plant need water or more light. you should add an RTC module like DS1307 and add some code to read time and calendar and display that or save some of them to have more details of the plant.
  • By adding a buzzer, you can set some alarm that warns you about plant conditions. for example when the sand is very dry, it can ring 1 time per hour.
  • We set just to emoji for different conditions. You can add more face model for any conditions. For this, you should read the OLED display tutorial to learn how to convert your image to a Hex code.

You can also read this project on ElectroPeak's official website:

https://electropeak.com/learn/guides/project_make_your_plant_smart/

Related Content

Comments


You May Also Like