-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
89 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
/* --------------------------------------------------------------------------------------------- | ||
OneWire Temperature SingleSensor 1.0 (DS18B20, MAX31820) (Single sensor) | ||
OneWire Temperature SingleSensor 1.1 (DS18B20, MAX31820) (Single sensor) | ||
Hardware/Firmware/Sketch/kdevice.xml by E.Burkowski / [email protected], GPL Licensed | ||
Compatible with: KONNEKTING Device Library 1.0.0 beta 4 | ||
Compatible with: KONNEKTING Device Library 1.0.0 beta 4b | ||
------------------------------------------------------------------------------------------------*/ | ||
|
||
/* this libraries are required (click on link and download with library manager): | ||
KONNEKTING Device Library: http://librarymanager/All#Konnekting | ||
FlashStorage: http://librarymanager/All#FlashStorage | ||
OneWire: http://librarymanager/All#OneWire | ||
DallasTemperature: http://librarymanager/All#DallasTemperature | ||
*/ | ||
|
||
#include <KonnektingDevice.h> | ||
|
||
// include device related configuration code, created by "KONNEKTING CodeGenerator" | ||
#include "kdevice_OneWire_Temeprature_SingleSensor_1_0.h" | ||
#include "kdevice_OneWire_Temeprature_SingleSensor_1_1.h" | ||
#include "mi.h" | ||
|
||
#include <OneWire.h> //https://github.com/PaulStoffregen/OneWire | ||
#include <DallasTemperature.h> //https://github.com/milesburton/Arduino-Temperature-Control-Library | ||
#include <FlashAsEEPROM.h> | ||
#include <OneWire.h> | ||
#include <DallasTemperature.h> | ||
|
||
|
||
// ################################################ | ||
// ### DEBUG CONFIGURATION | ||
// ################################################ | ||
#define KDEBUG // comment this line to disable DEBUG mode | ||
//#define KDEBUG // comment this line to disable DEBUG mode | ||
#ifdef KDEBUG | ||
#include <DebugUtil.h> | ||
#define DEBUGSERIAL SerialUSB | ||
|
@@ -27,18 +35,13 @@ Compatible with: KONNEKTING Device Library 1.0.0 beta 4 | |
// ################################################ | ||
// ### IO Configuration | ||
// ################################################ | ||
//OneWire on pin D3 | ||
#define ONE_WIRE OWD3 | ||
#define ONE_WIRE_PULLUP OWD3PullUp | ||
|
||
//OneWire on pin D4 | ||
//#define ONE_WIRE OWD4 | ||
//#define ONE_WIRE_PULLUP OWD4PullUp | ||
//OneWire on pin SDA (pin with approx 4k7 should be used) | ||
#define ONE_WIRE_PIN SDA | ||
|
||
#define TEMPERATURE_PRECISION 10 //9: 0.5°, 10: 0.25°, 11: 0.125°, 12: 0.0625° | ||
|
||
|
||
OneWire oneWire(ONE_WIRE); | ||
OneWire oneWire(ONE_WIRE_PIN); | ||
DallasTemperature sensors(&oneWire);/* Dallas Temperature Library */ | ||
|
||
unsigned long owDelay = 750; | ||
|
@@ -61,6 +64,10 @@ int16_t limitTempMin = 0; | |
uint8_t valueTempMax = 255; | ||
int16_t limitTempMax = 0; | ||
|
||
#include "OneWire_functions.h" | ||
#include "setup.h" | ||
#include "loop.h" | ||
|
||
// Callback function to handle com objects updates | ||
|
||
void knxEvents(byte index) { | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ Author: E.Burkowski / [email protected], GPL Licensed | |
Multi Interface has 6 SERCOMs, but each Sercom can be used only once! | ||
this 3 Sercoms are reserved for system and can't be changed! | ||
Sercom3: I�C EEPROM / external I�C header | ||
Sercom3: I2C EEPROM / external I2C header | ||
Sercom4: SPI-Flash | ||
Sercom5: Serial for KNX-Tranceiver | ||
|
@@ -20,10 +20,12 @@ Sercom1,2 are free for use. | |
#define useSerial3 //uses sercom1 | ||
*/ | ||
|
||
#define useExternalEEPROM // comment if internal Flash EEPROM is used | ||
//#define useExternalEEPROM // comment if internal Flash EEPROM is used | ||
|
||
//don't change this lines! | ||
#ifdef useExternalEEPROM | ||
#include <Wire.h> | ||
#endif | ||
#include <Arduino.h> | ||
#include "wiring_private.h" // for pinPeripheral() function | ||
|
||
|
@@ -95,14 +97,10 @@ void Serial3_init(){ | |
#define KNX_SERIAL Serial | ||
#define FLASH_CS 9 | ||
|
||
#define OWD3 3 | ||
#define OWD3PullUp A3 | ||
#define OWD4 4 | ||
#define OWD4PullUp A4 | ||
|
||
#ifdef useExternalEEPROM | ||
// MI uses 24AA256 I2C EEPROM | ||
int readMemory(int index) { | ||
byte readMemory(int index) { | ||
byte data = 0xFF; | ||
if(index >= 0 && index < 32768){ | ||
Wire.beginTransmission(0x50); | ||
|
@@ -117,7 +115,7 @@ int readMemory(int index) { | |
return data; | ||
} | ||
|
||
void writeMemory(int index, int val) { | ||
void writeMemory(int index, byte val) { | ||
if(index >= 0 && index < 32768 && val >= 0 && val < 256){ | ||
Wire.beginTransmission(0x50); | ||
Wire.write((int) (index >> 8)); | ||
|
@@ -128,7 +126,7 @@ void writeMemory(int index, int val) { | |
} | ||
} | ||
|
||
void updateMemory(int index, int val) { | ||
void updateMemory(int index, byte val) { | ||
if (readMemory(index) != val) { | ||
writeMemory(index, val); | ||
} | ||
|
@@ -139,25 +137,24 @@ void commitMemory() { | |
} | ||
|
||
#else | ||
#include "ZeroEEPROM.h" // download from connecting GIT and don't forget Emulated EEPROM lib referenced there | ||
#include "FlashAsEEPROM.h" // | ||
|
||
// ZeroEEPROM.init(); ...call this function in setup() after Konnekting.setMemory...() functions | ||
|
||
int readMemory(int index) { | ||
return ZeroEEPROM.read(index); | ||
byte readMemory(int index) { | ||
return EEPROM.read(index); | ||
} | ||
|
||
void writeMemory(int index, int val) { | ||
ZeroEEPROM.write(index, val); | ||
void writeMemory(int index, byte val) { | ||
EEPROM.write(index, val); | ||
} | ||
|
||
void updateMemory(int index, int val) { | ||
void updateMemory(int index, byte val) { | ||
if (readMemory(index) != val) { | ||
writeMemory(index, val); | ||
} | ||
} | ||
|
||
void commitMemory() { | ||
ZeroEEPROM.commit(); | ||
EEPROM.commit(); | ||
} | ||
#endif |
7 changes: 4 additions & 3 deletions
7
...re_Temperature_SingleSensor_1.0/setup.ino → ...Wire_Temperature_SingleSensor_1.1/setup.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
..._1.0/Temperature_RH_Sensor_HTU21D_1.0.ino → ..._1.1/Temperature_RH_Sensor_HTU21D_1.1.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
/* --------------------------------------------------------------------------------------------- | ||
Temperature and relative humidty Sensor (HTU21D, SHT21...) | ||
Temperature and relative humidty Sensor 1.1 (HTU21D, SHT21...) | ||
Hardware/Firmware/Sketch/kdevice.xml by E.Burkowski / [email protected], GPL Licensed | ||
Compatible with: KONNEKTING Device Library 1.0.0 beta 4 | ||
Compatible with: KONNEKTING Device Library 1.0.0 beta 4b | ||
------------------------------------------------------------------------------------------------*/ | ||
|
||
/* this libraries are required (click on link and download with library manager): | ||
KONNEKTING Device Library: http://librarymanager/All#Konnekting | ||
FlashStorage: http://librarymanager/All#FlashStorage | ||
SparkFun HTU21D: http://librarymanager/All#SparkFun_HTU21D | ||
*/ | ||
|
||
#include <KonnektingDevice.h> | ||
#include "mi.h" | ||
|
||
// include device related configuration code, created by "KONNEKTING CodeGenerator" | ||
#include "kdevice_Temp_RH.h" | ||
|
||
#include <FlashAsEEPROM.h> | ||
|
||
// ################################################ | ||
// ### DEBUG CONFIGURATION | ||
// ################################################ | ||
//#define KDEBUG // comment this line to disable DEBUG mode | ||
#define KDEBUG // comment this line to disable DEBUG mode | ||
#ifdef KDEBUG | ||
#include <DebugUtil.h> | ||
#define DEBUGSERIAL SerialUSB | ||
#endif | ||
|
||
#include "SparkFunHTU21D.h" //https://github.com/sparkfun/SparkFun_HTU21D_Breakout_Arduino_Library | ||
#include "SparkFunHTU21D.h" | ||
|
||
// Create an instance for HTU21D sensor | ||
HTU21D htu; | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ Author: E.Burkowski / [email protected], GPL Licensed | |
Multi Interface has 6 SERCOMs, but each Sercom can be used only once! | ||
this 3 Sercoms are reserved for system and can't be changed! | ||
Sercom3: I�C EEPROM / external I�C header | ||
Sercom3: I2C EEPROM / external I2C header | ||
Sercom4: SPI-Flash | ||
Sercom5: Serial for KXN-Tranceiver | ||
Sercom5: Serial for KNX-Tranceiver | ||
Sercom0 is reserved for "Serial1" (D0,D1) if you use Serial1.begin(..), but this pins are only internaly available | ||
|
@@ -20,8 +20,12 @@ Sercom1,2 are free for use. | |
#define useSerial3 //uses sercom1 | ||
*/ | ||
|
||
//#define useExternalEEPROM // comment if internal Flash EEPROM is used | ||
|
||
//don't change this lines! | ||
#ifdef useExternalEEPROM | ||
#include <Wire.h> | ||
#endif | ||
#include <Arduino.h> | ||
#include "wiring_private.h" // for pinPeripheral() function | ||
|
||
|
@@ -93,13 +97,10 @@ void Serial3_init(){ | |
#define KNX_SERIAL Serial | ||
#define FLASH_CS 9 | ||
|
||
#define OWD3 3 | ||
#define OWD3PullUp A3 | ||
#define OWD4 4 | ||
#define OWD4PullUp A4 | ||
|
||
#ifdef useExternalEEPROM | ||
// MI uses 24AA256 I2C EEPROM | ||
int readMemory(int index) { | ||
byte readMemory(int index) { | ||
byte data = 0xFF; | ||
if(index >= 0 && index < 32768){ | ||
Wire.beginTransmission(0x50); | ||
|
@@ -114,7 +115,7 @@ int readMemory(int index) { | |
return data; | ||
} | ||
|
||
void writeMemory(int index, int val) { | ||
void writeMemory(int index, byte val) { | ||
if(index >= 0 && index < 32768 && val >= 0 && val < 256){ | ||
Wire.beginTransmission(0x50); | ||
Wire.write((int) (index >> 8)); | ||
|
@@ -125,7 +126,7 @@ void writeMemory(int index, int val) { | |
} | ||
} | ||
|
||
void updateMemory(int index, int val) { | ||
void updateMemory(int index, byte val) { | ||
if (readMemory(index) != val) { | ||
writeMemory(index, val); | ||
} | ||
|
@@ -134,3 +135,26 @@ void updateMemory(int index, int val) { | |
void commitMemory() { | ||
// EEPROM needs no commit, so this function is intentionally left blank | ||
} | ||
|
||
#else | ||
#include "FlashAsEEPROM.h" // | ||
|
||
|
||
byte readMemory(int index) { | ||
return EEPROM.read(index); | ||
} | ||
|
||
void writeMemory(int index, byte val) { | ||
EEPROM.write(index, val); | ||
} | ||
|
||
void updateMemory(int index, byte val) { | ||
if (readMemory(index) != val) { | ||
writeMemory(index, val); | ||
} | ||
} | ||
|
||
void commitMemory() { | ||
EEPROM.commit(); | ||
} | ||
#endif |
4 changes: 2 additions & 2 deletions
4
.../Temperature_RH_Sensor_HTU21D_1.0/setup.h → .../Temperature_RH_Sensor_HTU21D_1.1/setup.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters