Skip to content

Commit

Permalink
Merge pull request #114 from orgua/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
orgua authored Oct 10, 2022
2 parents 834d4d1 + 50b1f5d commit a1a9325
Show file tree
Hide file tree
Showing 17 changed files with 233 additions and 89 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: CompileTests

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main" ]

jobs:

buildAllExamples:
runs-on: ubuntu-latest
strategy:
matrix:
board:
- uno
example:
- ./examples/BAE910_device/BAE910_device.ino
# - ./examples/DS18B20_asInterface/DS18B20_asInterface.ino # needs I2C
- ./examples/DS18B20_thermometer/DS18B20_thermometer.ino
- ./examples/DS2401_serial/DS2401_serial.ino
- ./examples/DS2405_switch/DS2405_switch.ino
- ./examples/DS2408_switch/DS2408_switch.ino
- ./examples/DS2413_switch/DS2413_switch.ino
- ./examples/DS2423_RAM/DS2423_RAM.ino
- ./examples/DS2430_EEPROM/DS2430_EEPROM.ino
- ./examples/DS2431_EEPROM/DS2431_EEPROM.ino
- ./examples/DS2433_EEPROM/DS2433_EEPROM.ino
- ./examples/DS2434_IBM701c/DS2434_IBM701c.ino
- ./examples/DS2438_battMon/DS2438_battMon.ino
- ./examples/DS2450_ADC/DS2450_ADC.ino
- ./examples/DS2502_DELLCHG/DS2502_DELLCHG.ino
- ./examples/DS2502_EEPROM/DS2502_EEPROM.ino
- ./examples/DS2506_EEPROM/DS2506_EEPROM.ino
- ./examples/DS2890_poti/DS2890_poti.ino
- ./examples/OneWireHubTest/OneWireHubTest.ino

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Set up Python 🐍
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies 🔧
run: sudo apt install cmake build-essential
- name: Install platformio 🔧
run: pip install -U platformio

- name: compile "${{ matrix.example }} for "${{ matrix.board }}" 🧱
run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}"

build4TargetsBig:
runs-on: ubuntu-latest
strategy:
matrix:
board:
- uno
#- teensy20
- teensy30
- teensy36
- esp01
- nodemcuv2
- espduino
#- espino32 # not capable of c++11?
#- esp32dev # not capable of c++11?

### Travis - LIST - TODO: find more and extend
# due # arduino due -> current tick-counting implementation not compatible
# zero # arduino zero -> current tick-counting implementation not compatible
# teensy30 teensy31 teensy35 teensy36 # teensy 3
# teensy20 teensy20pp # teensy 2 -> crc-lib has linker problem in platformIO but works in arduino-sw
# esp01 nodemcuv2 espduino # esp8266
# espino32 esp32dev # esp8266
# rfduino # nrf51 -> will probably fail due to old gcc 4.8.3 with artificial limit to c++98
# lenny uno_pic32 # pic32mx -> error: pic32-g++ not found
# genuino101 # intel curie -> value_ipl is unknown for this hardware
# attiny88 attiny84 # attiny -> linker error for unknown virtual function
# digispark-tiny # attiny

example:
- ./examples/OneWireHubTest/OneWireHubTest.ino

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Set up Python 🐍
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies 🔧
run: sudo apt install cmake build-essential
- name: Install platformio 🔧
run: pip install -U platformio

- name: compile "${{ matrix.example }} for "${{ matrix.board }}" 🧱
run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}"

build4TargetsSmall:
runs-on: ubuntu-latest
strategy:
matrix:
board:
- digispark-tiny
example:
- ./examples/DS2401_serial/DS2401_serial.ino

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Set up Python 🐍
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies 🔧
run: sudo apt install cmake build-essential
- name: Install platformio 🔧
run: pip install -U platformio

- name: compile "${{ matrix.example }} for "${{ matrix.board }}" 🧱
run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}"

testsuite:
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Install dependencies 🔧
run: sudo apt install cmake build-essential

