🪴💧 A Bluetooth Low Energy (BLE) soil moisture sensor.

Overview

b-parasite

PCB front and back photo

b-parasite is an open source Bluetooth Low Energy (BLE) soil moisture and ambient temperature/humidity sensor.

Features

  • Soil moisture sensor. I wrote about how capacitive soil moisture sensors works on this Twitter thread, based on this great post on wemakethings.net
  • Air temperature and humity sensor using a Sensirion's SHTC3
  • Powered by a common CR2032 coin cell, with a battery life of possibly over a year - see "Battery Life" below
  • Open hardware and open source design

Repository Organization

How It Works

Diagram containing two b-parasites, a bridge & an MQTT broker

b-parasite works by periodically measuring the soil moisture, air temperature/humidity and broadcasting those values via Bluetooth Low Energy (BLE) advertisement packets. After doing so, the board goes into a sleep mode until it's time for another measurement. The sleep interval is configurable - I often use 10 minutes between readings, which is a good compromise between fresh data and saving battery.

At this point, b-parasite's job is done. We have many possibilities of how to capture its BLE advertisement packet and what to do with the data. What works okay for me is having a BLE-MQTT bridge that listens for these BLE broadcasts, decodes them and ships the sensor values through MQTT messages. The MQTT broker is then responsible for relaying the sensor data to interested parties. This is the topology shown in the diagram above.

A popular choice for a BLE-MQTT bridge is the ESPHome project, which runs on our beloved ESP32 boards. I forked ESPHome into rbaron/esphome and added support for the b_parasite platform. An example project using this fork is defined in this repo, under bridge/ (check out README.md there for more info).

Battery Life

tl;dr: By taking readings 10 minutes apart, the battery should last for over a year.

The main parameters involved in estimating the battery life are:

  • Current consumption (both in operation and during sleep)
  • Duty cycle (how much time it spends in operation vs. sleeping)
  • Battery capacity - this is roughly 230 mAh for CR2032 cells

In the following screenshot, I measured the voltage of a 10 Ohm series resistor during the on-cycle, for a 8dBm transmitting power (the voltage is negative, so it is upside down):

A screenshot of an oscilloscope used to measure current consumption

The short high peaks correspond to when the radio is active, sending broadcasting packets. The average current consumption during this active time is roughly 9mA. Let's round it to 10mA. During off time, I measure a current of less than 3uA.

With these parameters in hand, I put together this spreadsheet in which you can estimate the battery life. For example, for an active time of one second and sleep time of ten minutes, we see a runtime of 488.10 days.

b-parasite stuck into a small plant vase

License

The hardware and associated design files are released under the Creative Commons CC BY-SA 4.0 license. The code is released under the MIT license.

