Creating an IoT platform for smart agriculture. Collecting data and sending them to thingspeak for analysis

Dependencies:   DHT11 LPS22HB LSM6DSL VL53L0X

Committer:
kaoriw
Date:
Fri Jun 08 12:16:19 2018 +0000
Revision:
1:469ea8167b80
Parent:
0:07ff689741d2
Uncomplete

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaoriw 0:07ff689741d2 1 #ifndef SENSORS_H
kaoriw 0:07ff689741d2 2 #define SENSORS_H
kaoriw 0:07ff689741d2 3
kaoriw 0:07ff689741d2 4 //Internal sensors
kaoriw 0:07ff689741d2 5 #include "Dht11.h" //Temperature & humidity sensor
kaoriw 0:07ff689741d2 6 #include "LPS22HBSensor.h" //Pressure sensor
kaoriw 0:07ff689741d2 7 #include "LSM6DSLSensor.h" //Accelerometer & gyroscope
kaoriw 0:07ff689741d2 8 #include "VL53L0X.h" //Proximity sensor
kaoriw 0:07ff689741d2 9
kaoriw 0:07ff689741d2 10
kaoriw 0:07ff689741d2 11 /* For errors while reading values */
kaoriw 0:07ff689741d2 12 #define VALUE_ERROR -1
kaoriw 0:07ff689741d2 13 int press_status;
kaoriw 0:07ff689741d2 14
kaoriw 0:07ff689741d2 15 /* Interface definition */
kaoriw 0:07ff689741d2 16 static DevI2C devI2c(PB_11,PB_10);
kaoriw 0:07ff689741d2 17
kaoriw 0:07ff689741d2 18 /* Environment sensors */
kaoriw 0:07ff689741d2 19 Dht11 hum_temp_s(D4);
kaoriw 0:07ff689741d2 20 DigitalIn light_s(D6);
kaoriw 0:07ff689741d2 21 static LPS22HBSensor press_s(&devI2c);
kaoriw 0:07ff689741d2 22
kaoriw 0:07ff689741d2 23 /* Motion sensors */
kaoriw 0:07ff689741d2 24 static LSM6DSLSensor acc_gyro(&devI2c,LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW,PD_11); // low address
kaoriw 0:07ff689741d2 25
kaoriw 0:07ff689741d2 26 /* Range sensor - B-L475E-IOT01A2 only */
kaoriw 0:07ff689741d2 27 static DigitalOut shutdown_pin(PC_6);
kaoriw 0:07ff689741d2 28 static VL53L0X range(&devI2c, &shutdown_pin, PC_7);
kaoriw 0:07ff689741d2 29
kaoriw 0:07ff689741d2 30 /* Variables */
kaoriw 0:07ff689741d2 31 int mag_axes[3];
kaoriw 0:07ff689741d2 32 int acc_axes[3];
kaoriw 0:07ff689741d2 33 int gyro_axes[3];
kaoriw 0:07ff689741d2 34 unsigned int distance;
kaoriw 0:07ff689741d2 35 float temp;
kaoriw 0:07ff689741d2 36 float hum;
kaoriw 0:07ff689741d2 37 int light;
kaoriw 0:07ff689741d2 38 float press;
kaoriw 0:07ff689741d2 39
kaoriw 0:07ff689741d2 40 /* Functions */
kaoriw 0:07ff689741d2 41 void enable_sensors();
kaoriw 0:07ff689741d2 42 void get_values();
kaoriw 0:07ff689741d2 43 void get_motion_data(int dt, int* speed, int* prev_speed, int* prev_pos, int* prev_angle);
kaoriw 0:07ff689741d2 44
kaoriw 0:07ff689741d2 45 #endif