mirror of https://github.com/arendst/Tasmota.git
Merge pull request #8598 from device111/development
Add support for up to eight MCP9808 temperature sensors
This commit is contained in:
commit
eb5ebfbf0f
|
@ -120,6 +120,9 @@
|
|||
| USE_WEMOS_MOTOR_V1 | - | - | - | - | x | - | - |
|
||||
| USE_IAQ | - | - | - | - | x | - | - |
|
||||
| USE_AS3935 | - | - | - | - | x | - | - |
|
||||
| USE_VEML6075 | - | - | - | - | - | - | - |
|
||||
| USE_VEML7700 | - | - | - | - | - | - | - |
|
||||
| USE_MCP9808 | - | - | - | - | - | - | - |
|
||||
| | | | | | | | |
|
||||
| Feature or Sensor | minimal | lite | tasmota | knx | sensors | ir | display | Remarks
|
||||
| USE_SPI | - | - | - | - | - | - | x |
|
||||
|
|
|
@ -71,4 +71,5 @@ Index | Define | Driver | Device | Address(es) | Description
|
|||
47 | USE_DISPLAY_SEVENSEG| xdsp_11 | HT16K33 | 0x70 - 0x77 | Seven segment LED
|
||||
48 | USE_AS3935 | xsns_67 | AS3935 | 0x03 | Franklin Lightning Sensor
|
||||
49 | USE_VEML6075 | xsns_70 | VEML6075 | 0x10 | UVA/UVB/UVINDEX Sensor
|
||||
50 | USE_VEML7700 | xsns_71 | VEML7700 | 0x10 | Ambient light intensity sensor
|
||||
50 | USE_VEML7700 | xsns_71 | VEML7700 | 0x10 | Ambient light intensity sensor
|
||||
51 | USE_MCP9808 | xsns_72 | MCP9808 | 0x18 - 0x1F | Temperature sensor
|
|
@ -72,3 +72,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
- Add ``CpuFrequency`` to ``status 2``
|
||||
- Add ``FlashFrequency`` to ``status 4``
|
||||
- Add support for up to two BH1750 sensors controlled by commands ``BH1750Resolution`` and ``BH1750MTime`` (#8139)
|
||||
- Add support for up to eight MCP9808 temperature sensors by device111 (#8594)
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
|
@ -0,0 +1,32 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit MCP9808 Arduino Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
|
@ -0,0 +1,8 @@
|
|||
# osx
|
||||
.DS_Store
|
||||
|
||||
# doxygen
|
||||
Doxyfile*
|
||||
doxygen_sqlite3.db
|
||||
html
|
||||
*.tmp
|
|
@ -0,0 +1,273 @@
|
|||
/*!
|
||||
* @file Adafruit_MCP9808.cpp
|
||||
*
|
||||
* @mainpage Adafruit MCP9808 I2C Temp Sensor
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* I2C Driver for Microchip's MCP9808 I2C Temp sensor
|
||||
*
|
||||
* This is a library for the Adafruit MCP9808 breakout:
|
||||
* http://www.adafruit.com/products/1782
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing products from
|
||||
* Adafruit!
|
||||
*
|
||||
* @section author Author
|
||||
*
|
||||
* K.Townsend (Adafruit Industries)
|
||||
*
|
||||
* @section license License
|
||||
*
|
||||
* BSD (see license.txt)
|
||||
*
|
||||
* @section HISTORY
|
||||
*
|
||||
* v1.0 - First release
|
||||
*
|
||||
* changes by Martin Wagner for tasmota project:
|
||||
*
|
||||
* - the libary supports variabel I2C address
|
||||
*
|
||||
*/
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#ifdef __AVR_ATtiny85__
|
||||
#include "TinyWireM.h"
|
||||
#define Wire TinyWireM
|
||||
#else
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#include "Adafruit_MCP9808.h"
|
||||
|
||||
/*!
|
||||
* @brief Instantiates a new MCP9808 class
|
||||
*/
|
||||
Adafruit_MCP9808::Adafruit_MCP9808() {}
|
||||
|
||||
/*!
|
||||
* @brief Setups the HW
|
||||
* @param *theWire
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_MCP9808::begin(TwoWire *theWire) {
|
||||
_wire = theWire;
|
||||
_i2caddr = MCP9808_I2CADDR_DEFAULT;
|
||||
return init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Setups the HW
|
||||
* @param addr
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_MCP9808::begin(uint8_t addr) {
|
||||
_i2caddr = addr;
|
||||
_wire = &Wire;
|
||||
return init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Setups the HW
|
||||
* @param addr
|
||||
* @param *theWire
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_MCP9808::begin(uint8_t addr, TwoWire *theWire) {
|
||||
_i2caddr = addr;
|
||||
_wire = theWire;
|
||||
return init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Setups the HW with default address
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_MCP9808::begin() {
|
||||
_i2caddr = MCP9808_I2CADDR_DEFAULT;
|
||||
_wire = &Wire;
|
||||
return init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief init function
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_MCP9808::init() {
|
||||
_wire->begin();
|
||||
|
||||
if (read16(MCP9808_REG_MANUF_ID) != 0x0054)
|
||||
return false;
|
||||
if (read16(MCP9808_REG_DEVICE_ID) != 0x0400)
|
||||
return false;
|
||||
|
||||
write16(MCP9808_REG_CONFIG, 0x0);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads the 16-bit temperature register and returns the Centigrade
|
||||
* temperature as a float.
|
||||
* @return Temperature in Centigrade.
|
||||
*/
|
||||
float Adafruit_MCP9808::readTempC(uint8_t addr) {
|
||||
_i2caddr = addr;
|
||||
float temp = NAN;
|
||||
uint16_t t = read16(MCP9808_REG_AMBIENT_TEMP);
|
||||
|
||||
if (t != 0xFFFF) {
|
||||
temp = t & 0x0FFF;
|
||||
temp /= 16.0;
|
||||
if (t & 0x1000)
|
||||
temp -= 256;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads the 16-bit temperature register and returns the Fahrenheit
|
||||
* temperature as a float.
|
||||
* @return Temperature in Fahrenheit.
|
||||
*/
|
||||
float Adafruit_MCP9808::readTempF(uint8_t addr) {
|
||||
_i2caddr = addr;
|
||||
float temp = NAN;
|
||||
uint16_t t = read16(MCP9808_REG_AMBIENT_TEMP);
|
||||
|
||||
if (t != 0xFFFF) {
|
||||
temp = t & 0x0FFF;
|
||||
temp /= 16.0;
|
||||
if (t & 0x1000)
|
||||
temp -= 256;
|
||||
|
||||
temp = temp * 9.0 / 5.0 + 32;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set Sensor to Shutdown-State or wake up (Conf_Register BIT8)
|
||||
* @param sw true = shutdown / false = wakeup
|
||||
*/
|
||||
void Adafruit_MCP9808::shutdown_wake(uint8_t addr, boolean sw) {
|
||||
_i2caddr = addr;
|
||||
uint16_t conf_shutdown;
|
||||
uint16_t conf_register = read16(MCP9808_REG_CONFIG);
|
||||
if (sw == true) {
|
||||
conf_shutdown = conf_register | MCP9808_REG_CONFIG_SHUTDOWN;
|
||||
write16(MCP9808_REG_CONFIG, conf_shutdown);
|
||||
}
|
||||
if (sw == false) {
|
||||
conf_shutdown = conf_register & ~MCP9808_REG_CONFIG_SHUTDOWN;
|
||||
write16(MCP9808_REG_CONFIG, conf_shutdown);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Shutdown MCP9808
|
||||
*/
|
||||
void Adafruit_MCP9808::shutdown(uint8_t addr) { shutdown_wake(addr, true); }
|
||||
|
||||
/*!
|
||||
* @brief Wake up MCP9808
|
||||
*/
|
||||
void Adafruit_MCP9808::wake(uint8_t addr) {
|
||||
shutdown_wake(addr, false);
|
||||
delay(250);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get Resolution Value
|
||||
* @return Resolution value
|
||||
*/
|
||||
uint8_t Adafruit_MCP9808::getResolution(uint8_t addr) {
|
||||
_i2caddr = addr;
|
||||
return read8(MCP9808_REG_RESOLUTION);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set Resolution Value
|
||||
* @param value
|
||||
*/
|
||||
void Adafruit_MCP9808::setResolution(uint8_t addr, uint8_t value) {
|
||||
_i2caddr = addr;
|
||||
write8(MCP9808_REG_RESOLUTION, value & 0x03);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Low level 16 bit write procedures
|
||||
* @param reg
|
||||
* @param value
|
||||
*/
|
||||
void Adafruit_MCP9808::write16(uint8_t reg, uint16_t value) {
|
||||
_wire->beginTransmission(_i2caddr);
|
||||
_wire->write((uint8_t)reg);
|
||||
_wire->write(value >> 8);
|
||||
_wire->write(value & 0xFF);
|
||||
_wire->endTransmission();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Low level 16 bit read procedure
|
||||
* @param reg
|
||||
* @return value
|
||||
*/
|
||||
uint16_t Adafruit_MCP9808::read16(uint8_t reg) {
|
||||
uint16_t val = 0xFFFF;
|
||||
uint8_t state;
|
||||
|
||||
_wire->beginTransmission(_i2caddr);
|
||||
_wire->write((uint8_t)reg);
|
||||
state = _wire->endTransmission();
|
||||
|
||||
if (state == 0) {
|
||||
_wire->requestFrom((uint8_t)_i2caddr, (uint8_t)2);
|
||||
val = _wire->read();
|
||||
val <<= 8;
|
||||
val |= _wire->read();
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Low level 8 bit write procedure
|
||||
* @param reg
|
||||
* @param value
|
||||
*/
|
||||
void Adafruit_MCP9808::write8(uint8_t reg, uint8_t value) {
|
||||
_wire->beginTransmission(_i2caddr);
|
||||
_wire->write((uint8_t)reg);
|
||||
_wire->write(value);
|
||||
_wire->endTransmission();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Low level 8 bit read procedure
|
||||
* @param reg
|
||||
* @return value
|
||||
*/
|
||||
uint8_t Adafruit_MCP9808::read8(uint8_t reg) {
|
||||
uint8_t val = 0xFF;
|
||||
uint8_t state;
|
||||
|
||||
_wire->beginTransmission(_i2caddr);
|
||||
_wire->write((uint8_t)reg);
|
||||
state = _wire->endTransmission();
|
||||
|
||||
if (state == 0) {
|
||||
_wire->requestFrom((uint8_t)_i2caddr, (uint8_t)1);
|
||||
val = _wire->read();
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*!
|
||||
* @file Adafruit_MCP9808.h
|
||||
*
|
||||
* I2C Driver for Microchip's MCP9808 I2C Temp sensor
|
||||
*
|
||||
* This is a library for the Adafruit MCP9808 breakout:
|
||||
* http://www.adafruit.com/products/1782
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
*please support Adafruit and open-source hardware by purchasing products from
|
||||
* Adafruit!
|
||||
*
|
||||
*
|
||||
* BSD license (see license.txt)
|
||||
*
|
||||
* changes by Martin Wagner for tasmota project:
|
||||
*
|
||||
* - the libary supports variabel I2C address
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ADAFRUIT_MCP9808_H
|
||||
#define _ADAFRUIT_MCP9808_H
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#define MCP9808_I2CADDR_DEFAULT 0x18 ///< I2C address
|
||||
#define MCP9808_REG_CONFIG 0x01 ///< MCP9808 config register
|
||||
|
||||
#define MCP9808_REG_CONFIG_SHUTDOWN 0x0100 ///< shutdown config
|
||||
#define MCP9808_REG_CONFIG_CRITLOCKED 0x0080 ///< critical trip lock
|
||||
#define MCP9808_REG_CONFIG_WINLOCKED 0x0040 ///< alarm window lock
|
||||
#define MCP9808_REG_CONFIG_INTCLR 0x0020 ///< interrupt clear
|
||||
#define MCP9808_REG_CONFIG_ALERTSTAT 0x0010 ///< alert output status
|
||||
#define MCP9808_REG_CONFIG_ALERTCTRL 0x0008 ///< alert output control
|
||||
#define MCP9808_REG_CONFIG_ALERTSEL 0x0004 ///< alert output select
|
||||
#define MCP9808_REG_CONFIG_ALERTPOL 0x0002 ///< alert output polarity
|
||||
#define MCP9808_REG_CONFIG_ALERTMODE 0x0001 ///< alert output mode
|
||||
|
||||
#define MCP9808_REG_UPPER_TEMP 0x02 ///< upper alert boundary
|
||||
#define MCP9808_REG_LOWER_TEMP 0x03 ///< lower alert boundery
|
||||
#define MCP9808_REG_CRIT_TEMP 0x04 ///< critical temperature
|
||||
#define MCP9808_REG_AMBIENT_TEMP 0x05 ///< ambient temperature
|
||||
#define MCP9808_REG_MANUF_ID 0x06 ///< manufacture ID
|
||||
#define MCP9808_REG_DEVICE_ID 0x07 ///< device ID
|
||||
#define MCP9808_REG_RESOLUTION 0x08 ///< resolutin
|
||||
|
||||
/*!
|
||||
* @brief Class that stores state and functions for interacting with
|
||||
* MCP9808 Temp Sensor
|
||||
*/
|
||||
class Adafruit_MCP9808 {
|
||||
public:
|
||||
Adafruit_MCP9808();
|
||||
bool begin();
|
||||
bool begin(TwoWire *theWire);
|
||||
bool begin(uint8_t addr);
|
||||
bool begin(uint8_t addr, TwoWire *theWire);
|
||||
|
||||
bool init();
|
||||
float readTempC(uint8_t addr);
|
||||
float readTempF(uint8_t addr);
|
||||
uint8_t getResolution(uint8_t addr);
|
||||
void setResolution(uint8_t addr, uint8_t value);
|
||||
|
||||
void shutdown_wake(uint8_t addr, boolean sw);
|
||||
void shutdown(uint8_t addr);
|
||||
void wake(uint8_t addr);
|
||||
|
||||
void write16(uint8_t reg, uint16_t val);
|
||||
uint16_t read16(uint8_t reg);
|
||||
|
||||
void write8(uint8_t reg, uint8_t val);
|
||||
uint8_t read8(uint8_t reg);
|
||||
|
||||
private:
|
||||
TwoWire *_wire;
|
||||
uint8_t _i2caddr;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,18 @@
|
|||
# Adafruit MCP9808 Library [![Build Status](https://github.com/adafruit/Adafruit_MCP9808_Library/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_MCP9808_Library/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_MCP9808_Library/html/index.html)
|
||||
|
||||
<a href="https://www.adafruit.com/product/1782"><img src="assets/board.jpg?raw=true" width="500px"></a>
|
||||
|
||||
This is the Adafruit MCP9808 Precision I2C Temperature sensor library
|
||||
|
||||
Tested and works great with the Adafruit MCP9808 Breakout Board
|
||||
* http://www.adafruit.com/products/1782
|
||||
|
||||
This chip uses I2C to communicate, 2 pins are required to interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
Written by Kevin Townsend/Limor Fried for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
|
||||
To install, use the Arduino Library Manager and search for "Adafruit MCP9808" and install the library.
|
Binary file not shown.
After Width: | Height: | Size: 132 KiB |
|
@ -0,0 +1,127 @@
|
|||
# Adafruit Community Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for
|
||||
all.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Be kind and courteous to others
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Collaborating with other community members
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and sexual attention or advances
|
||||
* The use of inappropriate images, including in a community member's avatar
|
||||
* The use of inappropriate language, including in a community member's nickname
|
||||
* Any spamming, flaming, baiting or other attention-stealing behavior
|
||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||
asked
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate
|
||||
|
||||
The goal of the standards and moderation guidelines outlined here is to build
|
||||
and maintain a respectful community. We ask that you don’t just aim to be
|
||||
"technically unimpeachable", but rather try to be your best self.
|
||||
|
||||
We value many things beyond technical expertise, including collaboration and
|
||||
supporting others within our community. Providing a positive experience for
|
||||
other community members can have a much more significant impact than simply
|
||||
providing the correct answer.
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
Instances of behaviors that violate the Adafruit Community Code of Conduct
|
||||
may be reported by any member of the community. Community members are
|
||||
encouraged to report these situations, including situations they witness
|
||||
involving other community members.
|
||||
|
||||
You may report in the following ways:
|
||||
|
||||
In any situation, you may send an email to <support@adafruit.com>.
|
||||
|
||||
On the Adafruit Discord, you may send an open message from any channel
|
||||
to all Community Helpers by tagging @community helpers. You may also send an
|
||||
open message from any channel, or a direct message to @kattni#1507,
|
||||
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
|
||||
@Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct and the enforcement policies listed above apply to all
|
||||
Adafruit Community venues. This includes but is not limited to any community
|
||||
spaces (both public and private), the entire Adafruit Discord server, and
|
||||
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
|
||||
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
|
||||
interaction at a conference.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.4, available at
|
||||
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
|
||||
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
|
||||
|
||||
For other projects adopting the Adafruit Community Code of
|
||||
Conduct, please contact the maintainers of those projects for enforcement.
|
||||
If you wish to use this code of conduct for your own project, consider
|
||||
explicitly mentioning your moderation policy or making a copy with your
|
||||
own moderation policy so as to avoid confusion.
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
This is a demo for the Adafruit MCP9808 breakout
|
||||
----> http://www.adafruit.com/products/1782
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "Adafruit_MCP9808.h"
|
||||
|
||||
// Create the MCP9808 temperature sensor object
|
||||
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial); //waits for serial terminal to be open, necessary in newer arduino boards.
|
||||
Serial.println("MCP9808 demo");
|
||||
|
||||
// Make sure the sensor is found, you can also pass in a different i2c
|
||||
// address with tempsensor.begin(0x19) for example, also can be left in blank for default address use
|
||||
// Also there is a table with all addres possible for this sensor, you can connect multiple sensors
|
||||
// to the same i2c bus, just configure each sensor with a different address and define multiple objects for that
|
||||
// A2 A1 A0 address
|
||||
// 0 0 0 0x18 this is the default address
|
||||
// 0 0 1 0x19
|
||||
// 0 1 0 0x1A
|
||||
// 0 1 1 0x1B
|
||||
// 1 0 0 0x1C
|
||||
// 1 0 1 0x1D
|
||||
// 1 1 0 0x1E
|
||||
// 1 1 1 0x1F
|
||||
if (!tempsensor.begin(0x18)) {
|
||||
Serial.println("Couldn't find MCP9808! Check your connections and verify the address is correct.");
|
||||
while (1);
|
||||
}
|
||||
|
||||
Serial.println("Found MCP9808!");
|
||||
|
||||
tempsensor.setResolution(3); // sets the resolution mode of reading, the modes are defined in the table bellow:
|
||||
// Mode Resolution SampleTime
|
||||
// 0 0.5°C 30 ms
|
||||
// 1 0.25°C 65 ms
|
||||
// 2 0.125°C 130 ms
|
||||
// 3 0.0625°C 250 ms
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("wake up MCP9808.... "); // wake up MCP9808 - power consumption ~200 mikro Ampere
|
||||
tempsensor.wake(); // wake up, ready to read!
|
||||
|
||||
// Read and print out the temperature, also shows the resolution mode used for reading.
|
||||
Serial.print("Resolution in mode: ");
|
||||
Serial.println (tempsensor.getResolution());
|
||||
float c = tempsensor.readTempC();
|
||||
float f = tempsensor.readTempF();
|
||||
Serial.print("Temp: ");
|
||||
Serial.print(c, 4); Serial.print("*C\t and ");
|
||||
Serial.print(f, 4); Serial.println("*F.");
|
||||
|
||||
delay(2000);
|
||||
Serial.println("Shutdown MCP9808.... ");
|
||||
tempsensor.shutdown_wake(1); // shutdown MSP9808 - power consumption ~0.1 mikro Ampere, stops temperature sampling
|
||||
Serial.println("");
|
||||
delay(200);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
name=Adafruit MCP9808 Library
|
||||
version=1.1.2
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for the MCP9808 sensors in the Adafruit shop
|
||||
paragraph=Arduino library for the MCP9808 sensors in the Adafruit shop
|
||||
category=Sensors
|
||||
url=https://github.com/adafruit/Adafruit_MCP9808_Library
|
||||
architectures=*
|
||||
depends=Adafruit Unified Sensor
|
|
@ -0,0 +1,26 @@
|
|||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2012, Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -518,6 +518,7 @@
|
|||
// #define USE_AS3935 // [I2cDriver48] Enable AS3935 Franklin Lightning Sensor (I2C address 0x03) (+5k4 code)
|
||||
// #define USE_VEML6075 // [I2cDriver49] Enable VEML6075 UVA/UVB/UVINDEX Sensor (I2C address 0x10) (+2k1 code)
|
||||
// #define USE_VEML7700 // [I2cDriver50] Enable VEML7700 Ambient Light sensor (I2C addresses 0x10) (+4k5 code)
|
||||
// #define USE_MCP9808 // [I2cDriver51] Enable MCP9808 temperature sensor (I2C addresses 0x18 - 0x1F) (+0k9 code)
|
||||
|
||||
// #define USE_DISPLAY // Add I2C Display Support (+2k code)
|
||||
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0
|
||||
|
|
|
@ -569,8 +569,10 @@ void GetFeatures(void)
|
|||
#ifdef USE_VEML7700
|
||||
feature6 |= 0x00001000; // xsns_71_veml7700.ino
|
||||
#endif
|
||||
#ifdef USE_MCP9808
|
||||
feature6 |= 0x00002000; // xsns_72_mcp9808.ino
|
||||
#endif
|
||||
|
||||
// feature6 |= 0x00002000;
|
||||
// feature6 |= 0x00004000;
|
||||
// feature6 |= 0x00008000;
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
#define USE_HRXL // Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders (+0k7)
|
||||
//#define USE_TASMOTA_SLAVE // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem)
|
||||
//#define USE_OPENTHERM // Add support for OpenTherm (+15k code)
|
||||
//#define USE_MCP9808 // Add support for MCP9808 temperature sensor (+0k9 code)
|
||||
|
||||
#define USE_ENERGY_SENSOR // Add energy sensors (-14k code)
|
||||
#define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code)
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
xsns_72_mcp9808 - MCP9808 I2C temperature sensor support for Tasmota
|
||||
|
||||
Copyright (C) 2020 Martin Wagner and Theo Arends
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef USE_I2C
|
||||
#ifdef USE_MCP9808
|
||||
/*********************************************************************************************\
|
||||
* MCP9808 - Temperature Sensor
|
||||
*
|
||||
* I2C Address: 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
|
||||
*
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XSNS_72 72
|
||||
#define XI2C_51 51 // See I2CDEVICES.md
|
||||
|
||||
#include "Adafruit_MCP9808.h"
|
||||
Adafruit_MCP9808 mcp9808 = Adafruit_MCP9808(); // create object copy
|
||||
|
||||
#define MCP9808_MAX_SENSORS 8
|
||||
#define MCP9808_START_ADDRESS 0x18
|
||||
|
||||
struct {
|
||||
char types[9] = "MCP9808";
|
||||
uint8_t count = 0;
|
||||
} mcp9808_cfg;
|
||||
|
||||
struct {
|
||||
float temperature = NAN;
|
||||
uint8_t address;
|
||||
} mcp9808_sensors[MCP9808_MAX_SENSORS];
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
float MCP9808Read(uint8_t addr) {
|
||||
float t = mcp9808.readTempC(addr);
|
||||
return t;
|
||||
}
|
||||
|
||||
void MCP9808Detect(void) {
|
||||
for (uint8_t i = 0; i < MCP9808_MAX_SENSORS; i++) {
|
||||
if (!I2cSetDevice(MCP9808_START_ADDRESS + i)) { continue; }
|
||||
|
||||
if (mcp9808.begin(MCP9808_START_ADDRESS + i)) {
|
||||
mcp9808_sensors[mcp9808_cfg.count].address = MCP9808_START_ADDRESS + i;
|
||||
I2cSetActiveFound(mcp9808_sensors[mcp9808_cfg.count].address, mcp9808_cfg.types);
|
||||
mcp9808.setResolution (mcp9808_sensors[mcp9808_cfg.count].address, 2); // Set Resolution to 0.125°C
|
||||
mcp9808_cfg.count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MCP9808EverySecond(void) {
|
||||
for (uint32_t i = 0; i < mcp9808_cfg.count; i++) {
|
||||
float t = MCP9808Read(mcp9808_sensors[i].address);
|
||||
mcp9808_sensors[i].temperature = ConvertTemp(t);
|
||||
}
|
||||
}
|
||||
|
||||
void MCP9808Show(bool json) {
|
||||
for (uint32_t i = 0; i < mcp9808_cfg.count; i++) {
|
||||
char temperature[33];
|
||||
dtostrfd(mcp9808_sensors[i].temperature, Settings.flag2.temperature_resolution, temperature);
|
||||
|
||||
char sensor_name[10];
|
||||
strlcpy(sensor_name, mcp9808_cfg.types, sizeof(sensor_name));
|
||||
if (mcp9808_cfg.count > 1) {
|
||||
snprintf_P(sensor_name, sizeof(sensor_name), PSTR("%s%c%d"), sensor_name, IndexSeparator(), i +1); // MCP9808-1
|
||||
}
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s}"), sensor_name, temperature);
|
||||
if ((0 == tele_period) && (0 == i)) {
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzSensor(DZ_TEMP, temperature);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_KNX
|
||||
KnxSensor(KNX_TEMPERATURE, mcp9808_sensors[i].temperature);
|
||||
#endif // USE_KNX
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_PD(HTTP_SNS_TEMP, sensor_name, temperature, TempUnit());
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
bool Xsns72(uint8_t function)
|
||||
{
|
||||
if (!I2cEnabled(XI2C_51)) { return false; }
|
||||
bool result = false;
|
||||
|
||||
if (FUNC_INIT == function) {
|
||||
MCP9808Detect();
|
||||
}
|
||||
else if (mcp9808_cfg.count){
|
||||
switch (function) {
|
||||
case FUNC_EVERY_SECOND:
|
||||
MCP9808EverySecond();
|
||||
break;
|
||||
case FUNC_JSON_APPEND:
|
||||
MCP9808Show(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_SENSOR:
|
||||
MCP9808Show(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // USE_MCP9808
|
||||
#endif // USE_I2C
|
|
@ -204,7 +204,7 @@ a_features = [[
|
|||
"USE_KEELOQ","USE_HRXL","USE_SONOFF_D1","USE_HDC1080",
|
||||
"USE_IAQ","USE_DISPLAY_SEVENSEG","USE_AS3935","USE_PING",
|
||||
"USE_WINDMETER","USE_OPENTHERM","USE_THERMOSTAT","USE_VEML6075",
|
||||
"USE_VEML7700","","","",
|
||||
"USE_VEML7700","USE_MCP9808","","",
|
||||
"","","","",
|
||||
"","","","",
|
||||
"","","","",
|
||||
|
|
Loading…
Reference in New Issue