Comments
  • Add Photoresistor

    Add Photoresistor

    This will add a light sensor to the parasite:

    This has been tested to work with JLCPCB manufacturing qoute but not ordered yet for the below reasons.

    1. I don't really know if this design is correct as I'm fairly begginer in electronics (so far my circuits are working but this is another level)
    2. I don't know how to program a compatible code...

    Partially solving https://github.com/rbaron/b-parasite/issues/4

    opened by yuvalabou 44
  • How to program

    How to program

    HI,

    Nice work!!

    I'm looking for guidance on how to program the devices, I have an Atmel ICE that has SWD would that work?

    Are there any cheap programmers that could easily be used?

    opened by volzb 20
  • programming - low voltage detected at the target

    programming - low voltage detected at the target

    hi,

    I try to flash the firmware with my J-Link Edu. but unfortunately I get following error? As it's the first time flashing with swd, I cannot figure out what the issue is. After a successful compile, it would like to flash the softdevice part and encounter the following error:

    % SDK_ROOT=~/Documents/b-parasite-main/code/nRF5_SDK_17.1.0_ddde560 PLATFORM=E73_2G4M08S1E make flash_softdevice
    Flashing: s140_nrf52_7.2.0_softdevice.hex
    nrfjprog -f nrf52 --program /Users/lorenz/Documents/b-parasite-main/code/nRF5_SDK_17.1.0_ddde560/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --sectorerase
    ERROR: Unable to connect to a debugger.
    ERROR: Low voltage detected at the target. Please make sure the device is
    ERROR: properly supplied.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.
    make: *** [flash_softdevice] Error 43
    

    same for just make flash, the Vcc is directly connected to the jlink. no coincell involved. Any ideas? Thx

    opened by SchmidL 15
  • How to solder nRF52

    How to solder nRF52

    Hi,

    I realize it's not really about the b parasite as such, but I've done what's suggested in the doc and ordered the board and controller separately. But I've never had to solder something that doesn't have pins before and after trying, it's insanely hard, I just made a huge mess.

    Any tips, tricks or links to good tutorial on how to assemble this ? Also is there a list of the "pins" (pads ?) actually used, looks like some of them can be ignored but which ones ?

    Thanks !

    opened by Ulrar 12
  • Phototransistor

    Phototransistor

    This PR substitutes the LDR introduced in #6 with a phototransistor. Some advantages:

    • RoHS compliance
    • More compact
    • Relatively linear
    • SMT, so it can be assembled by fabrication houses
    opened by rbaron 12
  • Moisture readings overflow

    Moisture readings overflow

    I haven't dug into this myself yet, but noticed this morning that one of my plants moisture reading "overflowed". When looking at the code, I saw that moisture readings are actually fit to a polynomial and the final values from the equation. Haven't done any debugging yet, so probably not much to go on, but opening the issue as something is clearly miss-behaving. Will follow up as I get time. I'm also not convinced that the moisture reading is right in the first place. It's continuously trending up, yet I haven't added water to the soil since adding the sensor.

    Love this project, thanks a bajillion for open sourcing.

    Screen Shot 2021-05-12 at 11 18 35 AM Screen Shot 2021-05-12 at 11 18 41 AM
    opened by AlexSzlavik 11
  • How to program

    How to program

    Hi, Can anyone help me how to program them? I already assembled a few, but I have no idea how to compile the firmware. The readme not much of a help. I will use the E73 2g4m08s1e version chip, and I have Arduino ide. Thanks in advance

    opened by kenny00111 7
  • Open source the rotisserie / drying jig

    Open source the rotisserie / drying jig

    A while ago I built this extremely questionable spinning jig to try and get the coating layer to dry more uniformly:

    rotisserie

    I wrote about it in a twitter thread and to my surprise more people wanted to join in on the fun. Fair warning: don't take it too seriously.

    opened by rbaron 7
  • Flashing Issue

    Flashing Issue

    I've been trying to flash a couple of these PCB's and I am getting this error on one of them

    [email protected]:~/Desktop/b-parasite/b-parasite-main/code/b-parasite$ make flash_softdevice Flashing: s140_nrf52_7.2.0_softdevice.hex nrfjprog -f nrf52 --program /home/user/Desktop/b-parasite/nRF5_SDK_17.0.2_d674dde/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --sectorerase Failed to read device memories. ERROR: JLinkARM DLL reported an error. Try again. If error condition ERROR: persists, run the same command again with argument --log, contact Nordic ERROR: Semiconductor and provide the generated log.log file to them. NOTE: For additional output, try running again with logging enabled (--log). NOTE: Any generated log error messages will be displayed. make: *** [Makefile:316: flash_softdevice] Error 33

    Not sure if I maybe cooked my Bluetooth module when I used the hot air reflow station on it, have some more on order but wasn't sure if I was missing something silly in the meantime.

    opened by binaryhellstorm 7
  • Alternate Parts Availability

    Alternate Parts Availability

    Right now as most have seen the nRF52840 (E73-2G4M08S1C) as proposed is currently unavailable for the most part and the ones that are available have obviously went up in price. From what I can determine this particular version of the part, the advantage is the fact that it is pre-mounted on a daughter board which makes hand soldering easier and has a ceramic antenna already attached.

    The Nordic nRF52840 SoC itself is available at LCSC (C190794) for pick and place manufacturing and at a better cost with 14,000+ currently available with more reportedly coming in. Using the Nordic in this fashion also gives you access to more of the IO's that are available.

    From what research I can find, the ceramic antenna is what is considered a medium gain antenna. Better range and performance could be achieved by designing in an IFA pcb copper trace antenna that would also occupy near the same footprint of the ceramic antenna.

    opened by MrEinstin 7
  • Mosfet instead of Q2 and Q3 bipolar?

    Mosfet instead of Q2 and Q3 bipolar?

    Hello,

    I ask myself why does Q2 and Q3 are bipolar tranistor and not mosfet ? There is an explanation of operation here : https://wemakethings.net/2012/09/26/capacitance_measurement/ But not why bipolar instead of mosfet to discharge the capacitor.

    Thanks

    opened by pit34 6
  • Migrate code to the nRF Connect SDK

    Migrate code to the nRF Connect SDK

    This PR rewrites all the code from the legacy nRF SDK to the nRF Connect SDK. I will keep pushing updates to this PR and merge it when all tasks are finished and tested. I am only going for feature parity with this rewrite, but I'm factoring out a common core that can be reused in different applications/samples.

    All help is welcome in testing the parts that are already implemented.

    Tasks

    • [x] Board definitions
      • [x] 1.2.0 @ nRF52840 (code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/)
      • [x] 1.2.0 @ nRF52833 (Untested, code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/)
    • [x] Read sensors (implemented in common lib code/nrf-connect/prstlib)
      • [x] SHT30C
      • [x] Photo diode
      • [x] Soil moisture
    • [x] Blinky sample (code/nrf-connect/samples/blinky)
    • [x] Read soil moisture sample (code/nrf-connect/samples/soil_read_loop)
    • [x] BLE sample (code/nrf-connect/samples/ble) (this is the rewrite of the old firmware)
      • [x] Protocols
        • [x] b-parasite v2
        • [x] BTHome v1
        • [x] BTHome v2 (Untested)
      • [x] BT address config
        • [x] Random, static
        • [x] User defined
      • [x] Power profile (2.7uA in sleep)
      • [x] Test in Home Assistant
    • [x] Set up GitHub workflow
      • [x] Lint all samples
      • [x] Build all samples
      • [x] Store build artifacts for samples
    • [x] Build samples with Docker
    • [ ] Write docs
      • [ ] How to build
        • [ ] With nRF Connect for Desktop
        • [ ] With Docker
      • [ ] Remove old docs
    • [ ] Remove old code/b-parasite/

    Notes

    Building the Samples

    With nRF Connect for Desktop + Visual Studio Code

    This is the usual way of building the nRF Connect SDK samples. The only caveat is that, for each sample here, you also need to add the code/nrf-connect/prstlib directory to your workspace in addition to the sample directory itself. The prstlib/ contains common source code for reading sensors and also common board definitions. There is a .code-workspace file inside each sample that does this automatically.

    With Docker

    To build the ble sample, cd into code/nrf-connect/ and run:

    $ docker run --rm -v ${PWD}:/code -w /code/samples/ble nordicplayground/nrfconnect-sdk:v2.1-branch west build --build-dir ./build --pristine --board bparasite_nrf52840
    

    The output will be in code/nrf-connect/samples/ble/build/zephyr/zephyr.hex.

    [Experimental but super cool] With GitHub Codespaces

    GitHub Codespaces let you run an instance of VS Code directly in your browser. More importantly, it also supports plugins, including nRF Connect for VS Code! This PR introduces .devcontainer/devcontainer.json, which configures a Codespace with both the nRF VS Code plugin, as well as the whole nRF Connect SDK + toolchain. This lets you edit code and build the sample straight in your browser.

    1. Go to Codespaces and click "New codespace"
    2. Select rbaron/b-parasite, branch nrf-connect
    3. Wait. The underlying Docker image is pretty big and the build might fail. It worked on the second try for me
    4. Once the codespace is ready, navigate to code/nrf-connect/samples/ble, select ble.code-workspace and click on "Open workspace". This makes sure both the ble sample and the prstlib are present in the workspace
    5. Build the sample normally, as described in the nRF Connect SDK docs
    6. Download the built sample from ble/build/zephyr/zephyr.hex

    Prebuilt Binaries

    The GitHub workflow in this PR clang-format-checks, builds and store the built binaries for all sample as artifacts. You can download them here (example). These are built with the default settings, but we may extend this machinery to build a few variants with different configs for each sample.

    opened by rbaron 2
  • 4 layer PCB version as alternative for coating

    4 layer PCB version as alternative for coating

    I'm very interested in this project. I have a couple of MiFlora's, but they have not proven to be reliable for me, so I'd like to try a different approach.

    I was wondering if any considerations or attempts have been made to use a 4 layer PCB instead. This would allow the copper pads for moisture measurement to be placed on the inner layers of the PCB, sandwiched between (bare) FR4. To me it seems more elegant and reliable option compared to using a coating spray, by mitigating the risk for corrosion. Of course the PCB will become a bit more expensive, but I think the benefits outweigh this.

    One concern I have is whether the measurement would be impacted by a change in the PCB layout. The capacitive coupling to the soil would become slightly different. Would there be any way to (re)calibrate such PCB layout to obtain the same performance as the original design?

    Note: a similar approach can be found here: https://github.com/diyruz/flower

    EDIT: I found some pointers on how to re-do the calibration for a different PCB layout.

    opened by nielsfaber 2
  • Wall moisture capacitance measurement?

    Wall moisture capacitance measurement?

    This is not an issue, but I wonder if I place the sensor on the wall, could it measure wall or at least wall surface moisture content?

    I know there multe wall humidity / moisture measurement method and devices, the basic ones are

    • resistance - with two prongs that is pretty much useless
    • capacitance - with ball at the end
    • microwave etc. I don't care really - super expensive devices, probably could be done somehow by mmwave sensors diy, but would require lot of research

    So when/if my test batch of assembled pcs arrive and i place them on the wall in different heights is it possible that they would give some reliable moisture measurement even if just one side is in contact with the wall?

    Even the air RH seems to be more accurate than the two prong meters.

    At first I wanted to order these sensors from JLCPCB as the first made to order HW experience, as the commercial sensing smart home solutions are unreliable and only ones working, at least for me, are hacked xiaomi BT TH sensors. But now I may have real use for this as I want to get rid of the moisture in walls of the 110+ years old house I'm attempting to fix. (the moisture is not much of an issue in the 110+ years old part of the house, but in the about 50 year old addition is crazy - like 0.8 meter of the wall from the ground is wet too the touch). So having actual data about how each attempted measure affects wall humidity would be awesome.

    opened by evlo 0
  • Flashing b-parasite more than once using GDB

    Flashing b-parasite more than once using GDB

    I flashed 4 b-parasite boards with the same firmware. Meaning that they all have the same MAC address. Realizing my mistake I edited the prst_config.h and changed the mac from f0:ca:f0:ca:01:01 to f0:ca:f0:ca:01:02, f0:ca:f0:ca:01:03, and f0:ca:f0:ca:01:04. Unfortunately GDB doesn't seem to pick up the board anymore.

    When the board is blank I ran the below to flash the boards.

    (gdb) monitor swdp_scan Target voltage: 3.3V Available Targets: No. Att Driver 1 Nordic nRF52 M4 2 Nordic nRF52 Access Port (gdb) attach 1 Attaching to Remote target warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. 0x0001ae30 in ?? () (gdb) load "bin/b-parasite_hex/s140_nrf52_7.2.0_softdevice.hex" Loading section .sec1, size 0xb00 lma 0x0 Loading section .sec2, size 0xf000 lma 0x1000 Loading section .sec3, size 0x10000 lma 0x10000 Loading section .sec4, size 0x6634 lma 0x20000 Start address 0x00000000, load size 155956 Transfer rate: 27 KB/sec, 974 bytes/write. (gdb) load "bin/b-parasite_hex/nrf52833_xxaa.hex" Loading section .sec1, size 0x9000 lma 0x27000 Loading section .sec2, size 0x52c lma 0x30000 Start address 0x000272f8, load size 38188 Transfer rate: 26 KB/sec, 954 bytes/write.

    When trying to reflash the monitor swdp_scan just fails. Even after bridging the rst and gnd I can't get the boards to show up.

    (gdb) monitor swdp_scan Target voltage: 3.3V SW-DP scan failed! Failed

    Anyone have a solution? For reference I'm using a black magic probe v2.3b. b-parasite was compiled on WSL Ubuntu 22.04.1 LTS then flashed through GDB via Windows.

    Edit: Added Ubuntu version

    opened by ZehelSitchel 0
  • Mini Parasite

    Mini Parasite

    My use case for bparasites is to have them buried in the soil - given the size of most pots around the house, this necessitates a smaller form factor, and eliminates need for photo sensing.

    After modifying the gerbers and having them made up, Ive finally been able to test them and confirm they work. Right now it seems sensitive enough with the smaller loop to still work well

    See size comparison

    The request/my repo has two new folders for the mini gerber and csvs for use.

    Calibration i found worked best with air and wet potting soil - I have worked with dry potting soil as a baseline but the %'s get thrown off - i also have some calibration references for cactus mix if people are interested - the cal equations modified in adc.h for potting soil are: const double dry = 59.66 * x + 331; const double wet = 34.44 * x + 173;

    these are in mini-adc.c, would just rename the file or put these equations in adc.c for the mini config

    My waterproofing process is dipped oil poly over the capacitance area, with adhesive heatshrink over the electronic bits. Dont love the heatshrink as modifying in the future makes it difficult to remove, so open to ideas there

    opened by chucknorris101 2