- name: Run primitive testsuite 🧱
run: |
mkdir build
cd ./build
cmake ..
make
./OneWireHub
68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ set(SOURCE_FILES
src/DS2408.cpp
src/DS2413.cpp
src/DS2423.cpp
src/DS2430.cpp
src/DS2431.cpp
src/DS2433.cpp
src/DS2434.cpp
src/DS2438.cpp
src/DS2450.cpp
src/DS2502.cpp
Expand All @@ -26,6 +28,6 @@ set(SOURCE_FILES
src/OneWireHub_config.h
src/OneWireItem.cpp
src/platform.cpp
)
) # TODO: this does not have to be manual

add_executable(OneWireHub ${SOURCE_FILES})
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ OneWireHub
The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Slaves with support for various devices. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one µC can emulate up to 32 ICs simultaneously.
The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment.

[![Build Status](https://travis-ci.org/orgua/OneWireHub.svg?branch=master)](https://travis-ci.org/orgua/OneWireHub)
[![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml)

### Implemented Slaves

Expand All @@ -24,7 +24,7 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL
- **DS2431 (0x2D) 1kbit protected EEPROM** (also known as DS1972 or DS28E07, same FC)
- DS2432 (0x33) 1kbit protected EEPROM (basically a ds2431 with extra sha-engine)
- **DS2433 (0x23) 4Kbit EEPROM** (also known as DS1973)
- DS2434 (0x1B ???) BatteryManagement used in some IBM Notebook-Batteries (similar to DS2436 (x1B), with one less cmd)
- DS2434 (0x1B ???) BatteryManagement used in some IBM Notebook-Batteries (similar to DS2436 (x1B), but without multidrop and one less cmd)
- **DS2438 (0x26) Smart Battery Monitor, measures temperature, 2x voltage and current, 10bit**
- **DS2450 (0x20) 4 channel A/D**
- **DS2501 (0x11, 0x91) 512bit EEPROM** -> use DS2502 with different family code
Expand All @@ -45,9 +45,9 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a
- support for most onewire-features: MATCH ROM (0x55), SKIP ROM (0xCC), READ ROM (0x0F,0x33), RESUME COMMAND (0xA5)
- **OVERDRIVE-Mode**: Master can issue OD SKIP ROM (0x13) or OD MATCH ROM (0x69) and slave stays in this mode till it sees a long reset -> OD-feature must be activated in config
- ALARM SEARCH (0xEC) is NOT implemented yet!
- cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=1.6.10 recommended)**
- cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=2.0.0 recommended)**
- use of constexpr instead of #define for better compiler-messages and cleaner code
- use static-assertions for plausibility checks
- use static-assertions for compile-time plausibility checks
- user defined literals convert constants into needed format / unit
- hardware-dependencies are combined in "platform.h", synced with [Onewire-Lib](https://github.com/PaulStoffregen/OneWire)
- supported: arduino zero, teensy, pic32, [ATtiny](https://github.com/damellis/attiny), esp8266, esp32, raspberry (...)
Expand Down Expand Up @@ -115,7 +115,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a
### HELP - What to do if things don't work as expected?

- check if your arduino software up to date (>v1.8.0)
- update this lib to the latest release (v2.2.2)
- update this lib to the latest release (v2.2.3)
- if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation
- check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical
- begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the master won't switch to higher data rates
Expand Down
7 changes: 4 additions & 3 deletions examples/DS2434_IBM701c/DS2434_IBM701c.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ void setup()
// add default-data
constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c,
0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0,
0x20, 0x20, 0x04, 0xee, 0x77, 0x66, 0x55, 0x44 }; // last 4 Byte seem to be Serial
0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem1),sizeof(mem1),0x00);

constexpr uint8_t mem2[8] = {0x34, 0x39, 0x29, 0xc4, 0x9e, 0xd0, 0x81, 0xb6 };
constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 };
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem2),sizeof(mem2),0x20);

