Skip to content

Commit a1a9325

Browse files
authored
Merge pull request #114 from orgua/dev
Dev
2 parents 834d4d1 + 50b1f5d commit a1a9325

17 files changed

Lines changed: 233 additions & 89 deletions

.github/workflows/compile.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: CompileTests
2+
3+
on:
4+
push:
5+
branches: [ "main", "dev" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
11+
buildAllExamples:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
board:
16+
- uno
17+
example:
18+
- ./examples/BAE910_device/BAE910_device.ino
19+
# - ./examples/DS18B20_asInterface/DS18B20_asInterface.ino # needs I2C
20+
- ./examples/DS18B20_thermometer/DS18B20_thermometer.ino
21+
- ./examples/DS2401_serial/DS2401_serial.ino
22+
- ./examples/DS2405_switch/DS2405_switch.ino
23+
- ./examples/DS2408_switch/DS2408_switch.ino
24+
- ./examples/DS2413_switch/DS2413_switch.ino
25+
- ./examples/DS2423_RAM/DS2423_RAM.ino
26+
- ./examples/DS2430_EEPROM/DS2430_EEPROM.ino
27+
- ./examples/DS2431_EEPROM/DS2431_EEPROM.ino
28+
- ./examples/DS2433_EEPROM/DS2433_EEPROM.ino
29+
- ./examples/DS2434_IBM701c/DS2434_IBM701c.ino
30+
- ./examples/DS2438_battMon/DS2438_battMon.ino
31+
- ./examples/DS2450_ADC/DS2450_ADC.ino
32+
- ./examples/DS2502_DELLCHG/DS2502_DELLCHG.ino
33+
- ./examples/DS2502_EEPROM/DS2502_EEPROM.ino
34+
- ./examples/DS2506_EEPROM/DS2506_EEPROM.ino
35+
- ./examples/DS2890_poti/DS2890_poti.ino
36+
- ./examples/OneWireHubTest/OneWireHubTest.ino
37+
38+
steps:
39+
- name: Checkout 🛎️
40+
uses: actions/checkout@v3
41+
- name: Set up Python 🐍
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.x'
45+
- name: Install dependencies 🔧
46+
run: sudo apt install cmake build-essential
47+
- name: Install platformio 🔧
48+
run: pip install -U platformio
49+
50+
- name: compile "${{ matrix.example }} for "${{ matrix.board }}" 🧱
51+
run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}"
52+
53+
build4TargetsBig:
54+
runs-on: ubuntu-latest
55+
strategy:
56+
matrix:
57+
board:
58+
- uno
59+
#- teensy20
60+
- teensy30
61+
- teensy36
62+
- esp01
63+
- nodemcuv2
64+
- espduino
65+
#- espino32 # not capable of c++11?
66+
#- esp32dev # not capable of c++11?
67+
68+
### Travis - LIST - TODO: find more and extend
69+
# due # arduino due -> current tick-counting implementation not compatible
70+
# zero # arduino zero -> current tick-counting implementation not compatible
71+
# teensy30 teensy31 teensy35 teensy36 # teensy 3
72+
# teensy20 teensy20pp # teensy 2 -> crc-lib has linker problem in platformIO but works in arduino-sw
73+
# esp01 nodemcuv2 espduino # esp8266
74+
# espino32 esp32dev # esp8266
75+
# rfduino # nrf51 -> will probably fail due to old gcc 4.8.3 with artificial limit to c++98
76+
# lenny uno_pic32 # pic32mx -> error: pic32-g++ not found
77+
# genuino101 # intel curie -> value_ipl is unknown for this hardware
78+
# attiny88 attiny84 # attiny -> linker error for unknown virtual function
79+
# digispark-tiny # attiny
80+
81+
example:
82+
- ./examples/OneWireHubTest/OneWireHubTest.ino
83+
84+
steps:
85+
- name: Checkout 🛎️
86+
uses: actions/checkout@v3
87+
- name: Set up Python 🐍
88+
uses: actions/setup-python@v4
89+
with:
90+
python-version: '3.x'
91+
- name: Install dependencies 🔧
92+
run: sudo apt install cmake build-essential
93+
- name: Install platformio 🔧
94+
run: pip install -U platformio
95+
96+
- name: compile "${{ matrix.example }} for "${{ matrix.board }}" 🧱
97+
run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}"
98+
99+
build4TargetsSmall:
100+
runs-on: ubuntu-latest
101+
strategy:
102+
matrix:
103+
board:
104+
- digispark-tiny
105+
example:
106+
- ./examples/DS2401_serial/DS2401_serial.ino
107+
108+
steps:
109+
- name: Checkout 🛎️
110+
uses: actions/checkout@v3
111+
- name: Set up Python 🐍
112+
uses: actions/setup-python@v4
113+
with:
114+
python-version: '3.x'
115+
- name: Install dependencies 🔧
116+
run: sudo apt install cmake build-essential
117+
- name: Install platformio 🔧
118+
run: pip install -U platformio
119+
120+
- name: compile "${{ matrix.example }} for "${{ matrix.board }}" 🧱
121+
run: "platformio ci --lib='.' -b ${{ matrix.board }} ${{ matrix.example }}"
122+
123+
testsuite:
124+
runs-on: ubuntu-latest
125+
126+
steps:
127+
- name: Checkout 🛎️
128+
uses: actions/checkout@v3
129+
- name: Install dependencies 🔧
130+
run: sudo apt install cmake build-essential
131+
132+
- name: Run primitive testsuite 🧱
133+
run: |
134+
mkdir build
135+
cd ./build
136+
cmake ..
137+
make
138+
./OneWireHub