Owner
null
Baseline Arduino shield for temperature, humidity, soil moisture and ambient light

Introduction Green-Shield is an Arduino R3 shield for temperature, humidity, soil moisture and ambient light optimized for use in greenhouses where th

#Eduh 3 Dec 29, 2021
Arduino Sketch and a Web Bluetooth API for loading models and running inference on the Nano Sense 33 BLE device.

TF4Micro Motion Kit This repo contains the Arduino Sketch and a Web Bluetooth API for loading models and running inference on the device. Install and

Google Creative Lab 52 Nov 24, 2022
ControllaBLE - A retro-controllers to Bluetooth BLE adapter

ControllaBLE - A retro-controllers to Bluetooth BLE adapter This is an ESP32 based controller adapter that outputs as a dual joypad through Bluetooth

null 14 Oct 16, 2022
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9inch e-Paper Module

How to join: If device in FN(factory new) state: Press and hold button (1) for 2-3 seconds, until device start flashing led Wait, in case of successfu

Sergey Koptyakov 5 Feb 13, 2022
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9/2.13/1.54 inch e-Paper Module

How to join: If device in FN(factory new) state: Press and hold button (1) for 2-3 seconds, until device start flashing led Wait, in case of successfu

Sergey Koptyakov 32 Nov 14, 2022
Exploits the Wii U's bluetooth stack to gain IOSU kernel access via bluetooth.

