├── .gitmodules ├── Images ├── arduino_bottom.jpg ├── arduino_settings_board.png ├── arduino_sketch_open.png ├── arduino_top.jpg ├── ftdi_flash.jpg ├── hm-rc-p1.jpg ├── hm_anlernen1.png ├── hm_config1.png ├── sketch_aes.png ├── sketch_pins.png ├── sketch_serial.png ├── wiring.fzz ├── wiring_arduino_cc1101.png └── wiring_arduino_cc1101_00.png ├── README.md └── examples ├── HB-LC-Bl1PBU-FM ├── HB-LC-Bl1PBU-FM.ino └── README.md ├── HB-LC-SW12-FM └── HB-LC-SW12-FM.ino ├── HB-LC-Sw1PBU-FM ├── HB-LC-Sw1PBU-FM.ino └── README.md ├── HB-LC-Sw2PBU-FM ├── HB-LC-Sw2PBU-FM.ino └── README.md ├── HB-LC-Sw3-LIDL ├── HB-LC-Sw3-LIDL.ino └── README.md ├── HB-UW-Sen-THPL ├── HB-UW-Sen-THPL.h ├── HB-UW-Sen-THPL.ino ├── Libraries │ ├── AskSin │ │ ├── AskSinMain.cpp │ │ ├── AskSinMain.h │ │ ├── Buttons.cpp │ │ ├── Buttons.h │ │ ├── Dummy.cpp │ │ ├── Dummy.h │ │ ├── Relay.cpp │ │ ├── Relay.h │ │ └── utility │ │ │ ├── Battery.cpp │ │ │ ├── Battery.h │ │ │ ├── Fastdelegate.h │ │ │ ├── Helpers.cpp │ │ │ ├── Helpers.h │ │ │ ├── PinChangeIntHandler.cpp │ │ │ ├── PinChangeIntHandler.h │ │ │ ├── Serial.cpp │ │ │ ├── Serial.h │ │ │ ├── StatusLed.cpp │ │ │ ├── StatusLed.h │ │ │ ├── cc110x.cpp │ │ │ └── cc110x.h │ ├── BH1750 │ │ ├── BH1750.cpp │ │ ├── BH1750.h │ │ ├── README.md │ │ ├── examples │ │ │ ├── BH1750advanced │ │ │ │ └── BH1750advanced.ino │ │ │ └── BH1750test │ │ │ │ └── BH1750test.ino │ │ ├── keywords.txt │ │ ├── library.json │ │ └── library.properties │ ├── BMP085 │ │ ├── BMP085.cpp │ │ ├── BMP085.h │ │ ├── BMP085.jpg │ │ ├── README.txt │ │ └── example │ │ │ ├── BMP085test - Kopie.html │ │ │ └── BMP085test.pde │ └── Wire │ │ ├── Wire.cpp │ │ ├── Wire.h │ │ ├── examples │ │ ├── SFRRanger_reader │ │ │ └── SFRRanger_reader.ino │ │ ├── digital_potentiometer │ │ │ └── digital_potentiometer.ino │ │ ├── master_reader │ │ │ └── master_reader.ino │ │ ├── master_writer │ │ │ └── master_writer.ino │ │ ├── slave_receiver │ │ │ └── slave_receiver.ino │ │ └── slave_sender │ │ │ └── slave_sender.ino │ │ ├── keywords.txt │ │ └── utility │ │ ├── twi.c │ │ └── twi.h ├── Register.h ├── Sensor_BMP180_BH1750.cpp ├── Sensor_BMP180_BH1750.h └── ccu-changelog.txt ├── HB-WDS40-THP-I ├── HB-WDS40-THP-I.ino └── Sens_BMP180.h ├── HB-WDS40-THP-O-BME280 ├── HB-WDS40-THP-O-BME280.ino └── Sens_BME280.h ├── HM-CC-SCD └── HM-CC-SCD.ino ├── HM-Dis-TD-T └── HM-Dis-TD-T.ino ├── HM-Dis-WM55 ├── FreeMono9pt7bMod.h ├── HM-Dis-WM55.ino └── Icons.h ├── HM-ES-PMSw1-Pl ├── HM-ES-PMSw1-Pl.ino ├── POW_Pinout.jpg └── README.md ├── HM-ES-PMSw1-Pl_GosundSP1 ├── Calibration │ └── Calibration.ino ├── HM-ES-PMSw1-Pl_GosundSP1.ino └── README.md ├── HM-ES-TX-WM_CCU └── HM-ES-TX-WM_CCU.ino ├── HM-LC-SW1-FM_Shelly1 ├── 1_Shelly_Open.jpeg ├── 2_Shelly_RemoveESP.jpg ├── 3_Shelly_RemovedESP.jpg ├── 4_ProMiniWithCC1101.jpg ├── 5_ShellyWithoutESP.jpg ├── 6_ShellyAssembled.jpeg ├── 7_ShellyCase.jpg ├── Deckel.stl ├── HM-LC-SW1-FM_Shelly1.ino └── README.md ├── HM-LC-SW1-SM_SONOFF_BASIC └── HM-LC-SW1-SM_SONOFF_BASIC.ino ├── HM-LC-Sw1-Pl-CT-R1 └── HM-LC-Sw1-Pl-CT-R1.ino ├── HM-LC-Sw1-Pl-DN-R1 └── HM-LC-Sw1-Pl-DN-R1.ino ├── HM-LC-Sw1-Pl-DN-R1_OBI ├── HM-LC-Sw1-Pl-DN-R1_OBI.ino ├── README.md └── SwitchObi.h ├── HM-LC-Sw2-FM └── HM-LC-Sw2-FM.ino ├── HM-MOD-Re-8 └── HM-MOD-Re-8.ino ├── HM-PB-2-FM └── HM-PB-2-FM.ino ├── HM-PB-2-WM55 └── HM-PB-2-WM55.ino ├── HM-PB-6-WM55 └── HM-PB-6-WM55.ino ├── HM-PB-MP-WM ├── ButtonMP.h └── HM-PB-MP-WM.ino ├── HM-PBI-4-FM └── HM-PBI-4-FM.ino ├── HM-RC-2-PBU-FM └── HM-RC-2-PBU-FM.ino ├── HM-SCI-3-FM └── HM-SCI-3-FM.ino ├── HM-SEC-SC └── HM-SEC-SC.ino ├── HM-SEC-SCO └── HM-SEC-SCO.ino ├── HM-SWI-3-FM └── HM-SWI-3-FM.ino ├── HM-Sec-TiS └── HM-Sec-TiS.ino ├── HM-Sen-DB-PCB └── HM-Sen-DB-PCB.ino ├── HM-Sen-LI-O └── HM-Sen-LI-O.ino ├── HM-Sen-WA-OD └── HM-Sen-WA-OD.ino ├── HM-Sys-sRP-Pl ├── HM-Sys-sRP-Pl.ino └── README.md ├── HM-WDS30-OT2-DS18B20 └── HM-WDS30-OT2-DS18B20.ino ├── HM-WDS30-OT2-NTC └── HM-WDS30-OT2-NTC.ino ├── HM-WDS30-T-O-NTC └── HM-WDS30-T-O-NTC.ino ├── HM-WDS40-TH-I-BME280 └── HM-WDS40-TH-I-BME280.ino ├── HM-WDS40-TH-I-DHT22 └── HM-WDS40-TH-I-DHT22.ino ├── HM-WDS40-TH-I-DS18B20 └── HM-WDS40-TH-I-DS18B20.ino ├── HM-WDS40-TH-I-SHT10 ├── HM-WDS40-TH-I-SHT10.ino ├── Images │ ├── Aufgehaengt.jpg │ ├── Deckel_und_Boden.jpg │ ├── Innen_Disp.jpg │ ├── Innen_Elektronik.jpg │ └── Temperaturanzeige.jpg ├── README.md ├── lcd.cpp └── lcd.h ├── HM-WDS40-TH-I-SHT31 └── HM-WDS40-TH-I-SHT31.ino ├── HM-WDS40-TH-I-SI7021 └── HM-WDS40-TH-I-SI7021.ino ├── RWE ├── HB-LC-Bl1PBU-FM_ISR2 │ └── HB-LC-Bl1PBU-FM_ISR2.ino ├── HM-LC-Bl1PBU-FM_ISR2.0 │ └── HM-LC-Bl1PBU-FM_ISR2.0.ino ├── HM-LC-Dim1TPBU-FM_ISD2 │ └── HM-LC-Dim1TPBU-FM_ISD2.ino ├── HM-LC-Sw1-Pl-DN-R1_PSS │ └── HM-LC-Sw1-Pl-DN-R1_PSS.ino ├── HM-LC-Sw1PBU-FM_ISS2 │ └── HM-LC-Sw1PBU-FM_ISS2.ino ├── HM-PB-2-FM_ISC2 │ └── HM-PB-2-FM_ISC2.ino ├── HM-PB-2-FM_WSC2 │ ├── HM-PB-2-FM_WSC2.ino │ └── schematic │ │ ├── schematic.png │ │ ├── wsc2-cache.lib │ │ ├── wsc2.kicad_pcb │ │ ├── wsc2.kicad_prl │ │ ├── wsc2.kicad_pro │ │ ├── wsc2.pro │ │ ├── wsc2.sch │ │ └── wsc2.sch-bak ├── HM-RC-8_BRC8 │ ├── HM-RC-8_BRC8.ino │ └── README.txt ├── HM-SEC-SC_WDS │ └── HM-SEC-SC_WDS.ino ├── HM-SEC-SC_WDSo2.0 │ └── HM-SEC-SC_WDSo2.0.ino └── HM-Sen-MDIR-O_WMD_O │ └── HM-Sen-MDIR-O_WMD_O.ino ├── _wip_HM-MOD-EM-8 └── _wip_HM-MOD-EM-8.ino └── _wip_HM-MOD-EM-8Bit └── _wip_HM-MOD-EM-8Bit.ino /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/.gitmodules -------------------------------------------------------------------------------- /Images/arduino_bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_bottom.jpg -------------------------------------------------------------------------------- /Images/arduino_settings_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_settings_board.png -------------------------------------------------------------------------------- /Images/arduino_sketch_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_sketch_open.png -------------------------------------------------------------------------------- /Images/arduino_top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/arduino_top.jpg -------------------------------------------------------------------------------- /Images/ftdi_flash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/ftdi_flash.jpg -------------------------------------------------------------------------------- /Images/hm-rc-p1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/hm-rc-p1.jpg -------------------------------------------------------------------------------- /Images/hm_anlernen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/hm_anlernen1.png -------------------------------------------------------------------------------- /Images/hm_config1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/hm_config1.png -------------------------------------------------------------------------------- /Images/sketch_aes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/sketch_aes.png -------------------------------------------------------------------------------- /Images/sketch_pins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/sketch_pins.png -------------------------------------------------------------------------------- /Images/sketch_serial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/sketch_serial.png -------------------------------------------------------------------------------- /Images/wiring.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/wiring.fzz -------------------------------------------------------------------------------- /Images/wiring_arduino_cc1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/wiring_arduino_cc1101.png -------------------------------------------------------------------------------- /Images/wiring_arduino_cc1101_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/Images/wiring_arduino_cc1101_00.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Beispiel für die Verwendung der [AskSinPP](https://github.com/pa-pa/AskSinPP) Bibliothek 2 | ## zum Nachbau eines HM-[1-Kanal Senders](https://github.com/pa-pa/AskSinPP/tree/master/examples/HM-RC-P1) mittels Arduino Pro mini, CC1101 und [AskSinPP](https://github.com/pa-pa/AskSinPP) Arduino-Bibliothek. 3 | ### Mithilfe dieser Bibliothek lässt sich sehr preiswert eine Vielzahl von HomeMatic[-Sensoren, -Aktoren und -Sendern](https://github.com/pa-pa/AskSinPP/tree/master/examples) nachbauen!
Eine Übersicht, welche Geräte es gibt, findet ihr [hier](https://github.com/jp112sdl/AskSinPPCollection). 4 | 5 | 6 | ![proto1](Images/hm-rc-p1.jpg) 7 | 8 | 9 | ## Hardwaresektion 10 | ### Bauteile 11 | - 1x Arduino Pro Mini (3.3V 8MHz) (ca. 2,20 EUR bei [eBay](https://www.ebay.de/itm/272812248667)) 12 | - 1x CC1101 Funkmodul 868MHz (ca. 2,60 EUR bei [eBay](https://www.ebay.de/itm/272455136087)) 13 | - 1x Batteriehalter 2x AA (ca. 2,30 EUR bei [eBay](http://www.ebay.de/itm/200988520956)) 14 | - 1x FTDI Adapter (falls nicht schon vorhanden, gibts bei [Amazon](https://www.amazon.de/FT232RL-FTDI-USB-auf-TTL-Serienadapter-Arduino/dp/B00HSXDGOE)) 15 | - 2x Taster (beliebig, z.B. [Kurzhubtaster](https://www.ebay.de/itm/112592788992)) 16 | - 2x AA Batterien 17 | 18 | ### Gehäuse 19 | - bei Thingiverse ([Link](https://www.thingiverse.com/thing:2840228)) gibt es für den Temp-/Feuchtesensor HM-WDS10-TH-I-DHT22 ein super praktisches Gehäuse! 20 | 21 | ### Verdrahtung 22 | _allgemeingültige Verdrahtung (Anschluss CC1101 an Arduino Pro Mini) auch für andere AskSinPP-Projekte_ 23 | ![wiring](Images/wiring_arduino_cc1101.png) 24 | 25 | **Der Anschluss des Sende-Tasters** 26 | - **erfolgt an A0 / GND!** 27 | 28 | **Der Anschluss der Batterien** 29 | - **+ an VCC** 30 | - **- an GND** 31 | 32 | **Stromverbrauch: Um den Stromverbrauch zu reduzieren, sind die beiden Bauteile (LDO und LED; rotes X) von der Arduino Pro Mini Platine zu entfernen.** 33 | 34 | **_Mithilfe von Kupferlackdraht kann das Funkmodul platzspared "huckepack" am Arduino Pro Mini angeschlossen werden:_** 35 | ![wiring2](Images/arduino_bottom.jpg) 36 | 37 | Unterseite: 38 | ![wiring3](Images/arduino_top.jpg) 39 | 40 | ## Universalplatine 41 | Wer eine eigene Platine herstellen möchte, kann auf eine Auswahl verschiedener vorgefertigter Layouts zurückgreifen. 42 | z.B.: 43 | - [PCB](https://github.com/alexreinert/PCB) von alexreinert 44 | - [HMSensor](https://github.com/pa-pa/HMSensor) von pa-pa 45 | 46 | ### Anschluss des FTDI Adapters zum Flashen 47 | - Um die Schaltung sehr kompakt zu halten, verzichte ich auf das Anlöten eines Steckverbinders. Es reicht aus, wenn man die Pins des FTDI Adapters durch die Lötbohrungen steckt. Während des Flash-Vorgangs verkantet man beide Platinen leicht, damit die Kontaktierung gegeben ist. 48 | 49 | ![flash](Images/ftdi_flash.jpg) 50 | 51 | ## Softwareabteilung 52 | ### Arduino IDE 53 | - Arduino IDE [herunterladen](https://www.arduino.cc/en/Main/Software) und installieren 54 | - AskSinPP Bibliothek als [ZIP herunterladen](https://github.com/pa-pa/AskSinPP/archive/master.zip) 55 | - notwendige Bibliotheken in der Arduino IDE hinzufügen: 56 | - Sketch -> Bibliothek einbinden -> .ZIP-Bibliothek hinzufügen 57 | - heruntergeladene AskSinPP Bibliothek ZIP-Datei auswählen 58 | - Sketch -> Bibliothek einbinden -> Bibliotheken verwalten 59 | - im Suchfeld folgende Bibliotheken suchen und installieren: 60 | - EnableInterrupt 61 | - Low-Power 62 | - Board einstellen: 63 | - Board: `Arduino Pro or Pro Mini` 64 | - Prozessor: `ATmega328P (3.3V, 8 MHz)` 65 | - Port: `COM-Port` des FTDI Adapters
66 | 67 | - Sketch öffnen: 68 | - Datei 69 | - Beispiele 70 | - AskSinPP 71 | - HM-RC-P1 72 | 73 | - Anpassungen: 74 | - gerade wenn man mehrere Geräte des selben Typs verwenden will, muss man für jedes Gerät eine eigene Seriennummer vergeben! Es sind dabei sowohl die `Device ID` (Hexadezimal) als auch die `Device Serial` (Freitext) zu ändern! 75 |     76 | 77 | 78 | - Sketch hochladen: 79 | - Sketch 80 | - Hochladen 81 | 82 | Die Pinbelegungen des Arduino stehen in den jeweiligen Sketchen der Projektdateien.
83 | Beim 1-Kanal Paniksender z.B.: Config-Taster an Pin **8** und Button1 an **A0**: 84 | 85 | 86 | 87 | ### Anlernen an HomeMatic 88 | - Geräte anlernen -> HM-Gerät anlernen klicken 89 | - **Config-Taster** am Arduino Pro Mini **kurz** drücken 90 | - das neue Gerät erscheint anschließend im Posteingang 91 | 92 | 93 | - Einstellungen -> Geräte -> "+" anklicken, anschließend den Kanal anklicken 94 | - "gesicherte" Übertragung deaktivieren 95 | 96 | 97 | **AES Verschlüsselung für die gesicherte Übertragung ist prinzipiell auch möglich, ist aber etwas kompliziert zu beschreiben (auch wenn die Sache selbst relativ unkompliziert ist** 98 | -------------------------------------------------------------------------------- /examples/HB-LC-Bl1PBU-FM/README.md: -------------------------------------------------------------------------------- 1 | # alternative Firmware für den HM-LC-Bl1PBU-FM 2 | 3 | Mit dieser Firmware lassen sich die beiden Taster (oben / unten) und die Rollladenrelais getrennt voneinander benutzen.
4 | (Es wird mind. Version 1.23 des [JP-HB-Devices Addon](https://github.com/jp112sdl/JP-HB-Devices-addon) benötigt) 5 | 6 | Anschluss des ISP an die Controller-Platine des HM-LC-Bl1PBU-FM:
7 | https://github.com/jabdoa2/Asksin_HM_LC_Sw1PBU_FM 8 | -------------------------------------------------------------------------------- /examples/HB-LC-SW12-FM/HB-LC-SW12-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-02-17 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define EI_NOTEXTERNAL 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | #define CONFIG_BUTTON_PIN 8 19 | #define RELAY1_PIN 3 20 | #define RELAY2_PIN 4 21 | #define RELAY3_PIN 5 22 | #define RELAY4_PIN 6 23 | #define RELAY5_PIN 7 24 | #define RELAY6_PIN 9 25 | #define RELAY7_PIN 14 26 | #define RELAY8_PIN 15 27 | #define RELAY9_PIN 16 28 | #define RELAY10_PIN 17 29 | #define RELAY11_PIN 18 30 | #define RELAY12_PIN 19 31 | 32 | // number of available peers per channel 33 | #define PEERS_PER_CHANNEL 2 34 | 35 | // all library classes are placed in the namespace 'as' 36 | using namespace as; 37 | 38 | // define all device properties 39 | const struct DeviceInfo PROGMEM devinfo = { 40 | {0xf3,0x20,0x00}, // Device ID 41 | "JPSW120001", // Device Serial 42 | {0xf3,0x20}, // Device Model 43 | 0x10, // Firmware Version 44 | as::DeviceType::Switch, // Device Type 45 | {0x01,0x00} // Info Bytes 46 | }; 47 | 48 | /** 49 | * Configure the used hardware 50 | */ 51 | typedef AvrSPI<10,11,12,13> RadioSPI; 52 | typedef AskSin > Hal; 53 | 54 | typedef MultiChannelDevice,12> SwitchType; 55 | Hal hal; 56 | SwitchType sdev(devinfo,0x20); 57 | ConfigButton cfgBtn(sdev); 58 | 59 | void initPeerings (bool first) { 60 | // create internal peerings - CCU2 needs this 61 | if( first == true ) { 62 | HMID devid; 63 | sdev.getDeviceID(devid); 64 | for( uint8_t i=1; i<=sdev.channels(); ++i ) { 65 | Peer ipeer(devid,i); 66 | sdev.channel(i).peer(ipeer); 67 | } 68 | } 69 | } 70 | 71 | void setup () { 72 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 73 | bool first = sdev.init(hal); 74 | sdev.channel(1).init(RELAY1_PIN); 75 | sdev.channel(2).init(RELAY2_PIN); 76 | sdev.channel(3).init(RELAY3_PIN); 77 | sdev.channel(4).init(RELAY4_PIN); 78 | sdev.channel(5).init(RELAY5_PIN); 79 | sdev.channel(6).init(RELAY6_PIN); 80 | sdev.channel(7).init(RELAY7_PIN); 81 | sdev.channel(8).init(RELAY8_PIN); 82 | sdev.channel(9).init(RELAY9_PIN); 83 | sdev.channel(10).init(RELAY10_PIN); 84 | sdev.channel(11).init(RELAY11_PIN); 85 | sdev.channel(12).init(RELAY12_PIN); 86 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 87 | initPeerings(first); 88 | sdev.initDone(); 89 | } 90 | 91 | void loop() { 92 | bool worked = hal.runready(); 93 | bool poll = sdev.pollRadio(); 94 | if( worked == false && poll == false ) { 95 | hal.activity.savePower >(hal); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /examples/HB-LC-Sw1PBU-FM/HB-LC-Sw1PBU-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-10-07 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=644p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | // Arduino IDE Settings 12 | // use support for 644PA from MightyCore: https://github.com/MCUdude/MightyCore 13 | // settings: 14 | // Board: ATMega644 15 | // Pinout: Standard 16 | // Clock: 8MHz external 17 | // Variant: 644P / 644PA 18 | // BOD: 2.7V 19 | // Compiler LTO: Enabled 20 | 21 | #define NDEBUG 22 | 23 | #define EI_NOTEXTERNAL 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define RELAY_PIN 12 //PD4 33 | #define BTN_PIN_1 14 //PD6 34 | #define BTN_PIN_2 8 //PD0 35 | #define LED_PIN 0 //PB0 36 | #define CONFIG_BUTTON_PIN 15 //PD7 37 | #define CS_PIN 4 //PB4 38 | #define GDO0_PIN 10 //PD2 39 | 40 | 41 | // number of available peers per channel 42 | #define PEERS_PER_SwitchChannel 8 43 | #define PEERS_PER_RemoteChannel 12 44 | 45 | // all library classes are placed in the namespace 'as' 46 | using namespace as; 47 | 48 | // define all device properties 49 | const struct DeviceInfo PROGMEM devinfo = { 50 | {0xf3, 0x35, 0x01},// Device ID 51 | "HBSw1PBU01", // Device Serial 52 | {0xf3, 0x35}, // Device Model 53 | 0x10, // Firmware Version 54 | as::DeviceType::Switch, // Device Type 55 | {0x01, 0x00} // Info Bytes 56 | }; 57 | /** 58 | Configure the used hardware 59 | */ 60 | typedef LibSPI SPIType; 61 | typedef Radio RadioType; 62 | typedef StatusLed LedType; 63 | typedef AskSin Hal; 64 | Hal hal; 65 | 66 | DEFREGISTER(Reg0, MASTERID_REGS, DREG_INTKEY, DREG_CYCLICINFOMSG) 67 | class SwList0 : public RegList0 { 68 | public: 69 | SwList0(uint16_t addr) : RegList0(addr) {} 70 | void defaults() { 71 | clear(); 72 | intKeyVisible(true); 73 | } 74 | }; 75 | 76 | typedef SwitchChannel SwChannel; 77 | typedef RemoteChannel BtnChannel; 78 | 79 | class MixDevice : public ChannelDevice, 3, SwList0> { 80 | public: 81 | VirtChannel swc1; 82 | VirtChannel btc1, btc2; 83 | 84 | public: 85 | typedef ChannelDevice, 3, SwList0> DeviceType; 86 | MixDevice (const DeviceInfo& info, uint16_t addr) : DeviceType(info, addr) { 87 | DeviceType::registerChannel(swc1, 1); 88 | DeviceType::registerChannel(btc1, 2); 89 | DeviceType::registerChannel(btc2, 3); 90 | } 91 | virtual ~MixDevice () {} 92 | 93 | SwChannel& sw1Channel () { 94 | return swc1; 95 | } 96 | 97 | BtnChannel& btn1Channel () { 98 | return btc1; 99 | } 100 | BtnChannel& btn2Channel () { 101 | return btc2; 102 | } 103 | }; 104 | MixDevice sdev(devinfo, 0x20); 105 | ConfigButton cfgBtn(sdev); 106 | 107 | void initPeerings (bool first) { 108 | if ( first == true ) { 109 | HMID devid; 110 | sdev.getDeviceID(devid); 111 | sdev.sw1Channel().peer(Peer(devid, 2), Peer(devid, 3)); 112 | sdev.btn1Channel().peer(Peer(devid, 1)); 113 | sdev.btn2Channel().peer(Peer(devid, 1)); 114 | } 115 | } 116 | 117 | void setup () { 118 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 119 | bool first = sdev.init(hal); 120 | sdev.sw1Channel().init(RELAY_PIN, false); 121 | remoteChannelISR(sdev.btn1Channel(), BTN_PIN_1); 122 | remoteChannelISR(sdev.btn2Channel(), BTN_PIN_2); 123 | 124 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 125 | 126 | initPeerings(first); 127 | storage().store(); 128 | 129 | sdev.initDone(); 130 | } 131 | 132 | void loop() { 133 | bool worked = hal.runready(); 134 | bool poll = sdev.pollRadio(); 135 | if ( worked == false && poll == false ) { 136 | hal.activity.savePower >(hal); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /examples/HB-LC-Sw1PBU-FM/README.md: -------------------------------------------------------------------------------- 1 | # alternative Firmware für den HM-LC-Sw1PBU-FM 2 | 3 | Mit dieser Firmware lassen sich die beiden Taster (oben / unten) und das Relais getrennt voneinander benutzen.
4 | (Es wird mind. Version 1.21 des [JP-HB-Devices Addon](https://github.com/jp112sdl/JP-HB-Devices-addon) benötigt) 5 | 6 | Anschluss des ISP an die Controller-Platine des HM-LC-Sw1PBU-FM:
7 | https://github.com/jabdoa2/Asksin_HM_LC_Sw1PBU_FM 8 | -------------------------------------------------------------------------------- /examples/HB-LC-Sw2PBU-FM/HB-LC-Sw2PBU-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-10-07 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=644p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | // Arduino IDE Settings 12 | // use support for 644PA from MightyCore: https://github.com/MCUdude/MightyCore 13 | // settings: 14 | // Board: ATMega644 15 | // Pinout: Standard 16 | // Clock: 8MHz external 17 | // Variant: 644P / 644PA 18 | // BOD: 2.7V 19 | // Compiler LTO: Enabled 20 | 21 | #define NDEBUG 22 | 23 | #define EI_NOTEXTERNAL 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define RELAY_1_PIN 12 //PD4 33 | #define RELAY_2_PIN 13 //PD5 34 | #define BTN_1_PIN 14 //PD6 35 | #define BTN_2_PIN 8 //PD0 36 | #define LED_PIN 0 //PB0 37 | #define CONFIG_BUTTON_PIN 15 //PD7 38 | #define CS_PIN 4 //PB4 39 | #define GDO0_PIN 10 //PD2 40 | 41 | 42 | // number of available peers per channel 43 | #define PEERS_PER_SwitchChannel 8 44 | #define PEERS_PER_RemoteChannel 12 45 | 46 | // all library classes are placed in the namespace 'as' 47 | using namespace as; 48 | 49 | // define all device properties 50 | const struct DeviceInfo PROGMEM devinfo = { 51 | {0xf3, 0x36, 0x01},// Device ID 52 | "HBSw2PBU01", // Device Serial 53 | {0xf3, 0x36}, // Device Model 54 | 0x10, // Firmware Version 55 | as::DeviceType::Switch, // Device Type 56 | {0x01, 0x00} // Info Bytes 57 | }; 58 | /** 59 | Configure the used hardware 60 | */ 61 | typedef LibSPI SPIType; 62 | typedef Radio RadioType; 63 | typedef StatusLed LedType; 64 | typedef AskSin Hal; 65 | Hal hal; 66 | 67 | DEFREGISTER(Reg0, MASTERID_REGS, DREG_INTKEY, DREG_CYCLICINFOMSG) 68 | class SwList0 : public RegList0 { 69 | public: 70 | SwList0(uint16_t addr) : RegList0(addr) {} 71 | void defaults() { 72 | clear(); 73 | intKeyVisible(true); 74 | } 75 | }; 76 | 77 | typedef SwitchChannel SwChannel; 78 | typedef RemoteChannel BtnChannel; 79 | 80 | class MixDevice : public ChannelDevice, 4, SwList0> { 81 | public: 82 | VirtChannel swc1, swc2; 83 | VirtChannel btc1, btc2; 84 | public: 85 | typedef ChannelDevice, 4, SwList0> DeviceType; 86 | MixDevice (const DeviceInfo& info, uint16_t addr) : DeviceType(info, addr) { 87 | DeviceType::registerChannel(swc1, 1); 88 | DeviceType::registerChannel(swc2, 2); 89 | DeviceType::registerChannel(btc1, 3); 90 | DeviceType::registerChannel(btc2, 4); 91 | } 92 | virtual ~MixDevice () {} 93 | 94 | SwChannel& sw1Channel () { 95 | return swc1; 96 | } 97 | SwChannel& sw2Channel () { 98 | return swc2; 99 | } 100 | BtnChannel& btn1Channel () { 101 | return btc1; 102 | } 103 | BtnChannel& btn2Channel () { 104 | return btc2; 105 | } 106 | }; 107 | MixDevice sdev(devinfo, 0x20); 108 | ConfigButton cfgBtn(sdev); 109 | 110 | void initPeerings (bool first) { 111 | if ( first == true ) { 112 | HMID devid; 113 | sdev.getDeviceID(devid); 114 | sdev.sw1Channel().peer(Peer(devid, 3)); 115 | sdev.sw2Channel().peer(Peer(devid, 4)); 116 | sdev.btn1Channel().peer(Peer(devid, 1)); 117 | sdev.btn2Channel().peer(Peer(devid, 2)); 118 | } 119 | } 120 | 121 | void setup () { 122 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 123 | bool first = sdev.init(hal); 124 | sdev.sw1Channel().init(RELAY_1_PIN, false); 125 | sdev.sw2Channel().init(RELAY_2_PIN, false); 126 | remoteChannelISR(sdev.btn1Channel(), BTN_1_PIN); 127 | remoteChannelISR(sdev.btn2Channel(), BTN_2_PIN); 128 | 129 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 130 | 131 | initPeerings(first); 132 | storage().store(); 133 | 134 | sdev.initDone(); 135 | } 136 | 137 | void loop() { 138 | bool worked = hal.runready(); 139 | bool poll = sdev.pollRadio(); 140 | if ( worked == false && poll == false ) { 141 | hal.activity.savePower >(hal); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /examples/HB-LC-Sw2PBU-FM/README.md: -------------------------------------------------------------------------------- 1 | # alternative Firmware für den HM-LC-Sw2PBU-FM 2 | 3 | Mit dieser Firmware lassen sich die beiden Taster (oben / unten) und die Relais getrennt voneinander benutzen.
4 | (Es wird mind. Version 1.22 des [JP-HB-Devices Addon](https://github.com/jp112sdl/JP-HB-Devices-addon) benötigt) 5 | 6 | Anschluss des ISP an die Controller-Platine des HM-LC-Sw2PBU-FM:
7 | https://github.com/jabdoa2/Asksin_HM_LC_Sw1PBU_FM 8 | -------------------------------------------------------------------------------- /examples/HB-LC-Sw3-LIDL/HB-LC-Sw3-LIDL.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2021-09-26 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | 7 | #define EI_NOTEXTERNAL 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define LED_PIN 4 //LED 14 | #define RELAY1_PIN 5 //K1 15 | #define RELAY2_PIN 6 //K2 16 | #define RELAY3_PIN 7 //K3 17 | #define CONFIG_BUTTON_PIN 8 //Switch 18 | 19 | #define RELAY_ACTIVE_LOW false 20 | 21 | #define PEERS_PER_CHANNEL 8 22 | 23 | using namespace as; 24 | const struct DeviceInfo PROGMEM devinfo = { 25 | {0xf3,0x26,0x01}, // Device ID 26 | "JHLCSW3L01", // Device Serial 27 | {0xf3,0x26}, // Device Model 28 | 0x16, // Firmware Version 29 | as::DeviceType::Switch, // Device Type 30 | {0x01,0x00} // Info Bytes 31 | }; 32 | typedef AvrSPI<10,11,12,13> RadioSPI; 33 | typedef AskSin,NoBattery,Radio > Hal; 34 | typedef MultiChannelDevice,3> SwitchType; 35 | Hal hal; 36 | SwitchType sdev(devinfo,0x20); 37 | ConfigButton cfgBtn(sdev); 38 | 39 | void setup () { 40 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 41 | sdev.init(hal); 42 | sdev.channel(1).init(RELAY1_PIN,RELAY_ACTIVE_LOW); 43 | sdev.channel(2).init(RELAY2_PIN,RELAY_ACTIVE_LOW); 44 | sdev.channel(3).init(RELAY3_PIN,RELAY_ACTIVE_LOW); 45 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 46 | sdev.led().invert(true); 47 | sdev.initDone(); 48 | } 49 | 50 | void loop() { 51 | bool worked = hal.runready(); 52 | bool poll = sdev.pollRadio(); 53 | if( worked == false && poll == false ) { 54 | hal.activity.savePower >(hal); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /examples/HB-LC-Sw3-LIDL/README.md: -------------------------------------------------------------------------------- 1 | weitere Informationen im Homematic-Forum: 2 | https://homematic-forum.de/forum/viewtopic.php?f=76&t=69743 3 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/HB-UW-Sen-THPL.h: -------------------------------------------------------------------------------- 1 | #if defined(ARDUINO) && ARDUINO >= 100 2 | #include "Arduino.h" 3 | #else 4 | #include "WProgram.h" 5 | #endif 6 | 7 | /** 8 | * Must set in AskSinMain.h to !!! 9 | * 10 | * Set to 1 to read address data from end of bootloader section 11 | * Set to 0 to read address data from program space 12 | */ 13 | #define USE_ADRESS_SECTION 0 14 | 15 | #define ADDRESS_SECTION_START 0x7FF0 // Start address of data in adress section at and of bootloader 16 | 17 | /** 18 | * Activate for serial debug infos 19 | */ 20 | #define SER_DBG 21 | 22 | #define FIRMWARE_VERSION 0x0F // 0.15 23 | 24 | /* 25 | * Address data if we don't read them from bootloader section 26 | */ 27 | #if USE_ADRESS_SECTION == 0 28 | //#define DEVICE_TYPE 0xF1, 0x01 // The model-ID 0xF1 0x01 = DIY (HB-UW-Sen-THPL-I) 29 | #define DEVICE_TYPE 0xF1, 0x02 // The model-ID 0xF1 0x02 = DIY (HB-UW-Sen-THPL-O) 30 | #define DEVICE_SERIAL 'U','W','S','0','0','0','0','0','0','1' // The serial 10 bytes, needed for pairing (Default for serial flash tool) 31 | #define DEVICE_ADDRESS 0x19, 0x15, 0x17 // The HM-ID 3 bytes, needed for pairing (Default for flash tool) 32 | #endif 33 | 34 | #define BATTERY_MEASSUREMENT_FACTOR 17 // Faktor Spannungsteiler externe Batteriemessung 35 | #define BATTERY_MIN_VOLTAGE 10 // minimal configuable low battery voltage level 36 | #define BATTERY_MAX_VOLTAGE 50 // maximal configuable low battery voltage level 37 | 38 | void getPgmSpaceData(uint8_t *buffer, uint16_t address, uint8_t len); 39 | void getDataFromAddressSection(uint8_t *buffer, uint8_t bufferStartAddress, uint16_t sectionAddress, uint8_t dataLen); 40 | 41 | void cmdConfigChanged(uint8_t *data, uint8_t len); 42 | void cmdReset(uint8_t *data, uint8_t len); 43 | void cmdStatusRequest(uint8_t *data, uint8_t len); 44 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/Dummy.cpp: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Dummy class for own developments -------------------------------------------------------------------------------------- 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | #include "Dummy.h" 8 | 9 | 10 | 11 | //- mandatory functions for every new module to communicate within HM protocol stack -------------------------------------- 12 | void Dummy::configCngEvent(void) { 13 | // it's only for information purpose while something in the channel config was changed (List0/1 or List3/4) 14 | #ifdef DM_DBG 15 | Serial << F("configCngEvent\n"); 16 | #endif 17 | } 18 | void Dummy::pairSetEvent(uint8_t *data, uint8_t len) { 19 | // we received a message from master to set a new value, typical you will find three bytes in data 20 | // 1st byte = value; 2nd byte = ramp time; 3rd byte = duration time; 21 | // after setting the new value we have to send an enhanced ACK (<- 0E E7 80 02 1F B7 4A 63 19 63 01 01 C8 00 54) 22 | #ifdef DM_DBG 23 | Serial << F("pairSetEvent, value:"); pHexB(data[0]); 24 | if (len > 1) Serial << F(", rampTime: "); pHexB(data[1]); 25 | if (len > 2) Serial << F(", duraTime: "); pHexB(data[2]); 26 | Serial << F("\n"); 27 | #endif 28 | 29 | hm->sendACKStatus(regCnl,modStat,0); 30 | } 31 | void Dummy::pairStatusReq(void) { 32 | // we received a status request, appropriate answer is an InfoActuatorStatus message 33 | #ifdef DM_DBG 34 | Serial << F("pairStatusReq\n"); 35 | #endif 36 | 37 | hm->sendInfoActuatorStatus(regCnl, modStat, 0); 38 | } 39 | void Dummy::peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len) { 40 | // we received a peer event, in type you will find the marker if it was a switch(3E), remote(40) or sensor(41) event 41 | // appropriate answer is an ACK 42 | #ifdef DM_DBG 43 | Serial << F("peerMsgEvent, type: "); pHexB(type); 44 | Serial << F(", data: "); pHex(data,len, SERIAL_DBG_PHEX_MODE_LF); 45 | #endif 46 | 47 | hm->send_ACK(); 48 | } 49 | 50 | void Dummy::poll(void) { 51 | // just polling, as the function name said 52 | } 53 | 54 | //- predefined, no reason to touch ---------------------------------------------------------------------------------------- 55 | void Dummy::regInHM(uint8_t cnl, HM *instPtr) { 56 | hm = instPtr; // set pointer to the HM module 57 | hm->regCnlModule(cnl,s_mod_dlgt(this,&Dummy::hmEventCol),(uint16_t*)&ptrMainList,(uint16_t*)&ptrPeerList); 58 | regCnl = cnl; // stores the channel we are responsible fore 59 | } 60 | void Dummy::hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len) { 61 | if (by3 == 0x00) poll(); 62 | else if ((by3 == 0x01) && (by11 == 0x06)) configCngEvent(); 63 | else if ((by3 == 0x11) && (by10 == 0x02)) pairSetEvent(data, len); 64 | else if ((by3 == 0x01) && (by11 == 0x0E)) pairStatusReq(); 65 | else if ((by3 == 0x01) && (by11 == 0x01)) peerAddEvent(data, len); 66 | else if (by3 >= 0x3E) peerMsgEvent(by3, data, len); 67 | else return; 68 | } 69 | void Dummy::peerAddEvent(uint8_t *data, uint8_t len) { 70 | // we received an peer add event, which means, there was a peer added in this respective channel 71 | // 1st byte and 2nd byte shows the peer channel, 3rd and 4th byte gives the peer index 72 | // no need for sending an answer, but we could set default data to the respective list3/4 73 | #ifdef DM_DBG 74 | Serial << F("peerAddEvent: pCnl1: "); pHexB(data[0]); 75 | Serial << F(", pCnl2: "); pHexB(data[1]); 76 | Serial << F(", pIdx1: "); pHexB(data[2]); 77 | Serial << F(", pIdx2: "); pHexB(data[3]); 78 | Serial << F("\n"); 79 | #endif 80 | 81 | if ((data[0]) && (data[1])) { // dual peer add 82 | if (data[0]%2) { // odd 83 | hm->setListFromModule(regCnl,data[2],(uint8_t*)peerOdd,sizeof(peerOdd)); 84 | hm->setListFromModule(regCnl,data[3],(uint8_t*)peerEven,sizeof(peerEven)); 85 | } else { // even 86 | hm->setListFromModule(regCnl,data[2],(uint8_t*)peerEven,sizeof(peerEven)); 87 | hm->setListFromModule(regCnl,data[3],(uint8_t*)peerOdd,sizeof(peerOdd)); 88 | } 89 | } else { // single peer add 90 | if (data[0]) hm->setListFromModule(regCnl,data[2],(uint8_t*)peerSingle,sizeof(peerSingle)); 91 | if (data[1]) hm->setListFromModule(regCnl,data[3],(uint8_t*)peerSingle,sizeof(peerSingle)); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/Dummy.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Dummy class for own developments -------------------------------------------------------------------------------------- 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | #ifndef DUMMY_H 8 | #define DUMMY_H 9 | 10 | #if defined(ARDUINO) && ARDUINO >= 100 11 | #include "Arduino.h" 12 | #else 13 | #include "WProgram.h" 14 | #endif 15 | 16 | #include "AskSinMain.h" 17 | #include "utility/Serial.h" 18 | #include "utility/Fastdelegate.h" 19 | 20 | #define DM_DBG // debug message flag 21 | 22 | const uint8_t peerOdd[] = {}; // default settings for list3 or list4 23 | const uint8_t peerEven[] = {}; 24 | const uint8_t peerSingle[] = {}; 25 | 26 | class Dummy { 27 | //- user code here ------------------------------------------------------------------------------------------------------ 28 | public://---------------------------------------------------------------------------------------------------------------- 29 | protected://------------------------------------------------------------------------------------------------------------- 30 | private://--------------------------------------------------------------------------------------------------------------- 31 | 32 | 33 | //- mandatory functions for every new module to communicate within HM protocol stack ------------------------------------ 34 | public://---------------------------------------------------------------------------------------------------------------- 35 | uint8_t modStat; // module status byte, needed for list3 modules to answer status requests 36 | uint8_t regCnl; // holds the channel for the module 37 | 38 | HM *hm; // pointer to HM class instance 39 | uint8_t *ptrPeerList; // pointer to list3/4 in regs struct 40 | uint8_t *ptrMainList; // pointer to list0/1 in regs struct 41 | 42 | void configCngEvent(void); // list1 on registered channel had changed 43 | void pairSetEvent(uint8_t *data, uint8_t len); // pair message to specific channel, handover information for value, ramp time and so on 44 | void pairStatusReq(void); // event on status request 45 | void peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len); // peer message was received on the registered channel, handover the message bytes and length 46 | 47 | void poll(void); // poll function, driven by HM loop 48 | 49 | //- predefined, no reason to touch ------------------------------------------------------------------------------------ 50 | void regInHM(uint8_t cnl, HM *instPtr); // register this module in HM on the specific channel 51 | void hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len); // call back address for HM for informing on events 52 | void peerAddEvent(uint8_t *data, uint8_t len); // peer was added to the specific channel, 1st and 2nd byte shows peer channel, third and fourth byte shows peer index 53 | }; 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Battery.cpp: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // dirk@forum.fhem.de 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | //- Low battery alarm ----------------------------------------------------------------------------------------------------- 7 | //- with a lot of contribution from Dirk at FHEM forum 8 | //- ----------------------------------------------------------------------------------------------------------------------- 9 | 10 | #include "Battery.h" 11 | 12 | /** 13 | * Configure the battery measurement 14 | * 15 | * mode: Measurement mode BATTERY_MODE_BANDGAP_MESSUREMENT or BATTERY_MODE_EXTERNAL_MESSUREMENT 16 | * enablePin: The pin which enables the external measurement helper hardware. Set to 0 if not needed. 17 | * adcPin: The ADC pin for external measurement. Set to 0 if not needed. 18 | * time: interval to check the battery voltage 19 | */ 20 | void Battery::config(uint8_t mode, uint8_t enablePin, uint8_t adcPin, uint8_t fact, uint16_t time) { 21 | tMode = mode; 22 | tEnablePin = enablePin; 23 | tAdcPin = adcPin; 24 | tFact = fact; 25 | tTime = time; 26 | nTime = time; 27 | 28 | if (tEnablePin > 0) { 29 | pinMode(tEnablePin, INPUT); 30 | } 31 | } 32 | 33 | /** 34 | * Set the minimal battery voltage in tenth volt 35 | * 36 | * tenthVolts: minimum voltage before battery warning occurs 37 | */ 38 | void Battery::setMinVoltage(uint8_t tenthVolts) { 39 | tTenthVolts = tenthVolts; 40 | } 41 | 42 | /** 43 | * Cyclic battery measurement function. 44 | */ 45 | void Battery::poll(void) { 46 | uint8_t batteryVoltage; 47 | 48 | if ((tMode == 0) || (millis() - nTime < tTime)) { 49 | return; // nothing to do, step out 50 | 51 | } else if (tMode == BATTERY_MODE_BANDGAP_MESSUREMENT) { 52 | voltage = getBatteryVoltageInternal(); 53 | 54 | } else if (tMode == BATTERY_MODE_EXTERNAL_MESSUREMENT) { 55 | voltage = getBatteryVoltageExternal(); 56 | } 57 | 58 | if ((voltage > oldVoltage && (voltage - oldVoltage) > BATTERY_STATE_HYSTERESIS) || voltage < oldVoltage) { 59 | oldVoltage = voltage; 60 | state = (voltage < tTenthVolts) ? 1 : 0; // set the battery status 61 | } 62 | 63 | nTime = millis(); 64 | 65 | } 66 | 67 | /** 68 | * get battery voltage 69 | * Measure AVCC again the the internal band gap reference 70 | * 71 | * REFS1 REFS0 --> internal bandgap reference 72 | * MUX3 MUX2 MUX1 MUX0 --> 1110 1.1V (VBG) (for instance Atmega 328p) 73 | */ 74 | uint8_t Battery::getBatteryVoltageInternal() { 75 | uint16_t adcValue = getAdcValue( 76 | (0 << REFS1) | (1 << REFS0), // Voltage Reference = AVCC with external capacitor at AREF pin 77 | (1 << MUX3) | (1 << MUX2) | (1 << MUX1) | (0 << MUX0) // Input Channel = 1.1V (V BG) 78 | ); 79 | adcValue = AVR_BANDGAP_VOLTAGE * 1023 / adcValue / 100; // calculate battery voltage in 1/10 V 80 | 81 | return adcValue; 82 | } 83 | 84 | uint8_t Battery::getBatteryVoltageExternal() { 85 | pinMode(tEnablePin, OUTPUT); 86 | digitalWrite(tEnablePin, LOW); 87 | 88 | uint16_t adcValue = getAdcValue( 89 | (1 << REFS1) | (1 << REFS0), tAdcPin // Voltage Reference = Internal 1.1V Voltage Reference 90 | ); 91 | 92 | adcValue = adcValue * AVR_BANDGAP_VOLTAGE / 1023 / tFact; // calculate battery voltage in 1/10 V 93 | 94 | pinMode(tEnablePin, INPUT); 95 | 96 | return adcValue; 97 | } 98 | 99 | uint16_t Battery::getAdcValue(uint8_t voltageReference, uint8_t inputChannel) { 100 | uint16_t adcValue = 0; 101 | 102 | ADMUX = (voltageReference | inputChannel); 103 | 104 | ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1); // Enable ADC and set ADC prescaler 105 | for(int i = 0; i < BATTERY_NUM_MESS_ADC + BATTERY_DUMMY_NUM_MESS_ADC; i++) { 106 | ADCSRA |= (1 << ADSC); // start conversion 107 | while (ADCSRA & (1 << ADSC)) {} // wait for conversion complete 108 | 109 | if (i >= BATTERY_DUMMY_NUM_MESS_ADC) { // we discard the first dummy measurements 110 | adcValue += ADCW; 111 | } 112 | } 113 | 114 | ADCSRA &= ~(1 << ADEN); // ADC disable 115 | 116 | adcValue = adcValue / BATTERY_NUM_MESS_ADC; 117 | 118 | return adcValue; 119 | } 120 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Battery.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Low battery alarm ----------------------------------------------------------------------------------------------------- 6 | //- with a lot of contribution from Dirk at FHEM forum 7 | //- ----------------------------------------------------------------------------------------------------------------------- 8 | 9 | #ifndef BATTERY_H 10 | #define BATTERY_H 11 | 12 | #if defined(ARDUINO) && ARDUINO >= 100 13 | #include "Arduino.h" 14 | #else 15 | #include "WProgram.h" 16 | #endif 17 | 18 | #include 19 | #include 20 | #include "Serial.h" 21 | 22 | class Battery { 23 | public://---------------------------------------------------------------------------------------------------------------- 24 | 25 | uint8_t state; // status byte for message handling 26 | uint16_t voltage; // last measured battery voltage 27 | 28 | void config(uint8_t mode, uint8_t enablePin, uint8_t adcPin, uint8_t fact, uint16_t time); 29 | void setMinVoltage(uint8_t tenthVolts); // set the reference voltage in 0.1 volts 30 | 31 | void poll(void); // poll for periodic check 32 | 33 | private://--------------------------------------------------------------------------------------------------------------- 34 | uint8_t tMode; // remember the mode 35 | uint8_t tEnablePin; 36 | uint8_t tAdcPin; 37 | float tFact; 38 | uint16_t tTime; // remember the time for periodic check 39 | uint32_t nTime; // timer for periodic check 40 | uint8_t tTenthVolts; // remember the tenth volts set 41 | uint8_t oldVoltage; // old last measured battery voltage 42 | 43 | #define BATTERY_STATE_HYSTERESIS 1 // battery state should reset only if voltage rise greater than given value 44 | #define BATTERY_NUM_MESS_ADC 64 45 | #define BATTERY_DUMMY_NUM_MESS_ADC 10 46 | #define AVR_BANDGAP_VOLTAGE 1100UL // Band gap reference for Atmega328p 47 | 48 | #define BATTERY_MODE_BANDGAP_MESSUREMENT 1 49 | #define BATTERY_MODE_EXTERNAL_MESSUREMENT 2 50 | 51 | 52 | uint8_t getBatteryVoltageInternal(); 53 | uint8_t getBatteryVoltageExternal(); 54 | 55 | uint16_t getAdcValue(uint8_t voltageReference, uint8_t inputChannel); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Helpers.cpp: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- helper functions ------------------------------------------------------------------------------------------------------ 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | 8 | #include "Helpers.h" 9 | 10 | extern uint16_t __bss_end, _pHeap_start; 11 | extern void *__brkval; 12 | uint16_t freeMem() { // shows free memory 13 | uint16_t free_memory; 14 | 15 | if((uint16_t)__brkval == 0) { 16 | free_memory = ((uint16_t)&free_memory) - ((uint16_t)&__bss_end); 17 | } else { 18 | free_memory = ((uint16_t)&free_memory) - ((uint16_t)__brkval); 19 | } 20 | 21 | return free_memory; 22 | } 23 | 24 | uint16_t crc16(uint16_t crc, uint8_t a) { 25 | crc ^= a; 26 | for (uint8_t i = 0; i < 8; ++i) { 27 | if (crc & 1) { 28 | crc = (crc >> 1) ^ 0xA001; 29 | } else { 30 | crc = (crc >> 1); 31 | } 32 | } 33 | 34 | return crc; 35 | } 36 | 37 | uint32_t byteTimeCvt(uint8_t tTime) { 38 | const uint16_t c[8] = {1,10,50,100,600,3000,6000,36000}; 39 | return (uint32_t)(tTime & 0x1f) * c[tTime >> 5] * 100; 40 | } 41 | 42 | uint32_t intTimeCvt(uint16_t iTime) { 43 | if (iTime == 0) { 44 | return 0; 45 | } 46 | 47 | uint8_t tByte; 48 | if ((iTime & 0x1F) != 0) { 49 | tByte = 2; 50 | for (uint8_t i = 1; i < (iTime & 0x1F); i++) { 51 | tByte *= 2; 52 | } 53 | } else { 54 | tByte = 1; 55 | } 56 | 57 | return (uint32_t)tByte * (iTime >> 5) * 100; 58 | } 59 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Helpers.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- helper functions ------------------------------------------------------------------------------------------------------ 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | #ifndef HELPERS_H 8 | #define HELPERS_H 9 | 10 | #if defined(ARDUINO) && ARDUINO >= 100 11 | #include "Arduino.h" 12 | #else 13 | #include "WProgram.h" 14 | #endif 15 | 16 | #include "utility/Serial.h" 17 | 18 | uint16_t freeMem(void); 19 | uint16_t crc16(uint16_t crc, uint8_t a); 20 | 21 | uint32_t byteTimeCvt(uint8_t tTime); 22 | uint32_t intTimeCvt(uint16_t iTime); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/PinChangeIntHandler.cpp: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Pin change interrupt handler ------------------------------------------------------------------------------------------ 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | #include "PinChangeIntHandler.h" 8 | 9 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Arduino Mega 10 | 11 | #elif defined(__AVR_AT90USB162__) // Teensy 1.0 12 | 13 | #elif defined(__AVR_ATmega32U4__) // Teensy 2.0 14 | 15 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) // Teensy++ 1.0 & 2.0 16 | 17 | #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) // Sanguino 18 | #define pinToSlot(p) (((p) >= 0 && (p) <= 7) ? 1: ((p) >= 8 && (p) <= 14) ? 3: ((p) >= 15 && (p) <= 23) ? 2: ((p) >= 24 && (p) <= 31) ? 0: ((p) >= A0 && (p) <= A7) ? 0: 0xff) 19 | volatile uint8_t* pinPort[] = { &PINA, &PINB, &PINC, &PIND, }; 20 | volatile uint8_t* intMask[] = { &PCMSK0, &PCMSK1, &PCMSK2, &PCMSK3, }; 21 | volatile uint8_t portByte[4]; 22 | 23 | #elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__) // Atmega8 24 | 25 | #else // Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc 26 | #define pinToSlot(p) (((p) >= 0 && (p) <= 7) ? 2: ((p) >= 8 && (p) <= 13) ? 0: ((p) >= A0 && (p) <= A5) ? 1: ((p) >= 14 && (p) <= 19) ? 1: 0xff) 27 | volatile uint8_t* intMask[] = { &PCMSK0, &PCMSK1, &PCMSK2, }; 28 | volatile uint8_t* pinPort[] = { &PINB, &PINC, &PIND, }; 29 | volatile uint8_t portByte[3]; 30 | 31 | #endif 32 | 33 | 34 | s_pcIntH pcIntH[10]; 35 | uint8_t pcIntNbr = 0; 36 | 37 | void registerInt(uint8_t tPin, s_dlgt tDelegate) { 38 | uint8_t pSlot = pinToSlot(tPin); // get the position in port or PCMSK array 39 | 40 | pcIntNbr++; // increase counter because we have to add a new pin 41 | //pcIntH = (s_pcIntH*) realloc (pcIntH, pcIntNbr * sizeof(s_pcIntH)); // size the table 42 | 43 | pcIntH[pcIntNbr-1].dlgt = tDelegate; // remember the address where we have to jump 44 | pcIntH[pcIntNbr-1].pcMask = pSlot; // remember the PCMSK 45 | pcIntH[pcIntNbr-1].byMask = digitalPinToBitMask(tPin); // remember the pin position 46 | 47 | pinMode(tPin,INPUT_PULLUP); // switch pin to input 48 | 49 | *intMask[pSlot] |= digitalPinToBitMask(tPin); // set the pin in the respective PCMSK 50 | //Serial << F("iM:") << *intMask[pSlot] << "\n"; 51 | PCICR |= (1 << pSlot); 52 | 53 | //PCICR |= _BV(pSlot); // register PCMSK in interrupt change register 54 | 55 | portByte[pSlot] = *pinPort[pSlot] & *intMask[pSlot]; // remember the byte in the current port to figure out changes 56 | 57 | //Serial << F("pin:") << tPin << F(" pSlot:") << pSlot << F(" pB:") << portByte[pSlot] << F("\n"); 58 | sei(); 59 | 60 | } 61 | 62 | void collectPCINT(uint8_t vectInt) { 63 | cli(); 64 | 65 | uint8_t intByte = *pinPort[vectInt] & *intMask[vectInt]; // get the input byte 66 | 67 | uint8_t msk = portByte[vectInt] ^ intByte; // mask out the changes 68 | portByte[vectInt] = intByte; // store pin byte for next time check 69 | 70 | if (msk == 0) { // seams to be a repeat, noting to do 71 | sei(); 72 | return; 73 | } 74 | 75 | uint8_t bitStat = (intByte < *intMask[vectInt]) ? 0 : 1; // prepare the bit status for the pin 76 | 77 | for (uint8_t i = 0; i < pcIntNbr; i++) { // jump through the table and search for registered function 78 | if ((pcIntH[i].pcMask == vectInt) && (pcIntH[i].byMask == msk)) { 79 | pcIntH[i].dlgt(bitStat); 80 | } 81 | } 82 | 83 | sei(); 84 | } 85 | 86 | 87 | ISR(PCINT0_vect) { 88 | collectPCINT(0); 89 | } 90 | ISR(PCINT1_vect) { 91 | collectPCINT(1); 92 | } 93 | ISR(PCINT2_vect) { 94 | collectPCINT(2); 95 | } 96 | ISR(PCINT3_vect) { 97 | collectPCINT(3); 98 | } 99 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/PinChangeIntHandler.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Pin change interrupt handler ------------------------------------------------------------------------------------------ 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | #ifndef _PINCHANGEINTHANDLER_H 8 | #define _PINCHANGEINTHANDLER_H 9 | 10 | #if defined(ARDUINO) && ARDUINO >= 100 11 | #include "Arduino.h" 12 | #else 13 | #include "WProgram.h" 14 | #endif 15 | 16 | #include "Serial.h" 17 | #include "Fastdelegate.h" 18 | 19 | using namespace fastdelegate; 20 | typedef FastDelegate1 s_dlgt; 21 | 22 | struct s_pcIntH { 23 | uint8_t pcMask; 24 | uint8_t byMask; 25 | s_dlgt dlgt; 26 | }; 27 | 28 | void registerInt(uint8_t pin, s_dlgt Delegate); 29 | void collectPCINT(uint8_t vectInt); 30 | 31 | ISR(PCINT0_vect); 32 | ISR(PCINT1_vect); 33 | ISR(PCINT2_vect); 34 | ISR(PCINT3_vect); 35 | 36 | 37 | 38 | #endif -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/Serial.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Serial interface functions -------------------------------------------------------------------------------------------- 6 | //- Parser sketch from: http://jeelabs.org/2010/10/24/parsing-input-commands/ 7 | //- ----------------------------------------------------------------------------------------------------------------------- 8 | #ifndef SERIAL_H 9 | #define SERIAL_H 10 | 11 | #if defined(ARDUINO) && ARDUINO >= 100 12 | #include "Arduino.h" 13 | #else 14 | #include "WProgram.h" 15 | #endif 16 | 17 | #include 18 | 19 | 20 | //- input parser class 21 | class InputParser { 22 | public: 23 | typedef struct { 24 | char code; // one-letter command code 25 | byte bytes; // number of bytes required as input 26 | void (*fun)(); // code to call for this command 27 | } Commands; 28 | 29 | InputParser (byte size, const Commands*, Stream& =Serial); // set up with a buffer of specified size 30 | 31 | byte count() { return fill; } // number of data bytes 32 | //byte *buffer; // holds the read data 33 | byte buffer[50]; // holds the read data 34 | 35 | void poll(); // call this frequently to check for incoming data 36 | 37 | InputParser& operator >> (char& v) { return get(&v, 1); } 38 | InputParser& operator >> (byte& v) { return get(&v, 1); } 39 | InputParser& operator >> (int& v) { return get(&v, 2); } 40 | InputParser& operator >> (word& v) { return get(&v, 2); } 41 | InputParser& operator >> (long& v) { return get(&v, 4); } 42 | InputParser& operator >> (uint32_t& v) { return get(&v, 4); } 43 | InputParser& operator >> (const char*& v); 44 | 45 | private: 46 | InputParser& get(void*, byte); 47 | void reset(); 48 | 49 | byte limit, fill, top, next; 50 | byte instring, hexmode, hasvalue; 51 | uint32_t value; 52 | const Commands* cmds; 53 | Stream& io; 54 | }; 55 | extern const InputParser::Commands cmdTab[]; 56 | 57 | #define SERIAL_DBG_PHEX_MODE_NONE 0 58 | #define SERIAL_DBG_PHEX_MODE_LEN 1 59 | #define SERIAL_DBG_PHEX_MODE_LF 2 60 | #define SERIAL_DBG_PHEX_MODE_TIME 4 61 | 62 | //- some support for serial function 63 | template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; } 64 | 65 | void pCharPGM(const uint8_t *buf); // print the content from PROGMEM 66 | void pHexPGM(const uint8_t *buf, uint8_t len); // print a couple of bytes in HEX format 67 | void pHexB(uint8_t val); // print one byte in HEX format 68 | void pHex(uint8_t *buf, uint8_t len, uint8_t mode); // print a couple of bytes in HEX format 69 | void pTime(void); // print a time stamp in brackets 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/StatusLed.cpp: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Status led driver ----------------------------------------------------------------------------------------------------- 6 | //- with a lot of contribution from Dirk at FHEM forum 7 | //- ----------------------------------------------------------------------------------------------------------------------- 8 | 9 | #include "StatusLed.h" 10 | 11 | 12 | void StatusLed::config(uint8_t pin1, uint8_t pin2) { 13 | pin[0] = pin1; 14 | pinMode(pin1, OUTPUT); // setting the pin1 to output mode 15 | off(0); 16 | 17 | pin[1] = pin2; 18 | pinMode(pin2, OUTPUT); // setting the pin2 to output mode 19 | off(1); 20 | } 21 | 22 | 23 | void StatusLed::poll() { 24 | for (uint8_t i = 0; i < 2; i++) { 25 | 26 | if (nTime[i] > 0 && (millis() - startTime[i] >= nTime[i])) { 27 | // Serial << F("LED:") < 3) { 47 | bCnt[i] = 0; 48 | } 49 | toggle_nTime = heartBeat[bCnt[i]++]; 50 | } 51 | 52 | if (mode[i] > STATUSLED_MODE_ON) { 53 | toggle(i); 54 | nTime[i] = toggle_nTime; 55 | startTime[i] = millis(); 56 | 57 | if (bCnt[i] > 0) { 58 | bCnt[i]--; 59 | 60 | if (bCnt[i] == 0) { 61 | off(i); // stop blinking next time 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | void StatusLed::set(uint8_t leds, uint8_t tMode, uint8_t blinkCount) { 70 | unsigned long mills = millis(); 71 | 72 | blinkCount = blinkCount * 2; 73 | 74 | if (leds & 0b01){ 75 | mode[0] = tMode; 76 | bCnt[0] = blinkCount; 77 | nTime[0] = 1; 78 | startTime[0] = mills; 79 | } 80 | 81 | if (leds & 0b10){ 82 | mode[1] = tMode; 83 | bCnt[1] = blinkCount; 84 | nTime[1] = 1; 85 | startTime[1] = mills; 86 | } 87 | } 88 | 89 | void StatusLed::stop(uint8_t leds) { 90 | if (leds & 0b01) off(0); 91 | if (leds & 0b10) off(1); 92 | 93 | for (uint8_t i = 0; i < 2; i++){ 94 | mode[i] = STATUSLED_MODE_OFF; 95 | bCnt[i] = 0; 96 | state[i] = 0; 97 | } 98 | } 99 | 100 | void StatusLed::on(uint8_t ledNum) { 101 | onOff(STATUSLED_MODE_ON, ledNum); // switch led on 102 | } 103 | 104 | void StatusLed::off(uint8_t ledNum) { 105 | onOff(STATUSLED_MODE_OFF, ledNum); // switch led off 106 | } 107 | 108 | void StatusLed::onOff(uint8_t mode, uint8_t ledNum) { 109 | digitalWrite(pin[ledNum], mode); 110 | state[ledNum] = mode; 111 | nTime[ledNum] = 0; 112 | } 113 | 114 | void StatusLed::toggle(uint8_t ledNum) { 115 | if (state[ledNum]) { 116 | off(ledNum); 117 | } else { 118 | on(ledNum); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/AskSin/utility/StatusLed.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin driver implementation 3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | //- Status led driver ----------------------------------------------------------------------------------------------------- 6 | //- with a lot of contribution from Dirk at FHEM forum 7 | //- ----------------------------------------------------------------------------------------------------------------------- 8 | 9 | #ifndef STATUSLED_H 10 | #define STATUSLED_H 11 | 12 | #if defined(ARDUINO) && ARDUINO >= 100 13 | #include "Arduino.h" 14 | #else 15 | #include "WProgram.h" 16 | #endif 17 | 18 | #include "Serial.h" 19 | 20 | const uint16_t heartBeat[] = { 50, 200, 50, 1000}; 21 | 22 | /** 23 | * Class for status led control 24 | */ 25 | class StatusLed { 26 | #define STATUSLED_BLINKRATE_SLOW 300 27 | #define STATUSLED_BLINKRATE_FAST 150 28 | #define STATUSLED_BLINKRATE_SFAST 50 29 | 30 | #define STATUSLED_1 1 31 | #define STATUSLED_2 2 32 | #define STATUSLED_BOTH 3 33 | 34 | #define STATUSLED_MODE_OFF 0 35 | #define STATUSLED_MODE_ON 1 36 | #define STATUSLED_MODE_BLINKSLOW 2 37 | #define STATUSLED_MODE_BLINKFAST 3 38 | #define STATUSLED_MODE_BLINKSFAST 4 39 | #define STATUSLED_MODE_HEARTBEAT 5 40 | 41 | public://--------------------------------------------------------------- 42 | 43 | /** 44 | * Configure the led pins 45 | * If you use one led only, you must define the first pin only 46 | * 47 | * @param the pin of status led 1 48 | * @param the pin of status led 2 49 | * @param a callback function 50 | */ 51 | void config(uint8_t pin1, uint8_t pin2); 52 | 53 | /** 54 | * Set mode for leds 55 | * 0 -> led1, 1 -> led2, 2 -> led1 and led2 56 | * 57 | * @param the leds 58 | * @param the mode 59 | */ 60 | void set(uint8_t leds, uint8_t tMode, uint8_t blinkCount = 0); 61 | 62 | /** 63 | * Set leds off 64 | * 0 -> led1, 1 -> led2, 2 -> led1 and led2 65 | * 66 | * @param the leds 67 | */ 68 | void stop(uint8_t leds); 69 | 70 | void poll(void); 71 | void on(uint8_t ledNum); 72 | void off(uint8_t ledNum); 73 | 74 | private://------------------------------------------------------------------------------------------------------------- 75 | uint8_t pin[2]; 76 | 77 | /* 0 off, 1 -> on */ 78 | uint8_t state[2]; 79 | uint8_t mode[2]; 80 | 81 | /* blink counter */ 82 | uint8_t bCnt[2]; 83 | uint32_t nTime[2]; 84 | uint32_t startTime[2]; 85 | 86 | void onOff(uint8_t mode, uint8_t ledNum); 87 | void toggle(uint8_t ledNum); 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/BH1750.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This is a library for the BH1750FVI Digital Light Sensor 4 | breakout board. 5 | 6 | The board uses I2C for communication. 2 pins are required to 7 | interface to the device. 8 | 9 | Written by Christopher Laws, March, 2013. 10 | 11 | */ 12 | 13 | #include "BH1750.h" 14 | 15 | // Define milliseconds delay for ESP8266 platform 16 | #if defined(ESP8266) 17 | 18 | #include 19 | #define _delay_ms(ms) delayMicroseconds((ms) * 1000) 20 | 21 | // Use _delay_ms from utils for AVR-based platforms 22 | #elif defined(__avr__) 23 | #include 24 | 25 | // Use Wiring's delay for compability with another platforms 26 | #else 27 | #define _delay_ms(ms) delay(ms) 28 | #endif 29 | 30 | 31 | // Legacy Wire.write() function fix 32 | #if (ARDUINO >= 100) 33 | #define __wire_write(d) Wire.write(d) 34 | #else 35 | #define __wire_write(d) Wire.send(d) 36 | #endif 37 | 38 | 39 | // Legacy Wire.read() function fix 40 | #if (ARDUINO >= 100) 41 | #define __wire_read() Wire.read() 42 | #else 43 | #define __wire_read() Wire.receive() 44 | #endif 45 | 46 | 47 | /** 48 | * Constructor 49 | * @params addr Sensor address (0x76 or 0x72, see datasheet) 50 | * 51 | * On most sensor boards, it was 0x76 52 | */ 53 | BH1750::BH1750(byte addr) { 54 | 55 | BH1750_I2CADDR = addr; 56 | 57 | } 58 | 59 | 60 | /** 61 | * Begin I2C and configure sensor 62 | * @param mode Measurment mode 63 | */ 64 | void BH1750::begin(uint8_t mode) { 65 | 66 | // Initialize I2C 67 | Wire.begin(); 68 | 69 | // Configure sensor in specified mode 70 | configure(mode); 71 | 72 | } 73 | 74 | 75 | /** 76 | * Configurate BH1750 with specified working mode 77 | * @param mode Measurment mode 78 | */ 79 | void BH1750::configure(uint8_t mode) { 80 | 81 | // Check, is measurment mode exist 82 | switch (mode) { 83 | 84 | case BH1750_CONTINUOUS_HIGH_RES_MODE: 85 | case BH1750_CONTINUOUS_HIGH_RES_MODE_2: 86 | case BH1750_CONTINUOUS_LOW_RES_MODE: 87 | case BH1750_ONE_TIME_HIGH_RES_MODE: 88 | case BH1750_ONE_TIME_HIGH_RES_MODE_2: 89 | case BH1750_ONE_TIME_LOW_RES_MODE: 90 | 91 | // Send mode to sensor 92 | Wire.beginTransmission(BH1750_I2CADDR); 93 | __wire_write((uint8_t)mode); 94 | Wire.endTransmission(); 95 | 96 | // Wait few moments for waking up 97 | _delay_ms(10); 98 | break; 99 | 100 | default: 101 | 102 | // Invalid measurement mode 103 | #ifdef BH1750_DEBUG 104 | Serial.println(F("BH1750: Invalid measurment mode")); 105 | #endif 106 | 107 | break; 108 | 109 | } 110 | 111 | } 112 | 113 | 114 | /** 115 | * Read light level from sensor 116 | * @return Lightness in lux (0 ~ 65535) 117 | */ 118 | uint16_t BH1750::readLightLevel(void) { 119 | 120 | // Measurment result will be stored here 121 | uint16_t level; 122 | 123 | // Read two bytes from sensor 124 | Wire.requestFrom(BH1750_I2CADDR, 2); 125 | 126 | // Read two bytes, which are low and high parts of sensor value 127 | level = __wire_read(); 128 | level <<= 8; 129 | level |= __wire_read(); 130 | 131 | // Send raw value if debug enabled 132 | #ifdef BH1750_DEBUG 133 | Serial.print(F("[BH1750] Raw value: ")); 134 | Serial.println(level); 135 | #endif 136 | 137 | // Convert raw value to lux 138 | level /= 1.2; 139 | 140 | // Send converted value, if debug enabled 141 | #ifdef BH1750_DEBUG 142 | Serial.print(F("[BH1750] Converted value: ")); 143 | Serial.println(level); 144 | #endif 145 | 146 | return level; 147 | 148 | } 149 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/BH1750.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This is a library for the BH1750FVI Digital Light Sensor 4 | breakout board. 5 | 6 | The board uses I2C for communication. 2 pins are required to 7 | interface to the device. 8 | 9 | Datasheet: http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf 10 | 11 | Written by Christopher Laws, March, 2013. 12 | 13 | */ 14 | 15 | #ifndef BH1750_h 16 | #define BH1750_h 17 | 18 | #if (ARDUINO >= 100) 19 | #include 20 | #else 21 | #include 22 | #endif 23 | 24 | #include "Wire.h" 25 | 26 | // Uncomment, to enable debug messages 27 | // #define BH1750_DEBUG 28 | 29 | // No active state 30 | #define BH1750_POWER_DOWN 0x00 31 | 32 | // Wating for measurment command 33 | #define BH1750_POWER_ON 0x01 34 | 35 | // Reset data register value - not accepted in POWER_DOWN mode 36 | #define BH1750_RESET 0x07 37 | 38 | // Start measurement at 1lx resolution. Measurement time is approx 120ms. 39 | #define BH1750_CONTINUOUS_HIGH_RES_MODE 0x10 40 | 41 | // Start measurement at 0.5lx resolution. Measurement time is approx 120ms. 42 | #define BH1750_CONTINUOUS_HIGH_RES_MODE_2 0x11 43 | 44 | // Start measurement at 4lx resolution. Measurement time is approx 16ms. 45 | #define BH1750_CONTINUOUS_LOW_RES_MODE 0x13 46 | 47 | // Start measurement at 1lx resolution. Measurement time is approx 120ms. 48 | // Device is automatically set to Power Down after measurement. 49 | #define BH1750_ONE_TIME_HIGH_RES_MODE 0x20 50 | 51 | // Start measurement at 0.5lx resolution. Measurement time is approx 120ms. 52 | // Device is automatically set to Power Down after measurement. 53 | #define BH1750_ONE_TIME_HIGH_RES_MODE_2 0x21 54 | 55 | // Start measurement at 1lx resolution. Measurement time is approx 120ms. 56 | // Device is automatically set to Power Down after measurement. 57 | #define BH1750_ONE_TIME_LOW_RES_MODE 0x23 58 | 59 | class BH1750 { 60 | 61 | public: 62 | BH1750 (byte addr = 0x23); 63 | void begin (uint8_t mode = BH1750_CONTINUOUS_HIGH_RES_MODE); 64 | void configure (uint8_t mode); 65 | uint16_t readLightLevel(void); 66 | 67 | private: 68 | int BH1750_I2CADDR; 69 | 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/README.md: -------------------------------------------------------------------------------- 1 | BH1750 2 | ========== 3 | 4 | An Arduino library for digital light sensor breakout boards containing the BH1750FVI IC. 5 | 6 | The board uses I2C for communication, and two pins are required to interface to the device. 7 | 8 | Datasheet can be obtained [here](http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf) 9 | 10 | ## Installation 11 | Click "Clone or download" -> "Download ZIP" button. 12 | 13 | - **(For Arduino < 1.5.x)** Extract the archive to ``/My Documents/Arduino/libraries/`` folder and rename it to `BH1750`. Restart IDE. 14 | - **(For Arduino >= 1.5.x)** Use the way above, or Library Manager. Open Arduino IDE, click `Sketch -> Include library -> Add .ZIP library ` and select the downloaded archive. 15 | 16 | Additional info, about library installation process - https://www.arduino.cc/en/Guide/Libraries 17 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/examples/BH1750advanced/BH1750advanced.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Advanced BH1750 library usage example 4 | 5 | This example had some comments about advanced usage features. 6 | 7 | Connection: 8 | 9 | VCC -> 5V (3V3 on Arduino Due, Zero, MKR1000, etc) 10 | GND -> GND 11 | SCL -> SCL (A5 on Arduino Uno, Leonardo, etc or 21 on Mega and Due) 12 | SDA -> SDA (A4 on Arduino Uno, Leonardo, etc or 20 on Mega and Due) 13 | ADD -> GND or VCC (see below) 14 | 15 | ADD pin uses to set sensor I2C address. If it has voltage greater or equal to 16 | 0.7VCC voltage (as example, you've connected it to VCC) - sensor address will be 17 | 0x5C. In other case (if ADD voltage less than 0.7 * VCC) - sensor address will 18 | be 0x23 (by default). 19 | 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | /* 26 | 27 | BH1750 can be physically configured to use two I2C addresses: 28 | - 0x23 (most common) (if ADD pin had < 0.7VCC voltage) 29 | - 0x5C (if ADD pin had > 0.7VCC voltage) 30 | 31 | Library use 0x23 address as default, but you can define any other address. 32 | If you had troubles with default value - try to change it to 0x5C. 33 | 34 | */ 35 | BH1750 lightMeter(0x23); 36 | 37 | void setup(){ 38 | 39 | Serial.begin(9600); 40 | 41 | /* 42 | 43 | BH1750 had six different measurment modes. They are divided in two groups - 44 | continuous and one-time measurments. In continuous mode, sensor continuously 45 | measures lightness value. And in one-time mode, sensor makes only one 46 | measurment, and going to Power Down mode after this. 47 | 48 | Each mode, has three different precisions: 49 | 50 | - Low Resolution Mode - (4 lx precision, 16ms measurment time) 51 | - High Resolution Mode - (1 lx precision, 120ms measurment time) 52 | - High Resolution Mode 2 - (0.5 lx precision, 120ms measurment time) 53 | 54 | By default, library use Continuous High Resolution Mode, but you can set 55 | any other mode, by define it to BH1750.begin() or BH1750.configure() functions. 56 | 57 | [!] Remember, if you use One-Time mode, your sensor will go to Power Down mode 58 | each time, when it completes measurment and you've read it. 59 | 60 | Full mode list: 61 | 62 | BH1750_CONTINUOUS_LOW_RES_MODE 63 | BH1750_CONTINUOUS_HIGH_RES_MODE (default) 64 | BH1750_CONTINUOUS_HIGH_RES_MODE_2 65 | 66 | BH1750_ONE_TIME_LOW_RES_MODE 67 | BH1750_ONE_TIME_HIGH_RES_MODE 68 | BH1750_ONE_TIME_HIGH_RES_MODE_2 69 | 70 | */ 71 | 72 | lightMeter.begin(BH1750_CONTINUOUS_HIGH_RES_MODE); 73 | Serial.println(F("BH1750 Test")); 74 | 75 | } 76 | 77 | 78 | void loop() { 79 | 80 | uint16_t lux = lightMeter.readLightLevel(); 81 | Serial.print("Light: "); 82 | Serial.print(lux); 83 | Serial.println(" lx"); 84 | delay(1000); 85 | 86 | } 87 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/examples/BH1750test/BH1750test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Example of BH1750 library usage. 4 | 5 | This example initalises the BH1750 object using the default 6 | high resolution mode and then makes a light level reading every second. 7 | 8 | Connection: 9 | 10 | VCC -> 5V (3V3 on Arduino Due, Zero, MKR1000, etc) 11 | GND -> GND 12 | SCL -> SCL (A5 on Arduino Uno, Leonardo, etc or 21 on Mega and Due) 13 | SDA -> SDA (A4 on Arduino Uno, Leonardo, etc or 20 on Mega and Due) 14 | ADD -> (not connected) or GND 15 | 16 | ADD pin uses to set sensor I2C address. If it has voltage greater or equal to 17 | 0.7VCC voltage (as example, you've connected it to VCC) - sensor address will be 18 | 0x5C. In other case (if ADD voltage less than 0.7 * VCC) - sensor address will 19 | be 0x23 (by default). 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | BH1750 lightMeter; 27 | 28 | void setup(){ 29 | 30 | Serial.begin(9600); 31 | lightMeter.begin(); 32 | Serial.println(F("BH1750 Test")); 33 | 34 | } 35 | 36 | 37 | void loop() { 38 | 39 | uint16_t lux = lightMeter.readLightLevel(); 40 | Serial.print("Light: "); 41 | Serial.print(lux); 42 | Serial.println(" lx"); 43 | delay(1000); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For BH1750 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | BH1750 KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | configure KEYWORD2 17 | readLightLevel KEYWORD2 18 | 19 | 20 | ####################################### 21 | # Instances (KEYWORD2) 22 | ####################################### 23 | 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### 28 | BH1750_CONTINUOUS_HIGH_RES_MODE LITERAL1 29 | BH1750_CONTINUOUS_HIGH_RES_MODE_2 LITERAL1 30 | BH1750_CONTINUOUS_LOW_RES_MODE LITERAL1 31 | BH1750_ONE_TIME_HIGH_RES_MODE LITERAL1 32 | BH1750_ONE_TIME_HIGH_RES_MODE_2 LITERAL1 33 | BH1750_ONE_TIME_LOW_RES_MODE LITERAL1 34 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BH1750", 3 | "keywords": "light, sensor", 4 | "description": "Digital light sensor breakout boards containing the BH1750FVI IC", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/claws/BH1750.git" 8 | }, 9 | "frameworks": "arduino", 10 | "platforms": ["atmelavr", "atmelsam", "espressif8266"] 11 | } 12 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BH1750/library.properties: -------------------------------------------------------------------------------- 1 | name=BH1750 2 | version=1.1.3 3 | author=Christopher Laws 4 | maintainer=Christopher Laws 5 | sentence=Digital light sensor breakout boards containing the BH1750FVI IC 6 | paragraph=Pretty simple and robust BH1750 library 7 | category=Sensors 8 | url=https://github.com/claws/BH1750 9 | architectures=* 10 | includes=BH1750.h 11 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BMP085/BMP085.h: -------------------------------------------------------------------------------- 1 | // BMP085 Pressure/Temperature (Altimeter) sensor 2 | 3 | // MIT license 4 | #ifndef BMP085_H 5 | #define BMP085_H 6 | 7 | 8 | #if (ARDUINO >= 100) 9 | #include "Arduino.h" 10 | #else 11 | #include "WProgram.h" 12 | #endif 13 | #include 14 | 15 | #define BMP085_DEBUG 0 16 | 17 | #define BMP085_I2CADDR 0x77 18 | 19 | #define BMP085_ULTRALOWPOWER 0 20 | #define BMP085_STANDARD 1 21 | #define BMP085_HIGHRES 2 22 | #define BMP085_ULTRAHIGHRES 3 23 | #define BMP085_CAL_AC1 0xAA // R Calibration data (16 bits) 24 | #define BMP085_CAL_AC2 0xAC // R Calibration data (16 bits) 25 | #define BMP085_CAL_AC3 0xAE // R Calibration data (16 bits) 26 | #define BMP085_CAL_AC4 0xB0 // R Calibration data (16 bits) 27 | #define BMP085_CAL_AC5 0xB2 // R Calibration data (16 bits) 28 | #define BMP085_CAL_AC6 0xB4 // R Calibration data (16 bits) 29 | #define BMP085_CAL_B1 0xB6 // R Calibration data (16 bits) 30 | #define BMP085_CAL_B2 0xB8 // R Calibration data (16 bits) 31 | #define BMP085_CAL_MB 0xBA // R Calibration data (16 bits) 32 | #define BMP085_CAL_MC 0xBC // R Calibration data (16 bits) 33 | #define BMP085_CAL_MD 0xBE // R Calibration data (16 bits) 34 | 35 | #define BMP085_CONTROL 0xF4 36 | #define BMP085_TEMPDATA 0xF6 37 | #define BMP085_PRESSUREDATA 0xF6 38 | #define BMP085_READTEMPCMD 0x2E 39 | #define BMP085_READPRESSURECMD 0x34 40 | 41 | 42 | class BMP085 { 43 | public: 44 | void begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres 45 | float readTemperature(void); 46 | int32_t readPressure(void); 47 | float readAltitude(float sealevelPressure = 101325); // std atmosphere 48 | uint16_t readRawTemperature(void); 49 | uint32_t readRawPressure(void); 50 | 51 | private: 52 | uint8_t read8(uint8_t addr); 53 | uint16_t read16(uint8_t addr); 54 | void write8(uint8_t addr, uint8_t data); 55 | 56 | uint8_t oversampling; 57 | 58 | int16_t ac1, ac2, ac3, b1, b2, mb, mc, md; 59 | uint16_t ac4, ac5, ac6; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/BMP085/BMP085.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HB-UW-Sen-THPL/Libraries/BMP085/BMP085.jpg -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/Wire.h: -------------------------------------------------------------------------------- 1 | /* 2 | TwoWire.h - TWI/I2C library for Arduino & Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts 20 | */ 21 | 22 | #ifndef TwoWire_h 23 | #define TwoWire_h 24 | 25 | #include 26 | #include "Stream.h" 27 | 28 | #define BUFFER_LENGTH 32 29 | 30 | class TwoWire : public Stream 31 | { 32 | private: 33 | static uint8_t rxBuffer[]; 34 | static uint8_t rxBufferIndex; 35 | static uint8_t rxBufferLength; 36 | 37 | static uint8_t txAddress; 38 | static uint8_t txBuffer[]; 39 | static uint8_t txBufferIndex; 40 | static uint8_t txBufferLength; 41 | 42 | static uint8_t transmitting; 43 | static void (*user_onRequest)(void); 44 | static void (*user_onReceive)(int); 45 | static void onRequestService(void); 46 | static void onReceiveService(uint8_t*, int); 47 | public: 48 | TwoWire(); 49 | void begin(); 50 | void begin(uint8_t); 51 | void begin(int); 52 | void beginTransmission(uint8_t); 53 | void beginTransmission(int); 54 | uint8_t endTransmission(void); 55 | uint8_t endTransmission(uint8_t); 56 | uint8_t requestFrom(uint8_t, uint8_t); 57 | uint8_t requestFrom(uint8_t, uint8_t, uint8_t); 58 | uint8_t requestFrom(int, int); 59 | uint8_t requestFrom(int, int, int); 60 | virtual size_t write(uint8_t); 61 | virtual size_t write(const uint8_t *, size_t); 62 | virtual int available(void); 63 | virtual int read(void); 64 | virtual int peek(void); 65 | virtual void flush(void); 66 | void onReceive( void (*)(int) ); 67 | void onRequest( void (*)(void) ); 68 | 69 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 70 | inline size_t write(long n) { return write((uint8_t)n); } 71 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 72 | inline size_t write(int n) { return write((uint8_t)n); } 73 | using Print::write; 74 | }; 75 | 76 | extern TwoWire Wire; 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino: -------------------------------------------------------------------------------- 1 | // I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder 2 | // by Nicholas Zambetti 3 | // and James Tichenor 4 | 5 | // Demonstrates use of the Wire library reading data from the 6 | // Devantech Utrasonic Rangers SFR08 and SFR10 7 | 8 | // Created 29 April 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | Serial.begin(9600); // start serial communication at 9600bps 19 | } 20 | 21 | int reading = 0; 22 | 23 | void loop() 24 | { 25 | // step 1: instruct sensor to read echoes 26 | Wire.beginTransmission(112); // transmit to device #112 (0x70) 27 | // the address specified in the datasheet is 224 (0xE0) 28 | // but i2c adressing uses the high 7 bits so it's 112 29 | Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) 30 | Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) 31 | // use 0x51 for centimeters 32 | // use 0x52 for ping microseconds 33 | Wire.endTransmission(); // stop transmitting 34 | 35 | // step 2: wait for readings to happen 36 | delay(70); // datasheet suggests at least 65 milliseconds 37 | 38 | // step 3: instruct sensor to return a particular echo reading 39 | Wire.beginTransmission(112); // transmit to device #112 40 | Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02) 41 | Wire.endTransmission(); // stop transmitting 42 | 43 | // step 4: request reading from sensor 44 | Wire.requestFrom(112, 2); // request 2 bytes from slave device #112 45 | 46 | // step 5: receive reading from sensor 47 | if(2 <= Wire.available()) // if two bytes were received 48 | { 49 | reading = Wire.read(); // receive high byte (overwrites previous reading) 50 | reading = reading << 8; // shift high byte to be high 8 bits 51 | reading |= Wire.read(); // receive low byte as lower 8 bits 52 | Serial.println(reading); // print the reading 53 | } 54 | 55 | delay(250); // wait a bit since people have to read the output :) 56 | } 57 | 58 | 59 | /* 60 | 61 | // The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08) 62 | // usage: changeAddress(0x70, 0xE6); 63 | 64 | void changeAddress(byte oldAddress, byte newAddress) 65 | { 66 | Wire.beginTransmission(oldAddress); 67 | Wire.write(byte(0x00)); 68 | Wire.write(byte(0xA0)); 69 | Wire.endTransmission(); 70 | 71 | Wire.beginTransmission(oldAddress); 72 | Wire.write(byte(0x00)); 73 | Wire.write(byte(0xAA)); 74 | Wire.endTransmission(); 75 | 76 | Wire.beginTransmission(oldAddress); 77 | Wire.write(byte(0x00)); 78 | Wire.write(byte(0xA5)); 79 | Wire.endTransmission(); 80 | 81 | Wire.beginTransmission(oldAddress); 82 | Wire.write(byte(0x00)); 83 | Wire.write(newAddress); 84 | Wire.endTransmission(); 85 | } 86 | 87 | */ 88 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino: -------------------------------------------------------------------------------- 1 | // I2C Digital Potentiometer 2 | // by Nicholas Zambetti 3 | // and Shawn Bonkowski 4 | 5 | // Demonstrates use of the Wire library 6 | // Controls AD5171 digital potentiometer via I2C/TWI 7 | 8 | // Created 31 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | // This example code is in the public domain. 13 | 14 | 15 | #include 16 | 17 | void setup() 18 | { 19 | Wire.begin(); // join i2c bus (address optional for master) 20 | } 21 | 22 | byte val = 0; 23 | 24 | void loop() 25 | { 26 | Wire.beginTransmission(44); // transmit to device #44 (0x2c) 27 | // device address is specified in datasheet 28 | Wire.write(byte(0x00)); // sends instruction byte 29 | Wire.write(val); // sends potentiometer value byte 30 | Wire.endTransmission(); // stop transmitting 31 | 32 | val++; // increment value 33 | if(val == 64) // if reached 64th position (max) 34 | { 35 | val = 0; // start over from lowest value 36 | } 37 | delay(500); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/examples/master_reader/master_reader.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Reader 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Reads data from an I2C/TWI slave device 6 | // Refer to the "Wire Slave Sender" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | Serial.begin(9600); // start serial for output 19 | } 20 | 21 | void loop() 22 | { 23 | Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 24 | 25 | while(Wire.available()) // slave may send less than requested 26 | { 27 | char c = Wire.read(); // receive a byte as character 28 | Serial.print(c); // print the character 29 | } 30 | 31 | delay(500); 32 | } 33 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/examples/master_writer/master_writer.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Writer 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Writes data to an I2C/TWI slave device 6 | // Refer to the "Wire Slave Receiver" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | } 19 | 20 | byte x = 0; 21 | 22 | void loop() 23 | { 24 | Wire.beginTransmission(4); // transmit to device #4 25 | Wire.write("x is "); // sends five bytes 26 | Wire.write(x); // sends one byte 27 | Wire.endTransmission(); // stop transmitting 28 | 29 | x++; 30 | delay(500); 31 | } 32 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/examples/slave_receiver/slave_receiver.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Receiver 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Receives data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Writer" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(4); // join i2c bus with address #4 18 | Wire.onReceive(receiveEvent); // register event 19 | Serial.begin(9600); // start serial for output 20 | } 21 | 22 | void loop() 23 | { 24 | delay(100); 25 | } 26 | 27 | // function that executes whenever data is received from master 28 | // this function is registered as an event, see setup() 29 | void receiveEvent(int howMany) 30 | { 31 | while(1 < Wire.available()) // loop through all but the last 32 | { 33 | char c = Wire.read(); // receive byte as a character 34 | Serial.print(c); // print the character 35 | } 36 | int x = Wire.read(); // receive byte as an integer 37 | Serial.println(x); // print the integer 38 | } 39 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/examples/slave_sender/slave_sender.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Sender 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Sends data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Reader" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() 16 | { 17 | Wire.begin(2); // join i2c bus with address #2 18 | Wire.onRequest(requestEvent); // register event 19 | } 20 | 21 | void loop() 22 | { 23 | delay(100); 24 | } 25 | 26 | // function that executes whenever data is requested by master 27 | // this function is registered as an event, see setup() 28 | void requestEvent() 29 | { 30 | Wire.write("hello "); // respond with message of 6 bytes 31 | // as expected by master 32 | } 33 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | beginTransmission KEYWORD2 15 | endTransmission KEYWORD2 16 | requestFrom KEYWORD2 17 | send KEYWORD2 18 | receive KEYWORD2 19 | onReceive KEYWORD2 20 | onRequest KEYWORD2 21 | 22 | ####################################### 23 | # Instances (KEYWORD2) 24 | ####################################### 25 | 26 | Wire KEYWORD2 27 | 28 | ####################################### 29 | # Constants (LITERAL1) 30 | ####################################### 31 | 32 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Libraries/Wire/utility/twi.h: -------------------------------------------------------------------------------- 1 | /* 2 | twi.h - TWI/I2C library for Wiring & Arduino 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef twi_h 21 | #define twi_h 22 | 23 | #include 24 | 25 | //#define ATMEGA8 26 | 27 | #ifndef TWI_FREQ 28 | #define TWI_FREQ 100000L 29 | #endif 30 | 31 | #ifndef TWI_BUFFER_LENGTH 32 | #define TWI_BUFFER_LENGTH 32 33 | #endif 34 | 35 | #define TWI_READY 0 36 | #define TWI_MRX 1 37 | #define TWI_MTX 2 38 | #define TWI_SRX 3 39 | #define TWI_STX 4 40 | 41 | void twi_init(void); 42 | void twi_setAddress(uint8_t); 43 | uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t); 44 | uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); 45 | uint8_t twi_transmit(const uint8_t*, uint8_t); 46 | void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) ); 47 | void twi_attachSlaveTxEvent( void (*)(void) ); 48 | void twi_reply(uint8_t); 49 | void twi_stop(void); 50 | void twi_releaseBus(void); 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Register.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef _REGISTER_h 4 | #define _REGISTER_h 5 | 6 | #define FRAME_TYPE 0x70 // Frame type 0x70 = WEATHER_EVENT 7 | #define DEVICE_INFO 0x01, 0x01, 0x00 // Device Info, 3 byte, describes device, not completely clear yet. includes amount of channels 8 | 9 | #if USE_ADRESS_SECTION == 1 10 | uint8_t devParam[] = { 11 | FIRMWARE_VERSION, 12 | 0xFF, 0xFF, // space for device type, assigned later 13 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // space for device serial, assigned later 14 | FRAME_TYPE, 15 | DEVICE_INFO, 16 | 0xFF, 0xFF, 0xFF // space for device address, assigned later 17 | }; 18 | #else 19 | uint8_t devParam[] = { 20 | FIRMWARE_VERSION, 21 | DEVICE_TYPE, 22 | DEVICE_SERIAL, 23 | FRAME_TYPE, 24 | DEVICE_INFO, 25 | DEVICE_ADDRESS 26 | }; 27 | #endif 28 | 29 | HM::s_devParm dParm = { 30 | 3, // send retries, 1 byte, how often a string should be send out until we get an answer 31 | 700, // send timeout, 2 byte, time out for ACK handling 32 | devParam // pointer to devParam, see above 33 | }; 34 | 35 | //- channel device list table -------------------------------------------------------------------------------------------- 36 | HM::s_modtable modTbl[] = { 37 | { 0, 0, (s_mod_dlgt) NULL }, // ??? 38 | { 0, 0, (s_mod_dlgt) NULL }, // ??? 39 | }; // 16 byte 40 | 41 | /** 42 | * channel slice definition 43 | * Each value represents a register index defined in s_regDevL0 below 44 | */ 45 | uint8_t sliceStr[] = { 46 | 0x01, 0x05, 0x0A, 0x0B, 0x0C, 0x12, 0x14, 0x24, 0x25 47 | }; 48 | 49 | /** 50 | * Register definition for List 0 51 | */ 52 | struct s_regDevL0 { 53 | // 0x01, 0x05, 0x0A, 0x0B, 0x0C, 0x12, 0x14, 0x24, 0x25 54 | uint8_t burstRx; // 0x01, startBit:0, bits:8 55 | uint8_t :6; // 0x05 startBit:0, bits:6 56 | uint8_t ledMode :2; // 0x05, startBit:6, bits:2 57 | uint8_t pairCentral[3]; // 0x0A, 0x0B, 0x0C, startBit:0, bits:8 (3 mal) 58 | uint8_t lowBatLimit; // 0x12, startBit:0, bits:8 59 | uint8_t transmDevTryMax; // 0x14, startBit:0, bits:8 60 | uint8_t altitude[2]; // 0x24, 0x25 startBit:0, bits:8 61 | }; 62 | 63 | // todo 64 | struct s_regChanL4 { 65 | // 0x01, 66 | uint8_t peerNeedsBurst:1; // 0x01, s:0, e:1 67 | uint8_t :7; // 68 | }; 69 | 70 | struct s_regDev { 71 | s_regDevL0 l0; 72 | }; 73 | 74 | struct s_regChan { 75 | s_regChanL4 l4; 76 | }; 77 | 78 | struct s_regs { 79 | s_regDev ch0; 80 | s_regChan ch1; 81 | } regs; // 11 byte 82 | 83 | /** 84 | * channel device list table, 22 bytes 85 | */ 86 | const s_cnlDefType cnlDefType[] PROGMEM = { 87 | // cnl, lst, peersMax, sIdx, sLen, pAddr, pPeer, *pRegs (pointer to regs structure) 88 | { 0, 0, 0, 0x00, 9, 0x0000, 0x0000, (void*)®s.ch0.l0}, // List 0 89 | { 1, 4, 6, 0x05, 1, 0x0005, 0x0000, (void*)®s.ch1.l4}, // List 4 90 | }; 91 | 92 | // handover to AskSin lib, 6 bytes 93 | HM::s_devDef dDef = { 94 | 1, 2, sliceStr, cnlDefType, 95 | }; 96 | 97 | /** 98 | * EEprom definition, 16 bytes 99 | * Define start address and size in eeprom for magicNumber, peerDB, regsDB, userSpace 100 | */ 101 | HM::s_eeprom ee[] = { 102 | //magicNum, peerDB, regsDB, userSpace 103 | { 0x0000, 0x0002, 0x001a, 0x0025, }, // start address 104 | { 0x0002, 0x0030, 0x000b, 0x0000, }, // length 105 | }; 106 | 107 | /** 108 | * Definitions for EEprom defaults. 109 | * Must enter in same order as e.g. defined in s_regDevL0 110 | */ 111 | const uint8_t regs00[] PROGMEM = {0x00, 0x64, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00}; 112 | const uint8_t regs04[] PROGMEM = {0x1f, 0xa6, 0x5c, 0x05}; 113 | 114 | s_defaultRegsTbl defaultRegsTbl[] = { 115 | // peer(0) or regs(1), channel, list, peer index, len, pointer to payload 116 | { 1, 0, 0, 0, 9, regs00 }, 117 | }; 118 | 119 | HM::s_dtRegs dtRegs = { 120 | //amount of lines in defaultRegsTbl[], pointer to defaultRegsTbl[] 121 | 1, defaultRegsTbl 122 | }; 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/Sensor_BMP180_BH1750.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SHT10, BMP085, TSL2561 Sensor class 3 | * 4 | * (c) 2014 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | * Author: Horst Bittner 6 | * Dirk Hoffmann dirk@fhem.forum 7 | */ 8 | 9 | #ifndef SENSOR_BMP180_BH1750_H 10 | #define SENSOR_BMP180_BH1750_H 11 | 12 | #if defined(ARDUINO) && ARDUINO >= 100 13 | #include "Arduino.h" 14 | #else 15 | #include "WProgram.h" 16 | #endif 17 | 18 | #include "AskSinMain.h" 19 | #include "utility/Serial.h" 20 | #include "utility/Fastdelegate.h" 21 | #include "utility/PinChangeIntHandler.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | #define BMP180_BH1750 Sensors_BMP180_BH1750 // module name as macro to overcome the problem of renaming functions all the time 29 | //#define DM_DBG // debug message flag 30 | 31 | #define BMP180_BH1750_nACTION_MEASURE_INIT 1 32 | #define BMP180_BH1750_nACTION_MEASURE_L 2 33 | #define BMP180_BH1750_nACTION_CALC_L 3 34 | #define BMP180_BH1750_nACTION_MEASURE_THP 4 35 | #define BMP180_BH1750_nACTION_TRANSMIT 5 36 | 37 | #define BMP180_BH1750_MAX_MEASURE_TIME 50 38 | #define BMP180_BH1750_MINIMAL_CYCLE_LENGTH 480 // minimal cycle length in 250ms units 39 | 40 | const uint8_t peerOdd[] = {}; // default settings for list3 or list4 41 | const uint8_t peerEven[] = {}; 42 | const uint8_t peerSingle[] = {}; 43 | 44 | class BMP180_BH1750 { 45 | // user code here 46 | public: 47 | void config(uint8_t data, uint8_t sck, uint16_t timing, BMP085 *pPtr, BH1750 *lPtr); 48 | 49 | // mandatory functions for every new module to communicate within HM protocol stack 50 | uint8_t modStat; // module status byte, needed for list3 modules to answer status requests 51 | uint8_t regCnl; // holds the channel for the module 52 | 53 | HM *hm; // pointer to HM class instance 54 | uint8_t *ptrPeerList; // pointer to list3/4 in regs struct 55 | uint8_t *ptrMainList; // pointer to list0/1 in regs struct 56 | 57 | long counter; 58 | 59 | void configCngEvent(void); // list1 on registered channel had changed 60 | void pairSetEvent(uint8_t *data, uint8_t len); // pair message to specific channel, handover information for value, ramp time and so on 61 | void pairStatusReq(void); // event on status request 62 | void peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len); // peer message was received on the registered channel, handover the message bytes and length 63 | void poll(void); // poll function, driven by HM loop 64 | 65 | //- predefined, no reason to touch ------------------------------------------------------------------------------------ 66 | void regInHM(uint8_t cnl, HM *instPtr); // register this module in HM on the specific channel 67 | void hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len); // call back address for HM for informing on events 68 | void peerAddEvent(uint8_t *data, uint8_t len); // peer was added to the specific channel, 1st and 2nd byte shows peer channel, third and fourth byte shows peer index 69 | void setAltitude(int16_t altitude); 70 | 71 | protected: 72 | 73 | private: 74 | BMP085 *bm180; 75 | BH1750 *bh1750; 76 | 77 | uint8_t nAction; 78 | uint32_t nTime; 79 | uint32_t startTime; 80 | uint16_t tTiming; 81 | 82 | int16_t tTemp; 83 | uint8_t tHum; 84 | uint16_t tPres; 85 | int16_t tAltitude; // altitude for calculating air pressure at sea level 86 | 87 | uint32_t tLux; 88 | 89 | uint8_t bh1750IntFlag; 90 | 91 | uint32_t calcSendSlot(void); 92 | void poll_measureCalcLight(void); 93 | void poll_measureTHP(void); 94 | void poll_transmit(void); 95 | }; 96 | 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /examples/HB-UW-Sen-THPL/ccu-changelog.txt: -------------------------------------------------------------------------------- 1 | For the firmware update, the Sensor must switched off and switched on again. 2 | 3 | 1. Take at least one battery out of the sensor. 4 | 2. Press the config button and insert the battery in the sensor. 5 | 3. Still holding the config button a few seconds after inserting the batteries. 6 | 4. Bootloader should starts. 7 | 8 | Changelog: 9 | 10 | Version Beta 0.14 11 | ------------- 12 | 13 | ** Improvement 14 | * Add new register: 15 | - Fix millis() overflow bug. Now, the sensor stays in sleep mode after 49 days, so battery should not drained anymore 16 | - Battery voltage now measured with 1 digit only. 17 | 18 | Version Beta 0.13 19 | ------------- 20 | 21 | ** Improvement 22 | * Add new register: 23 | - transmitTryMax: How often should the sensor try to send data without ack. 24 | - lowBatLimit: Defined the battery voltage used for low battery detection. 25 | - ledMode: Switch the device LED on or off while sent out data. 26 | - altitude: Define the sensor-altitude for calculating the air pressure at sea level. 27 | -------------------------------------------------------------------------------- /examples/HB-WDS40-THP-I/Sens_BMP180.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SENS_BMP180_H_ 3 | #define _SENS_BMP180_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace as { 10 | 11 | class Sens_Bmp180 : public Sensor { 12 | 13 | int16_t _temperature; 14 | uint16_t _pressure; 15 | uint16_t _pressureNN; 16 | 17 | SFE_BMP180 bmp180; 18 | 19 | public: 20 | 21 | Sens_Bmp180 () : _temperature(0), _pressure(0), _pressureNN(0) {} 22 | 23 | void init () { 24 | Wire.begin(); //ToDo sync with further I2C sensor classes 25 | _present = bmp180.begin(); 26 | 27 | DPRINT("BMP180 init ");DDECLN(_present); 28 | } 29 | 30 | void measure (uint16_t height) { 31 | if (_present == true) { 32 | double T,P,p0; 33 | char status = bmp180.startTemperature(); 34 | 35 | if (status != 0) { 36 | // Wait for the measurement to complete: 37 | delay(status); 38 | status = bmp180.getTemperature(T); 39 | if (status != 0) { 40 | status = bmp180.startPressure(3); 41 | if (status != 0) { 42 | delay(status); 43 | status = bmp180.getPressure(P,T); 44 | if (status != 0) { 45 | p0 = bmp180.sealevel(P,height); 46 | } 47 | } 48 | } 49 | } 50 | 51 | _temperature = (int16_t)(T * 10); 52 | _pressure = (uint16_t)(P * 10); 53 | _pressureNN = (uint16_t)(p0 * 10); 54 | 55 | DPRINTLN(F("BMP180:")); 56 | DPRINT(F("-T : ")); DDECLN(_temperature); 57 | DPRINT(F("-P : ")); DDECLN(_pressure); 58 | DPRINT(F("-P(NN): ")); DDECLN(_pressureNN); 59 | } 60 | } 61 | 62 | int16_t temperature () { return _temperature; } 63 | uint16_t pressure () { return _pressure; } 64 | uint16_t pressureNN () { return _pressureNN; } 65 | 66 | }; 67 | 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /examples/HB-WDS40-THP-O-BME280/Sens_BME280.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SENS_BME280_H_ 3 | #define _SENS_BME280_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace as { 11 | 12 | BME280I2C::Settings settings( 13 | BME280::OSR_X1, // Temperature Oversampling Rate (tempOSR): OSR Enum, default = OSR_X1 14 | BME280::OSR_X1, // Humidity Oversampling Rate (humOSR): OSR Enum, default = OSR_X1 15 | BME280::OSR_X1, // Pressure Oversampling Rate (presOSR): OSR Enum, default = OSR_X1 16 | BME280::Mode_Forced, // Mode (mode): Mode Enum, default = Mode_Forced 17 | BME280::StandbyTime_1000ms, // Standby Time (standbyTime): StandbyTime Enum, default = StandbyTime_1000ms 18 | BME280::Filter_Off, // Filter (filter): Filter Enum, default = Filter_16 19 | BME280::SpiEnable_False // SPI Enable: SpiEnable Enum, default = false 20 | ); 21 | 22 | class Sens_Bme280 : public Sensor { 23 | 24 | int16_t _temperature; 25 | uint16_t _pressure; 26 | uint16_t _pressureNN; 27 | uint8_t _humidity; 28 | uint16_t _dewPoint; 29 | 30 | BME280I2C _bme280; // Default : forced mode, standby time = 1000 ms, Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off 31 | 32 | public: 33 | 34 | Sens_Bme280 () : _temperature(0), _pressure(0), _pressureNN(0), _humidity(0), _dewPoint(0) {} 35 | 36 | void init () { 37 | 38 | Wire.begin(); //ToDo sync with further I2C sensor classes 39 | 40 | uint8_t i = 10; 41 | while( (!_bme280.begin()) && (i > 0) ) { 42 | delay(100); 43 | i--; 44 | } 45 | 46 | switch(_bme280.chipModel()) { 47 | case BME280::ChipModel_BME280: 48 | _present = true; 49 | DPRINTLN(F("BME280 sensor OK")); 50 | break; 51 | default: 52 | DPRINTLN(F("BME280 sensor NOT OK")); 53 | } 54 | 55 | _bme280.setSettings(settings); 56 | } 57 | 58 | void measure (uint16_t height) { 59 | if (_present == true) { 60 | float temp(NAN), hum(NAN), pres(NAN); 61 | _bme280.read(pres, temp, hum, BME280::TempUnit_Celsius, BME280::PresUnit_hPa); 62 | 63 | _temperature = (int16_t)(temp * 10); 64 | _pressure = (uint16_t)(pres * 10); 65 | _pressureNN = (uint16_t)(EnvironmentCalculations::EquivalentSeaLevelPressure(float(height), temp, pres) * 10); 66 | _humidity = (uint8_t)hum; 67 | _dewPoint = (int16_t)(EnvironmentCalculations::DewPoint(temp, hum, EnvironmentCalculations::TempUnit_Celsius) * 10); 68 | 69 | DPRINTLN(F("BME280:")); 70 | DPRINT(F("-T : ")); DDECLN(_temperature); 71 | DPRINT(F("-P : ")); DDECLN(_pressure); 72 | DPRINT(F("-P(NN): ")); DDECLN(_pressureNN); 73 | DPRINT(F("-H : ")); DDECLN(_humidity); 74 | DPRINT(F("-DP : ")); DDECLN(_dewPoint); 75 | } 76 | } 77 | 78 | int16_t temperature () { return _temperature; } 79 | uint16_t pressure () { return _pressure; } 80 | uint16_t pressureNN () { return _pressureNN; } 81 | uint8_t humidity () { return _humidity; } 82 | int16_t dewPoint () { return _dewPoint; } 83 | }; 84 | 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /examples/HM-Dis-TD-T/HM-Dis-TD-T.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-10-07 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | #define USE_WOR 11 | 12 | #define EI_NOTEXTERNAL 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | // we use a Pro Mini 20 | // Arduino pin for the LED 21 | // D4 == PIN 4 on Pro Mini 22 | #define LED_PIN 4 23 | // Arduino pin for the config button 24 | // B0 == PIN 8 on Pro Mini 25 | #define CONFIG_BUTTON_PIN 8 26 | 27 | #define RELAY1_PIN 17 28 | 29 | // number of available peers per channel 30 | #define PEERS_PER_CHANNEL 8 31 | 32 | // all library classes are placed in the namespace 'as' 33 | using namespace as; 34 | 35 | // define all device properties 36 | const struct DeviceInfo PROGMEM devinfo = { 37 | {0x00,0x78,0x01}, // Device ID 38 | "HMDISTDT01", // Device Serial 39 | {0x00,0x78}, // Device Model 40 | 0x10, // Firmware Version 41 | as::DeviceType::Switch, // Device Type 42 | {0x01,0x00} // Info Bytes 43 | }; 44 | 45 | /** 46 | * Configure the used hardware 47 | */ 48 | typedef AvrSPI<10,11,12,13> RadioSPI; 49 | typedef AskSin,BatterySensor,Radio > Hal; 50 | 51 | DEFREGISTER(Reg0,DREG_INTKEY,DREG_LEDMODE,MASTERID_REGS,DREG_LOWBATLIMIT) 52 | class SwList0 : public RegList0 { 53 | public: 54 | SwList0(uint16_t addr) : RegList0(addr) {} 55 | void defaults () { 56 | clear(); 57 | lowBatLimit(22); 58 | } 59 | }; 60 | 61 | // setup the device with channel type and number of channels 62 | class SwitchType : public MultiChannelDevice,1,SwList0> { 63 | public: 64 | typedef MultiChannelDevice,1,SwList0> DevType; 65 | SwitchType (const DeviceInfo& i,uint16_t addr) : DevType(i,addr) {} 66 | virtual ~SwitchType () {} 67 | 68 | virtual void configChanged () { 69 | DevType::configChanged(); 70 | uint8_t lowbat = getList0().lowBatLimit(); 71 | DDECLN(lowbat); 72 | if( lowbat > 0 ) { 73 | battery().low(lowbat); 74 | } 75 | } 76 | }; 77 | 78 | Hal hal; 79 | SwitchType sdev(devinfo,0x20); 80 | ConfigToggleButton cfgBtn(sdev); 81 | 82 | void initPeerings (bool first) { 83 | // create internal peerings - CCU2 needs this 84 | if( first == true ) { 85 | HMID devid; 86 | sdev.getDeviceID(devid); 87 | for( uint8_t i=1; i<=sdev.channels(); ++i ) { 88 | Peer ipeer(devid,i); 89 | sdev.channel(i).peer(ipeer); 90 | } 91 | } 92 | } 93 | 94 | 95 | void setup () { 96 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 97 | bool first = sdev.init(hal); 98 | sdev.channel(1).init(RELAY1_PIN); 99 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 100 | initPeerings(first); 101 | // stay on for 15 seconds after start 102 | hal.activity.stayAwake(seconds2ticks(15)); 103 | // measure battery every hour 104 | hal.battery.init(seconds2ticks(60UL*60),sysclock); 105 | sdev.initDone(); 106 | } 107 | 108 | void loop() { 109 | bool worked = hal.runready(); 110 | bool poll = sdev.pollRadio(); 111 | if( worked == false && poll == false ) { 112 | hal.activity.savePower >(hal); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /examples/HM-ES-PMSw1-Pl/POW_Pinout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-ES-PMSw1-Pl/POW_Pinout.jpg -------------------------------------------------------------------------------- /examples/HM-ES-PMSw1-Pl/README.md: -------------------------------------------------------------------------------- 1 | # Library 2 | 3 | Die Library [HLW8012](https://github.com/xoseperez/hlw8012) wird zum Kompilieren des Sketches benötigt. 4 | 5 | # Anschlüsse 6 | 7 | ![pinout](POW_Pinout.jpg) 8 | -------------------------------------------------------------------------------- /examples/HM-ES-PMSw1-Pl_GosundSP1/README.md: -------------------------------------------------------------------------------- 1 | # Library 2 | 3 | Die Library [HLW8012](https://github.com/xoseperez/hlw8012) wird zum Kompilieren des Sketches benötigt. 4 | 5 | # Adapterplatine 6 | 7 | https://github.com/stan23/HM-ES-PMSw1-Pl_GosundSP1 -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/1_Shelly_Open.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/1_Shelly_Open.jpeg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/2_Shelly_RemoveESP.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/2_Shelly_RemoveESP.jpg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/3_Shelly_RemovedESP.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/3_Shelly_RemovedESP.jpg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/4_ProMiniWithCC1101.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/4_ProMiniWithCC1101.jpg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/5_ShellyWithoutESP.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/5_ShellyWithoutESP.jpg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/6_ShellyAssembled.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/6_ShellyAssembled.jpeg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/7_ShellyCase.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/7_ShellyCase.jpg -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/Deckel.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/HM-LC-SW1-FM_Shelly1.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-10-21 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define EI_NOTEXTERNAL 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | #define LED_PIN 4 19 | #define RELAY1_PIN 5 20 | #define CONFIG_BUTTON_PIN 8 21 | #define PEERS_PER_CHANNEL 12 22 | 23 | 24 | // all library classes are placed in the namespace 'as' 25 | using namespace as; 26 | 27 | // define all device properties 28 | const struct DeviceInfo PROGMEM devinfo = { 29 | {0x00, 0x04, 0x00}, // Device ID 30 | "JPSW1FM000", // Device Serial 31 | {0x00, 0x04}, // Device Model 32 | 0x16, // Firmware Version 33 | as::DeviceType::Switch, // Device Type 34 | {0x01, 0x00} // Info Bytes 35 | }; 36 | 37 | 38 | typedef AskSin, NoBattery, Radio , 2> > Hal; 39 | typedef MultiChannelDevice, 1> SwitchType; 40 | 41 | Hal hal; 42 | SwitchType sdev(devinfo, 0x20); 43 | ConfigToggleButton cfgBtn(sdev); 44 | 45 | void setup () { 46 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 47 | sdev.init(hal); 48 | 49 | sdev.channel(1).init(RELAY1_PIN, false); 50 | 51 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 52 | 53 | HMID devid; 54 | sdev.getDeviceID(devid); 55 | Peer ipeer(devid, 1); 56 | sdev.channel(1).peer(ipeer); 57 | sdev.initDone(); 58 | } 59 | 60 | void loop() { 61 | bool worked = hal.runready(); 62 | bool poll = sdev.pollRadio(); 63 | if ( worked == false && poll == false ) { 64 | hal.activity.savePower >(hal); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /examples/HM-LC-SW1-FM_Shelly1/README.md: -------------------------------------------------------------------------------- 1 | # Umbau Shelly1 auf AskSinPP 2 | - [Sketch](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/HM-LC-SW1-FM_Shelly1.ino) 3 | - [Deckel](https://github.com/jp112sdl/Beispiel_AskSinPP/blob/master/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl) 4 | 5 | #### 1. Gehäuse öffnen 6 | ![1](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/1_Shelly_Open.jpeg) 7 | 8 | #### 2. ESP entfernen 9 | _Geht wunderbar mit einem kleinen Lötbrenner. 3-4 Sekunden auf die Mitte des ESP halten und mit einer Pinzette abheben_ 10 | ![2](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/2_Shelly_RemoveESP.jpg) 11 | 12 | #### 3. Einen Pro Mini mit CC1101 "verheiraten" und den [Sketch](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/HM-LC-SW1-FM_Shelly1.ino) flashen 13 | ![3](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/4_ProMiniWithCC1101.jpg) 14 | 15 | #### 4. Die Pro Mini Pins Vcc (3.3V), GND, 5 und 8 mit den markierten Lötstellen verdrahten 16 | ![4](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/5_ShellyWithoutESP.jpg) 17 | 18 | #### 5. Eine Isolation zwischen Pro Mini und Shelly anbringen und das Ganze mit etwas Kleber fixieren 19 | ![5](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/6_ShellyAssembled.jpeg) 20 | 21 | #### 6. [Deckel](https://github.com/jp112sdl/Beispiel_AskSinPP/blob/master/examples/HM-LC-SW1-FM_Shelly1/Deckel.stl) ausdrucken und am Shelly verkleben 22 | ![6](https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/master/examples/HM-LC-SW1-FM_Shelly1/7_ShellyCase.jpg) 23 | 24 | **Zuletzt noch anlernen -> Das Gerät erscheint als HM-LC-Sw1-FM in der HomeMatic Zentrale. 25 | Zum Anlernen den Taster an "SW" lange (ca. 3 Sekunden) drücken.** 26 | -------------------------------------------------------------------------------- /examples/HM-LC-SW1-SM_SONOFF_BASIC/HM-LC-SW1-SM_SONOFF_BASIC.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-09-12 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | // number of relays by defining the device 12 | #define EI_NOTEXTERNAL 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #define LED_PIN A3 20 | #define CONFIG_BUTTON_PIN 8 21 | #define RELAY1_PIN 5 22 | 23 | // number of available peers per channel 24 | #define PEERS_PER_CHANNEL 8 25 | 26 | // all library classes are placed in the namespace 'as' 27 | using namespace as; 28 | 29 | // define all device properties 30 | const struct DeviceInfo PROGMEM devinfo = { 31 | {0x00, 0x02, 0x01}, // Device ID 32 | "SONOFF0001", // Device Serial 33 | {0x00, 0x02}, // Device Model 34 | 0x16, // Firmware Version 35 | as::DeviceType::Switch, // Device Type 36 | {0x01, 0x00} // Info Bytes 37 | }; 38 | 39 | /** 40 | Configure the used hardware 41 | */ 42 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 43 | typedef AskSin, NoBattery, Radio > Hal; 44 | 45 | // setup the device with channel type and number of channels 46 | typedef MultiChannelDevice, 1> SwitchType; 47 | 48 | Hal hal; 49 | SwitchType sdev(devinfo, 0x20); 50 | 51 | ConfigToggleButton cfgBtn(sdev); 52 | 53 | void initPeerings (bool first) { 54 | // create internal peerings - CCU2 needs this 55 | if ( first == true ) { 56 | HMID devid; 57 | sdev.getDeviceID(devid); 58 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) { 59 | Peer ipeer(devid, i); 60 | sdev.channel(i).peer(ipeer); 61 | } 62 | } 63 | } 64 | 65 | void setup () { 66 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 67 | bool first = sdev.init(hal); 68 | sdev.channel(1).init(RELAY1_PIN, false); 69 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 70 | sdev.channels(1); 71 | initPeerings(first); 72 | sdev.initDone(); 73 | } 74 | 75 | void loop() { 76 | bool worked = hal.runready(); 77 | bool poll = sdev.pollRadio(); 78 | if ( worked == false && poll == false ) { 79 | hal.activity.savePower >(hal); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /examples/HM-LC-Sw1-Pl-CT-R1/HM-LC-Sw1-Pl-CT-R1.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | // number of relays by defining the device 11 | #define HM_LC_SW1_SM 0x00,0x02 12 | 13 | 14 | #define CFG_LOWACTIVE_BYTE 0x00 15 | #define CFG_LOWACTIVE_ON 0x01 16 | #define CFG_LOWACTIVE_OFF 0x00 17 | 18 | #define DEVICE_CONFIG CFG_LOWACTIVE_OFF 19 | 20 | #define EI_NOTEXTERNAL 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | // we use a Pro Mini 28 | // Arduino pin for the LED 29 | // D4 == PIN 4 on Pro Mini 30 | #define LED_PIN 4 31 | // Arduino pin for the config button 32 | // B0 == PIN 8 on Pro Mini 33 | #define CONFIG_BUTTON_PIN 8 34 | #define RELAY1_PIN 5 35 | 36 | // number of available peers per channel 37 | #define PEERS_PER_CHANNEL 8 38 | 39 | 40 | // all library classes are placed in the namespace 'as' 41 | using namespace as; 42 | 43 | // define all device properties 44 | const struct DeviceInfo PROGMEM devinfo = { 45 | {0x00, 0xeb, 0x02}, // Device ID 46 | "JPSw1CT001", // Device Serial 47 | {0x00, 0xeb}, // Device Model 48 | 0x24, // Firmware Version 49 | as::DeviceType::Switch, // Device Type 50 | {0x01, 0x00} // Info Bytes 51 | }; 52 | 53 | /** 54 | Configure the used hardware 55 | */ 56 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 57 | typedef AskSin, NoBattery, Radio > Hal; 58 | 59 | // setup the device with channel type and number of channels 60 | typedef MultiChannelDevice, 4> SwitchType; 61 | 62 | Hal hal; 63 | SwitchType sdev(devinfo, 0x20); 64 | 65 | ConfigToggleButton cfgBtn(sdev); 66 | 67 | // if A0 and A1 connected 68 | // we use LOW for ON and HIGH for OFF 69 | bool checkLowActive () { 70 | pinMode(14, OUTPUT); // A0 71 | pinMode(15, INPUT_PULLUP); // A1 72 | digitalWrite(15, HIGH); 73 | digitalWrite(14, LOW); 74 | bool result = digitalRead(15) == LOW; 75 | digitalWrite(14, HIGH); 76 | return result; 77 | } 78 | 79 | void initPeerings (bool first) { 80 | // create internal peerings - CCU2 needs this 81 | if ( first == true ) { 82 | HMID devid; 83 | sdev.getDeviceID(devid); 84 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) { 85 | Peer ipeer(devid, i); 86 | sdev.channel(i).peer(ipeer); 87 | } 88 | } 89 | } 90 | 91 | void initModelType () { 92 | uint8_t model[2]; 93 | sdev.getDeviceModel(model); 94 | sdev.channels(1); 95 | } 96 | 97 | void setup () { 98 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 99 | bool first = sdev.init(hal); 100 | bool low = (sdev.getConfigByte(CFG_LOWACTIVE_BYTE) == CFG_LOWACTIVE_ON) || checkLowActive(); 101 | sdev.channel(1).init(RELAY1_PIN, low); 102 | 103 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 104 | 105 | initModelType(); 106 | initPeerings(first); 107 | sdev.initDone(); 108 | } 109 | 110 | void loop() { 111 | bool worked = hal.runready(); 112 | bool poll = sdev.pollRadio(); 113 | if ( worked == false && poll == false ) { 114 | hal.activity.savePower >(hal); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /examples/HM-LC-Sw1-Pl-DN-R1/HM-LC-Sw1-Pl-DN-R1.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | // number of relays by defining the device 11 | 12 | 13 | #define CFG_LOWACTIVE_BYTE 0x00 14 | #define CFG_LOWACTIVE_ON 0x01 15 | #define CFG_LOWACTIVE_OFF 0x00 16 | 17 | #define DEVICE_CONFIG CFG_LOWACTIVE_OFF 18 | 19 | #define EI_NOTEXTERNAL 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | // we use a Pro Mini 27 | // Arduino pin for the LED 28 | // D4 == PIN 4 on Pro Mini 29 | #define LED_PIN 4 30 | // Arduino pin for the config button 31 | // B0 == PIN 8 on Pro Mini 32 | #define CONFIG_BUTTON_PIN 8 33 | #define LED_PIN 4 34 | #define RELAY1_PIN 5 35 | 36 | 37 | // number of available peers per channel 38 | #define PEERS_PER_CHANNEL 8 39 | 40 | 41 | // all library classes are placed in the namespace 'as' 42 | using namespace as; 43 | 44 | // define all device properties 45 | const struct DeviceInfo PROGMEM devinfo = { 46 | {0x01, 0xd8, 0x09}, // Device ID 47 | "JPLCSw1002", // Device Serial 48 | {0x00,0xd8}, // Device Model 49 | 0x26, // Firmware Version 50 | as::DeviceType::Switch, // Device Type 51 | {0x01, 0x00} // Info Bytes 52 | }; 53 | 54 | /** 55 | Configure the used hardware 56 | */ 57 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 58 | typedef AskSin, NoBattery, Radio > Hal; 59 | 60 | // setup the device with channel type and number of channels 61 | typedef MultiChannelDevice, 1> SwitchType; 62 | 63 | Hal hal; 64 | SwitchType sdev(devinfo, 0x20); 65 | ConfigToggleButton cfgBtn(sdev); 66 | 67 | void initPeerings (bool first) { 68 | // create internal peerings - CCU2 needs this 69 | if ( first == true ) { 70 | HMID devid; 71 | sdev.getDeviceID(devid); 72 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) { 73 | Peer ipeer(devid, i); 74 | sdev.channel(i).peer(ipeer); 75 | } 76 | } 77 | } 78 | 79 | void initModelType () { 80 | uint8_t model[2]; 81 | sdev.getDeviceModel(model); 82 | sdev.channels(1); 83 | } 84 | 85 | void setup () { 86 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 87 | bool first = sdev.init(hal); 88 | sdev.channel(1).init(RELAY1_PIN, false); 89 | 90 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 91 | 92 | initModelType(); 93 | initPeerings(first); 94 | sdev.initDone(); 95 | } 96 | 97 | void loop() { 98 | bool worked = hal.runready(); 99 | bool poll = sdev.pollRadio(); 100 | if ( worked == false && poll == false ) { 101 | hal.activity.savePower >(hal); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /examples/HM-LC-Sw1-Pl-DN-R1_OBI/HM-LC-Sw1-Pl-DN-R1_OBI.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-07-13 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | // number of relays by defining the device 12 | 13 | 14 | #define EI_NOTEXTERNAL 15 | #include 16 | #include 17 | #include 18 | 19 | #define USE_PIN_PULSE 20 | #define PIN_PULSE_MILLIS 100 21 | #define PIN_PULSE_STATE LOW 22 | 23 | #include "SwitchObi.h" 24 | 25 | // we use a Pro Mini 26 | // Arduino pin for the LED 27 | // D4 == PIN 4 on Pro Mini 28 | #define LED_PIN 4 29 | // Arduino pin for the config button 30 | // B0 == PIN 8 on Pro Mini 31 | #define CONFIG_BUTTON_PIN 8 32 | 33 | #define RELAY_ON_PIN 5 34 | #define RELAY_OFF_PIN 6 35 | 36 | 37 | // number of available peers per channel 38 | #define PEERS_PER_CHANNEL 8 39 | 40 | 41 | // all library classes are placed in the namespace 'as' 42 | using namespace as; 43 | 44 | // define all device properties 45 | const struct DeviceInfo PROGMEM devinfo = { 46 | {0x00, 0xd8, 0x99}, // Device ID 47 | "JPLCSw1099", // Device Serial 48 | {0x00,0xd8}, // Device Model 49 | 0x26, // Firmware Version 50 | as::DeviceType::Switch, // Device Type 51 | {0x01, 0x00} // Info Bytes 52 | }; 53 | 54 | /** 55 | Configure the used hardware 56 | */ 57 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 58 | typedef AskSin, NoBattery, Radio > Hal; 59 | 60 | // setup the device with channel type and number of channels 61 | typedef MultiChannelDevice, 1> SwitchType; 62 | 63 | Hal hal; 64 | SwitchType sdev(devinfo, 0x20); 65 | ConfigToggleButton cfgBtn(sdev); 66 | 67 | void initPeerings (bool first) { 68 | // create internal peerings - CCU2 needs this 69 | if ( first == true ) { 70 | HMID devid; 71 | sdev.getDeviceID(devid); 72 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) { 73 | Peer ipeer(devid, i); 74 | sdev.channel(i).peer(ipeer); 75 | } 76 | } 77 | } 78 | 79 | void initModelType () { 80 | uint8_t model[2]; 81 | sdev.getDeviceModel(model); 82 | sdev.channels(1); 83 | } 84 | 85 | void setup () { 86 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 87 | bool first = sdev.init(hal); 88 | sdev.channel(1).init(RELAY_ON_PIN, RELAY_OFF_PIN, false); 89 | 90 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 91 | 92 | initModelType(); 93 | initPeerings(first); 94 | sdev.initDone(); 95 | } 96 | 97 | void loop() { 98 | bool worked = hal.runready(); 99 | bool poll = sdev.pollRadio(); 100 | if ( worked == false && poll == false ) { 101 | hal.activity.savePower >(hal); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /examples/HM-LC-Sw1-Pl-DN-R1_OBI/README.md: -------------------------------------------------------------------------------- 1 | Sketch für den Umbau eines OBI WiFi Zwischensteckers 2 | 3 | Eine Platine gibts hier: https://github.com/stan23/HM-LC-Sw1-Pl-DN-R1_OBI 4 | -------------------------------------------------------------------------------- /examples/HM-LC-Sw2-FM/HM-LC-Sw2-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | // we use a Pro Mini 18 | // Arduino pin for the LED 19 | // D4 == PIN 4 on Pro Mini 20 | #define LED_PIN 4 21 | // Arduino pin for the config button 22 | // B0 == PIN 8 on Pro Mini 23 | #define CONFIG_BUTTON_PIN 8 24 | 25 | //set to 0x01 if the RELAY should be switched on LOW level 26 | #define LOW_ACTIVE 0x00 27 | #define RELAY1_PIN 17 //A3 28 | #define RELAY2_PIN 16 //A2 29 | 30 | #define BUTTON1_PIN 6 31 | #define BUTTON2_PIN 3 32 | 33 | // number of available peers per channel 34 | #define PEERS_PER_CHANNEL 8 35 | 36 | // all library classes are placed in the namespace 'as' 37 | using namespace as; 38 | 39 | // define all device properties 40 | const struct DeviceInfo PROGMEM devinfo = { 41 | {0x12, 0x09, 0x00}, // Device ID 42 | "JPLCSw2001", // Device Serial 43 | {0x00, 0x09}, // Device Model 44 | 0x24, // Firmware Version 45 | as::DeviceType::Switch, // Device Type 46 | {0x01, 0x00} // Info Bytes 47 | }; 48 | 49 | /** 50 | Configure the used hardware 51 | */ 52 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 53 | typedef AskSin, NoBattery, Radio > Hal; 54 | 55 | // setup the device with channel type and number of channels 56 | typedef MultiChannelDevice, 2> SwitchType; 57 | 58 | Hal hal; 59 | SwitchType sdev(devinfo, 0x20); 60 | ConfigButton cfgBtn(sdev); 61 | InternalButton btn1(sdev, 1); 62 | InternalButton btn2(sdev, 2); 63 | 64 | void initPeerings (bool first) { 65 | // create internal peerings - CCU2 needs this 66 | if ( first == true ) { 67 | HMID devid; 68 | sdev.getDeviceID(devid); 69 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) { 70 | Peer ipeer(devid, i); 71 | sdev.channel(i).peer(ipeer); 72 | } 73 | } 74 | } 75 | 76 | void setup () { 77 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 78 | bool first = sdev.init(hal); 79 | sdev.channel(1).init(RELAY1_PIN, LOW_ACTIVE); 80 | sdev.channel(2).init(RELAY2_PIN, LOW_ACTIVE); 81 | 82 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 83 | buttonISR(btn1, BUTTON1_PIN); 84 | buttonISR(btn2, BUTTON2_PIN); 85 | 86 | sdev.channels(2); 87 | initPeerings(first); 88 | sdev.initDone(); 89 | } 90 | 91 | void loop() { 92 | bool worked = hal.runready(); 93 | bool poll = sdev.pollRadio(); 94 | if ( worked == false && poll == false ) { 95 | hal.activity.savePower >(hal); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /examples/HM-MOD-Re-8/HM-MOD-Re-8.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-09-29 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | #define USE_WOR 11 | 12 | #define EI_NOTEXTERNAL 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | 20 | // we use a Pro Mini 21 | // Arduino pin for the LED 22 | // D4 == PIN 4 on Pro Mini 23 | #define LED_PIN 4 24 | // Arduino pin for the config button 25 | // B0 == PIN 8 on Pro Mini 26 | #define CONFIG_BUTTON_PIN 8 27 | 28 | #define RELAY1_PIN 14 29 | #define RELAY2_PIN 15 30 | #define RELAY3_PIN 16 31 | #define RELAY4_PIN 17 32 | #define RELAY5_PIN 7 33 | #define RELAY6_PIN 9 34 | #define RELAY7_PIN 6 35 | #define RELAY8_PIN 5 36 | 37 | // number of available peers per channel 38 | #define PEERS_PER_CHANNEL 4 39 | 40 | // all library classes are placed in the namespace 'as' 41 | using namespace as; 42 | 43 | // define all device properties 44 | const struct DeviceInfo PROGMEM devinfo = { 45 | {0x00,0xBE,0x00}, // Device ID 46 | "JP00BE0000", // Device Serial 47 | {0x00,0xbe}, // Device Model 48 | 0x12, // Firmware Version 49 | as::DeviceType::Switch, // Device Type 50 | {0x01,0x00} // Info Bytes 51 | }; 52 | 53 | /** 54 | * Configure the used hardware 55 | */ 56 | typedef AvrSPI<10,11,12,13> RadioSPI; 57 | typedef AskSin,BatterySensor,Radio > Hal; 58 | 59 | DEFREGISTER(Reg0,DREG_INTKEY,DREG_LEDMODE,MASTERID_REGS,DREG_LOWBATLIMIT) 60 | class SwList0 : public RegList0 { 61 | public: 62 | SwList0(uint16_t addr) : RegList0(addr) {} 63 | void defaults () { 64 | clear(); 65 | lowBatLimit(22); 66 | } 67 | }; 68 | 69 | // setup the device with channel type and number of channels 70 | class SwitchType : public MultiChannelDevice,8,SwList0> { 71 | public: 72 | typedef MultiChannelDevice,8,SwList0> DevType; 73 | SwitchType (const DeviceInfo& i,uint16_t addr) : DevType(i,addr) {} 74 | virtual ~SwitchType () {} 75 | 76 | virtual void configChanged () { 77 | DevType::configChanged(); 78 | uint8_t lowbat = getList0().lowBatLimit(); 79 | DDECLN(lowbat); 80 | if( lowbat > 0 ) { 81 | battery().low(lowbat); 82 | } 83 | } 84 | }; 85 | 86 | Hal hal; 87 | SwitchType sdev(devinfo,0x20); 88 | ConfigButton cfgBtn(sdev); 89 | 90 | void initPeerings (bool first) { 91 | // create internal peerings - CCU2 needs this 92 | if( first == true ) { 93 | HMID devid; 94 | sdev.getDeviceID(devid); 95 | for( uint8_t i=1; i<=sdev.channels(); ++i ) { 96 | Peer ipeer(devid,i); 97 | sdev.channel(i).peer(ipeer); 98 | } 99 | } 100 | } 101 | 102 | 103 | void setup () { 104 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 105 | bool first = sdev.init(hal); 106 | sdev.channel(1).init(RELAY1_PIN); 107 | sdev.channel(2).init(RELAY2_PIN); 108 | sdev.channel(3).init(RELAY3_PIN); 109 | sdev.channel(4).init(RELAY4_PIN); 110 | sdev.channel(5).init(RELAY5_PIN); 111 | sdev.channel(6).init(RELAY6_PIN); 112 | sdev.channel(7).init(RELAY7_PIN); 113 | sdev.channel(8).init(RELAY8_PIN); 114 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 115 | initPeerings(first); 116 | // stay on for 15 seconds after start 117 | hal.activity.stayAwake(seconds2ticks(15)); 118 | // measure battery every hour 119 | hal.battery.init(seconds2ticks(60UL*60),sysclock); 120 | sdev.initDone(); 121 | } 122 | 123 | void loop() { 124 | bool worked = hal.runready(); 125 | bool poll = sdev.pollRadio(); 126 | if( worked == false && poll == false ) { 127 | hal.activity.savePower >(hal); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /examples/HM-PB-2-FM/HM-PB-2-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include // after including SPI Library - we can use LibSPI class 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | 20 | // we use a Pro Mini 21 | // Arduino pin for the LED 22 | // D4 == PIN 4 on Pro Mini 23 | #define LED_PIN 4 24 | #define LED_PIN2 5 25 | // Arduino pin for the config button 26 | // B0 == PIN 8 on Pro Mini 27 | #define CONFIG_BUTTON_PIN 8 28 | // Arduino pins for the buttons 29 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini 30 | #define BTN1_PIN 14 31 | #define BTN2_PIN 15 32 | 33 | 34 | // number of available peers per channel 35 | #define PEERS_PER_CHANNEL 10 36 | 37 | // all library classes are placed in the namespace 'as' 38 | using namespace as; 39 | 40 | // define all device properties 41 | const struct DeviceInfo PROGMEM devinfo = { 42 | {0x02, 0xBF, 0x01}, // Device ID 43 | "JPPB2FM001", // Device Serial 44 | {0x00, 0xBF}, // Device Model 45 | 0x14, // Firmware Version 46 | as::DeviceType::Remote, // Device Type 47 | {0x00, 0x00} // Info Bytes 48 | }; 49 | 50 | /** 51 | Configure the used hardware 52 | */ 53 | typedef LibSPI<10> SPIType; 54 | typedef Radio RadioType; 55 | typedef DualStatusLed LedType; 56 | typedef AskSin HalType; 57 | class Hal : public HalType { 58 | // extra clock to count button press events 59 | AlarmClock btncounter; 60 | public: 61 | void init (const HMID& id) { 62 | HalType::init(id); 63 | // get new battery value after 50 key press 64 | battery.init(50, btncounter); 65 | battery.low(22); 66 | battery.critical(19); 67 | } 68 | 69 | void sendPeer () { 70 | --btncounter; 71 | } 72 | 73 | bool runready () { 74 | return HalType::runready() || btncounter.runready(); 75 | } 76 | }; 77 | 78 | typedef RemoteChannel ChannelType; 79 | typedef MultiChannelDevice RemoteType; 80 | 81 | Hal hal; 82 | RemoteType sdev(devinfo, 0x20); 83 | ConfigButton cfgBtn(sdev); 84 | 85 | void setup () { 86 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 87 | sdev.init(hal); 88 | remoteISR(sdev, 1, BTN1_PIN); 89 | remoteISR(sdev, 2, BTN2_PIN); 90 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 91 | sdev.initDone(); 92 | } 93 | 94 | void loop() { 95 | bool worked = hal.runready(); 96 | bool poll = sdev.pollRadio(); 97 | if (worked == false && poll == false ) { 98 | hal.activity.savePower>(hal); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/HM-PB-2-WM55/HM-PB-2-WM55.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include // after including SPI Library - we can use LibSPI class 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | 20 | // we use a Pro Mini 21 | // Arduino pin for the LED 22 | // D4 == PIN 4 on Pro Mini 23 | #define LED_PIN 4 24 | #define LED_PIN2 5 25 | // Arduino pin for the config button 26 | // B0 == PIN 8 on Pro Mini 27 | #define CONFIG_BUTTON_PIN 8 28 | // Arduino pins for the buttons 29 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini 30 | #define BTN1_PIN 14 31 | #define BTN2_PIN 15 32 | 33 | 34 | // number of available peers per channel 35 | #define PEERS_PER_CHANNEL 10 36 | 37 | // all library classes are placed in the namespace 'as' 38 | using namespace as; 39 | 40 | // define all device properties 41 | const struct DeviceInfo PROGMEM devinfo = { 42 | {0x72,0x6B,0x12}, // Device ID 43 | "JPPB200001", // Device Serial 44 | {0x00,0x6B}, // Device Model 45 | 0x14, // Firmware Version 46 | as::DeviceType::Remote, // Device Type 47 | {0x00,0x00} // Info Bytes 48 | }; 49 | 50 | /** 51 | * Configure the used hardware 52 | */ 53 | typedef LibSPI<10> SPIType; 54 | typedef Radio RadioType; 55 | typedef DualStatusLed LedType; 56 | typedef AskSin HalType; 57 | class Hal : public HalType { 58 | // extra clock to count button press events 59 | AlarmClock btncounter; 60 | public: 61 | void init (const HMID& id) { 62 | HalType::init(id); 63 | // get new battery value after 50 key press 64 | battery.init(50,btncounter); 65 | battery.low(22); 66 | battery.critical(19); 67 | } 68 | 69 | void sendPeer () { 70 | --btncounter; 71 | } 72 | 73 | bool runready () { 74 | return HalType::runready() || btncounter.runready(); 75 | } 76 | }; 77 | 78 | typedef RemoteChannel ChannelType; 79 | typedef MultiChannelDevice RemoteType; 80 | 81 | Hal hal; 82 | RemoteType sdev(devinfo,0x20); 83 | ConfigButton cfgBtn(sdev); 84 | 85 | void setup () { 86 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 87 | sdev.init(hal); 88 | remoteISR(sdev,1,BTN1_PIN); 89 | remoteISR(sdev,2,BTN2_PIN); 90 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 91 | sdev.initDone(); 92 | } 93 | 94 | void loop() { 95 | bool worked = hal.runready(); 96 | bool poll = sdev.pollRadio(); 97 | if( worked == false && poll == false ) { 98 | hal.activity.savePower>(hal); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/HM-PB-6-WM55/HM-PB-6-WM55.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | 19 | // we use a Pro Mini 20 | // Arduino pin for the LED 21 | // D4/D5 == PIN 4/5 22 | #define LED_GREEN 4 23 | #define LED_RED 5 24 | // Arduino pin for the config button 25 | // B0 == PIN 8 26 | #define CONFIG_BUTTON_PIN 8 27 | // Arduino pins for the buttons 28 | #define BTN01_PIN 14 // PC0 29 | #define BTN02_PIN 3 // PD3 30 | #define BTN03_PIN 15 // PC1 31 | #define BTN04_PIN 7 // PD7 32 | #define BTN05_PIN 9 // PB1 33 | #define BTN06_PIN 6 // PD6 34 | 35 | 36 | 37 | // number of available peers per channel 38 | #define PEERS_PER_CHANNEL 10 39 | 40 | // all library classes are placed in the namespace 'as' 41 | using namespace as; 42 | 43 | // define all device properties 44 | const struct DeviceInfo PROGMEM devinfo = { 45 | {0x04,0xa9,0x00}, // Device ID 46 | "HMRC00da00", // Device Serial 47 | {0x00,0xA9}, // Device Model 48 | 0x01, // Firmware Version 49 | as::DeviceType::Remote, // Device Type 50 | {0x00,0x00} // Info Bytes 51 | }; 52 | 53 | /** 54 | * Configure the used hardware 55 | */ 56 | typedef AvrSPI<10,11,12,13> SPIType; 57 | typedef Radio RadioType; 58 | typedef DualStatusLed LedType; 59 | typedef AskSin HalType; 60 | class Hal : public HalType { 61 | // extra clock to count button press events 62 | AlarmClock btncounter; 63 | public: 64 | void init (const HMID& id) { 65 | HalType::init(id); 66 | // get new battery value after 50 key press 67 | battery.init(50,btncounter); 68 | battery.low(22); 69 | battery.critical(19); 70 | } 71 | 72 | void sendPeer () { 73 | --btncounter; 74 | } 75 | 76 | bool runready () { 77 | return HalType::runready() || btncounter.runready(); 78 | } 79 | }; 80 | 81 | typedef RemoteChannel ChannelType; 82 | typedef MultiChannelDevice RemoteType; 83 | 84 | Hal hal; 85 | RemoteType sdev(devinfo,0x20); 86 | ConfigButton cfgBtn(sdev); 87 | 88 | void setup () { 89 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 90 | sdev.init(hal); 91 | 92 | remoteISR(sdev,1,BTN01_PIN); 93 | remoteISR(sdev,2,BTN02_PIN); 94 | remoteISR(sdev,3,BTN03_PIN); 95 | remoteISR(sdev,4,BTN04_PIN); 96 | remoteISR(sdev,5,BTN05_PIN); 97 | remoteISR(sdev,6,BTN06_PIN); 98 | 99 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 100 | 101 | sdev.initDone(); 102 | } 103 | 104 | void loop() { 105 | bool worked = hal.runready(); 106 | bool poll = sdev.pollRadio(); 107 | if(worked == false && poll == false ) { 108 | hal.activity.savePower>(hal); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /examples/HM-PBI-4-FM/HM-PBI-4-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | #define EI_NOTEXTERNAL 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | // we use a Pro Mini 18 | // Arduino pin for the LED 19 | // D4 == PIN 4 on Pro Mini 20 | #define LED_PIN 4 21 | #define LED_PIN2 5 22 | // Arduino pin for the config button 23 | // B0 == PIN 8 on Pro Mini 24 | #define CONFIG_BUTTON_PIN 8 25 | // Arduino pins for the buttons 26 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini 27 | #define BTN1_PIN 14 28 | #define BTN2_PIN 15 29 | #define BTN3_PIN 16 30 | #define BTN4_PIN 17 31 | 32 | // number of available peers per channel 33 | #define PEERS_PER_CHANNEL 10 34 | 35 | // all library classes are placed in the namespace 'as' 36 | using namespace as; 37 | 38 | // define all device properties 39 | const struct DeviceInfo PROGMEM devinfo = { 40 | {0x78,0x90,0x12}, // Device ID 41 | "JPPBI4FM01", // Device Serial 42 | {0x00,0x34}, // Device Model 43 | 0x01, // Firmware Version 44 | as::DeviceType::Remote, // Device Type 45 | {0x00,0x00} // Info Bytes 46 | }; 47 | 48 | /** 49 | * Configure the used hardware 50 | */ 51 | typedef AvrSPI<10, 11, 12, 13> SPIType; 52 | typedef Radio RadioType; 53 | typedef DualStatusLed LedType; 54 | typedef AskSin HalType; 55 | class Hal : public HalType { 56 | // extra clock to count button press events 57 | AlarmClock btncounter; 58 | public: 59 | void init (const HMID& id) { 60 | HalType::init(id); 61 | // get new battery value after 50 key press 62 | battery.init(50,btncounter); 63 | battery.low(22); 64 | battery.critical(19); 65 | } 66 | 67 | void sendPeer () { 68 | --btncounter; 69 | } 70 | 71 | bool runready () { 72 | return HalType::runready() || btncounter.runready(); 73 | } 74 | }; 75 | 76 | typedef RemoteChannel ChannelType; 77 | typedef MultiChannelDevice RemoteType; 78 | 79 | Hal hal; 80 | RemoteType sdev(devinfo,0x20); 81 | ConfigButton cfgBtn(sdev); 82 | 83 | void setup () { 84 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 85 | sdev.init(hal); 86 | remoteISR(sdev,1,BTN1_PIN); 87 | remoteISR(sdev,2,BTN2_PIN); 88 | remoteISR(sdev,3,BTN3_PIN); 89 | remoteISR(sdev,4,BTN4_PIN); 90 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 91 | sdev.initDone(); 92 | } 93 | 94 | void loop() { 95 | bool worked = hal.runready(); 96 | bool poll = sdev.pollRadio(); 97 | if(worked == false && poll == false ) { 98 | hal.activity.savePower>(hal); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/HM-RC-2-PBU-FM/HM-RC-2-PBU-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include // after including SPI Library - we can use LibSPI class 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | 20 | // we use a Pro Mini 21 | // Arduino pin for the LED 22 | // D4 == PIN 4 on Pro Mini 23 | #define LED_PIN 4 24 | #define LED_PIN2 5 25 | // Arduino pin for the config button 26 | // B0 == PIN 8 on Pro Mini 27 | #define CONFIG_BUTTON_PIN 8 28 | // Arduino pins for the buttons 29 | // A0,A1,A2,A3 == PIN 14,15,16,17 on Pro Mini 30 | #define BTN1_PIN 14 31 | #define BTN2_PIN 15 32 | 33 | 34 | // number of available peers per channel 35 | #define PEERS_PER_CHANNEL 10 36 | 37 | // all library classes are placed in the namespace 'as' 38 | using namespace as; 39 | 40 | // define all device properties 41 | const struct DeviceInfo PROGMEM devinfo = { 42 | {0x02,0xE0,0x01}, // Device ID 43 | "JPRC2FM001", // Device Serial 44 | {0x00,0xE0}, // Device Model 45 | 0x14, // Firmware Version 46 | as::DeviceType::Remote, // Device Type 47 | {0x00,0x00} // Info Bytes 48 | }; 49 | 50 | /** 51 | * Configure the used hardware 52 | */ 53 | typedef LibSPI<10> SPIType; 54 | typedef Radio RadioType; 55 | typedef DualStatusLed LedType; 56 | typedef AskSin HalType; 57 | class Hal : public HalType { 58 | // extra clock to count button press events 59 | AlarmClock btncounter; 60 | public: 61 | void init (const HMID& id) { 62 | HalType::init(id); 63 | // get new battery value after 50 key press 64 | battery.init(50,btncounter); 65 | battery.low(22); 66 | battery.critical(19); 67 | } 68 | 69 | void sendPeer () { 70 | --btncounter; 71 | } 72 | 73 | bool runready () { 74 | return HalType::runready() || btncounter.runready(); 75 | } 76 | }; 77 | 78 | typedef RemoteChannel ChannelType; 79 | typedef MultiChannelDevice RemoteType; 80 | 81 | Hal hal; 82 | RemoteType sdev(devinfo,0x20); 83 | ConfigButton cfgBtn(sdev); 84 | 85 | void setup () { 86 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 87 | sdev.init(hal); 88 | remoteISR(sdev,1,BTN1_PIN); 89 | remoteISR(sdev,2,BTN2_PIN); 90 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 91 | sdev.initDone(); 92 | } 93 | 94 | void loop() { 95 | bool worked = hal.runready(); 96 | bool poll = sdev.pollRadio(); 97 | if( worked == false && poll == false ) { 98 | hal.activity.savePower>(hal); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /examples/HM-SCI-3-FM/HM-SCI-3-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | // we use a Pro Mini 19 | // Arduino pin for the LED 20 | // D4 == PIN 4 on Pro Mini 21 | #define LED1_PIN 4 22 | #define LED2_PIN 5 23 | // Arduino pin for the config button 24 | // B0 == PIN 8 on Pro Mini 25 | #define CONFIG_BUTTON_PIN 8 26 | 27 | // Anzahl Kanäle (3 - 7) 28 | #define CHANNEL_COUNT 3 29 | // Pin für Kanal 1 2 3 4 5 6 7 30 | uint8_t sens_pins[] = {14, 15, 16, 17, 3, 6, 9 }; 31 | 32 | // number of available peers per channel 33 | #define PEERS_PER_CHANNEL 10 34 | #define CYCLETIME seconds2ticks(60UL*60*16) 35 | 36 | // all library classes are placed in the namespace 'as' 37 | using namespace as; 38 | 39 | // define all device properties 40 | const struct DeviceInfo PROGMEM devinfo = { 41 | {0x07, 0x5F, 0x02}, // Device ID 42 | "JPSCI30002", // Device Serial 43 | {0x00, 0x5F}, // Device Model 44 | 0x01, // Firmware Version 45 | as::DeviceType::Swi, // Device Type 46 | {0x00, 0x00} // Info Bytes 47 | }; 48 | 49 | /** 50 | Configure the used hardware 51 | */ 52 | typedef AvrSPI<10, 11, 12, 13> SPIType; 53 | typedef Radio RadioType; 54 | typedef DualStatusLed LedType; 55 | typedef AskSin, RadioType> BaseHal; 56 | class Hal : public BaseHal { 57 | public: 58 | void init (const HMID& id) { 59 | BaseHal::init(id); 60 | // measure battery every 1h 61 | battery.init(seconds2ticks(60UL * 60), sysclock); 62 | } 63 | } hal; 64 | 65 | DEFREGISTER(Reg0, DREG_INTKEY, DREG_CYCLICINFOMSG, MASTERID_REGS, DREG_TRANSMITTRYMAX) 66 | class SCIList0 : public RegList0 { 67 | public: 68 | SCIList0(uint16_t addr) : RegList0(addr) {} 69 | void defaults () { 70 | clear(); 71 | cycleInfoMsg(true); 72 | transmitDevTryMax(6); 73 | } 74 | }; 75 | 76 | DEFREGISTER(Reg1, CREG_AES_ACTIVE, CREG_MSGFORPOS, CREG_EVENTDELAYTIME, CREG_LEDONTIME, CREG_TRANSMITTRYMAX) 77 | class SCIList1 : public RegList1 { 78 | public: 79 | SCIList1 (uint16_t addr) : RegList1(addr) {} 80 | void defaults () { 81 | clear(); 82 | msgForPosA(1); 83 | msgForPosB(2); 84 | //aesActive(false); 85 | eventDelaytime(0); 86 | //ledOntime(100); 87 | transmitTryMax(6); 88 | } 89 | }; 90 | 91 | typedef TwoStateChannel ChannelType; 92 | typedef StateDevice SCIType; 93 | 94 | SCIType sdev(devinfo, 0x20); 95 | ConfigButton cfgBtn(sdev); 96 | 97 | void setup () { 98 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 99 | sdev.init(hal); 100 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 101 | 102 | for (int i = 0; i < CHANNEL_COUNT; i++) { 103 | sdev.channel(i+1).init(sens_pins[i]); 104 | } 105 | sdev.initDone(); 106 | } 107 | 108 | void loop() { 109 | bool worked = hal.runready(); 110 | bool poll = sdev.pollRadio(); 111 | if ( worked == false && poll == false ) { 112 | // deep discharge protection 113 | // if we drop below critical battery level - switch off all and sleep forever 114 | if ( hal.battery.critical() ) { 115 | // this call will never return 116 | hal.activity.sleepForever(hal); 117 | } 118 | // if nothing to do - go sleep 119 | hal.activity.savePower >(hal); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /examples/HM-SEC-SCO/HM-SEC-SCO.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | #define EI_NOTEXTERNAL 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | // we use a Pro Mini 18 | // Arduino pin for the LED 19 | // D4 == PIN 4 on Pro Mini 20 | #define LED1_PIN 4 21 | #define LED2_PIN 5 22 | // Arduino pin for the config button 23 | // B0 == PIN 8 on Pro Mini 24 | #define CONFIG_BUTTON_PIN 8 25 | 26 | #define SENS_PIN 9 27 | #define SENS_EN_PIN 6 28 | #define SENS_EN_WAIT 50 //millis to wait after enable pin = high 29 | #define SABOTAGE_PIN 7 30 | 31 | // number of available peers per channel 32 | #define PEERS_PER_CHANNEL 10 33 | #define CYCLETIME seconds2ticks(60UL * 60 * 1) 34 | 35 | // all library classes are placed in the namespace 'as' 36 | using namespace as; 37 | 38 | // define all device properties 39 | const struct DeviceInfo PROGMEM devinfo = { 40 | {0x03,0xc7,0x01}, // Device ID 41 | "JPSCO00001", // Device Serial 42 | {0x00,0xC7}, // Device Model 43 | 0x06, // Firmware Version 44 | as::DeviceType::ThreeStateSensor, // Device Type 45 | {0x01,0x00} // Info Bytes 46 | }; 47 | 48 | /** 49 | * Configure the used hardware 50 | */ 51 | typedef AvrSPI<10,11,12,13> SPIType; 52 | typedef Radio RadioType; 53 | typedef DualStatusLed LedType; 54 | typedef AskSin BaseHal; 55 | class Hal : public BaseHal { 56 | public: 57 | void init (const HMID& id) { 58 | BaseHal::init(id); 59 | // measure battery every 1h 60 | battery.init(seconds2ticks(60UL*60),sysclock); 61 | } 62 | } hal; 63 | 64 | DEFREGISTER(Reg0,DREG_INTKEY,DREG_CYCLICINFOMSG,MASTERID_REGS,DREG_TRANSMITTRYMAX,DREG_SABOTAGEMSG) 65 | class SCOList0 : public RegList0 { 66 | public: 67 | SCOList0(uint16_t addr) : RegList0(addr) {} 68 | void defaults () { 69 | clear(); 70 | cycleInfoMsg(true); 71 | transmitDevTryMax(6); 72 | sabotageMsg(true); 73 | } 74 | }; 75 | 76 | DEFREGISTER(Reg1,CREG_AES_ACTIVE,CREG_MSGFORPOS,CREG_EVENTDELAYTIME,CREG_LEDONTIME,CREG_TRANSMITTRYMAX) 77 | class SCOList1 : public RegList1 { 78 | public: 79 | SCOList1 (uint16_t addr) : RegList1(addr) {} 80 | void defaults () { 81 | clear(); 82 | msgForPosA(1); // CLOSED 83 | msgForPosB(2); // OPEN 84 | aesActive(false); 85 | eventDelaytime(0); 86 | ledOntime(100); 87 | transmitTryMax(6); 88 | } 89 | }; 90 | 91 | typedef TwoStateChannel ChannelType; 92 | typedef StateDevice SCOType; 93 | 94 | SCOType sdev(devinfo,0x20); 95 | ConfigButton cfgBtn(sdev); 96 | 97 | void setup () { 98 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 99 | sdev.init(hal); 100 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 101 | sdev.channel(1).init(SENS_PIN, SENS_EN_PIN, SABOTAGE_PIN); 102 | while (hal.battery.current() == 0); 103 | sdev.initDone(); 104 | } 105 | 106 | void loop() { 107 | bool worked = hal.runready(); 108 | bool poll = sdev.pollRadio(); 109 | if( worked == false && poll == false ) { 110 | // deep discharge protection 111 | // if we drop below critical battery level - switch off all and sleep forever 112 | if( hal.battery.critical() ) { 113 | // this call will never return 114 | hal.activity.sleepForever(hal); 115 | } 116 | // if nothing to do - go sleep 117 | hal.activity.savePower >(hal); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /examples/HM-SWI-3-FM/HM-SWI-3-FM.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2020-06-19 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define EI_NOTEXTERNAL 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | // we use a Pro Mini 20 | // Arduino pin for the LED 21 | // D4 == PIN 4 on Pro Mini 22 | #define LED1_PIN 4 23 | #define LED2_PIN 5 24 | // Arduino pin for the config button 25 | // B0 == PIN 8 on Pro Mini 26 | #define CONFIG_BUTTON_PIN 8 27 | 28 | // Anzahl Kanäle (3 - 7) 29 | #define CHANNEL_COUNT 3 30 | #define IN1_PIN 9 31 | #define IN2_PIN 7 32 | #define IN3_PIN 14 33 | 34 | // number of available peers per channel 35 | #define PEERS_PER_CHANNEL 10 36 | 37 | 38 | #define switchISR(device,chan,pin) class device##chan##ISRHandler { \ 39 | public: \ 40 | static void isr () { device.channel(chan).irq(); } \ 41 | }; \ 42 | device.channel(chan).initPin(pin); \ 43 | if( digitalPinToInterrupt(pin) == NOT_AN_INTERRUPT ) \ 44 | enableInterrupt(pin,device##chan##ISRHandler::isr,CHANGE); \ 45 | else \ 46 | attachInterrupt(digitalPinToInterrupt(pin),device##chan##ISRHandler::isr,CHANGE); 47 | 48 | // all library classes are placed in the namespace 'as' 49 | using namespace as; 50 | 51 | // define all device properties 52 | const struct DeviceInfo PROGMEM devinfo = { 53 | {0x00, 0x46, 0x09}, // Device ID 54 | "JPSWI30009", // Device Serial 55 | {0x00, 0x46}, // Device Model 56 | 0x01, // Firmware Version 57 | as::DeviceType::Swi, // Device Type 58 | {0x00, 0x00} // Info Bytes 59 | }; 60 | 61 | /** 62 | Configure the used hardware 63 | */ 64 | typedef AvrSPI<10, 11, 12, 13> SPIType; 65 | typedef Radio RadioType; 66 | typedef DualStatusLed LedType; 67 | typedef AskSin Hal; 68 | Hal hal; 69 | 70 | 71 | class SwiChannel : public Channel { 72 | class pinChangedAlarm : public Alarm { 73 | public: 74 | SwiChannel& swic; 75 | pinChangedAlarm (SwiChannel& _swic) : Alarm(0), swic(_swic) {} 76 | ~pinChangedAlarm () {} 77 | virtual void trigger(__attribute__((unused)) AlarmClock& clock) { 78 | swic.send(); 79 | } 80 | }; 81 | protected: 82 | pinChangedAlarm pca; 83 | private: 84 | bool last; 85 | uint8_t p; 86 | uint8_t cnt; 87 | public: 88 | 89 | typedef Channel BaseChannel; 90 | 91 | SwiChannel () : BaseChannel(), pca(*this), last(false), p(0), cnt(0) {} 92 | virtual ~SwiChannel () {} 93 | 94 | uint8_t status () const { 95 | return 0; 96 | } 97 | 98 | uint8_t flags () const { 99 | return 0; 100 | } 101 | 102 | void irq () { 103 | sysclock.cancel(pca); 104 | sysclock.add(pca); 105 | } 106 | 107 | void initPin (uint8_t pin) { 108 | p = pin; 109 | pinMode(p, INPUT_PULLUP); 110 | last = digitalRead(p); 111 | } 112 | 113 | void send() { 114 | bool s = digitalRead(p); 115 | if (s != last) { 116 | last = s; 117 | DHEX(BaseChannel::number()); 118 | RemoteEventMsg& msg = (RemoteEventMsg&)this->device().message(); 119 | msg.init(this->device().nextcount(),this->number(),cnt++,false,false); 120 | this->device().broadcastPeerEvent(msg,*this); 121 | } 122 | } 123 | }; 124 | 125 | typedef MultiChannelDevice SWIType; 126 | 127 | SWIType sdev(devinfo, 0x20); 128 | ConfigButton cfgBtn(sdev); 129 | 130 | void setup () { 131 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 132 | sdev.init(hal); 133 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 134 | switchISR(sdev, 1, IN1_PIN); 135 | switchISR(sdev, 2, IN2_PIN); 136 | switchISR(sdev, 3, IN3_PIN); 137 | sdev.initDone(); 138 | } 139 | 140 | void loop() { 141 | hal.runready(); 142 | sdev.pollRadio(); 143 | 144 | } 145 | 146 | -------------------------------------------------------------------------------- /examples/HM-Sen-DB-PCB/HM-Sen-DB-PCB.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2017-07-26 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2019-03-01 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define EI_NOTEXTERNAL 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #define LED_PIN 4 20 | #define CONFIG_BUTTON_PIN 8 21 | #define TRG_PIN 9 22 | #define SEND_ON_EDGE FALLING // FALLING -> senden bei Pegelwechsel von HIGH auf LOW 23 | // RISING -> senden bei Pegelwechsel von LOW auf HIGH 24 | 25 | // number of available peers per channel 26 | #define PEERS_PER_CHANNEL 10 27 | 28 | // all library classes are placed in the namespace 'as' 29 | using namespace as; 30 | 31 | // define all device properties 32 | const struct DeviceInfo PROGMEM devinfo = { 33 | {0x00, 0xdc, 0x01}, // Device ID 34 | "HMJPDB0001", // Device Serial 35 | {0x00, 0xDC}, // Device Model 36 | 0x16, // Firmware Version 37 | as::DeviceType::Remote, // Device Type 38 | {0x01, 0x00} // Info Bytes 39 | }; 40 | 41 | /** 42 | Configure the used hardware 43 | */ 44 | typedef AvrSPI<10, 11, 12, 13> SPIType; 45 | typedef Radio RadioType; 46 | typedef StatusLed LedType; 47 | typedef AskSin HalType; 48 | class Hal : public HalType { 49 | // extra clock to count button press events 50 | AlarmClock btncounter; 51 | public: 52 | void init (const HMID& id) { 53 | HalType::init(id); 54 | // get new battery value after 50 key press 55 | battery.init(50, btncounter); 56 | battery.low(22); 57 | battery.critical(19); 58 | } 59 | 60 | void sendPeer () { 61 | --btncounter; 62 | } 63 | 64 | bool runready () { 65 | return HalType::runready() || btncounter.runready(); 66 | } 67 | }; 68 | 69 | DEFREGISTER(DBReg0, MASTERID_REGS, DREG_LEDMODE, DREG_TRANSMITTRYMAX, DREG_LOCALRESETDISABLE) 70 | class DBList0 : public RegList0 { 71 | public: 72 | DBList0(uint16_t addr) : RegList0(addr) {} 73 | void defaults () { 74 | clear(); 75 | ledMode(1); 76 | transmitDevTryMax(6); 77 | localResetDisable(false); 78 | } 79 | }; 80 | 81 | typedef RemoteChannel ChannelType; 82 | typedef MultiChannelDevice RemoteType; 83 | 84 | Hal hal; 85 | RemoteType sdev(devinfo, 0x20); 86 | ConfigButton cfgBtn(sdev); 87 | 88 | volatile bool isr = false; 89 | static void isr1 () { 90 | isr = true; 91 | } 92 | 93 | void setup () { 94 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 95 | sdev.init(hal); 96 | 97 | pinMode(TRG_PIN, INPUT_PULLUP); 98 | if ( digitalPinToInterrupt(TRG_PIN) == NOT_AN_INTERRUPT ) 99 | enableInterrupt(TRG_PIN, isr1, SEND_ON_EDGE); 100 | else 101 | attachInterrupt(digitalPinToInterrupt(TRG_PIN), isr1, SEND_ON_EDGE); 102 | 103 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 104 | sdev.initDone(); 105 | } 106 | 107 | void loop() { 108 | bool worked = hal.runready(); 109 | bool poll = sdev.pollRadio(); 110 | if ( worked == false && poll == false ) { 111 | hal.activity.savePower>(hal); 112 | } 113 | 114 | if (isr == true) { 115 | isr = false; 116 | _delay_ms(50); //DEBOUNCE 117 | sdev.channel(1).state(Button::released); 118 | } 119 | 120 | } 121 | 122 | -------------------------------------------------------------------------------- /examples/HM-Sys-sRP-Pl/README.md: -------------------------------------------------------------------------------- 1 | # WIP 2 | 3 | ### :white_check_mark: DONE 4 | - save sender/receiver addresses in List2
5 | - repeat BCAST messages
6 | - repeat BIDI messages
7 | - send ACK to sender
8 | 9 | ### :x: TODO 10 | 11 | -------------------------------------------------------------------------------- /examples/HM-WDS30-T-O-NTC/HM-WDS30-T-O-NTC.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | // Arduino Pro mini 8 Mhz 20 | // Arduino pin for the config button 21 | #define CONFIG_BUTTON_PIN 8 22 | #define LED_PIN 4 23 | 24 | // number of available peers per channel 25 | #define PEERS_PER_CHANNEL 6 26 | 27 | // send all xx seconds 28 | #define MSG_INTERVAL 180 29 | 30 | // temperature where ntc has resistor value of R0 31 | #define NTC_T0 25 32 | // resistance both of ntc and known resistor 33 | #define NTC_R0 10000 34 | // b value of ntc (see datasheet) 35 | #define NTC_B 3435 36 | 37 | // number of additional bits by oversampling (should be between 0 and 6, highly increases number of measurements) 38 | #define NTC_OVERSAMPLING 2 39 | 40 | // pin to measure ntc 41 | #define NTC_SENSE_PIN 14 42 | // pin to power ntc (or 0 if connected to vcc) 43 | #define NTC_ACTIVATOR_PIN 6 44 | 45 | // all library classes are placed in the namespace 'as' 46 | using namespace as; 47 | 48 | // define all device properties 49 | const struct DeviceInfo PROGMEM devinfo = { 50 | {0x00, 0x3e, 0x01}, // Device ID 51 | "ARTO000001", // Device Serial 52 | {0x00, 0x3e}, // Device Model 53 | 0x10, // Firmware Version 54 | as::DeviceType::THSensor, // Device Type 55 | {0x01, 0x01} // Info Bytes 56 | }; 57 | 58 | /** 59 | Configure the used hardware 60 | */ 61 | typedef AvrSPI<10, 11, 12, 13> SPIType; 62 | typedef Radio RadioType; 63 | typedef StatusLed LedType; 64 | typedef AskSin Hal; 65 | Hal hal; 66 | 67 | class WeatherEventMsg : public Message { 68 | public: 69 | void init(uint8_t msgcnt, int temp, bool batlow) { 70 | uint8_t t1 = (temp >> 8) & 0x7f; 71 | uint8_t t2 = temp & 0xff; 72 | if ( batlow == true ) { 73 | t1 |= 0x80; // set bat low bit 74 | } 75 | Message::init(0xb, msgcnt, 0x70, BIDI | WKMEUP, t1, t2); 76 | } 77 | }; 78 | 79 | class WeatherChannel : public Channel, public Alarm { 80 | 81 | WeatherEventMsg msg; 82 | 83 | Ntc ntc; 84 | 85 | public: 86 | WeatherChannel () : Channel(), Alarm(5) {} 87 | virtual ~WeatherChannel () {} 88 | 89 | 90 | // here we do the measurement 91 | void measure () { 92 | DPRINT("Measure...\n"); 93 | ntc.measure(); 94 | DPRINT("T = ");DDECLN(ntc.temperature()); 95 | } 96 | 97 | virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) { 98 | uint8_t msgcnt = device().nextcount(); 99 | // reactivate for next measure 100 | tick = delay(); 101 | clock.add(*this); 102 | measure(); 103 | 104 | msg.init(msgcnt, ntc.temperature(), device().battery().low()); 105 | if (msgcnt % 20 == 1) device().sendPeerEvent(msg, *this); else device().broadcastEvent(msg, *this); 106 | } 107 | 108 | uint32_t delay () { 109 | return seconds2ticks(MSG_INTERVAL); 110 | } 111 | void setup(Device* dev, uint8_t number, uint16_t addr) { 112 | Channel::setup(dev, number, addr); 113 | ntc.init(); 114 | sysclock.add(*this); 115 | } 116 | 117 | uint8_t status () const { 118 | return 0; 119 | } 120 | 121 | uint8_t flags () const { 122 | return 0; 123 | } 124 | }; 125 | 126 | typedef MultiChannelDevice WeatherType; 127 | WeatherType sdev(devinfo, 0x20); 128 | ConfigButton cfgBtn(sdev); 129 | 130 | void setup () { 131 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 132 | sdev.init(hal); 133 | hal.initBattery(60UL * 60, 22, 19); 134 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 135 | sdev.initDone(); 136 | } 137 | 138 | void loop() { 139 | bool worked = hal.runready(); 140 | bool poll = sdev.pollRadio(); 141 | if ( worked == false && poll == false ) { 142 | hal.activity.savePower>(hal); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/Images/Aufgehaengt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-WDS40-TH-I-SHT10/Images/Aufgehaengt.jpg -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/Images/Deckel_und_Boden.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-WDS40-TH-I-SHT10/Images/Deckel_und_Boden.jpg -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/Images/Innen_Disp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-WDS40-TH-I-SHT10/Images/Innen_Disp.jpg -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/Images/Innen_Elektronik.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-WDS40-TH-I-SHT10/Images/Innen_Elektronik.jpg -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/Images/Temperaturanzeige.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/HM-WDS40-TH-I-SHT10/Images/Temperaturanzeige.jpg -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/README.md: -------------------------------------------------------------------------------- 1 | # HM-WDS40-TH-I-SHT10 mit LCD Display 2 | 3 | #### weitere Infos: https://homematic-forum.de/forum/viewtopic.php?f=76&t=53444 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT10/lcd.h: -------------------------------------------------------------------------------- 1 | #ifndef __lcd__h 2 | #define __lcd__h 3 | 4 | class Lcd { 5 | public: 6 | //public functions 7 | void begin(int csPin, int wrPin, int dataPin); //initiate the LCD 8 | void clear(); //Clear all number on LCD 9 | void printH(uint8_t number); //diplay integer number 10 | void printC(int16_t number); //display the temperature in C with floating number 11 | void printLowBat(); 12 | 13 | private: 14 | //private functions 15 | void wrCMD(byte command); //sending command to LCD 16 | void update(int type); //sending data to LCD. Type = 1; send integer number; type =2 send floating number; type =3 sending time format; type =4 send temp in C. 17 | int dotPos(float number); 18 | 19 | //private variable 20 | char localBuffer[4]={}; //store the mapping segment number 21 | byte dispNumArray[4]={}; //store the data that will use to send to LCD RAM 22 | byte bufferMem; 23 | int _csPin; 24 | int _wrPin; 25 | int _dataPin; 26 | int _dotPosVal; 27 | }; 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SHT31/HM-WDS40-TH-I-SHT31.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | // ci-test=yes board=328p aes=no 6 | 7 | // define this to read the device id, serial and device type from bootloader section 8 | // #define USE_OTA_BOOTLOADER 9 | 10 | #define EI_NOTEXTERNAL 11 | #include 12 | #include 13 | #include 14 | #include //https://github.com/adafruit/Adafruit_SHT31 15 | 16 | #include 17 | 18 | // we use a Pro Mini 19 | // Arduino pin for the LED 20 | // D4 == PIN 4 on Pro Mini 21 | #define LED_PIN 4 22 | // Arduino pin for the config button 23 | // B0 == PIN 8 on Pro Mini 24 | #define CONFIG_BUTTON_PIN 8 25 | 26 | 27 | //----------------------------------------------------------------------------------------- 28 | 29 | //Korrektur von Temperatur und Luftfeuchte 30 | //Einstellbarer OFFSET für Temperatur -> gemessene Temp +/- Offset = Angezeigte Temp. 31 | #define OFFSETtemp 0 //z.B -50 ≙ -5°C / 50 ≙ +5°C 32 | 33 | //Einstellbarer OFFSET für Luftfeuchte -> gemessene Luftf. +/- Offset = Angezeigte Luftf. 34 | #define OFFSEThumi 0 //z.B -10 ≙ -10%RF / 10 ≙ +10%RF 35 | 36 | //----------------------------------------------------------------------------------------- 37 | 38 | // number of available peers per channel 39 | #define PEERS_PER_CHANNEL 6 40 | 41 | //seconds between sending messages 42 | #define MSG_INTERVAL 180 43 | 44 | // all library classes are placed in the namespace 'as' 45 | using namespace as; 46 | 47 | // define all device properties 48 | const struct DeviceInfo PROGMEM devinfo = { 49 | {0x34, 0x3f, 0x00}, // Device ID 50 | "JPTH10I000", // Device Serial 51 | //{0x00, 0x3d}, // Device Model Outdoor 52 | {0x00, 0x3f}, // Device Model Indoor 53 | 0x10, // Firmware Version 54 | as::DeviceType::THSensor, // Device Type 55 | {0x01, 0x00} // Info Bytes 56 | }; 57 | 58 | /** 59 | Configure the used hardware 60 | */ 61 | typedef AvrSPI<10, 11, 12, 13> SPIType; 62 | typedef Radio RadioType; 63 | typedef StatusLed LedType; 64 | typedef AskSin Hal; 65 | Hal hal; 66 | 67 | class WeatherEventMsg : public Message { 68 | public: 69 | void init(uint8_t msgcnt, int16_t temp, uint8_t humidity, bool batlow) { 70 | uint8_t t1 = (temp >> 8) & 0x7f; 71 | uint8_t t2 = temp & 0xff; 72 | if ( batlow == true ) { 73 | t1 |= 0x80; // set bat low bit 74 | } 75 | Message::init(0xc, msgcnt, 0x70, BIDI | WKMEUP, t1, t2); 76 | pload[0] = humidity; 77 | } 78 | }; 79 | 80 | class WeatherChannel : public Channel, public Alarm { 81 | 82 | WeatherEventMsg msg; 83 | int16_t temp; 84 | uint8_t humidity; 85 | Sht31<> sht31; 86 | uint16_t millis; 87 | 88 | public: 89 | WeatherChannel () : Channel(), Alarm(5), temp(0), humidity(0), millis(0) {} 90 | virtual ~WeatherChannel () {} 91 | 92 | 93 | // here we do the measurement 94 | void measure () { 95 | DPRINT("Measure...\n"); 96 | sht31.measure(); 97 | temp = sht31.temperature(); 98 | humidity = sht31.humidity(); 99 | DPRINT("T/H = " + String(temp+OFFSETtemp) + "/" + String(humidity+OFFSEThumi) + "\n"); 100 | } 101 | 102 | virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) { 103 | uint8_t msgcnt = device().nextcount(); 104 | // reactivate for next measure 105 | tick = delay(); 106 | clock.add(*this); 107 | measure(); 108 | 109 | msg.init(msgcnt, temp+OFFSETtemp, humidity+OFFSEThumi, device().battery().low()); 110 | if (msgcnt % 20 == 1) device().sendPeerEvent(msg, *this); else device().broadcastEvent(msg, *this); 111 | } 112 | 113 | uint32_t delay () { 114 | return seconds2ticks(MSG_INTERVAL); 115 | } 116 | void setup(Device* dev, uint8_t number, uint16_t addr) { 117 | Channel::setup(dev, number, addr); 118 | sht31.init(); 119 | sysclock.add(*this); 120 | } 121 | 122 | uint8_t status () const { 123 | return 0; 124 | } 125 | 126 | uint8_t flags () const { 127 | return 0; 128 | } 129 | }; 130 | 131 | typedef MultiChannelDevice WeatherType; 132 | WeatherType sdev(devinfo, 0x20); 133 | ConfigButton cfgBtn(sdev); 134 | 135 | void setup () { 136 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 137 | sdev.init(hal); 138 | hal.initBattery(60UL * 60, 22, 19); 139 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 140 | sdev.initDone(); 141 | } 142 | 143 | void loop() { 144 | bool worked = hal.runready(); 145 | bool poll = sdev.pollRadio(); 146 | if ( worked == false && poll == false ) { 147 | hal.activity.savePower>(hal); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /examples/HM-WDS40-TH-I-SI7021/HM-WDS40-TH-I-SI7021.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2018-09-13 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define EI_NOTEXTERNAL 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | //https://github.com/jayjayuk/Si7021-Humidity-And-Temperature-Sensor-Library 18 | #include 19 | 20 | // we use a Pro Mini 21 | // Arduino pin for the LED 22 | // D4 == PIN 4 on Pro Mini 23 | #define LED_PIN 4 24 | // Arduino pin for the config button 25 | // B0 == PIN 8 on Pro Mini 26 | #define CONFIG_BUTTON_PIN 8 27 | 28 | //----------------------------------------------------------------------------------------- 29 | 30 | //Korrektur von Temperatur und Luftfeuchte 31 | //Einstellbarer OFFSET für Temperatur -> gemessene Temp +/- Offset = Angezeigte Temp. 32 | #define OFFSETtemp 0 //z.B -50 ≙ -5°C / 50 ≙ +5°C 33 | 34 | //Einstellbarer OFFSET für Luftfeuchte -> gemessene Luftf. +/- Offset = Angezeigte Luftf. 35 | #define OFFSEThumi 0 //z.B -10 ≙ -10%RF / 10 ≙ +10%RF 36 | 37 | //----------------------------------------------------------------------------------------- 38 | 39 | // number of available peers per channel 40 | #define PEERS_PER_CHANNEL 6 41 | 42 | //seconds between sending messages 43 | #define MSG_INTERVAL 180 44 | 45 | // all library classes are placed in the namespace 'as' 46 | using namespace as; 47 | 48 | // define all device properties 49 | const struct DeviceInfo PROGMEM devinfo = { 50 | {0x00, 0x3f, 0x00}, // Device ID 51 | "JPTH40I000", // Device Serial 52 | {0x00, 0x3f}, // Device Model Indoor 53 | 0x10, // Firmware Version 54 | as::DeviceType::THSensor, // Device Type 55 | {0x01, 0x00} // Info Bytes 56 | }; 57 | 58 | /** 59 | Configure the used hardware 60 | */ 61 | typedef AvrSPI<10, 11, 12, 13> SPIType; 62 | typedef Radio RadioType; 63 | typedef StatusLed LedType; 64 | typedef AskSin Hal; 65 | Hal hal; 66 | 67 | class WeatherEventMsg : public Message { 68 | public: 69 | void init(uint8_t msgcnt, int16_t temp, uint8_t humidity, bool batlow) { 70 | uint8_t t1 = (temp >> 8) & 0x7f; 71 | uint8_t t2 = temp & 0xff; 72 | if ( batlow == true ) { 73 | t1 |= 0x80; // set bat low bit 74 | } 75 | Message::init(0xc, msgcnt, 0x70, BIDI | WKMEUP, t1, t2); 76 | pload[0] = humidity; 77 | } 78 | }; 79 | 80 | class WeatherChannel : public Channel, public Alarm { 81 | 82 | WeatherEventMsg msg; 83 | 84 | Si7021 si7021; 85 | uint16_t millis; 86 | 87 | public: 88 | WeatherChannel () : Channel(), Alarm(5), millis(0) {} 89 | virtual ~WeatherChannel () {} 90 | 91 | 92 | // here we do the measurement 93 | void measure () { 94 | DPRINT("Measure...\n"); 95 | si7021.measure(); 96 | DPRINT("T/H = ");DDEC(si7021.temperature()+OFFSETtemp);DPRINT("/");DDECLN(si7021.humidity()+OFFSEThumi); 97 | } 98 | 99 | virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) { 100 | uint8_t msgcnt = device().nextcount(); 101 | // reactivate for next measure 102 | tick = delay(); 103 | clock.add(*this); 104 | measure(); 105 | 106 | msg.init(msgcnt, si7021.temperature()+OFFSETtemp,si7021.humidity()+OFFSEThumi, device().battery().low()); 107 | if (msgcnt % 20 == 1) device().sendPeerEvent(msg, *this); else device().broadcastEvent(msg, *this); 108 | } 109 | 110 | uint32_t delay () { 111 | return seconds2ticks(MSG_INTERVAL); 112 | } 113 | void setup(Device* dev, uint8_t number, uint16_t addr) { 114 | Channel::setup(dev, number, addr); 115 | si7021.init(); 116 | sysclock.add(*this); 117 | } 118 | 119 | uint8_t status () const { 120 | return 0; 121 | } 122 | 123 | uint8_t flags () const { 124 | return 0; 125 | } 126 | }; 127 | 128 | typedef MultiChannelDevice WeatherType; 129 | WeatherType sdev(devinfo, 0x20); 130 | ConfigButton cfgBtn(sdev); 131 | 132 | void setup () { 133 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 134 | sdev.init(hal); 135 | hal.initBattery(60UL * 60, 22, 19); 136 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 137 | sdev.initDone(); 138 | } 139 | 140 | void loop() { 141 | bool worked = hal.runready(); 142 | bool poll = sdev.pollRadio(); 143 | if ( worked == false && poll == false ) { 144 | hal.activity.savePower>(hal); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /examples/RWE/HM-LC-Bl1PBU-FM_ISR2.0/HM-LC-Bl1PBU-FM_ISR2.0.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2017-12-14 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | 6 | #define USE_HW_SERIAL 7 | 8 | //#define HIDE_IGNORE_MSG 9 | #define NDEBUG 10 | 11 | #include 12 | TwoWireSoft Wire(SDA, SCL); 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define DIR_RELAY_PIN PB8 22 | #define ON_RELAY_PIN PB7 23 | #define BTN_PIN_1 PB11 24 | #define BTN_PIN_2 PA2 25 | 26 | #define LED1_PIN PA0 27 | #define LED2_PIN PA1 28 | #define CONFIG_BUTTON_PIN PC13 29 | 30 | #define TRX_CS PC14 31 | #define TRX_GDO0 PC15 32 | 33 | // number of available peers per channel 34 | #define PEERS_PER_CHANNEL 12 35 | #define PEERS_PER_BlindChannel 8 36 | 37 | // all library classes are placed in the namespace 'as' 38 | using namespace as; 39 | 40 | // define all device properties 41 | const struct DeviceInfo PROGMEM devinfo = { 42 | {0xaf,0x00,0x01}, // Device ID 43 | "FS20RSU201", // Device Serial 44 | {0x00,0x6A}, // Device Model 45 | 0x24, // Firmware Version 46 | as::DeviceType::BlindActuator, // Device Type 47 | {0x01,0x00} // Info Bytes 48 | }; // 49 | 50 | /** 51 | * Configure the used hardware 52 | */ 53 | 54 | typedef LibSPI SPIType; 55 | typedef CC1101Radio RadioType; 56 | typedef DualStatusLed LedType; 57 | typedef AskSin Hal; 58 | 59 | DEFREGISTER(BlindReg0,MASTERID_REGS,DREG_INTKEY,DREG_CONFBUTTONTIME,DREG_LOCALRESETDISABLE) 60 | 61 | class BlindList0 : public RegList0 { 62 | public: 63 | BlindList0 (uint16_t addr) : RegList0(addr) {} 64 | void defaults () { 65 | clear(); 66 | // intKeyVisible(false); 67 | confButtonTime(0xff); 68 | // localResetDisable(false); 69 | } 70 | }; 71 | 72 | class BlChannel : public ActorChannel { 73 | public: 74 | typedef ActorChannel BaseChannel; 75 | 76 | BlChannel () {} 77 | virtual ~BlChannel () {} 78 | 79 | virtual void switchState(uint8_t oldstate,uint8_t newstate, uint32_t stateDelay) { 80 | BaseChannel::switchState(oldstate, newstate, stateDelay); 81 | if( newstate == AS_CM_JT_RAMPON && stateDelay > 0 ) { 82 | motorUp(); 83 | } 84 | else if( newstate == AS_CM_JT_RAMPOFF && stateDelay > 0 ) { 85 | motorDown(); 86 | } 87 | else { 88 | motorStop(); 89 | } 90 | } 91 | 92 | void motorUp () { 93 | digitalWrite(DIR_RELAY_PIN,HIGH); 94 | digitalWrite(ON_RELAY_PIN,HIGH); 95 | } 96 | 97 | void motorDown () { 98 | digitalWrite(DIR_RELAY_PIN,LOW); 99 | digitalWrite(ON_RELAY_PIN,HIGH); 100 | } 101 | 102 | void motorStop () { 103 | digitalWrite(DIR_RELAY_PIN,LOW); 104 | digitalWrite(ON_RELAY_PIN,LOW); 105 | } 106 | 107 | void init () { 108 | pinMode(ON_RELAY_PIN,OUTPUT); 109 | pinMode(DIR_RELAY_PIN,OUTPUT); 110 | motorStop(); 111 | BaseChannel::init(); 112 | } 113 | }; 114 | 115 | // setup the device with channel type and number of channels 116 | typedef MultiChannelDevice BlindType; 117 | 118 | Hal hal; 119 | BlindType sdev(devinfo,0x20); 120 | ConfigButton cfgBtn(sdev); 121 | InternalButton btnup(sdev,1); 122 | InternalButton btndown(sdev,2); 123 | 124 | void initPeerings (bool first) { 125 | // create internal peerings - CCU2 needs this 126 | if( first == true ) { 127 | sdev.channel(1).peer(btnup.peer(),btndown.peer()); 128 | } 129 | } 130 | 131 | void setup () { 132 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 133 | //storage().setByte(0,0); 134 | bool first = sdev.init(hal); 135 | sdev.channel(1).init(); 136 | 137 | // sdev.channel(1).getList1().refRunningTimeBottomTop(270); 138 | // sdev.channel(1).getList1().refRunningTimeTopBottom(270); 139 | 140 | buttonISR(cfgBtn,CONFIG_BUTTON_PIN); 141 | buttonISR(btnup,BTN_PIN_1); 142 | buttonISR(btndown,BTN_PIN_2); 143 | 144 | initPeerings(first); 145 | sdev.initDone(); 146 | } 147 | 148 | void loop() { 149 | bool worked = hal.runready(); 150 | bool poll = sdev.pollRadio(); 151 | if( worked == false && poll == false ) { 152 | // hal.activity.savePower >(hal); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /examples/RWE/HM-LC-Sw1-Pl-DN-R1_PSS/HM-LC-Sw1-Pl-DN-R1_PSS.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2021-01-29 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define EI_NOTEXTERNAL 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | #define LED_PIN 8 19 | #define CONFIG_BUTTON_PIN 0 20 | #define RELAY1_PIN A0 21 | 22 | 23 | // number of available peers per channel 24 | #define PEERS_PER_CHANNEL 8 25 | 26 | 27 | // all library classes are placed in the namespace 'as' 28 | using namespace as; 29 | 30 | // define all device properties 31 | const struct DeviceInfo PROGMEM devinfo = { 32 | {0x01, 0xd8, 0xa9}, // Device ID 33 | "JPPSS00001", // Device Serial 34 | {0x00,0xd8}, // Device Model 35 | 0x26, // Firmware Version 36 | as::DeviceType::Switch, // Device Type 37 | {0x01, 0x00} // Info Bytes 38 | }; 39 | 40 | /** 41 | Configure the used hardware 42 | */ 43 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 44 | typedef AskSin, NoBattery, Radio > Hal; 45 | 46 | class PSSSwitchChannel : public ActorChannel { 47 | protected: 48 | typedef ActorChannel BaseChannel; 49 | uint8_t pin; 50 | 51 | public: 52 | PSSSwitchChannel () : BaseChannel(), pin(0) {} 53 | virtual ~PSSSwitchChannel() {} 54 | 55 | void init (uint8_t p,bool value=false) { 56 | pin=p; 57 | ArduinoPins::setOutput(pin); 58 | typename BaseChannel::List1 l1 = BaseChannel::getList1(); 59 | this->set(l1.powerUpAction() == true ? 200 : 0, 0, 0xffff ); 60 | this->changed(true); 61 | } 62 | 63 | uint8_t flags () const { 64 | return BaseChannel::flags(); 65 | } 66 | 67 | 68 | virtual void switchState(__attribute__((unused)) uint8_t oldstate,uint8_t newstate,__attribute__((unused)) uint32_t delay) { 69 | if( newstate == AS_CM_JT_ON ) { 70 | ArduinoPins::setHigh(pin); 71 | device().led().invert(true); 72 | } 73 | else if ( newstate == AS_CM_JT_OFF ) { 74 | ArduinoPins::setLow(pin); 75 | device().led().invert(false); 76 | } 77 | this->changed(true); 78 | } 79 | }; 80 | 81 | typedef PSSSwitchChannel swc; 82 | 83 | typedef MultiChannelDevice SwitchType; 84 | 85 | Hal hal; 86 | SwitchType sdev(devinfo, 0x20); 87 | ConfigToggleButton cfgBtn(sdev); 88 | 89 | void initPeerings (bool first) { 90 | // create internal peerings - CCU2 needs this 91 | if ( first == true ) { 92 | HMID devid; 93 | sdev.getDeviceID(devid); 94 | for ( uint8_t i = 1; i <= sdev.channels(); ++i ) { 95 | Peer ipeer(devid, i); 96 | sdev.channel(i).peer(ipeer); 97 | } 98 | } 99 | } 100 | 101 | void setup () { 102 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 103 | bool first = sdev.init(hal); 104 | sdev.channels(1); 105 | sdev.channel(1).init(RELAY1_PIN, false); 106 | 107 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 108 | 109 | initPeerings(first); 110 | sdev.initDone(); 111 | } 112 | 113 | void loop() { 114 | bool worked = hal.runready(); 115 | bool poll = sdev.pollRadio(); 116 | if ( worked == false && poll == false ) { 117 | hal.activity.savePower >(hal); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /examples/RWE/HM-LC-Sw1PBU-FM_ISS2/HM-LC-Sw1PBU-FM_ISS2.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2021-01-30 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=644p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | // Arduino IDE Settings 12 | // use support for 644PA from MightyCore: https://github.com/MCUdude/MightyCore 13 | // settings: 14 | // Board: ATMega644 15 | // Pinout: Standard 16 | // Clock: 8MHz external 17 | // Variant: 644P / 644PA 18 | // BOD: 2.7V 19 | // Compiler LTO: Enabled 20 | 21 | #define NDEBUG 22 | 23 | #define EI_NOTEXTERNAL 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define RELAY_PIN 12 //PD4 31 | #define BTN_PIN_1 14 //PD6 32 | #define BTN_PIN_2 8 //PD0 33 | #define LED_PIN 0 //PB0 34 | #define CONFIG_BUTTON_PIN 15 //PD7 35 | #define CS_PIN 4 //PB4 36 | #define GDO0_PIN 10 //PD2 37 | 38 | 39 | // number of available peers per channel 40 | #define PEERS_PER_CHANNEL 10 41 | 42 | // all library classes are placed in the namespace 'as' 43 | using namespace as; 44 | 45 | // define all device properties 46 | const struct DeviceInfo PROGMEM devinfo = { 47 | {0x00, 0x69, 0x51}, // Device ID 48 | "JPRWEISS21", // Device Serial 49 | {0x00, 0x69}, // Device Model 50 | 0x28, // Firmware Version 51 | as::DeviceType::Switch, // Device Type 52 | {0x01, 0x00} // Info Bytes 53 | }; 54 | /** 55 | Configure the used hardware 56 | */ 57 | typedef LibSPI SPIType; 58 | typedef Radio RadioType; 59 | typedef StatusLed LedType; 60 | typedef AskSin Hal; 61 | Hal hal; 62 | 63 | class ISS2SwitchChannel : public ActorChannel { 64 | protected: 65 | typedef ActorChannel BaseChannel; 66 | uint8_t pin; 67 | 68 | public: 69 | ISS2SwitchChannel () : BaseChannel(), pin(0) {} 70 | virtual ~ISS2SwitchChannel() {} 71 | 72 | void init (uint8_t p,bool value=false) { 73 | pin=p; 74 | ArduinoPins::setOutput(pin); 75 | typename BaseChannel::List1 l1 = BaseChannel::getList1(); 76 | this->set(l1.powerUpAction() == true ? 200 : 0, 0, 0xffff ); 77 | this->changed(true); 78 | } 79 | 80 | uint8_t flags () const { 81 | return BaseChannel::flags(); 82 | } 83 | 84 | 85 | virtual void switchState(__attribute__((unused)) uint8_t oldstate,uint8_t newstate,__attribute__((unused)) uint32_t delay) { 86 | if( newstate == AS_CM_JT_ON ) { 87 | ArduinoPins::setHigh(pin); 88 | device().led().invert(true); 89 | } 90 | else if ( newstate == AS_CM_JT_OFF ) { 91 | ArduinoPins::setLow(pin); 92 | device().led().invert(false); 93 | } 94 | this->changed(true); 95 | } 96 | }; 97 | 98 | typedef ISS2SwitchChannel swc; 99 | typedef MultiChannelDevice SwitchType; 100 | 101 | SwitchType sdev(devinfo,0x20); 102 | ConfigButton cfgBtn(sdev); 103 | InternalButton btn1(sdev,1); 104 | InternalButton btn2(sdev,2); 105 | 106 | void initPeerings (bool first) { 107 | if ( first == true ) { 108 | HMID devid; 109 | sdev.getDeviceID(devid); 110 | sdev.channel(1).peer(Peer(devid, 1), Peer(devid, 2)); 111 | } 112 | } 113 | 114 | void setup () { 115 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 116 | bool first = sdev.init(hal); 117 | sdev.channel(1).init(RELAY_PIN, false); 118 | 119 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 120 | buttonISR(btn1,BTN_PIN_1); 121 | buttonISR(btn2,BTN_PIN_2); 122 | 123 | initPeerings(first); 124 | storage().store(); 125 | 126 | sdev.initDone(); 127 | } 128 | 129 | void loop() { 130 | bool worked = hal.runready(); 131 | bool poll = sdev.pollRadio(); 132 | if ( worked == false && poll == false ) { 133 | hal.activity.savePower >(hal); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /examples/RWE/HM-PB-2-FM_ISC2/HM-PB-2-FM_ISC2.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2021-02-12 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | // 2021-02-12 re-vo-lution Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 6 | //- ----------------------------------------------------------------------------------------------------------------------- 7 | // ci-test=yes board=328p aes=no 8 | 9 | // define this to read the device id, serial and device type from bootloader section 10 | // #define USE_OTA_BOOTLOADER 11 | 12 | #define EI_NOTEXTERNAL 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #define LED_PIN 8 21 | #define CONFIG_BUTTON_PIN 0 22 | #define BTN1_PIN 15 23 | #define BTN2_PIN 14 24 | #define CC1101_PWR_PIN 5 25 | #define CC1101_GDO0_PIN 2 26 | 27 | 28 | // number of available peers per channel 29 | #define PEERS_PER_CHANNEL 16 30 | 31 | // all library classes are placed in the namespace 'as' 32 | using namespace as; 33 | 34 | // define all device properties 35 | const struct DeviceInfo PROGMEM devinfo = { 36 | {0x02, 0xBF, 0x01}, // Device ID - 01 vergeben 37 | "RWEISC2001", // Device Serial - 01 vergeben 38 | {0x00, 0xBF}, // Device Model 39 | 0x14, // Firmware Version 40 | as::DeviceType::Remote, // Device Type 41 | {0x00, 0x00} // Info Bytes 42 | }; 43 | 44 | /** 45 | Configure the used hardware 46 | */ 47 | typedef AvrSPI<10, 11, 12, 13> RadioSPI; 48 | typedef Radio RadioType; 49 | typedef StatusLed LedType; 50 | typedef AskSin Hal; 51 | 52 | typedef RemoteChannel ChannelType; 53 | typedef MultiChannelDevice RemoteType; 54 | 55 | Hal hal; 56 | RemoteType sdev(devinfo, 0x20); 57 | ConfigButton cfgBtn(sdev); 58 | 59 | void setup () { 60 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 61 | sdev.init(hal); 62 | hal.battery.init(); 63 | hal.battery.low(22); 64 | hal.battery.critical(19); 65 | 66 | remoteISR(sdev, 1, BTN1_PIN); 67 | remoteISR(sdev, 2, BTN2_PIN); 68 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 69 | 70 | while (hal.battery.current() == 0); 71 | 72 | sdev.initDone(); 73 | } 74 | 75 | void loop() { 76 | bool worked = hal.runready(); 77 | bool poll = sdev.pollRadio(); 78 | if (worked == false && poll == false ) { 79 | hal.activity.savePower>(hal); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /examples/RWE/HM-PB-2-FM_WSC2/schematic/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp112sdl/Beispiel_AskSinPP/79e1d10c0cf542686870144b3836098745efa5b2/examples/RWE/HM-PB-2-FM_WSC2/schematic/schematic.png -------------------------------------------------------------------------------- /examples/RWE/HM-PB-2-FM_WSC2/schematic/wsc2.kicad_pcb: -------------------------------------------------------------------------------- 1 | (kicad_pcb (version 4) (host kicad "dummy file") ) 2 | -------------------------------------------------------------------------------- /examples/RWE/HM-PB-2-FM_WSC2/schematic/wsc2.kicad_prl: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "active_layer": 0, 4 | "active_layer_preset": "", 5 | "auto_track_width": true, 6 | "hidden_nets": [], 7 | "high_contrast_mode": 0, 8 | "net_color_mode": 1, 9 | "opacity": { 10 | "pads": 1.0, 11 | "tracks": 1.0, 12 | "vias": 1.0, 13 | "zones": 0.6 14 | }, 15 | "ratsnest_display_mode": 0, 16 | "selection_filter": { 17 | "dimensions": true, 18 | "footprints": true, 19 | "graphics": true, 20 | "keepouts": true, 21 | "lockedItems": true, 22 | "otherItems": true, 23 | "pads": true, 24 | "text": true, 25 | "tracks": true, 26 | "vias": true, 27 | "zones": true 28 | }, 29 | "visible_items": [ 30 | 0, 31 | 1, 32 | 2, 33 | 3, 34 | 4, 35 | 5, 36 | 8, 37 | 9, 38 | 10, 39 | 11, 40 | 12, 41 | 13, 42 | 14, 43 | 15, 44 | 16, 45 | 17, 46 | 18, 47 | 19, 48 | 20, 49 | 21, 50 | 22, 51 | 23, 52 | 24, 53 | 25, 54 | 26, 55 | 27, 56 | 28, 57 | 29, 58 | 30, 59 | 32, 60 | 33, 61 | 34, 62 | 35, 63 | 36 64 | ], 65 | "visible_layers": "fffffff_ffffffff", 66 | "zone_display_mode": 0 67 | }, 68 | "meta": { 69 | "filename": "wsc2.kicad_prl", 70 | "version": 3 71 | }, 72 | "project": { 73 | "files": [] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /examples/RWE/HM-PB-2-FM_WSC2/schematic/wsc2.kicad_pro: -------------------------------------------------------------------------------- 1 | { 2 | "board": { 3 | "design_settings": { 4 | "defaults": { 5 | "board_outline_line_width": 0.1, 6 | "copper_line_width": 0.2, 7 | "copper_text_size_h": 1.5, 8 | "copper_text_size_v": 1.5, 9 | "copper_text_thickness": 0.3, 10 | "other_line_width": 0.15, 11 | "silk_line_width": 0.15, 12 | "silk_text_size_h": 1.0, 13 | "silk_text_size_v": 1.0, 14 | "silk_text_thickness": 0.15 15 | }, 16 | "diff_pair_dimensions": [], 17 | "drc_exclusions": [], 18 | "rules": { 19 | "solder_mask_clearance": 0.0, 20 | "solder_mask_min_width": 0.0 21 | }, 22 | "track_widths": [], 23 | "via_dimensions": [] 24 | }, 25 | "layer_presets": [] 26 | }, 27 | "boards": [], 28 | "cvpcb": { 29 | "equivalence_files": [] 30 | }, 31 | "libraries": { 32 | "pinned_footprint_libs": [], 33 | "pinned_symbol_libs": [] 34 | }, 35 | "meta": { 36 | "filename": "wsc2.kicad_pro", 37 | "version": 1 38 | }, 39 | "net_settings": { 40 | "classes": [ 41 | { 42 | "bus_width": 12.0, 43 | "clearance": 0.2, 44 | "diff_pair_gap": 0.25, 45 | "diff_pair_via_gap": 0.25, 46 | "diff_pair_width": 0.2, 47 | "line_style": 0, 48 | "microvia_diameter": 0.3, 49 | "microvia_drill": 0.1, 50 | "name": "Default", 51 | "pcb_color": "rgba(0, 0, 0, 0.000)", 52 | "schematic_color": "rgba(0, 0, 0, 0.000)", 53 | "track_width": 0.25, 54 | "via_diameter": 0.8, 55 | "via_drill": 0.4, 56 | "wire_width": 6.0 57 | } 58 | ], 59 | "meta": { 60 | "version": 2 61 | }, 62 | "net_colors": null 63 | }, 64 | "pcbnew": { 65 | "last_paths": { 66 | "gencad": "", 67 | "idf": "", 68 | "netlist": "", 69 | "specctra_dsn": "", 70 | "step": "", 71 | "vrml": "" 72 | }, 73 | "page_layout_descr_file": "" 74 | }, 75 | "schematic": { 76 | "drawing": { 77 | "label_size_ratio": 0.25, 78 | "text_offset_ratio": 0.08 79 | }, 80 | "legacy_lib_dir": "", 81 | "legacy_lib_list": [] 82 | }, 83 | "sheets": [], 84 | "text_variables": {} 85 | } 86 | -------------------------------------------------------------------------------- /examples/RWE/HM-PB-2-FM_WSC2/schematic/wsc2.pro: -------------------------------------------------------------------------------- 1 | update=22/05/2015 07:44:53 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [pcbnew] 9 | version=1 10 | LastNetListRead= 11 | UseCmpFile=1 12 | PadDrill=0.600000000000 13 | PadDrillOvalY=0.600000000000 14 | PadSizeH=1.500000000000 15 | PadSizeV=1.500000000000 16 | PcbTextSizeV=1.500000000000 17 | PcbTextSizeH=1.500000000000 18 | PcbTextThickness=0.300000000000 19 | ModuleTextSizeV=1.000000000000 20 | ModuleTextSizeH=1.000000000000 21 | ModuleTextSizeThickness=0.150000000000 22 | SolderMaskClearance=0.000000000000 23 | SolderMaskMinWidth=0.000000000000 24 | DrawSegmentWidth=0.200000000000 25 | BoardOutlineThickness=0.100000000000 26 | ModuleOutlineThickness=0.150000000000 27 | [cvpcb] 28 | version=1 29 | NetIExt=net 30 | [eeschema] 31 | version=1 32 | LibDir= 33 | [eeschema/libraries] 34 | -------------------------------------------------------------------------------- /examples/RWE/HM-RC-8_BRC8/HM-RC-8_BRC8.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2020-12-26 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | #define SENSOR_ONLY 11 | #define SIMPLE_CC1101_INIT 12 | #define NOCRC 13 | #define NDEBUG 14 | 15 | #define STORAGEDRIVER at24cX<0x50,128,32> 16 | #include 17 | 18 | #define EI_NOTEXTERNAL 19 | #include 20 | #include 21 | #include 22 | //#include 23 | 24 | #include 25 | #include 26 | 27 | #define LED 8 28 | #define CC1101_GDO0 2 29 | #define CC1101_PWR 5 30 | #define BTN01_PIN 0 31 | #define BTN02_PIN 14 32 | #define BTN03_PIN 15 33 | #define BTN04_PIN 16 34 | #define BTN05_PIN 17 35 | #define BTN06_PIN 4 36 | #define BTN07_PIN 6 37 | #define BTN08_PIN 7 38 | 39 | #define SLEEP_DELAY_MS 3000 //wait milliseconds before sleep mode 40 | #define PEERS_PER_CHANNEL 10 41 | 42 | // all library classes are placed in the namespace 'as' 43 | using namespace as; 44 | 45 | // define all device properties 46 | const struct DeviceInfo PROGMEM devinfo = { 47 | {0x00,0xda,0x00}, // Device ID 48 | "HMRC00da00", // Device Serial 49 | {0x00,0xda}, // Device Model 50 | 0x10, // Firmware Version 51 | as::DeviceType::Remote, // Device Type 52 | {0x00,0x00} // Info Bytes 53 | }; 54 | 55 | /** 56 | * Configure the used hardware 57 | */ 58 | typedef AvrSPI<10,11,12,13> SPIType; 59 | typedef Radio RadioType; 60 | typedef StatusLed LedType; 61 | typedef AskSin Hal; 62 | 63 | typedef RemoteChannel ChannelType; 64 | typedef MultiChannelDevice RemoteType; 65 | 66 | Hal hal; 67 | RemoteType sdev(devinfo,0x20); 68 | //ResetOnBoot resetOnBoot(sdev); 69 | 70 | void setup () { 71 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 72 | sdev.init(hal); 73 | hal.battery.init(); 74 | hal.battery.low(22); 75 | hal.battery.critical(19); 76 | 77 | remoteISR(sdev,1,BTN01_PIN); 78 | remoteISR(sdev,2,BTN02_PIN); 79 | remoteISR(sdev,3,BTN03_PIN); 80 | remoteISR(sdev,4,BTN04_PIN); 81 | remoteISR(sdev,5,BTN05_PIN); 82 | remoteISR(sdev,6,BTN06_PIN); 83 | remoteISR(sdev,7,BTN07_PIN); 84 | remoteISR(sdev,8,BTN08_PIN); 85 | 86 | while (hal.battery.current() == 0); 87 | 88 | // resetOnBoot.init(); 89 | sdev.initDone(); 90 | sdev.startPairing(); 91 | } 92 | 93 | class PowerOffAlarm : public Alarm { 94 | private: 95 | bool timerActive; 96 | public: 97 | PowerOffAlarm () : Alarm(0), timerActive(false) {} 98 | virtual ~PowerOffAlarm () {} 99 | 100 | void activateTimer(bool en) { 101 | if (en == true && timerActive == false) { 102 | sysclock.cancel(*this); 103 | set(millis2ticks(SLEEP_DELAY_MS)); 104 | sysclock.add(*this); 105 | } else if (en == false) { 106 | sysclock.cancel(*this); 107 | } 108 | timerActive = en; 109 | } 110 | 111 | virtual void trigger(__attribute__((unused)) AlarmClock& clock) { 112 | powerOff(); 113 | } 114 | 115 | void powerOff() { 116 | hal.led.ledOff(); 117 | hal.radio.setIdle(); 118 | LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 119 | } 120 | 121 | } pwrOffAlarm; 122 | 123 | void loop() { 124 | bool worked = hal.runready(); 125 | bool poll = sdev.pollRadio(); 126 | pwrOffAlarm.activateTimer( hal.activity.stayAwake() == false && worked == false && poll == false ); 127 | 128 | } 129 | -------------------------------------------------------------------------------- /examples/RWE/HM-RC-8_BRC8/README.txt: -------------------------------------------------------------------------------- 1 | Fuses (original) 2 | L: 0xe2 3 | H: 0xdc 4 | E: 0xfe 5 | -------------------------------------------------------------------------------- /examples/RWE/HM-SEC-SC_WDS/HM-SEC-SC_WDS.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | // 2021-01-29 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 5 | //- ----------------------------------------------------------------------------------------------------------------------- 6 | // ci-test=yes board=328p aes=no 7 | 8 | // define this to read the device id, serial and device type from bootloader section 9 | // #define USE_OTA_BOOTLOADER 10 | 11 | #define NDEBUG 12 | #define EI_NOTEXTERNAL 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #define LED_PIN 8 21 | #define CONFIG_BTN 0 22 | #define SENS1_PIN A0 23 | #define CC1101_PWR 5 24 | #define CYCLETIME seconds2ticks(60UL * 60 * 16) 25 | #define BAT_LOW 22 26 | #define BAT_CRIT 20 27 | 28 | #define PEERS_PER_CHANNEL 10 29 | 30 | // all library classes are placed in the namespace 'as' 31 | using namespace as; 32 | 33 | // define all device properties 34 | const struct DeviceInfo PROGMEM devinfo = { 35 | {0x00,0x2f,0x01}, // Device ID 36 | "JPWDS00001", // Device Serial 37 | {0x00,0x2F}, // Device Model 38 | 0x18, // Firmware Version 39 | as::DeviceType::ThreeStateSensor, // Device Type 40 | {0x01,0x00} // Info Bytes 41 | }; 42 | 43 | typedef AvrSPI<10,11,12,13> SPIType; 44 | typedef Radio RadioType; 45 | typedef StatusLed LedType; 46 | typedef AskSin Hal; 47 | Hal hal; 48 | 49 | DEFREGISTER(Reg0,DREG_INTKEY,DREG_CYCLICINFOMSG,MASTERID_REGS,DREG_TRANSMITTRYMAX,DREG_SABOTAGEMSG) 50 | class SCList0 : public RegList0 { 51 | public: 52 | SCList0(uint16_t addr) : RegList0(addr) {} 53 | void defaults () { 54 | clear(); 55 | cycleInfoMsg(true); 56 | transmitDevTryMax(6); 57 | sabotageMsg(false); 58 | } 59 | }; 60 | 61 | DEFREGISTER(Reg1,CREG_AES_ACTIVE,CREG_MSGFORPOS,CREG_EVENTDELAYTIME,CREG_LEDONTIME,CREG_TRANSMITTRYMAX) 62 | class SCList1 : public RegList1 { 63 | public: 64 | SCList1 (uint16_t addr) : RegList1(addr) {} 65 | void defaults () { 66 | clear(); 67 | msgForPosA(1); // CLOSED 68 | msgForPosB(2); // OPEN 69 | // aesActive(false); 70 | // eventDelaytime(0); 71 | ledOntime(100); 72 | transmitTryMax(6); 73 | } 74 | }; 75 | 76 | 77 | class WDSPosition : public Position { 78 | private: 79 | uint8_t pin; 80 | public: 81 | WDSPosition () : pin(0) {} 82 | void init (uint8_t p) { 83 | pin = p; 84 | pinMode(p,INPUT); 85 | } 86 | 87 | void measure (__attribute__((unused)) bool async=false) { 88 | _position = digitalRead(pin) == LOW ? State::PosA : State::PosB; 89 | } 90 | uint32_t interval () { return 0; } 91 | }; 92 | 93 | template 94 | class TwoPinChannel : public StateGenericChannel { 95 | public: 96 | typedef StateGenericChannel BaseChannel; 97 | 98 | TwoPinChannel () : BaseChannel() {}; 99 | ~TwoPinChannel () {} 100 | 101 | void init (uint8_t pin) { 102 | BaseChannel::possens.init(pin); 103 | } 104 | 105 | uint32_t interval () { return BaseChannel::possens.interval(); } 106 | }; 107 | 108 | typedef TwoPinChannel ChannelType; 109 | typedef StateDevice SCType; 110 | 111 | SCType sdev(devinfo,0x20); 112 | ConfigButton cfgBtn(sdev); 113 | 114 | void funcISR () { 115 | // we simply activate the alarm 116 | Alarm& a = sdev.channel(1); 117 | sysclock.cancel(a); 118 | sysclock.add(a); 119 | } 120 | 121 | void setup () { 122 | DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER); 123 | sdev.init(hal); 124 | hal.battery.init(); 125 | hal.battery.low(BAT_LOW); 126 | hal.battery.critical(BAT_CRIT); 127 | while (hal.battery.current() == 0); 128 | 129 | buttonISR(cfgBtn,CONFIG_BTN); 130 | sdev.channel(1).init(SENS1_PIN); 131 | sdev.initDone(); 132 | 133 | contactISR(SENS1_PIN,funcISR); 134 | 135 | sdev.channel(1).changed(true); 136 | } 137 | 138 | void loop() { 139 | bool worked = hal.runready(); 140 | bool poll = sdev.pollRadio(); 141 | if( worked == false && poll == false ) { 142 | if( hal.battery.critical() ) { 143 | hal.activity.sleepForever(hal); 144 | } 145 | hal.activity.savePower >(hal); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /examples/_wip_HM-MOD-EM-8/_wip_HM-MOD-EM-8.ino: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------------------------------------------------------------- 2 | // AskSin++ 3 | // 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ 4 | //- ----------------------------------------------------------------------------------------------------------------------- 5 | 6 | // define this to read the device id, serial and device type from bootloader section 7 | // #define USE_OTA_BOOTLOADER 8 | 9 | #define EI_NOTEXTERNAL 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | // we use a Pro Mini 18 | // Arduino pin for the LED 19 | // D4 == PIN 4 on Pro Mini 20 | #define LED1_PIN 4 21 | #define LED2_PIN 5 22 | // Arduino pin for the config button 23 | // B0 == PIN 8 on Pro Mini 24 | #define CONFIG_BUTTON_PIN 8 25 | 26 | #define CHANNEL_COUNT 8 27 | // Pin für Kanal 1 2 3 4 5 6 7 8 28 | uint8_t sens_pins[] = {14, 15, 16, 17, 18, 3, 6, 9 }; 29 | 30 | // number of available peers per channel 31 | #define PEERS_PER_CHANNEL 10 32 | #define CYCLETIME seconds2ticks(60UL*60*16) 33 | 34 | // all library classes are placed in the namespace 'as' 35 | using namespace as; 36 | 37 | // define all device properties 38 | const struct DeviceInfo PROGMEM devinfo = { 39 | {0x00, 0xd9, 0x01}, // Device ID 40 | "JPEM000001", // Device Serial 41 | {0x00, 0xd9}, // Device Model 42 | 0x10, // Firmware Version 43 | as::DeviceType::Switch, // Device Type 44 | {0x00, 0x00} // Info Bytes 45 | }; 46 | 47 | /** 48 | Configure the used hardware 49 | */ 50 | typedef AvrSPI<10, 11, 12, 13> SPIType; 51 | typedef Radio RadioType; 52 | typedef DualStatusLed LedType; 53 | typedef AskSin BaseHal; 54 | class Hal : public BaseHal { 55 | public: 56 | void init (const HMID& id) { 57 | BaseHal::init(id); 58 | // measure battery every 1h 59 | battery.init(seconds2ticks(60UL*60),sysclock); 60 | battery.low(22); 61 | battery.critical(19); 62 | } 63 | } hal; 64 | 65 | DEFREGISTER(Reg0, DREG_INTKEY, DREG_CYCLICINFOMSG, MASTERID_REGS, DREG_TRANSMITTRYMAX) 66 | class SCIList0 : public RegList0 { 67 | public: 68 | SCIList0(uint16_t addr) : RegList0(addr) {} 69 | void defaults () { 70 | clear(); 71 | cycleInfoMsg(true); 72 | transmitDevTryMax(6); 73 | } 74 | }; 75 | 76 | DEFREGISTER(Reg1, CREG_AES_ACTIVE, CREG_MSGFORPOS, CREG_EVENTDELAYTIME, CREG_LEDONTIME, CREG_TRANSMITTRYMAX) 77 | class SCIList1 : public RegList1 { 78 | public: 79 | SCIList1 (uint16_t addr) : RegList1(addr) {} 80 | void defaults () { 81 | clear(); 82 | msgForPosA(1); 83 | msgForPosB(2); 84 | //aesActive(false); 85 | eventDelaytime(0); 86 | //ledOntime(100); 87 | transmitTryMax(6); 88 | } 89 | }; 90 | 91 | typedef TwoStateChannel ChannelType; 92 | typedef StateDevice SCIType; 93 | 94 | SCIType sdev(devinfo, 0x20); 95 | ConfigButton cfgBtn(sdev); 96 | 97 | void setup () { 98 | DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER); 99 | sdev.init(hal); 100 | buttonISR(cfgBtn, CONFIG_BUTTON_PIN); 101 | 102 | for (int i = 0; i < CHANNEL_COUNT; i++) { 103 | sdev.channel(i+1).init(sens_pins[i]); 104 | } 105 | sdev.initDone(); 106 | } 107 | 108 | void loop() { 109 | bool worked = hal.runready(); 110 | bool poll = sdev.pollRadio(); 111 | if ( worked == false && poll == false ) { 112 | // deep discharge protection 113 | // if we drop below critical battery level - switch off all and sleep forever 114 | if ( hal.battery.critical() ) { 115 | // this call will never return 116 | hal.activity.sleepForever(hal); 117 | } 118 | // if nothing to do - go sleep 119 | hal.activity.savePower >(hal); 120 | } 121 | } 122 | --------------------------------------------------------------------------------