Edge Collective

Vale da Lama Greenhouse Monitoring


All of this research and prototyping is occurring at Quinta Vale Da Lama.

April 13, 2020


Great talk on Sqllite, arguing that it's appropriate for a database located on 'the edge'.

24 Apr 2020

Test Feather Code

Simple test code for Adafruit Feather + RAK

05 May 2020

Configuring the region on the RAK

General setup for the RAK 7243 + Pi firmware is here.

Information about the configuration file is here.

The firmware we're using is here.

Can use 'gateway-config' command line script on RAK to set the region:

sudo gateway-config

This script modifies this file:


Basic Arduino Test Code

Basic test code for sending data to the RAK in OTAA mode is in gist form here.

Configuring the region on the Arduino

Changing the region on the Arduino requires modifing a special header file.

See the Adafruit Arduino tutorial here.

Adafruit Feather 900 Mhz can be tuned to 868 Mhz band

See the below snippet from the Adafruit Feather M0 LoRa 900 Mhz product page:

Adafruit LMIC OTAA basic code will attempt to rejoin periodically

See this example serial output:

Needed tweak on Adafruit for EU band

See the forum post here:

This might be a useful reference for setting up 868 band.

Current impression is that RAK hardware does indeed distinguish between 868 and 915 Mhz bands ... ?

05 May 2020 13:27 Update: there is a 'project_config' file located in the 'src' folder on in the lmic library folder itself -- and it's set to the US band -- perhaps this is overriding the project files? Trying setting it to EU and the RAK to EU. One open question is how specific the RAK Pi Hat is re: freq bands ... can it handle 868?

So the current thinking for getting 868 band to work is:

Meanwhile, note that upload via bossac did work on the Pi.

Confirmed -- was able to get upload on RAK in US '915' version by setting to '868' following above steps. Key seems to have been the Arduino library project_config folder issue.

Note: we are using mcci-catena arduino-lmic 2.3.2 version of library with success. Later versions haven't always worked. Stick with that for now.




Wiring Adafruit Feather to BME280

As per instructions here:

BME280 ---> Feather

Code for BME280 + Feather M0 LoRa

Using the BME280 can be accomplished by using the Adafruit BME280 Arduino Library, which also requires using the Adafruit Sensor Library.

Uplaoding firmware to Adafruit Feather M0 via command line (bossac)

An Adafruit tutorial is here. Note that we need the 'arduino' branch of the bossac tool on github, which is version 1.7.X.

sudo bossac -p /dev/ttyACM0 -e -w -v -R firmware.bin

Debugging the BME280 sensor

Sensor not working on Walt's RAK. Q: is it because of connection to Feather / problem with Feather, or is it because of some setting on the Gateway?

Diagnostic: some basic BME280 test code, non-LoRa -- just prints values out to serial port. Wrote the binary, and then sent it to Walt's feather remotely -- and got back an error:

09 May 2020

BME280 Node Fixed

Walt was able to fix the BME280 node by re-soldering nad re-wiring:

Local Sqlite database on USB

We've been able to get a local sqlite database up and running now, stored on a USB flash drive on the RAK:

Human-readable date format

And we added a field to the database that provides a human-readable date.

## Overview

Assembly Guide for Version 4.

Video explanation of the current status as of Oct 07 2020 ..

AM2315 and 'new' i2c on Feather M0

Issue: we designed a breakout board (in Eagle CAD) to be milled in Portugal by Lucio; but the original intent was for a different, non-i2c sensor; the one we're using now is an i2c sensor (the AM2315, and requires:



Ah -- update -- can't reassign the pins because of the 'pad constraint', see the section here.


Adafruit Feather M0 LoRa (for pin reference).

FAB Farm


Lucio's FAB Farm.

Feather BME280 data export from server

One can grab CSV data from the Valedalama server like thus:

where the 'limit=N' parameter gives the 'most recent N values'.

A snapshot of all of the historical data from "Valedalama BME280 Feather" from the earliest collection date (July 10 2020) up through Oct 10 2020 can be downloaded here.

Board Designs


Remote Version 4: Eagle CAD

Design files are here

Remote schematic, version 4.
Remote board, version 4.

Remote Version 5 in KiCAD:

Repo is here.

Remote board, version 5.