BluuBomb Exploits the Wii U's bluetooth stack to gain IOSU kernel access via bluetooth. For a more detailed write-up see WRITEUP.md. Not to be confuse

null 97 Sep 10, 2022
Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

BluetoothJoystick Bluetooth Joystick : A wireless joystick with ESP-32 microcontroller and Dual Axis Joystick Module using the Bluetooth connectivity.

null 9 Feb 24, 2022
Allows for multiple SwitchBot buttons and curtains to be controlled via MQTT sent to ESP32. ESP32 will send BLE commands to switchbots and return MQTT responses to the broker. Also supports Meter/Temp Sensor

SwitchBot-MQTT-BLE-ESP32 Switchbot local control using ESP32. no switchbot hub used/required. works with any smarthub that supports MQTT https://githu

null 332 Nov 26, 2022
Control of 4 DOF robotic arm using Bluetooth HC-05 Sensor

SERV-E -> "At your Service" Problem Statement With the current boom of technology where the whole world is running towards digitisation and automation

Swarup Tripathy 2 Apr 27, 2022
Control Heidelberg Wallbox Energy Control over WiFi using ESP8266 and configure your own local load management

< scroll down for English version and additional information > wbec WLAN-Anbindung der Heidelberg WallBox Energy Control über ESP8266 Die Heidelberg W

