edison science corner
Published © CC BY

Smart Solar Plant

Artificial plant with environmental monitoring

IntermediateFull instructions provided3 days767
Smart Solar Plant

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
Carbon Monoxide Sensor (MQ7)
DFRobot Carbon Monoxide Sensor (MQ7)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino IoT Cloud
Arduino IoT Cloud
Arduino Web Editor
Arduino Web Editor

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering
Breadboard, 400 Pin
Breadboard, 400 Pin

Story

Read more

Custom parts and enclosures

3d printing files

Schematics

circuit digram

Code

ssp code

C/C++
#include "arduino_secrets.h"


#include <DFRobot_AHT20.h>

#include <FastLED.h>

DFRobot_AHT20 aht20;


int s0 = 0;

int s1 = 2;

int s2 = 15;

//Mux in "Z" pin

int Z_pin = A0;

#define NUM_LEDS 5

#define DATA_PIN 3

CRGB leds[NUM_LEDS];

/* 

  Sketch generated by the Arduino IoT Cloud Thing "Untitled"

  https://create.arduino.cc/cloud/things/4f22dc21-777b-4da6-bef3-2873e216…;


  Arduino IoT Cloud Variables description


  The following variables are automatically generated and updated when changes are made to the Thing


  float humidity;

  float temperature;

  int carbon_Monoxide;

  int light;

  int nitrogen_Dioxide;


  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions

  which are called when their values are changed from the Dashboard.

  These functions are generated with the Thing and added at the end of this sketch.

*/


#include "thingProperties.h"


void setup() {

  pinMode(s0, OUTPUT); 

  pinMode(s1, OUTPUT); 

  pinMode(s2, OUTPUT); 


  digitalWrite(s0, LOW);

  digitalWrite(s1, LOW);

  digitalWrite(s2, LOW);

  // Initialize serial and wait for port to open:

  Serial.begin(9600);

  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found

  delay(1500); 

  aht20.begin();


  // Defined in thingProperties.h

  initProperties();


  // Connect to Arduino IoT Cloud

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  

  /*

     The following function allows you to obtain more information

     related to the state of network and IoT Cloud connection and errors

     the higher number the more granular information you’ll get.

     The default is 0 (only errors).

     Maximum is 4

 */

  setDebugMessageLevel(2);

  ArduinoCloud.printDebugInfo();

   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

}


void loop() {

  ArduinoCloud.update();

  if(aht20.startMeasurementReady(/* crcEn = */true))

  humidity=aht20.getHumidity_RH();

  temperature=aht20.getTemperature_C();

  delay(1000);

  light=map(readMux(1),10,1024,0,100);

  carbon_Monoxide=readMux(0);

  nitrogen_Dioxide=readMux(3);

  delay(1000);

  if(light<=20)

  {

  leds[0] = CRGB::White;

  leds[1] = CRGB::White;

  leds[2] = CRGB::White;

  leds[3] = CRGB::White;

  leds[4] = CRGB::White;

  FastLED.show();

  delay(500);

  }

   if(light<=20)

  {

  leds[0] = CRGB::White;

  leds[1] = CRGB::White;

  leds[2] = CRGB::White;

  leds[3] = CRGB::White;

  leds[4] = CRGB::White;

  FastLED.show();

  delay(500);

  }

}

float readMux(int channel){

  int controlPin[] = {s0, s1, s2};


  int muxChannel[4][3]={

    {0,0,0}, //channel 0

    {1,0,0}, //channel 1

    {0,1,0}, //channel 2

    {1,1,0}, //channel 3

  }


  //loop through the 3 sig

  for(int i = 0; i < 3; i ++){

    digitalWrite(controlPin[i], muxChannel[channel][i]);

  }


  int val = analogRead(Z_pin);

 return val;

 delay(2000);

}



 


,>

Credits

edison science corner

edison science corner

54 projects • 65 followers
Electronic enthusiast watch videos from here https://www.youtube.com/channel/UCVcOsUBmH4hzVSnmJA_i5SA

Comments