Assembly Guide for Remote Node Version 4

(Update OCT 30 2020)

Lucio has milled both Version 3 and Version 4 of the remote node. Current focus is on assembly of Version 4 (design files here.

For reference, Version 4 board design looks like this:

Remote board, version 4.

It is a 'mother board' for a Feather M0 LoRa microcontroller.

The remote board version 4 requires:

It is obvious from the footprints on the board which of the above go where :)

Note: the ESP32 device only requires that the accompanying antenna that came with the baord be plugged into it (it's a bit fiddly, but no soldering required).

2020 Nov 10

The associated version 5 kicad pcb file is easy to upload to Aisler (German PCB producer) -- about $25 euros for 3 PCBs, 3-5 day turnaround:

2020 Nov 11

Lucio's setup, with his milled board:

Sensor working with the feather:

Data flowing through to Bayou:

2020 Nov 14

Next steps:

Can offer ...




So -- all off-the-shelf, o r fully custom. Along with guides for all of this.

OTA for the remote node?

NRF52 OTA programming link (weather buoy project) here

Features to add in REV_C


2020 Nov 17

Data coming in from first deploymend of milled board version of the remote node.



Pagination strategies with pouchdb -- useful for setting up the server, here

Humidity sensor issue?

Looks like the Humidity tends to get pegged ...

Date Conversion formula in Excel

Example is [here[(https://docs.google.com/spreadsheets/d/1yDYKKenBeMRpYumavZ4Df_dnJOKyFEXB-Inp_YYGFdY/edit?usp=sharing).

2020 NOV 19

Added 'hop' parameter and modified units on Bayou display

NOTE: running the branch 'ticks', code on gitlab here. Might need to tweak if a new sensor is added, because the ticks currently do only every hour.

Humidity sensor details

AM2315 temp + humidity sensor tech details:

AM2315 datasheet

Architecture Idea

Gateway is Heltec. Can do AP wifi credentials and FarmOS / Bayou configuration.

Remote node is Feather / Mothbot. Has a DIP switch to modify the node ID.

Both might allow for serial configuration, or OTA programming (need to add SPI Memory to Mothbot if so).

Battery holders

3XAA holder here.

Guide to battery holders and mounts here.

Adafruit guide to using the battery on the Feather

Do's and don't's, here.

What if we put use 3.3V regulator and power the Feather this way? Try this experiment out at home. Turning a Feather into a lower-power device would be a win.

Breakout boards for:

Using: dip switch + MCP1700

2020 NOV 22

Looks like remote node (Feather) is requiring reset periodically (every few days) -- doesn't appear to be a battery issue. Might be in the code -- e.g. if it doesn't read from sensor successfully.

ESP32 Watchdog timer

Guide here.

Also, working code here. <--- this looks like the proper setup. Great!

SAMD21 Watchdog timer

There's a discussion here <<-- this is a GREAT discussion.

Note that he's also got an e-ink project running, here.

Getting sleepy dog to work, here.

Another blog post on it here.

AVR Watchdog timers

Another article on the watchdog timer for AVRs is here.

And yet another nice article for WDTs in AVRs is here.

Good point made in this tutorial:

One possible issue with the watchdog timer, depending on the bootloader of your Arduino is that if the watchdog timer value is too low and the bootloader does not reset the timer when uploading new code, you may end up damaging your Arduino board in a way that it will always be stuck in the boot phase. The bootloader will try to start, but the timer will keep resetting the board, never allowing it to properly start. To prevent issues like this, make sure to always use threshold intervals of 2 seconds or more.

Another good description by Electronic Wings, here.

Powerdown Sleep

Nice post from Tony D, here.

ArduBadge system for Arduino libraries

Check out some of the libraries here.

Overview of system architecture

Remote access to Pis

Indeed, this looks like cool software -- browser-based. Check it here.

Ah, a better, RPi-specific set of options is here.

Jim Spark's guide to port forwarding / SSH with Pis here.

He says it's very dangerous to do; and that cloud proxy is better. His guide here.

pre-burning an image on the pi from remote.it, here.

Copy-paste in RealVNC

Descriptive link is here.

Remote Access via hyperssh

Diff of dwblair's hyperssh and mafintosh's versions, here.

2020 NOV 23

REV_A of the 'greenhouse' system uses the following code:

Going to try a watchdog timer on the feather ...

Implemented very basic watchdog here.

Data here.

2020-11-26 20:33:48

Design notes

Interesting Things Network post on a BME280 outdoor LoRa node, here.

Relies on a really low power LoRa node design based on an Atmel 328p -- elegant! -- here

Nice post on OLED sleep current, here. Looks like the 128x65 display I favor uses around 25 uA when asleep.

A nice general review of OLEDs and various libraries and use-cases, here. Includes code for putting the OLED to sleep.


Need designs for:

2020-11-29 04:42:55

Update NOV 29 2020

Current situation. Adding the watchdog timer seems to have made the remote node more robust; it has been operating non-stop for several days now, plugged into the RAK Pi. We'd like to move to installing the device into the greenhouse. Are there any things we ought to do first to improve the likelihood of success there?

There are two things we might consider doing immediately:

  1. Reduce remote node power consumption. The remote node is currently broadcasting every 10 seconds or so, and sleeping in between. This is far more data than is useful, and will unnecessarily drain the battery. We should change this to an interval of about 10 minutes or so.
  2. Add remote node battery measurement. It would be helpful to add remote battery level measurement to the remote node, so we can better assess the solar charging statistics. Note: doing so would require re-programming the gateway, as well, to accommodate the additional parameter.

Discussion. (1) Above (increasing the sleep time between measurements / broadcasts) is an quick fix, which can be accomplished with the Feather plugged into the RAK, and the process has been done before, and recently. The process for (2) should be straightforward, but hasn't been done before via the RAK. It could require some fiddling, iterating, back-and-forth, and risks 'breaking' the system until the Arduino IDE is used; and we currently don't have an on-site way of using the Arduino IDE to reprogram the ESP32 (ran into security issues installing ESP32 on Walt's computer).

Recommendation. In following Lucio's philosophy of making minimal changes in-place to a system that is mostly working, my recommendatoin at this point would be: let's do (1) above (increase the sleep time), and wait on (2) (adding battery level). While it would be nice to measure battery level, adding the feature increases the risk that we'll have a somewhat 'bricked' system for a bit, and it seems that there's a fairly high chance of success if we can sleep the node for 10 minutes (and higher still if we can sleep longer, as we'd be even less likely to run the battery down). In the meantime, I can work on workflow / testing for (2).

Proposed next steps.

Meanwhile, I will test locally the procedure for accomplishing (2) above -- adding battery level monitoring to the remote node.

2020-11-30 08:57:54

Watchdog Sleep

Use Moteino M0 sleep code as a reference, here.

Test feed here

Alright, looking for every 5 min, after 1606774953 ...


Works! When get home will try for 10 minute intervals, and test the power consumption ...

2020-12-01 07:36:47

Update on code ...

timestamp difference:

10 minute intervals!

Working code is part of "REV_A" greenhouse suite, here.

Also have improved REV_A gateway code that displays wifi status (sort of), here.

2020-12-01 13:37:55

Note -- hadn't fully implemented the watchdog timer in previous REV_A version; and now we send a sensor reading on startup, which is easier for debugging -- latest version (ready for testing) here

2020-12-15 08:45:07

Next steps:

Note: device is called walt-rak ... can connect via VNC viewer in Downloads ...

2020-12-15 12:25:29

Programming heltec from command line

Guide here

Code is here

2020-12-17 09:45:17

looks like the p2p2-farm server code requires that hop>=1 in 'get-drives-data.js'

this is now in 'fixhop' branch

remote code sleeps at 0.15 mA

latest remote node code is here -- sleeps at 0.15mA, uses watchdog timer.

latest gateway code is here.

next steps:

first: testing that code works at 10 min interval.

command to load onto feather was: ./bossac -p /dev/ttyACM0 -e -w -v -R ./remote_watch_sleep_10min.ino.bin

bayou feed is located here

2020-12-17 15:23:43

2020-12-23 08:17:40

Test of the battery level over a few days ...

2021-01-01 17:48:29

Battery level seems to be holding steady!

Feed here:

2021-01-08 08:59:07

Batt level continues to hold ... feed here

2021-01-21 21:06:53

Still going strong! feed