null 88 Nov 27, 2022
multispectral monitoring of a sourdough starter; esp32 eink module, scd30 co2 sensor, vl6180 distance sensor

EINK STARTER MONITOR See full blogpost here Tracks height of starter with a VL6180 i2c distance sensor, and CO2/temperature/humidity with an SCD30. A

AKA 15 Feb 16, 2022
Sensirion Mass Flow Sensor Arduino library, modified from MyElectrons and Nabilphysics Arduino repositories for SFM3300 Digital Mass Flow Sensor

Sensirion Mass Flow Sensor Arduino library, modified from MyElectrons and Nabilphysics Arduino repositories for SFM3300 Digital Mass Flow Sensor. When the sensor data gets stuck, the library has a hard reset function to ensure that it is read continuously.

Paul Ryan Santiago 3 Apr 11, 2022
Tasmota-Berry Tank Sensor for fuel-oil usind VL53L1X or SR04 sensor

Tasmota-Tank-Sensor Tasmota-Berry Tank Sensor for fuel-oil volume measurement using an VL53L1X or SR04 sensor The Sensor body The sensor was prepared

Tom Lafleur 3 Oct 9, 2022
My new zigbee project. Wireless temperature and humidity mini sensor with electronic ink display 2.13 inches, low power consumption, compact size, enclosure with magnets.

