panotech poly
Published

PanneauTech

Green roofs have been proven to increase Solar Panel's performance. What are the optimal plants that provide the best efficiency ?

IntermediateFull instructions provided57
PanneauTech

Things used in this project

Hardware components

Gravity: TCS34725 RGB Color Sensor For Arduino
DFRobot Gravity: TCS34725 RGB Color Sensor For Arduino
×2
Adafruit Waterproof DS18B20 Digital temperature sensor
Adafruit Waterproof DS18B20 Digital temperature sensor
×2
SparkFun Humidity and Temperature Sensor Breakout - Si7021
SparkFun Humidity and Temperature Sensor Breakout - Si7021
×2
SSD1306
×1
Wisol SIGFOX
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
MCP73831 Single Cell, Li-Ion/Li-Polymer Charge Management Controller
Microchip MCP73831 Single Cell, Li-Ion/Li-Polymer Charge Management Controller
For the PCB
×1
S7V8F3
For the PCB
×1
MCP73831 Single Cell, Li-Ion/Li-Polymer Charge Management Controller
Microchip MCP73831 Single Cell, Li-Ion/Li-Polymer Charge Management Controller
For the PCB
×1
Custom PCB
Custom PCB
PCB
×2
STM32 Nucleo STM32 L432KC
×1
Pololu - USB Micro-B Connector Breakout Board
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Solar Panel 2W
×1

Software apps and online services

MDK-Essential Edition
Arm Mbed MDK-Essential Edition
Arduino IDE
Arduino IDE
Microsoft Azure
Microsoft Azure
Backend Sigfox

Hand tools and fabrication machines

Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long
Breadboard, 170 Pin
Breadboard, 170 Pin

Story

Read more

Custom parts and enclosures

PCB Control card

Schematics

PanneauTech

Code

Master PanneauTech

C/C++
MBED Platform
/*
 * This file is part of a student's project in computer & electronics engineering.
 * Microcontroller used : NUCLEO-L432KC
 * Developed for the LSST Data Management System.
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * To get a copy of the GNU General Public License
 * see <https://www.gnu.org/licenses></https:>.
 */

//Default libraries
#include <math.h>
#include "mbed.h"
#include <stdint.h>
#include <string>

//Sensor libraries
#include "Adafruit_SSD1306.h" //OLED Screen
#include "DS18B20.h" //Temperature SOL (patched to use software serial)
#include "Adafruit_TCS34725.h" //RGB & LUX
#include "Si7021.h" //Temperature & Humidity AIR

//Pin's definition
#define D_RST D3
#define SDA1_PIN D4
#define SCL1_PIN D5
#define SDA3_PIN D12
#define SCL3_PIN A6
#define Sensor_TempSOL_PIN_1 D6
#define Sensor_TempSOL_PIN_2 D9
#define Sensor_HumiditySOL_1_PIN A1
#define Sensor_HumiditySOL_2_PIN A3
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16

//Communication
I2C i2c_1(SDA1_PIN, SCL1_PIN);
I2C i2c_3(SDA3_PIN, SCL3_PIN);

//OLED objects
Adafruit_SSD1306_I2c myOled(i2c_1, D_RST, 0x7A, 64, 128); //0x3D+SA0+RW

//Sensors objects
AnalogIn Sensor_HumiditySOL_1(Sensor_HumiditySOL_1_PIN);
AnalogIn Sensor_HumiditySOL_2(Sensor_HumiditySOL_2_PIN);

DS18B20 Sensor_TempSOL_1(Sensor_TempSOL_PIN_1, DS18B20::RES_12_BIT); // Dallas 1-wire (patched)
DS18B20 Sensor_TempSOL_2(Sensor_TempSOL_PIN_2, DS18B20::RES_12_BIT); // Dallas 1-wire (patched)

