This blog post is part of a series of posts:
- Part 1 : Introduction
- Part 2 : From prototypes to V1.0
- Part 3 : Hardware design
- Part 4 : Software
- Part 5 : Integration with TTN, Node-RED and Home-Assistant
As I previously said, I started this project more than 2 years ago. I obviously didn’t work on it full time since then, but I nevertheless tried many solutions to implement my idea.
I’ll introduce the different options I experimented with in this section.
PyCom Lopy & MicroPython
I bought a kit of 2 PyCom Lopy boards a few years ago. Those boards, based on the ESP32, are equipped with a LoRa module. I bought these to experiment with LoRa and LoRaWAN, but never built an actual project with them.
The software support for those boards is really great. You can easily program them using MicroPython , and PyCom provides all the libraries needed to use all onboard peripherals, the LoRa module included.
The idea was to use one of the boards are an emitter : it counts the pulses from the water meter and sends the data over raw LoRa. The second board is a receiver : it receives the data from the first one and publish them over MQTT (using the WiFi radio from the ESP32). I can then use Home-Assistant to process and display the data.
A picture of the boards I took while working on the software. The board on the left is the emitter. The button allows to simulate a pulse from the water meter. The board on the right is the receiver.
Debugging the software : logic analyzer on the top, Home-Assistant and MQTT on the left, Grafana on the right.
I was able to build this prototype over the course of a week-end, and it worked great. Except that the battery life was really bad : the emitter ran for 10 days on a 10000mAh battery.
The emitter board installed in a plastic board and connected to the watermeter in the shed.
I tried to reduce the power usage of this build, with not much success. If I remember correctly, the only way to reduce the power usage was to put the system in deep sleep mode, which needed a full reset of the MCU to wake it up. Since the ESP32 doesn’t have any RAM retention functionality, I couldn’t find a way to store any information that would survive a reset.
Since I had already figured that my water installation was fine, I did not try to overcome this limitation and put the project on the side to focus on other projects like InfiniTime .
RISC-V, Bouffalo BL602, BL702, BL616
As you may know, I’m quite invested in the Pine64 community. In 2020, Pine64 released the Pinecil , a soldering iron based on a RISC-V MCU. 2020 was also the year of the Nutcracker challenge : the goal was to incentive developers to work on a FOSS BLE/WIFI stack for the BL602 RISC-V MCU from Bouffalo . They would send a PineCone (development board based on the BL602) to any developer interested in this challenge. Since then, Pine64 confirmed their interested in RISC-V by releasing the Pinecil V2 (based on the BL706), the Star64 (SBC), the OX64 (MCU/SBC based on the BL808) and the PineTab-V (RISC-V tablet, based on the same MCU that the Star64).
TL Lim, founder of Pine64 also sent me a few prototypes of the PineDio (development kit based on the BL604, equipped with LoRa, battery charger, solar panel, GPS,…) and a development board for the BL618, which could be useful for future projects.
The PineDio STACK prototype running some LVGL demo.
This shows how Pine64, TL and I are interested in experimenting with RISC-V, Bouffalo chips and LoRa!
Since my watermeter project is a quite simple project, I wanted to implement it on one of those RISC-V chips. I did many attempts but haven’t been able put everything together. The issue here is documentation and software support. Their SDKs (yes, there are mutliple SDK) are quite new and… they are a mess. At that time, they had 2 SDKs : the IOT and the MCU SDK. The IOT SDK was bloated and difficult to work with, but it provided support for BLE and WIFI. The MCU SDK was a bit lighter and easier to work with, but far from ideal, still. Both of them where missing drivers and examples for multiple low level functionalities of the MCU like the power management, for example.
The situation improved later on, both SDKs were merged into a single one : the Bouffalo SDK . From what I can tell, the state of the SDK improves regularly, they add missing functionalities, clean the architecture,… but last time I checked, power management wasn’t integrated in the SDK yet, and it’s also missing from the documentation.
I did some tests, manage to hack a few tests to put the MCU in sleep/hibernate mode, but couldn’t use it relibably enough.
That’s a shame since I could implement all other functionalities : SPI driver, communication with the SX1262 (LoRa module), pulse counting, port the LoRaMAC stack,…
Bouffalo will hopefully improve their SDK and documentation so that I can build this project on their chips at some point in the future!
NRF52
I restarted this project when I learnt about the Seeed Studio Xiao boards . Those are minimalist and cheap development boards for multiples MCU : RP2040, SAMD21, ESP32C3 and the NRF52840. I was especially interested in the later one, since Seeed Studio claims that it sips only 5µA in sleep mode and that it’s small and cheap. Moreover, working with the NRF52840 will be very easy for me because it’s the big brother of the NRF52832 which I very well thanks to the PineTime and InfiniTime projects.
Eventually, over the course of a few weeks, I went from this prototype on a breadboard…
… to this nice V1 of the project :
I’ll dedicate the rest of this series to this implementation of the project : hardware design, software implementation, tests, integration with TTN and Home-Assistant,… The next part will focus on the hardware design .