My new zigbee project. Wireless temperature and humidity mini sensor with electronic ink display 2.13 inches, low power consumption, compact size, enclosure with magnets. The device use SHTC3 sensors, chip CC2530, battery CR2477.

Andrew Lamchenko 20 Nov 20, 2022
A water tank level sensor **Built With WisBlock** to detect overflow and low level conditions.

RAK12014 Laser TOF sensor coming soon WisBlock Watertank Level Sensor Watertank Overflow detection using the RAKwireless WisBlock modules. It implemen

Bernd Giesecke 3 Feb 3, 2022
CC2500 Low-Cost Low-Power 2.4 GHz RF Transceiver driver for esp-idf

esp-idf-cc2500 CC2500 Low-Cost Low-Power 2.4 GHz RF Transceiver driver for esp-idf. I ported from this. 2.00mm pitch External Antena 1.27mm pitch PCB

null 3 May 29, 2022
nrf52832 nrf52810 ble keyboard firmware

BLEKeyboard nrf52832 nrf52810 ble keyboard firmware WHY Learm more about hardware design and engineering. WHAT Implement a full featured powerful and

Jason Zhou 周正昌 42 Dec 1, 2022
sc-ble-bridge is a utility that for every connected Steam Controller creates a virtual one acting as a bridge between SC and Steam

sc-ble-bridge The main goal of this utility is to provide workaround for steam-for-linux issue which makes Valve's Steam Controller unusable in BLE mo

null 5 Apr 19, 2022
WisBlock API takes care of all the LoRaWAN, BLE, AT command functionality

WisBlock-API Targeting low power consumption, this Arduino library for RAKwireless WisBlock Core modules takes care of all the LoRaWAN, BLE, AT comman

Bernd Giesecke 18 Nov 16, 2022