Adafruit_TCS34725 Sensor_RGB_1 = Adafruit_TCS34725( & i2c_1, TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
Adafruit_TCS34725 Sensor_RGB_2 = Adafruit_TCS34725( & i2c_3, TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

Si7021 Sensor_TempHumidityAIR_1(SDA1_PIN, SCL1_PIN);
Si7021 Sensor_TempHumidityAIR_2(SDA3_PIN, SCL3_PIN);

//Variables (Device 1)
float temperatureSOL_1, humiditySOL_1;
uint16_t clear_1, red_1, green_1, blue_1, ColorTemperature_1, Lux_1;
float temperatureAIR_1, humidityAIR_1;

//Variables (Device 2)
float temperatureSOL_2, humiditySOL_2;
uint16_t clear_2, red_2, green_2, blue_2, ColorTemperature_2, Lux_2;
float temperatureAIR_2, humidityAIR_2;

int CounterDebug = 0; //a counter to debug serial communication


Serial pc(D1, D0); // tx, rx : Serial communication "SIGFOX", use NUCLEO-L432KC default pins


DigitalOut mySW1(D9);
DigitalOut mySW2(D10);



/// <summary>Returns the humidity from DS18B20 sensor</summary>
/// <param name="Sensor_HimiditySOL">Analog Pin used to get the humidity</param>  
/// <returns>Returns the humidity in float format</returns>  

float humiditySol(AnalogIn Sensor_HimiditySOL) {
  float valeur_min = 24830;
  float valeur_max = 50300;

  float valeur = 0.0f;
  valeur = 100.0f - ((((float) Sensor_HimiditySOL.read_u16()) - valeur_min) / (valeur_max - valeur_min) * 100.0f);
  if (valeur >= 100.0f) {
    return 100.0f;
  } else if (valeur <= 0.0f) {
    return 0.0f;
  } else {
    return valeur;
  }
}

/// <summary>Display data on an OLED screen, it alternates data displaying into 2 pages</summary>
/// <param name="DeviceName">A user friendly name for the first or the second device</param> 
/// <param name="temperatureSOL">Sol's tempertaure</param> 
/// <param name="HumiditySOL">Sol's humidity</param> 
/// <param name="TemperatureAIR">Air's temperature</param> 
/// <param name="HumidityAIR">Air's humidity</param> 
/// <param name="C">Clear light</param> 
/// <param name="R">Red component</param> 
/// <param name="G">Green component</param> 
/// <param name="B">Blue component</param> 
/// <param name="ColorTemperature">Color temperature</param> 
/// <param name="Lux">Lux parameter</param> 
/// <returns>void</returns>  

void DisplayDataOLED(string DeviceName, float temperatureSOL, float HumiditySOL, float TemperatureAIR, float HumidityAIR, uint16_t C, uint16_t R, uint16_t G, uint16_t B, uint16_t ColorTemperature, uint16_t Lux) {
  myOled.setTextSize(1);
  myOled.setTextColor(WHITE);

  //myOled.setTextCursor(Row, Column);
  myOled.setTextCursor(0, 0);
  myOled.printf("%s\r", DeviceName);

  myOled.setTextCursor(0, 8);
  myOled.printf("T-AIR %.02f", TemperatureAIR);

  myOled.setTextCursor(0, 16);
  myOled.printf("H-AIR %.02f\r", HumidityAIR);
  
  myOled.setTextCursor(0, 24);
  myOled.printf("T-SOL %.02f\r", temperatureSOL);

  myOled.setTextCursor(0, 32);
  myOled.printf("H-SOL%.02f\r", HumiditySOL);

  

  myOled.setTextCursor(0, 40);
  myOled.printf("C%d R%d G%d B%d\r", C, R, G, B);

  myOled.setTextCursor(0, 48);
  myOled.printf("Color Temp: %d\r", ColorTemperature);

  myOled.setTextCursor(0, 56);
  myOled.printf("Lux: %d\r", Lux);
}





int getFraction(float x)
{  
    float floating = (int)(x * 10.0f) / 10.0f; 
    float fractional, integer;
    fractional = modf(floating, &integer);
    return (int)(fractional * 10);
}

int getInt(float x)
{
    float floating = (int)(x * 10.0f) / 10.0f; 
    float fractional, integer;
    fractional = modf(floating, &integer);
    return (int)integer;
}





void FormatDataUART(string DeviceName, float temperatureSOL, float HumiditySOL, float TemperatureAIR, float HumidityAIR, uint16_t C, uint16_t R, uint16_t G, uint16_t B, uint16_t ColorTemperature, uint16_t Lux)
{
  pc.printf("Device : %s ################\r\n", DeviceName);
  pc.printf("SOL => [T: %f C]  [H: %f C]\r\n", temperatureSOL, HumiditySOL);
  pc.printf("AIR => [T: %f C]  [H: %f C]\r\n", TemperatureAIR, HumidityAIR);
  pc.printf("Color => RGB[%d ,%d ,%d ,%d]   C[%d]\r\n", R, G, B, C);
  pc.printf("Lux,Temp => [%d ,%d]\r\n", Lux, ColorTemperature);
}



void FormatDataWISOL(string DeviceName, float temperatureSOL, float HumiditySOL, float TemperatureAIR, float HumidityAIR, uint16_t C, uint16_t R, uint16_t G, uint16_t B, uint16_t ColorTemperature, uint16_t Lux)
{
  //pc.printf("SOL => [T: %f C]  [H: %f C]\r\n", temperatureSOL, HumiditySOL);
  //pc.printf("AIR => [T: %f C]  [H: %f C]\r\n", TemperatureAIR, HumidityAIR);
  //pc.printf("Color => RGB[%d ,%d ,%d ,%d]   C[%d]\r\n", R, G, B, C);
  //pc.printf("Lux,Temp => [%d ,%d]\r\n", Lux, ColorTemperature);
  
  // {      8bits        }{     8bit       }{       4 bits              4 bits       }
  // {INT TEMPERATURE SOL}{INT HUMIDITY SOL}{[FRA TEMPERATURE SOL] [FRA HUMIDITY SOL]}
  int IntTempSOL = getInt(temperatureSOL);//*
  int IntHumSOL = getInt(HumiditySOL);//*
  
  int FraTempSOL = getInt(temperatureSOL);
  int FraHumSOL = getInt(HumiditySOL);
  
  int FraTempSOL_FraHumSOL = (FraTempSOL << 4) | FraHumSOL;//*
  

  int RR = (int)R;
  int GG = (int)G;
  int BB = (int)B;
  int LLUX = (int)Lux;
  
}





void dataAT_Command(int id, float temperatureSOL, float HumiditySOL, float TemperatureAIR, float HumidityAIR, uint16_t C, uint16_t R, uint16_t G, uint16_t B, uint16_t ColorTemperature, uint16_t Lux)
{
   //Limit to 0-255
    int temp1 =  (temperatureSOL<255)?(int)temperatureSOL:255;
    int temp2 = (TemperatureAIR<255)?(int)TemperatureAIR:255;  
    int hu1 = (HumiditySOL<255)?(int)HumiditySOL:255;
    int hu2 = (HumidityAIR<255)?(int)HumidityAIR:255;
    int r = (R< 255)?(int)R:255;
    int g = (G< 255)?(int)G:255;
    int b = (B< 255)?(int)B:255;
    int llux = (Lux< 255)?(int)Lux:255;
    
    //pc.printf("{%02X}{%02X}{%02X}{%02X}{%02X}{%02X}{%02X}{%02X}{%02X}\n",id, temp1, temp2, hu1, hu2, r, g,b, llux);
    pc.printf("AT$SF=%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",id, temp1, temp2, hu1, hu2, r, g,b, llux);



  //string Message = ""
  //AT$SF=0012FF42 Envoie sur le réseau les octets "00", "12", "FF" et "42"
  
}







int main() {
  //Init Sensors ##########################################""

  //Region : Temperature SOL (ROM code is optional, the next lines can be removed)
  DS18B20::ROM_Code_t ROM_Code;
  Sensor_TempSOL_1.ReadROM( & ROM_Code);
  Sensor_TempSOL_2.ReadROM( & ROM_Code);

  //Region : RGB
  Sensor_RGB_1.begin();
  Sensor_RGB_2.begin();

  //Region OLED
  myOled.begin();

  while (1) {
      mySW1 = 1;
      mySW2 = 1;

    //### SHT Temperature & Humidity SOL   ###############################
    //------------First Device----------------
    temperatureSOL_1 = Sensor_TempSOL_1.GetTemperature();
    humiditySOL_1 = humiditySol(Sensor_HumiditySOL_1);
    //------------Second Device----------------
    temperatureSOL_2 = Sensor_TempSOL_2.GetTemperature();
    humiditySOL_2 = humiditySol(Sensor_HumiditySOL_2);

      
      
    //### Si7021 Temperature/Humidity AIR   ###############################
    //------------First Device----------------
    if (Sensor_TempHumidityAIR_1.measure()) {
      temperatureAIR_1 = (float) Sensor_TempHumidityAIR_1.get_temperature() / 1000.0f;
      humidityAIR_1 = (float) Sensor_TempHumidityAIR_1.get_humidity() / 1000.0f;
    }
    //------------Second Device----------------
    if (Sensor_TempHumidityAIR_2.measure()) {
      temperatureAIR_2 = (float) Sensor_TempHumidityAIR_2.get_temperature() / 1000.0f;
      humidityAIR_2 = (float) Sensor_TempHumidityAIR_2.get_humidity() / 1000.0f;
    }

      
    //### RGB  ###############################################################
    //------------First Device----------------
    Sensor_RGB_1.setInterrupt(false);
    Sensor_RGB_1.getRawData( & red_1, & green_1, & blue_1, & clear_1);
    Sensor_RGB_1.setInterrupt(true);
    ColorTemperature_1 = Sensor_RGB_1.calculateColorTemperature(red_1, green_1, blue_1);
    Lux_1 = Sensor_RGB_1.calculateLux(red_1, green_1, blue_1);
    //------------Second Device----------------
    Sensor_RGB_2.setInterrupt(false);
    Sensor_RGB_2.getRawData( & red_2, & green_2, & blue_2, & clear_2);
    Sensor_RGB_2.setInterrupt(true);
    ColorTemperature_2 = Sensor_RGB_2.calculateColorTemperature(red_2, green_2, blue_2);
    Lux_2 = Sensor_RGB_2.calculateLux(red_2, green_2, blue_2);

      
    //### Display data using an OLED screen   ################################
    //------------First Device----------------
    myOled.clearDisplay();
    DisplayDataOLED("Sous le panneau", temperatureSOL_1, humiditySOL_1, temperatureAIR_1, humidityAIR_1, clear_1, red_1, green_1, blue_1, ColorTemperature_1, Lux_1);
    myOled.display();
    wait(2);

    //------------Second Device----------------
    myOled.clearDisplay();
    DisplayDataOLED("A cote du panneau", temperatureSOL_2, humiditySOL_2, temperatureAIR_2, humidityAIR_2, clear_2, red_2, green_2, blue_2, ColorTemperature_2, Lux_2);
    myOled.display();
    wait(2);
    //################################### SIGFOX Communication ####################################
    //Wait for 1 second (This value need to be changed to meet SIGFOX time limitations for IOT)
    
    //TEST printing (Change this line to send AT commands using WISOL)
    //FormatDataUART("Sous le panneau", temperatureSOL_1, humiditySOL_1, temperatureAIR_1, humidityAIR_1, clear_1, red_1, green_1, blue_1, ColorTemperature_1, Lux_1);
    //FormatDataUART("A cote du panneau", temperatureSOL_2, humiditySOL_2, temperatureAIR_2, humidityAIR_2, clear_2, red_2, green_2, blue_2, ColorTemperature_2, Lux_2);

    //pc.printf("My Counter : %d\n", CounterDebug);
    CounterDebug++;
    
    
    //test Seperation
    dataAT_Command(1, temperatureSOL_1, humiditySOL_1, temperatureAIR_1, humidityAIR_1, clear_1, red_1, green_1, blue_1, ColorTemperature_1, Lux_1);
    dataAT_Command(2, temperatureSOL_2, humiditySOL_2, temperatureAIR_2, humidityAIR_2, clear_2, red_2, green_2, blue_2, ColorTemperature_2, Lux_2);
    wait(5);
   
    
    
    
    
    
    //pc.printf ("Floating: %f\nInteger: %d\nFractional: %d\n\r", x, getInt(x), getFraction(x)); // when using printf, there are no floats

    //pc.printf("Number = %f, Integer = %f, Fraction = %f\r\n", a, a_frac * 10, a_int);
    
    //HAL_PWR_EnterSTANDBYMode();
    
    

  }

}

Credits

panotech poly

panotech poly

1 project • 0 followers
Thanks to Polytech Sorbonne PanneauTech TEAM, DOUZE Yann, and VIATEUR Sylvain .

Comments

Add projectSign up / Login