.travis.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ set(SOURCE_FILES
1515
src/DS2408.cpp
1616
src/DS2413.cpp
1717
src/DS2423.cpp
18+
src/DS2430.cpp
1819
src/DS2431.cpp
1920
src/DS2433.cpp
21+
src/DS2434.cpp
2022
src/DS2438.cpp
2123
src/DS2450.cpp
2224
src/DS2502.cpp
@@ -26,6 +28,6 @@ set(SOURCE_FILES
2628
src/OneWireHub_config.h
2729
src/OneWireItem.cpp
2830
src/platform.cpp
29-
)
31+
) # TODO: this does not have to be manual
3032

3133
add_executable(OneWireHub ${SOURCE_FILES})

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OneWireHub
44
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.
55
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.
66

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

99
### Implemented Slaves
1010

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

117117
- check if your arduino software up to date (>v1.8.0)
118-
- update this lib to the latest release (v2.2.2)
118+
- update this lib to the latest release (v2.2.3)
119119
- 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
120120
- 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
121121
- 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

examples/DS2434_IBM701c/DS2434_IBM701c.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ void setup()
2121
// add default-data
2222
constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c,
2323
0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0,
24-
0x20, 0x20, 0x04, 0xee, 0x77, 0x66, 0x55, 0x44 }; // last 4 Byte seem to be Serial
24+
0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial
2525
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem1),sizeof(mem1),0x00);
2626

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

3030
ds2434.lockNV1();
3131
ds2434.setID(0xCABDu);
32-
ds2434.setBatteryCounter(1234u);
32+
ds2434.setBatteryCounter(0x0123u);
33+
ds2434.setTemperature(22u);
3334
}
3435

3536
void loop()

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "OneWireHub",
33
"frameworks": "Arduino",
4-
"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",
4+
"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",
55
"description": "OneWire slave device emulator with support for up to 32 simultaneous devices",
66
"authors":
77
[
@@ -22,7 +22,7 @@
2222
"type": "git",
2323
"url": "https://github.com/orgua/OneWireHub"
2424
},
25-
"version": "2.2.2",
25+
"version": "2.2.3",
2626
"examples": [
2727
"examples/*/*.ino"
2828
]

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=OneWireHub
2-
version=2.2.2
2+
version=2.2.3
33
author=Ingmar Splitt, orgua, MarkusLange, Shagrat2
44
maintainer=orgua
55
sentence=OneWire slave device emulator with support for up to 32 simultaneous 1wire devices.
6-
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
6+
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
77
category=Sensors
88
url=https://github.com/orgua/OneWireHub
99
architectures=*

main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ using namespace std;
2020
#include "src/DS2423.h" // 4kb 1-Wire RAM with Counter
2121
#include "src/DS2431.h" // 1kb 1-Wire EEPROM
2222
#include "src/DS2433.h" // 4Kb 1-Wire EEPROM
23+
#include "src/DS2434.h" // 1-Wire EEPROM
2324
#include "src/DS2438.h" // Smart Battery Monitor
2425
#include "src/DS2450.h" // 4 channel A/D
2526
#include "src/DS2502.h" // 1kb EEPROM
@@ -87,6 +88,7 @@ int main()
8788
auto hubA = OneWireHub(OneWire_PIN);
8889
auto hubB = OneWireHub(OneWire_PIN);
8990
auto hubC = OneWireHub(OneWire_PIN);
91+
auto hubD = OneWireHub(OneWire_PIN);
9092

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

121+
auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78);
122+
119123
cout << "- attach devices to hubs" << endl;
120124

121125
// Setup OneWire
@@ -145,6 +149,8 @@ int main()
145149
hubC.attach(ds2890C);
146150
hubC.attach(bae910);
147151

152+
hubD.attach(ds2434);
153+
148154
cout << "- use every device-function at least once and do some unit-testing" << endl;
149155

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

645+
{
646+
// DS2434
647+
// add default-data
648+
constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c,
649+
0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0,
650+
0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial
651+
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem1),sizeof(mem1),0x00);
652+
653+
constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 };
654+
ds2434.writeMemory(reinterpret_cast<const uint8_t *>(mem2),sizeof(mem2),0x20);
655+
656+
ds2434.lockNV1();
657+
ds2434.setID(0xCABDu);
658+
ds2434.setBatteryCounter(0x0123u);
659+
ds2434.setTemperature(22);
660+
}
661+
639662

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

src/BAE910.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ BAE910::BAE910(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5,
77

88
// clear memory
99
memset(&memory.bytes[0], static_cast<uint8_t>(0x00), BAE910_MEMORY_SIZE);
10+
11+
// disable bus-features:
12+
// TODO: test, as datasheet does not clear this up -> this settings keeps the previous behavior
13+
fast_read_rom = false;
14+
fast_search_rom = false;
1015
}
1116

1217

src/DS18B20.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ DS18B20::DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5
1515
updateCRC(); // update scratchpad[8]
1616

1717
ds18s20_mode = (ID1 == 0x10); // different tempRegister
18+
19+
// disable bus-features:
20+
fast_search_rom = false;
1821
}
1922

2023
void DS18B20::updateCRC()

0 commit comments

Comments
 (0)