Commit graph

127 commits

Author SHA1 Message Date
rbaron
5510fd963c BLE sample kinda works. Pending calibration 2022-11-25 22:30:42 +01:00
rbaron
339e5bebe9 Fixs PWM current consumption - SYSTEM ON sleep @ ~2.7uA 2022-11-22 22:21:16 +01:00
rbaron
6705c11867 Cleanup 2022-11-18 01:16:44 +01:00
rbaron
d18e7ab2d6 Kconfigure BLE service data length 2022-11-18 01:14:58 +01:00
rbaron
c5a5fcaf5f Adds simple Kconfig 2022-11-18 00:50:10 +01:00
rbaron
a65b00a439 Cleanup 2022-11-17 19:56:02 +01:00
rbaron
9333913571 Encoding of b-parasite protocol v2 works I guess 2022-11-17 19:51:35 +01:00
rbaron
8c7a2c35de Update shtc3 API 2022-11-16 19:49:09 +01:00
rbaron
597542649a Moved BLE stuff to src/ble/ 2022-11-16 19:28:40 +01:00
rbaron
3749d689ba Very minimal, working BLE advertising 2022-11-16 00:00:16 +01:00
rbaron
8cfb87ef32 Configs button 2022-11-14 22:37:03 +01:00
rbaron
ffeca36c27 Configures LED 2022-11-14 22:22:08 +01:00
rbaron
c15120178f Enables RTT console for bparasite_nrf52840 2022-11-14 19:13:04 +01:00
rbaron
a639343b6e Code commpiles for custom bparasite_nrf52840 board 2022-11-14 19:01:39 +01:00
rbaron
2779fe9af6 Started adding a b-parasite board. Not working yet 2022-11-14 08:47:14 +01:00
rbaron
3d6b4eaef1 Tame log levels 2022-11-13 17:28:38 +01:00
rbaron
59f2aad3db Some hacky macros for error handling 2022-11-13 17:26:50 +01:00
rbaron
107936770e Better error handling in adc.c 2022-11-13 16:50:34 +01:00
rbaron
6b1f52925e Moved adc stuff to adc.c 2022-11-13 16:18:30 +01:00
rbaron
522452b465 ADC works 2022-11-13 14:37:55 +01:00
rbaron
9c9492567f PWM kinda works 2022-11-13 11:20:31 +01:00
rbaron
bae06952fb Initial commit
SHTC3 comm via i2c works
2022-11-12 12:46:15 +01:00
Hedda
c339538913
Makefile comment nrf2480 -> nRF52840
Makefile comment nrf2480 -> nRF52840
2022-09-09 16:53:01 +02:00
Hedda
314a7f2fe3
README.md nrf2480 -> nRF52840
README.md nrf2480 -> nRF52840
2022-09-09 16:51:33 +02:00
rbaron
82eabe778a Fixes BTHome encoding 2022-08-30 21:02:51 +02:00
rbaron
81f0af3cf2 Fixes humidity factor & removes illumminance
The reason for removing illuminance is to leave enough space for the
full name AD element "prst". There may be options for also sending the
illuminance (extended adv, scan response etc), with different power
consumption/overhead/complexity tradeoffs. For now let's keep it simple.
2022-08-29 21:17:17 +02:00
rbaron
ce4c496f4d Uses newly minted 0x14 sensor type for moisture
I also comment out the illiminance sensor, since we need the space for
encoding the device's name - "prst".
2022-08-28 22:47:21 +02:00
rbaron
6ea0bb8525 First stab at an alternative, BTHome compatible BLE protocol
This protococol (https://bthome.io/) allows for automatic sensor
detection in Home Assistant, as long as the device broadcasts its
sensors in the expected format.
2022-08-28 18:58:16 +02:00
rbaron
5cfd69479a Advertises while in deep sleep.
Related to the investigation in #48
2022-08-08 19:34:07 +02:00
rbaron
a7732f106b Introduces new config flag PRST_BLE_EXPERIMENTAL_LONG_RANGE
This flags makes use of the Coded PHY from Bluetooth 5. It should be
treated as an experimental feature and it's disabled by default.
Note that clients (such as ESPHomme) would also have to scan on the
Coded PHY to be able to find b-parasites operating in this mode.
Currently, no client does that. Thus the feature is disabled and marked
as experimental.
2022-08-03 23:14:06 +02:00
Per Thomas Jahr
d56f60ceef Fix a couple of spelling errors and whitespaces. 2022-07-07 10:03:21 +02:00
rbaron
99abae6f50 Adds comment about valid BLE protocol versions 2022-03-15 08:56:06 +01:00
rbaron
0d307d8ef5 Defaults to BLE protocol version 1
I'll keep it at v1 until at least the ESPHome and Home Assistant bridges
versions are released with support to v2.
2022-03-15 08:52:37 +01:00
rbaron
b4acd3fad7 Unsets debug flags 2022-03-14 18:25:09 +01:00
rbaron
8fd4d7222a Implements BLE protocol v2
The only change from v1 is how the temperature is encoded. In v2, two
bytes at offset 4 and 5  represent a 16-bit signed int (in big-endian).
It contains the temperature in degrees Celsius *  100.

Fixes #29
2022-03-14 18:23:49 +01:00
rbaron
77f398757a Fixes MAC address in the BLE advertisement packet
The bug was introduced in https://github.com/rbaron/b-parasite/pull/26.
2022-02-12 18:38:57 +01:00
rbaron
1abff035cb Adds PRST_BLINK_LED config to save battery 2022-02-12 18:37:43 +01:00
rbaron
e16f61509c Add support for using the nRF52 preprogrammed random MAC address
Each nRF52 chip comes preprogrammed with a random static MAC address.
This is the default MAC address that is used if we don't specify one.

Fixes #25
2022-01-06 22:12:34 +01:00
rbaron
85643fe41e Cleans up debugging code 2021-10-09 09:33:50 +02:00
rbaron
79384cd6b2 Accidentally cleaned up too much 2021-10-09 09:33:23 +02:00
rbaron
ded36d1c3d Cleanup leftover tests 2021-10-09 09:33:23 +02:00
rbaron
bebf8c0a13 Adds code for reading the phototransistor values 2021-10-09 09:33:23 +02:00
Jan-Henrik Bruhn
44adefedb3 Fix overflow in very dark or noisy situations 2021-09-30 10:24:51 +02:00
rbaron
9b90d5a112 Disabled debug and set deep sleep time to 5 minutes 2021-09-24 19:08:10 +02:00
rbaron
ef2bfcdadd Updates #ifdef's to #if in main.c 2021-09-22 22:43:49 +02:00
rbaron
e1f385adbd Fixes #if PRST_HAS_LDR check in ble.c 2021-09-22 22:39:19 +02:00
rbaron
d8aea1d4ef Introduces version-specific config & condition BLE lux encoding
In the BLE service data payload, one of the reserved bits is now used to
indicate whether or not the ambient lux value is encoded in the packet.
Bit 0 of the first byte is now the `has_lux` bit. If it is set, bytes
16-17 in the service data will contain the ambient lux. If `has_lux` is
not set, bytes 16-17 may not exist (for compatibility with older
firmwares) or may hold meaningless values.

This commit also introduces version-specific configuration in
prst_config.h. Photoresistor config, for example, is only meaninful for
version 1.1.x.
2021-09-22 22:39:11 +02:00
rbaron
a00559a98b Uses better LDR x lux model 2021-09-22 22:38:30 +02:00
rbaron
6f98aa34b1 Calls nrf_gpio_cfg_output(PRST_PHOTO_V) 2021-09-22 22:38:30 +02:00
rbaron
d2daefaf46 Updates ambient brightness estimation code
Also renames the `lux` field from `photo_read_t` to the more generic `brightness`.
2021-09-22 22:38:30 +02:00