Hackster will be offline on Monday, June 15 from 5pm to 7pm PDT to perform some scheduled maintenance.
Yoan LabeauAndy KindongoLaure Delahaye
Created January 18, 2019

Harvest and Display of data

The goal is to recover via Ubidots temperature and humidity data from sensor sent by the Sigfox Module.

Work in progress23
Harvest and Display of data

Things used in this project

Hardware components

Nucleo 144 STM32F7
ST STM32L4, STM32F7 Nucleo 144 STM32F7
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Adafruit Waterproof DS18B20 Digital temperature sensor
Adafruit Waterproof DS18B20 Digital temperature sensor
×1
Grove - Barometer Sensor (BMP280)
Seeed Studio Grove - Barometer Sensor (BMP280)
×1
SparkFun MAG3110
×1
DFRobot SEN0193
×1
D1306
×1
Seeed Studio lipo rider pro 10699008
×1
Gatronic Technologies Cellule solaire SOL2W
×1
Batterie 1050mAh
×1

Software apps and online services

Ubidots
Ubidots
Mbed
Solidworks
Circuit Maker
CircuitMaker by Altium Circuit Maker
Sigfox
Sigfox

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Fichier solidworks du boitier principal

Schematics

Schéma du circuit imprimé

Code

Main

C/C++
Ceci est le programme principal.

Dans un premier temps, nous déclarons des variables globales qui pourront être modifier par toutes les fonctions.
Par la suite, nous récoltons les données, qui seront affiché sur un écran et envoyé par un modules Sigfox .
#include "mbed.h"
#include <stdint.h>
#include "WakeUp.h"

#include "bold_font.h"      // 6. lcd OLDE Display 128x64 
#include "standard_font.h"  // 6. lcd OLDE Display 128x64 
#include "ssd1306.h"        // 6. lcd OLDE Display 128x64 

#include "DHT22.h" //air

#include "fichier.h"

//6.OLED
SSD1306 ecran(PB_0 /* cs */, PA_6/* reset */, PA_11 /* dc */, PA_5 /* clock */, PA_7 /* data */); //DC = PB_5

//Humidity sol
int mymin = 370;
int mymax = 780;
float Pourcentage;


//Humidity et temp Air
float Tab[2]; //Tab[0] = Humi , Tab[1] = Temp

//Temp sol
float Temp_sol;

//Magneto
float XYZ[3];

//Pression
float Valeur_pressions;

//Ticker pour sleep mode.
bool expired = false;
Ticker EventWakeUp;
    
void callback(void) {
    printf("end sleep\r\n");
    expired = true;
}

//Ticker pour envoie du msg toutes les x secondes.

Ticker EventSend;
    
void Send(void) {
    Sigfox(Pourcentage, Tab[0], (Temp_sol+20)*10, (Tab[1]+20)*10, Valeur_pressions, XYZ[0], XYZ[1], XYZ[2] );
}


int main()
{
    //EventSend.attach(&Send, 30.0); //15min = 900sec
    int compteur =0;
    ecran.initialise();
    ecran.clear();
    ecran.set_contrast(255); // max contrast
    ecran.update();
    ecran.set_font(bold_font, 8);
    ecran.printf("\r\n");
    ecran.printf("\r\n");
    ecran.printf("----------------\r\n");
    ecran.printf("UPTADE DONNEES\r\n");
    ecran.printf("----------------\r\n");

 
    while (1)
    {
        //RECUPERATION DES DONNEES
        Humidite_sol(&mymax,&mymin,&Pourcentage);
        TempSol(&Temp_sol);
        
        TempAndHumi(Tab);
        
        //magneto(XYZ);
        
        Fonction_Pression(&Valeur_pressions);
        
        //-----  SOL ------
        ecran.clear();
                
        ecran.set_font(bold_font, 8);
        ecran.printf("Humidite Sol\r\n");
        ecran.set_font(standard_font, 6);
        ecran.printf("Humidite = %.1f%% \r\n",Pourcentage);
        
        ecran.printf("\r\n");
        ecran.printf("--------------------\r\n");
        ecran.printf("\r\n");
        
        ecran.set_font(bold_font, 8);
        ecran.printf("Temp sol\r\n");
        ecran.set_font(standard_font, 6);
        ecran.printf("Temp = %.1f C \r\n",Temp_sol);
        
        ecran.update();
        wait(2);
        ecran.clear();
        
        //------ AIR ------
        ecran.set_font(bold_font, 8);
        ecran.printf("Humidite air\r\n");
        ecran.set_font(standard_font, 6);
        ecran.printf("Humidite = %.1f%% \r\n",Tab[0]);
        
        ecran.printf("\r\n");
        ecran.printf("********************\r\n");
        ecran.printf("\r\n");
        
        ecran.set_font(bold_font, 8);
        ecran.printf("Temp air\r\n");
        ecran.set_font(standard_font, 6);
        ecran.printf("Temp = %.1f C \r\n",Tab[1]);
        
        ecran.update();
        wait(2);
        ecran.clear();


        //------ MAGNETO ------
        ecran.set_font(bold_font, 8);
        ecran.printf("Champs magnetique\r\n");
        ecran.set_font(standard_font, 6);
        ecran.printf("X = %.1f \r\n",XYZ[0]);
        ecran.printf("Y = %.1f \r\n",XYZ[1]);
        ecran.printf("Z = %.1f \r\n",XYZ[2]);
        
        ecran.update();
        wait(2);
        ecran.clear();

        //------ PRESSIONS ------
        ecran.set_font(bold_font, 8);
        ecran.printf("PRESSIONS\r\n");
        ecran.set_font(standard_font, 6);
        ecran.printf("X = %.1f \r\n",Valeur_pressions);
 
        
        ecran.update();
        wait(2);
        ecran.clear();
        
        
        EventWakeUp.attach(&callback, 10.0);
        
        while(!expired){
            ecran.off();
            
            sleep();
            //or
            //standby();
            //NVIC_SystemReset();

            }
        ecran.on();
        ecran.initialise();
        ecran.clear();
        ecran.set_contrast(255); // max contrast
        ecran.update();
        expired = false;
        EventWakeUp.detach();


        compteur ++;        
        if(compteur >15){
            Send();
            compteur =0;
            }

        
        printf("----------------------------------------------\r\n\n");
        
        //------ FIN/UPTADE DONNEES ------
        ecran.set_font(bold_font, 8);
        ecran.printf("\r\n");
        ecran.printf("\r\n");
        ecran.printf("----------------\r\n");
        ecran.printf("UPTADE DONNEES\r\n");
        ecran.printf("----------------\r\n");

 
        
        ecran.update();
        
        
        
    }
    
}