ds2434.lockNV1();
ds2434.setID(0xCABDu);
ds2434.setBatteryCounter(1234u);
ds2434.setBatteryCounter(0x0123u);
ds2434.setTemperature(22u);
}

void loop()
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "OneWireHub",
"frameworks": "Arduino",
"keywords": "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2431, DS2432, DS2433, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890",
"keywords": "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890",
"description": "OneWire slave device emulator with support for up to 32 simultaneous devices",
"authors":
[
Expand All @@ -22,7 +22,7 @@
"type": "git",
"url": "https://github.com/orgua/OneWireHub"
},
"version": "2.2.2",
"version": "2.2.3",
"examples": [
"examples/*/*.ino"
]
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=OneWireHub
version=2.2.2
version=2.2.3
author=Ingmar Splitt, orgua, MarkusLange, Shagrat2
maintainer=orgua
sentence=OneWire slave device emulator with support for up to 32 simultaneous 1wire devices.
paragraph=supported sensors: BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2431, DS2432, DS2433, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890
paragraph=supported sensors: BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890
category=Sensors
url=https://github.com/orgua/OneWireHub
architectures=*
23 changes: 23 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using namespace std;
#include "src/DS2423.h" // 4kb 1-Wire RAM with Counter
#include "src/DS2431.h" // 1kb 1-Wire EEPROM
#include "src/DS2433.h" // 4Kb 1-Wire EEPROM
#include "src/DS2434.h" // 1-Wire EEPROM
#include "src/DS2438.h" // Smart Battery Monitor
#include "src/DS2450.h" // 4 channel A/D
#include "src/DS2502.h" // 1kb EEPROM
Expand Down Expand Up @@ -87,6 +88,7 @@ int main()
auto hubA = OneWireHub(OneWire_PIN);
auto hubB = OneWireHub(OneWire_PIN);
auto hubC = OneWireHub(OneWire_PIN);
auto hubD = OneWireHub(OneWire_PIN);

auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00);
auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer
Expand Down Expand Up @@ -116,6 +118,8 @@ int main()
auto ds2890C = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0C );
auto bae910 = BAE910(BAE910::family_code, 0x00, 0x00, 0x10, 0xE9, 0xBA, 0x00);

auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78);

cout << "- attach devices to hubs" << endl;

// Setup OneWire
Expand Down Expand Up @@ -145,6 +149,8 @@ int main()
hubC.attach(ds2890C);
hubC.attach(bae910);

hubD.attach(ds2434);

cout << "- use every device-function at least once and do some unit-testing" << endl;

// TODO: maybe put the code in src_files to the depending device_unittest.h
Expand Down Expand Up @@ -636,6 +642,23 @@ int main()
test_eq(ds2890A.getRegFeat(), 255_u8, "DS2890 feature register preset");
}

{
// DS2434
// add default-data
constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c,
0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0,
0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem1),sizeof(mem1),0x00);

constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 };
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem2),sizeof(mem2),0x20);

ds2434.lockNV1();
ds2434.setID(0xCABDu);
ds2434.setBatteryCounter(0x0123u);
ds2434.setTemperature(22);
}


cout << "- test the hub" << endl;

Expand Down
5 changes: 5 additions & 0 deletions src/BAE910.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ BAE910::BAE910(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5,

// clear memory
memset(&memory.bytes[0], static_cast<uint8_t>(0x00), BAE910_MEMORY_SIZE);

// disable bus-features:
// TODO: test, as datasheet does not clear this up -> this settings keeps the previous behavior
fast_read_rom = false;
fast_search_rom = false;
}


Expand Down
3 changes: 3 additions & 0 deletions src/DS18B20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ DS18B20::DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5
updateCRC(); // update scratchpad[8]

ds18s20_mode = (ID1 == 0x10); // different tempRegister

// disable bus-features:
fast_search_rom = false;
}

void DS18B20::updateCRC()
Expand Down
Loading

0 comments on commit a1a9325

Please sign in to comment.