Add sensor MPU6050

Add initial support for sensor MPU6050 (#3352)
This commit is contained in:
Theo Arends 2018-07-28 16:16:53 +02:00
parent 0afe15b0d3
commit 277e776cf3
6 changed files with 40 additions and 29 deletions

View File

@ -1,4 +1,5 @@
/* 6.1.1c /* 6.1.1c
* Add initial support for sensor MPU6050 (#3352)
* Add command SerialSend4 to send binary serial data (#3345) * Add command SerialSend4 to send binary serial data (#3345)
* Add rule triggers Wifi#Connected and Wifi#Disconnected (#3359) * Add rule triggers Wifi#Connected and Wifi#Disconnected (#3359)
* Fix unsecure main webpage update * Fix unsecure main webpage update

View File

@ -138,12 +138,6 @@
#define D_JSON_WRONG_PARAMETERS "Wrong parameters" #define D_JSON_WRONG_PARAMETERS "Wrong parameters"
#define D_JSON_YESTERDAY "Yesterday" #define D_JSON_YESTERDAY "Yesterday"
#define D_JSON_ZERO_POINT_CALIBRATION "Zero Point Calibration" #define D_JSON_ZERO_POINT_CALIBRATION "Zero Point Calibration"
#define D_JSON_AXIS_AX "AccelXAxis"
#define D_JSON_AXIS_AY "AccelYAxis"
#define D_JSON_AXIS_AZ "AccelZAxis"
#define D_JSON_AXIS_GX "GyroXAxis"
#define D_JSON_AXIS_GY "GyroYAxis"
#define D_JSON_AXIS_GZ "GyroZAxis"
#define D_RSLT_ENERGY "ENERGY" #define D_RSLT_ENERGY "ENERGY"
#define D_RSLT_INFO "INFO" #define D_RSLT_INFO "INFO"
@ -529,12 +523,6 @@ const char HTTP_SNS_HUM[] PROGMEM = "%s{s}%s " D_HUMIDITY "{m}%s%%{e}";
const char HTTP_SNS_PRESSURE[] PROGMEM = "%s{s}%s " D_PRESSURE "{m}%s " D_UNIT_PRESSURE "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr> const char HTTP_SNS_PRESSURE[] PROGMEM = "%s{s}%s " D_PRESSURE "{m}%s " D_UNIT_PRESSURE "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_SEAPRESSURE[] PROGMEM = "%s{s}%s " D_PRESSUREATSEALEVEL "{m}%s " D_UNIT_PRESSURE "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr> const char HTTP_SNS_SEAPRESSURE[] PROGMEM = "%s{s}%s " D_PRESSUREATSEALEVEL "{m}%s " D_UNIT_PRESSURE "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_ANALOG[] PROGMEM = "%s{s}%s " D_ANALOG_INPUT "%d{m}%d{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr> const char HTTP_SNS_ANALOG[] PROGMEM = "%s{s}%s " D_ANALOG_INPUT "%d{m}%d{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_AX_AXIS[] PROGMEM = "%s{s}%s " D_AX_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_AY_AXIS[] PROGMEM = "%s{s}%s " D_AY_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_AZ_AXIS[] PROGMEM = "%s{s}%s " D_AZ_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_GX_AXIS[] PROGMEM = "%s{s}%s " D_GX_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_GY_AXIS[] PROGMEM = "%s{s}%s " D_GY_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_GZ_AXIS[] PROGMEM = "%s{s}%s " D_GZ_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
#if defined(USE_MHZ19) || defined(USE_SENSEAIR) #if defined(USE_MHZ19) || defined(USE_SENSEAIR)
const char HTTP_SNS_CO2[] PROGMEM = "%s{s}%s " D_CO2 "{m}%d " D_UNIT_PARTS_PER_MILLION "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr> const char HTTP_SNS_CO2[] PROGMEM = "%s{s}%s " D_CO2 "{m}%d " D_UNIT_PARTS_PER_MILLION "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>

View File

@ -149,12 +149,6 @@
#define D_SUNRISE "Sonnenaufgang" #define D_SUNRISE "Sonnenaufgang"
#define D_SUNSET "Sonnenuntergang" #define D_SUNSET "Sonnenuntergang"
#define D_TEMPERATURE "Temperatur" #define D_TEMPERATURE "Temperatur"
#define D_AX_AXIS "Beschl. X-Achse"
#define D_AY_AXIS "Beschl. Y-Achse"
#define D_AZ_AXIS "Beschl. Z-Achse"
#define D_GX_AXIS "Gyroskop X-Achse"
#define D_GY_AXIS "Gyroskop Y-Achse"
#define D_GZ_AXIS "Gyroskop Z-Achse"
#define D_TO "zu" #define D_TO "zu"
#define D_TOGGLE "An/Aus" #define D_TOGGLE "An/Aus"
#define D_TOPIC "topic" #define D_TOPIC "topic"
@ -442,6 +436,14 @@
#define D_ENVIRONMENTAL_CONCENTRATION "PM" // Environmetal Particle Matter #define D_ENVIRONMENTAL_CONCENTRATION "PM" // Environmetal Particle Matter
#define D_PARTICALS_BEYOND "Particals" #define D_PARTICALS_BEYOND "Particals"
// xsns_32_mpu6050.ino
#define D_AX_AXIS "Beschl. X-Achse"
#define D_AY_AXIS "Beschl. Y-Achse"
#define D_AZ_AXIS "Beschl. Z-Achse"
#define D_GX_AXIS "Gyroskop X-Achse"
#define D_GY_AXIS "Gyroskop Y-Achse"
#define D_GZ_AXIS "Gyroskop Z-Achse"
// sonoff_template.h // sonoff_template.h
#define D_SENSOR_NONE "None" #define D_SENSOR_NONE "None"
#define D_SENSOR_DHT11 "DHT11" #define D_SENSOR_DHT11 "DHT11"
@ -481,7 +483,6 @@
#define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_CLK "TM16 CLK"
#define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_DIO "TM16 DIO"
#define D_SENSOR_TM1638_STB "TM16 STB" #define D_SENSOR_TM1638_STB "TM16 STB"
#define D_SENSOR_MPU6050 "MPU6050"
// Units // Units
#define D_UNIT_AMPERE "A" #define D_UNIT_AMPERE "A"

View File

@ -149,12 +149,6 @@
#define D_SUNRISE "Sunrise" #define D_SUNRISE "Sunrise"
#define D_SUNSET "Sunset" #define D_SUNSET "Sunset"
#define D_TEMPERATURE "Temperature" #define D_TEMPERATURE "Temperature"
#define D_AX_AXIS "Accel. X-Axis"
#define D_AY_AXIS "Accel. Y-Axis"
#define D_AZ_AXIS "Accel. Z-Axis"
#define D_GX_AXIS "Gyro X-Axis"
#define D_GY_AXIS "Gyro Y-Axis"
#define D_GZ_AXIS "Gyro Z-Axis"
#define D_TO "to" #define D_TO "to"
#define D_TOGGLE "Toggle" #define D_TOGGLE "Toggle"
#define D_TOPIC "Topic" #define D_TOPIC "Topic"
@ -442,6 +436,14 @@
#define D_ENVIRONMENTAL_CONCENTRATION "PM" // Environmetal Particle Matter #define D_ENVIRONMENTAL_CONCENTRATION "PM" // Environmetal Particle Matter
#define D_PARTICALS_BEYOND "Particals" #define D_PARTICALS_BEYOND "Particals"
// xsns_32_mpu6050.ino
#define D_AX_AXIS "Accel. X-Axis"
#define D_AY_AXIS "Accel. Y-Axis"
#define D_AZ_AXIS "Accel. Z-Axis"
#define D_GX_AXIS "Gyro X-Axis"
#define D_GY_AXIS "Gyro Y-Axis"
#define D_GZ_AXIS "Gyro Z-Axis"
// sonoff_template.h // sonoff_template.h
#define D_SENSOR_NONE "None" #define D_SENSOR_NONE "None"
#define D_SENSOR_DHT11 "DHT11" #define D_SENSOR_DHT11 "DHT11"
@ -481,7 +483,6 @@
#define D_SENSOR_TM1638_CLK "TM16 CLK" #define D_SENSOR_TM1638_CLK "TM16 CLK"
#define D_SENSOR_TM1638_DIO "TM16 DIO" #define D_SENSOR_TM1638_DIO "TM16 DIO"
#define D_SENSOR_TM1638_STB "TM16 STB" #define D_SENSOR_TM1638_STB "TM16 STB"
#define D_SENSOR_MPU6050 "MPU6050"
// Units // Units
#define D_UNIT_AMPERE "A" #define D_UNIT_AMPERE "A"

View File

@ -292,7 +292,7 @@
// #define USE_MCP230xx // Enable MCP23008/MCP23017 for GP INPUT ONLY (I2C addresses 0x20 - 0x27) providing command Sensor29 for configuration (+2k2 code) // #define USE_MCP230xx // Enable MCP23008/MCP23017 for GP INPUT ONLY (I2C addresses 0x20 - 0x27) providing command Sensor29 for configuration (+2k2 code)
// #define USE_MPR121 // Enable MPR121 controller (I2C addresses 0x5A, 0x5B, 0x5C and 0x5D) in input mode for touch buttons (+1k3 code) // #define USE_MPR121 // Enable MPR121 controller (I2C addresses 0x5A, 0x5B, 0x5C and 0x5D) in input mode for touch buttons (+1k3 code)
// #define USE_CCS811 // Enable CCS811 sensor (I2C address 0x5A) (+2k2 code) // #define USE_CCS811 // Enable CCS811 sensor (I2C address 0x5A) (+2k2 code)
#define USE_MPU_6050 // Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) // #define USE_MPU6050 // Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+2k6 code)
#endif // USE_I2C #endif // USE_I2C
// -- SPI sensors --------------------------------- // -- SPI sensors ---------------------------------

View File

@ -18,7 +18,7 @@
*/ */
#ifdef USE_I2C #ifdef USE_I2C
#ifdef USE_MPU_6050 #ifdef USE_MPU6050
/*********************************************************************************************\ /*********************************************************************************************\
* MPU_6050 3 axis gyroscope and temperature sensor * MPU_6050 3 axis gyroscope and temperature sensor
* *
@ -27,6 +27,8 @@
* I2C Address: 0x68 or 0x69 with AD0 HIGH * I2C Address: 0x68 or 0x69 with AD0 HIGH
\*********************************************************************************************/ \*********************************************************************************************/
#define D_SENSOR_MPU6050 "MPU6050"
#define MPU_6050_ADDR_AD0_LOW 0x68 #define MPU_6050_ADDR_AD0_LOW 0x68
#define MPU_6050_ADDR_AD0_HIGH 0x69 #define MPU_6050_ADDR_AD0_HIGH 0x69
@ -85,6 +87,8 @@ void MPU_6050Detect()
mpu6050.setAddr(MPU_6050_address); mpu6050.setAddr(MPU_6050_address);
mpu6050.initialize(); mpu6050.initialize();
Settings.flag2.axis_resolution = 2; // Need to be services by command Sensor32
MPU_6050_found = mpu6050.testConnection(); MPU_6050_found = mpu6050.testConnection();
} }
@ -95,6 +99,22 @@ void MPU_6050Detect()
} }
} }
#ifdef USE_WEBSERVER
const char HTTP_SNS_AX_AXIS[] PROGMEM = "%s{s}%s " D_AX_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_AY_AXIS[] PROGMEM = "%s{s}%s " D_AY_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_AZ_AXIS[] PROGMEM = "%s{s}%s " D_AZ_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_GX_AXIS[] PROGMEM = "%s{s}%s " D_GX_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_GY_AXIS[] PROGMEM = "%s{s}%s " D_GY_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
const char HTTP_SNS_GZ_AXIS[] PROGMEM = "%s{s}%s " D_GZ_AXIS "{m}%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
#endif // USE_WEBSERVER
#define D_JSON_AXIS_AX "AccelXAxis"
#define D_JSON_AXIS_AY "AccelYAxis"
#define D_JSON_AXIS_AZ "AccelZAxis"
#define D_JSON_AXIS_GX "GyroXAxis"
#define D_JSON_AXIS_GY "GyroYAxis"
#define D_JSON_AXIS_GZ "GyroZAxis"
void MPU_6050Show(boolean json) void MPU_6050Show(boolean json)
{ {
double tempConv = (MPU_6050_temperature / 340.0 + 35.53); double tempConv = (MPU_6050_temperature / 340.0 + 35.53);
@ -183,5 +203,5 @@ boolean Xsns32(byte function)
return result; return result;
} }
#endif // USE_MPU_6050 #endif // USE_MPU6050
#endif // USE_I2C #endif // USE_I2C