Green Roof Monitoring

This is a simple system which keeps watching over your vegetalized roof.

IntermediateFull instructions provided5 days1,584
Green Roof Monitoring

Things used in this project

Hardware components

DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
ST STM32L4, STM32F7 NUCLEO-L432KC - Carte de développement
×1
Cellule solaire
×1
Batterie Li-Ion 3,7V 1050 mAh
×1
Module Sigfox Wisol
×1
Breadboard (generic)
Breadboard (generic)
×1
DS18B20 Programmable Resolution 1-Wire Digital Thermometer
Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer
×1
Seeed Studio Power adapter Module (LiPo Rider Pro)
×1
Female Header 8 Position 1 Row (0.1")
Female Header 8 Position 1 Row (0.1")
×5
Male-Header 36 Position 1 Row- Long (0.1")
Male-Header 36 Position 1 Row- Long (0.1")
×1
Vishay Triode BS250
×2
Adafruit Color Sensor ADA1334
×1
Step-Up/Step-Down Voltage Regulator
×1
Adafruit Light Sensor ADA1384
×1
Through Hole Resistor, 1.5 kohm
Through Hole Resistor, 1.5 kohm
×4
Soil moisture sensor SEN0193
×1
Through Hole Resistor, 68 kohm
Through Hole Resistor, 68 kohm
×1
Capacitor 47 µF
Capacitor 47 µF
×2
Through Hole Resistor, 1.8 kohm
Through Hole Resistor, 1.8 kohm
×1

Software apps and online services

Sigfox
Sigfox
Ubidots
Ubidots
Mbed Studio
Arm Mbed Studio
KiCad
KiCad

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)
Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)
Solder Wire, Lead Free
Solder Wire, Lead Free
Wire Stripper & Cutter, 26-14 AWG Solid & Stranded Wires
Wire Stripper & Cutter, 26-14 AWG Solid & Stranded Wires

Story

Read more

Schematics

Supply schematic

The schematic of the power supply board

Supply PCB

The PCB of the power supply board.

NUCLEO card schematic

The schematic of the principal card that contains the NUCLEO card, the sensors and the Sigfox module

NUCLEO card PCB

The PCB of the principal card

Mapping

This is how we have connected our cables and wires.

Photo of System

This is a photo of our system.

Code

main.cpp

C/C++
The main program of project.
#include"mbed.h"
#include"DS1820.h"
#include"DHT.h"
#include "TCS34725.h"
#include "Sigfox.h"
#include "WakeUp.h"
#include <math.h>

#define LOG_RANGE           5.0f

float Temp_Sol;
float Temp_Air;
float Humi_Air;
float Humi_Sol;
float Lumiere;
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t c;

DHT dht22(D6,DHT22);//pin,type
DS1820  ds1820(A0);//pin
TCS34725 tcs34725(D12, A6); //I2C sda and scl
AnalogIn humigrove(A1);
AnalogIn lumiere(A2);
AnalogIn bat(A4);
DigitalOut ledTest(LED1);
DigitalOut mos(D9);

u8 readBat() {
    float tmp;
    tmp = 7.0f*(float)bat - 3.3f;
    if(tmp > 1)
        tmp = 1;
    else if(tmp < 0)
        tmp = 0;
    return (u8)(tmp * 255);
}

void ReadTempHumiAir(){
  int err=1;
  while(err!=0){
    err=dht22.readData();
    ledTest = 1;
    wait(1);
   }
  if(err==0){
     Temp_Air= dht22.ReadTemperature(CELCIUS);
     Humi_Air=dht22.ReadHumidity();
     ledTest = 0;
     }

 }
 
void ReadTempSol(){
  if (ds1820.begin()) {
        ds1820.startConversion();   // start temperature conversion from analog to digital
        wait(1);                  // let DS1820 complete the temperature conversion
        Temp_Sol = ds1820.read();
        Temp_Sol = Temp_Sol - (-0.06923*Temp_Sol + 7.621); 
   }
}  

void ReadRGBC(){
    if(tcs34725.init(TCS34725_INTEGRATIONTIME_101MS, TCS34725_GAIN_60X)){
        ledTest = 1;
        wait(1);
        ledTest = 0;
         tcs34725.getColor(r,g,b,c);
         r/=256;
         g/=256;
         b/=256;
         c/=256;
    }
}

void ReadHumiSol(){
    float grove_moist=humigrove.read();
    Humi_Sol= -252.2*(float)grove_moist + 196.7;
    if(Humi_Sol < 0)    Humi_Sol = 0;
    if(Humi_Sol > 100)    Humi_Sol = 100;
}

void ReadLumi(){
    float raw=lumiere.read();
    float loglux=2*raw*LOG_RANGE;
    Lumiere=(float)(pow(10,loglux)*65535.0f)/100000.0f;
    Lumiere = 1.64 * (float)Lumiere + 119.0f;
}

int main(){
    Sigfox sigfox(D1,D0);
    WakeUp::calibrate();
    ReadRGBC();
    wait(5);
    
    while(1){
        WakeUp::set(1200);
        mos = 0;
        sigfox.wake();
        wait(2);
        ReadTempHumiAir();
        ReadTempSol();
        ReadRGBC();
        ReadHumiSol();
        wait(1); 
        ReadLumi();
        wait(1);               
        //printf("R:%d, G:%d, B:%d\n\r", r, g, b);  
        sigfox.send((s16)(Temp_Air*10),(u16)(Humi_Air*10),(s16)(Temp_Sol*10),(u8)Humi_Sol,
            (u8)Lumiere,(u8)r,(u8)g,(u8)b, readBat());
        wait(5);
        mos = 1;
        sigfox.sleep();
        deepsleep();
    }
}

sigfox.cpp

C/C++
The sigfox class
#include "Sigfox.h"

Sigfox::Sigfox(PinName tx, PinName rx): Serial(tx, rx) {
    
}

/**
  * @brief  Tester si le module sigfox est pret
  * @param  
  * @retval 1 si OK, 0 sinon
  */
bool Sigfox::ready() {
    printf("AT");
    char c = getc();
    if(c == 'O')
        return 1;
    else
        return 0;
}

/**
  * @brief  Envoyer les parametres recuperees par les capteurs
  * @param  Les valeurs detectees par les capteurs
  * @retval 
  */
void Sigfox::send(s16 temp_air, u16 hum_air, s16 temp_sol, u8 hum_sol, u16 lum, u8 val_r, u8 val_g, u8 val_b, u8 bat) {
    uint16_t temp1, temp2;
    uint32_t tmp;
    temp1 = temp_air + 200;
    temp2 = temp_sol + 200;
    tmp = temp1 | (temp2<<10) | (hum_air<<20);
    printf("AT$SF=%08x%02x%04x%02x%02x%02x%02x\r", tmp, hum_sol, lum, val_r, val_g, val_b, bat);
}

void Sigfox::sleep() {
    printf("AT$P=1\r");  
}

void Sigfox::wake() {
    printf("AT$P=0\r");   
}

sigfox.h

C/C++
The sigfox class
#ifndef SIGFOX_H
#define SIGFOX_H

#include "mbed.h"

typedef uint8_t     u8;
typedef uint16_t    u16;
typedef int16_t     s16;

class Sigfox: public Serial{
    public:
        Sigfox(PinName tx, PinName rx);
    
        /**
        * @brief  Tester si le module sigfox est pret
        * @param  
        * @retval 1 si OK, 0 sinon
        */
        bool ready();
    
        /**
        * @brief  Envoyer les parametres recuperees par les capteurs
        * @param  Les valeurs detectees par les capteurs
        * @retval 
        */
        void send(s16 temp_air, u16 hum_air, s16 temp_sol, u8 hum_sol, u16 lum, u8 val_r, u8 val_g, u8 val_b,u8 bat);
        
        // Sleep mode
        void sleep();
        
        // Wake up
        void wake();
};

#endif

Credits

包慧灵
1 project • 0 followers
Contact
刘颖姗
1 project • 0 followers
Contact
Diego Moreno Villanueva
1 project • 1 follower
Contact
Yuxiao ZHANG
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.