Fichier.h

C/C++
Toutes les fonctions utiliser pour les différents capteurs sont listé ci-dessous.
void TempAndHumi(float *Tab);

void Humidite_sol(int* mymax, int* mymin, float * Pourcentage);

void TempSol(float * Temp_Sol);

void magneto(float *XYZ);

void Fonction_Pression(float * Valeur_Pression );
 

void Sigfox(unsigned int HumiditySol,unsigned int HumidityAir, float TempSol, int TempAir, unsigned int Pression, int X, int Y, int Z);

Température et humidité air

C/C++
Grâce à la bibliothèque mbed du DHT22, On peut lire les données de température et d'humidité de l'aire.
 #include "mbed.h"
 #include "DHT22.h"
 


DHT22 cap(PA_3); //avant PB_4
 
void TempAndHumi(float * Tab)
{

    
    cap.sample();

    wait(0.2);
    Tab[0]=cap.getHumidity()/10.0;
    Tab[1]=cap.getTemperature()/10.0;
    printf("AIR humidite: %.1f , temperature: %.1f\r\n",Tab[0],Tab[1]);
        
    return;
    }

Envoi Sigfox

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



    


void Sigfox(unsigned int HumiditySol,unsigned int HumidityAir, float TempSol, int TempAir, unsigned int Pression, int X, int Y, int Z) {

Serial lpwan(PA_9, PA_10); //tx , rx

        char text[4];

        lpwan.printf("AT\r\n");
        lpwan.scanf("%s",text);
        printf("Sigfox: AT : %s\r\n",text);
        
        if (strcmp(text,"OK")==0){
            lpwan.printf("AT$SF=%02x%02x%04x%04x%04x%04x%04x\r\n",HumidityAir, HumiditySol, (int)TempSol, TempAir,Pression,X,Y);
            printf("msg sigfox envoye: ");
            printf("AT$SF=%02x%02x%04x%04x%04x%04x%04x\r\n",HumidityAir, HumiditySol, (int)TempSol,TempAir,Pression,X,Y);          
          }
        else
            printf("Erreur, pas d'OK Sigfox\r\n");
            
            

        
}

Humidité sol

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

 // Capteur humidite sol
//AnalogIn Humidite(PA_0);
 
//Millieu sec base (air) = 775
//Millieu humide base (verre d'eau) = 375



AnalogIn Humidite(PA_0);

void Humidite_sol(int* mymax, int* mymin, float * Pourcentage) {
        
        int Moisture;

        
        Moisture = Humidite * 1000; //take the value, translate float to int
           
        if (Moisture > *mymax){
            *mymax = Moisture; //if a new mymax appear
            }
        if (Moisture < *mymin){
            *mymin = Moisture;//if a new min appear
            }
            
        *Pourcentage = 100-(((float)Moisture - (float)*mymin)/((float)*mymax - (float)*mymin))*100; //make a %
        printf("Valeur humidite sol: %0.1f%%\r\n", *Pourcentage);
        
        return ;
    
}
 
 
 
 

Pression

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

 // Capteur humidite sol
//AnalogIn Humidite(PA_0);
 
//Millieu sec base (air) = 775
//Millieu humide base (verre d'eau) = 375



AnalogIn Humidite(PA_0);

void Humidite_sol(int* mymax, int* mymin, float * Pourcentage) {
        
        int Moisture;

        
        Moisture = Humidite * 1000; //take the value, translate float to int
           
        if (Moisture > *mymax){
            *mymax = Moisture; //if a new mymax appear
            }
        if (Moisture < *mymin){
            *mymin = Moisture;//if a new min appear
            }
            
        *Pourcentage = 100-(((float)Moisture - (float)*mymin)/((float)*mymax - (float)*mymin))*100; //make a %
        printf("Valeur humidite sol: %0.1f%%\r\n", *Pourcentage);
        
        return ;
    
}
 
 
 
 

Température sol

C/C++
 #include "mbed.h"
 #include "DS1820.h"
 


DS1820 capt(PA_1);
 
void TempSol(float * Temp_Sol)
{

    
    capt.begin();
    capt.startConversion();
    wait(0.5);
    *Temp_Sol = capt.read();
    printf("temperature SOL: %.1f\r\n", *Temp_Sol);
        
    return;
    }

Credits

Yoan Labeau
1 project • 0 followers
Andy Kindongo
0 projects • 0 followers
Laure Delahaye
0 projects • 0 followers

Comments