SunLeaf

An Open Source Sensing Module

Abstract

The SunLeaf is a wireless sensor module for remote sensing applications. The module is solar/battery powered, low power, connected via WiFi, low cost, and highly scalable. SunLeaf interfaces with several variety sensors, samples, and transmits the data to the cloud. Data is viewed through a web interface. The SunLeaf module intends to be a solution for many remote wireless sensing applications, such as plant health, agriculture, monitoring pollution, and monitoring climate.

Overview

SunLeaf is a wireless sensor module for remote sensing applications. The module is a simple low power device that interfaces with sensors and transmits that data to the cloud. The SunLeaf hardware makes up a rather complex printed circuit board. The brains of the device are an ARM Cortex M4 microcontroller and an ESP8266 module. The ARM interfaces with the sensors, and is the general brains of the device, the ESP8266 acts as a dedicated WiFi modem and interface to the web. SunLeaf will be able to perform firmware updates over the air. Sensors connect to the module via SeeedStudio Grove sensor connectors, SunLeaf accepts up to four UART, I2C, and analog/GPIO variety sensors. Module power is supplied by an onboard lithium ion battery, of which is charged by an onboard charge controller via solar panel or USB. Configuring the module for a given sensing application is performed by connecting with a PC either over USB or WiFi. The data logged from the sensors attached to a SunLeaf module is logged into https://thingspeak.com/ channel.

Inspiration, and Why

SunLeaf has roots dating back to HydroPWNics in spring 2015. Originally SunLeaf was going to be a redesign of the sensor modules and module hub as a standalone board. A module for interfacing with both digital sensors and analog sensors transmitting it over WiFi. Just being able to interface sensors and transmit data wirelessly wasn't enough, so the ability to run off a solar charged battery was added as a core feature. Solar power is an important feature because the module will be self sustaining also it makes the project innovative being one of the first solar powered sensor modules of this kind. All those features packed together made the module capable of much more than monitoring plant health and the environment. In short SunLeaf is a solar/battery powered pic power wireless sensing module for all wireless sensing applications.

Applications

Hydroponics:

SunLeaf has its roots in hydroponics, given that it is an evolution of the original hydroPWNics project’s electronics. In the application of hydroponics SunLeaf would be employed for monitoring the environment of the plant grow room. Multiple SunLeaf modules would be deployed along with a multitude of SeeedStudio Grove temperature and humidity modules. Additionally a single SunLeaf with equipped with Atlas Scientific (https://www.atlas-scientific.com/ ) pH, dissolved oxygen, electrical conductivity, temperature, and ORP sesnsors, these sensors will allow precise monitoring of water quality and with software monitoring of the nutrient content of the water. The same SunLeaf in charge of water quality monitoring would also be setup with additional hardware for controlling pH and delivering nutrients to the water supply. All SunLeaf units in the grow room should be able to run off excess light from the grow light units.

Water Quality Monitoring:

As mentioned in the hydroponics application SunLeaf also has use in water quality monitoring and management. The application is not limited to hydroponic water monitoring. Another application is pool water quality monitoring, make sure there isn’t too much or too little chlorine in the pool. A SunLeaf would be setup in a waterproof enclosure with the right probes with the solar panel on top, it would just float in the pool and run of the sun. In some parts of the country some folks do have access to water utilities provided by their town, in this case they have a water well that pumps fresh water into their home. SunLeaf could be setup either indoors off an AC adaptor or outside in an enclosure with the right probes to monitor drinking water quality of well water.

Environmental Monitoring:

Monitoring a given environment can be very handy. Already we talked about the application of monitoring a hydroponic grow room, focusing mostly on plant climate/environment. There are other applications for this kind of sensing. The SunLeaf can be setup with air quality and gas sensors from Seeedstudio in addition to the temp and humidity modules. A SunLeaf module setup like this could be used for air quality monitoring or monitoring environments of homes. Some folks are concerned about air quality and could monitor each room with a SunLeaf, placed by a window for power. Additionally realtors could use the SunLeaf module for the same purposes much akin to the open hardware device here: https://github.com/NationalAssociationOfRealtors/IndoorAirQualitySensor . Future versions of the SunLeaf will feature longer range RF tech, in the future SunLeaf modules could be used to monitor climate change around the globe. Future models with long range RF will cover remote areas, the existing SunLeaf can be used for urban and residential locations where WiFi is available.

SunLeaf has its roots in hydroponics, given that it is an evolution of the original hydroPWNics project’s electronics. In the application of hydroponics SunLeaf would be employed for monitoring the environment of the plant grow room. Multiple SunLeaf modules would be deployed along with a multitude of SeeedStudio Grove temperature and humidity modules. Additionally a single SunLeaf with equipped with Atlas Scientific (https://www.atlas-scientific.com/ ) pH, dissolved oxygen, electrical conductivity, temperature, and ORP sesnsors, these sensors will allow precise monitoring of water quality and with software minitorigin of the nutrient content of the water. The same SunLeaf in charge of water quality monitoring would also be setup with additional hardware for controlling pH and delivering nutrients to the water supply. All SunLeaf units in the grow room should be able to run off excess light from the grow light units.

Assistive Technology Application:

SunLeaf is a strong competitor for the Hackaday prize, specifically the Assistive Technology challenge on both global and local levels. Globally, SunLeaf will assist environmentally minded individuals to reduce their impact on the environment. SunLeaf does this by helping the individual understand when the best times to use water on their crops and the right amount of fertilizer to use. This will reduce water waste, fertilizer contamination and overall cost to support a plant. SunLeaf only needs a battery recharge every 2 years at most. By using solar energy and low power chips we’ve optimized the data upload times while also minimizing the max power usage time. This assists in getting the best information for your application. Locally, SunLeaf assists in environmental monitoring at all levels.
We have a very diverse I/O selection and sensor compatibility selection. This allows a complete picture of your plant’s growing environment. Some environmental sensing systems are very complicated to set up and get online. They are big and bulky-both physically and in software. With SunLeaf all you need to do to get started is set it in the sun to charge-then log onto your ThingSpeak.com channel. Our hardware is small and completely open source. The software is also completely open source; anyone can take this and have it constructed for their use (just make sure to give our team the credit if asked).

SunLeaf Module Hardware Overview:

General Function:

The SunLeaf module's function is easily described. At the heard of the system is the STM32F446RET6 ARM Cotex M4F microcontroller. The STM32 samples sensors through hardware multiplexer interfaces, packages the data and sends it to the ESP-09 module (containing the ESP8266) where it is transmitted to the cloud database. While all this sensor sampling, packaging, and transmission of data is occurring the system is constantly supplied a steady 3V3 voltage from the onboard power supply. The Power is provided by a LDO fed by lithium ion battery charged from either solar power or USB via onboard charge controller. Below is a simple block diagram of the SunLeaf module and general tech specs:

SunLeaf Module General Specifications:

- ST Microelectronics STM32F446RET6 ARM Cortex M4F 180MHZ MCU

- ESP-09 ESP8266 WiFi Module

- 4x Seeedstudio UART/USART Grove Sensor Connectors

- 4x Seeedstudio I2C Grove Sensor Connectors

- 4x Seeedstudio GPIO/Analog Grove Connectors (8 GPIO/Ana)

- USB 2.0 Connectivity for Development and Battery Charging

- Solar lithium battery charge controller and battery power suply

- Over the air updates via WiFi

- Ultra low power ultra long battery performance.

Overall System Control (ARM) - The brains of the device is the STM32F446RET6 ARM Cortex M4F microcontroller from ST Microelectronics. Onboard the STM32F446RET6 lives at the center of the device PCB. The MCU is supported by bypass capacitors, analog ref circuit, 8MHZ system crystal oscillator, 32KHZ RTC Oscillator (realtime), reset circuity, and JTAG header. The 8MHZ crystal is responsible for the system PLL of the STM32 and partly responsible for the 180MHZ clockspeed. The 32KHZ crystal serves the internal realtime clock of the STM32 chip, it will be necessary for keeping track of real world time. The STM32 performs all sampling of the sensors either directly (analog), or through the hardware interfaces onboard (UART/I2C multiplexers). The STM32 is programmed either via USB, over the air (ESP8266/UART), and via the ARM Cortex M JTAG debugger board. The STM32 can be separated from the ESP-09 module on the bottom via jumper.

Power Supply (Solar/Battery/LDO) - The power supply consists of a battery input, solar panel input, Ti BQ24210 charge controller, and a AZ1117CR-3.3TRG1-1 3V3 LDO voltage regulator. The BQ24210 charge controller handles all charging of the battery, via solar panel or USB input, USB input bypasses the solar panel input with a Schottky diode and two swtiching MOSFETs, one disconnecting the solar panel and the other the battery. The power supply as designed for the first prototype can supple up to 800mA 3V3 power. Through the continued development of SunLeaf the goal will be to get the system consumption down to 500mA and the PSU design revised.

Sensor Interfacing (Grove) - Sensor Interfacing is handled in combination between the STM32F446RET6 and dedicated multiplexer circuitry. UART sensors interface with the STM32 via a 74HC4052D analog multiplexer/demultiplexer, using only one UART port on the STM32. I2C sensors are interfaced via the PCA9518 I2C multiplexer, using up only one I2C port on the STM32. A specialized multiplexer is required for I2C because of capacitive load requirements of the I2C bus specification. Analog sensors directly interface with the STM32 via the built in ADC, also function as GPIO. The STM32F446RET6 has special power filtering for the analog rail so the ADC samples accurately. Lastly all senors interface with the SunLeaf via tjhe same 4 pin JST connector, 4 UART ports, 4 I2C Ports, and 4 GPIO/Analog Ports (8 signals total).

Wireless Interfacing (ESP8266, ESP-09) - Wireless interfacing with the internet is taken care of by the ESP8266 WiFi SoC aboard the ESP-09 module mounted next to the STM32F446RET6 . The ESP-09 module performs all the heavy lifting of interfacing with the cloud server, allowing the STM32F446RET6 to be dedicated to all other tasks. Onboard there are headers for separately programing the ESP-09 module, the connector is inlined with the connection to the STM32. The ESP-09 module does not come with an antenna or antenna connector, as a result one has be provided for it on the newest SunLeaf design revision. The ESP-09 module will use the same antennas with the ultraminiatrure coaxial connectors. The ESP-09 is also connected to the STM32 with all relevant signals for over the air programming of the STM32 via wifi. The ESP-09 module is capable of driving the STM32 into a bootloader mode that will allow firmware to be loaded over a UART port onto the STM32. Eventually we plan to have the entire device update itself, program the the STM32 first, load firmware for the ESP8266.

Hardware Iterations:

Prototype iteration - built off an Adafruit Huzzah (ESP-12E) and a ST Microelectronics Nucleo board, with FTDI board for ESP programming.

First iterations SunLeaf 0.1 Alpha, Design completed May 2016, assembled July/August 2016, this is the first design of the PCB implementation of SunLeaf.

OSHPark Frabicated and self assembled:

New PCB prototypeSunLeaf 0.2a, featuring proper GPIO grove connectors and other fixes

Embedded Software System Overview

Let's take a high-level look at how the embedded system is going to function. There are three main requirements from a user standpoint for this project:

  1. It must be 'easy' to configure. To me this means that my parents need to be able to configure it so they can use it with their gardens.
  2. We need to be able to update the embedded software remotely.
  3. it must be able to interface with a cloud database like Azure or Mongo

This is a tall order for a bare metal micro controller but to achieve the power point and cost point we set we'll need to make it happen. At first we evaluated several embedded Operating systems in the hope of using an RTOS. We foundZephyr. Zephyr is:

"... a small, scalable real-time operating system for use on resource-constrained systems supporting multiple architectures. Developers are able to tailor their optimal solution. As a true open source project, the community can evolve the Zephyr Project to support new hardware, developer tools, sensor and device drivers. Advancements in security, device management capabilities, connectivity stacks and file systems can be easily implemented."

This sounded perfect for what we need on this project. We just need the hardware to run it on (see the hardware description above). But we decided not to go with Zephyr in the end. The requirements are still the same but we can achieve these requirements with less cost in terms of power and dollars by using a less expensive and lower power hardware stack. This stack will be too small to efficiently support Zephyr.

Firmware Overview

This is a very high level state diagram and should only be used to illustrate the intended functionality of the system. The green circles represent the power states of the ST chip. The fuchsia circles represent the power states of the ESP chip. Within the run power state of each device the majority of the work occurs. Clearly right now we are thinking a lot about how to minimize the amount of power while making sure the system meets all of the functional requirements. From the run states we either update the firmware or we do I/O management. Once the sensor data is managed appropriately. Some data clean up occurs and the devices are set into their low power states. The devices will be triggered to wake up by a timer.

The mBed platform is a lot like Arduino, its the official easy to use ARM development platform, originally started out on NXP MCUs, and later expanded to FreeScale and ST Microelectronics hardware. We decided to use mBed so development would move along quick, in the end we plan to implement everything on the bare metal from scratch.

Image: http://www.edom.com.tw/userfiles/Image/ARM%20mbed%20logo.png

From the mBed site:

"What is mbed?

ARM mbed is the idea that the Internet of Things (IoT) is a collaboration between the people who make things, the people who use things and the people who make the services all these things use. ARM created a solution to help lead sustainable growth within the IoT and named it mbed.

mbed has a large community of developers, an ecosystem of open source IoT code, a network of hardware partners, and products and services that serve the IoT market. When we talk about the elements of mbed together, we talk about the ARM mbed IoT Device Platform: the mbed Developer Community, mbed OS, ,mbed Device Connector Service, mbed TLS, and mbed Client."

Source: https://www.mbed.com/en/about-mbed/what-mbed/

ESP8266

Image: https://avatars3.githubusercontent.com/u/9460735?v=3&s=280

Firmware for the ESP8266 module is developed using the ESP-open-sdk found here: https://github.com/pfalcon/esp-open-sdk you can read more about how to set it up in our project log here: https://hackaday.io/project/10457-sunleaf/log/37806-embedded-toolchains As for the firmware itself its a modified fork of ESP-Link you can read more about it here: https://github.com/HydroPWNics/SunLeaf-ESP8266

Open Source Licensing

SunLeaf Hardware Module:

SunLeaf Module Hardware source hosted at https://github.com/HydroPWNics/SunLeaf

Under the CERN Open Source Hardware License, http://www.ohwr.org/attachments/2388/cern_ohl_v_1_2.txt

Firmware Licensing

STM32F446RET6 - Firmware License - https://www.apache.org/licenses/LICENSE-2.0.html

mBed License - https://www.apache.org/licenses/LICENSE-2.0.html

ESP8266 - FIrmware/ESP-Link License - https://github.com/jeelabs/esp-link/blob/master/LICENSE.txt

ESP-Open-SDK License - https://opensource.org/licenses/MIT