Open Grow Controller + Arduino + NRF24L01 + Software

With our Open Source Firmware for your Arduino you can make from your development board one more GroBot for our system to control.

In this way you are able to build your own GroBots with the sensors and outputs you need.

The example provided in this post is for the Default User Bot we created, a GroBot with one button and one LED.

Always keep in mind that you can configure up to 10 different inputs and 10 different outputs, you just need to make some firmware tweaks as we'll explain later.

Basic Hardware Config

An Arduino, one module NRF24L01, one button and one LED is everything you need to create your basic UserBot.

Usually these RF Modules present some troubles with floating power, happens because the module has some current spikes that probably your Arduino can't handle, so a 10uF capacitor was added to eliminate possible power issues.

As you can see, the schematic is quite simple, just assemble your RF Module as showed, and use the remaining free pins in your Arduino to connect your inputs/outputs.

In this case Analog 0 for the button and Digital 3 for the LED. Digital 3 was chose because it can implement PWM in that way you can see the speed parameter working.

Firmware Basics

Before we explain what bits of code you need to change in order to add your own sensors, let's look at the main firmware and understand how those parts are configured by default.

Lets start to understand the structures for an Input and an Output are defined in GroBotConfig.h

Definition of an Arduino Input:

type - A value that defines what type of input you are using

growRoomID - The Area that you want to associate this sensor. growID - Grow inside the Area where the sensor belongs. value - a double value that contains the sensor acquired from sensor (If Boolean. sensor value = 0 = false, value >0 = true. Name - A string with 14 chars,, that describes this sensor.

Definition of an Arduino Output:

type - A value that defines what type of output you are using

growRoomID - The Area that you want to associate this output. growID - Grow inside the Area where the output belongs. value - a byte value that contains the state of the output speed - A value from 0 to 255 to define the speed of the output (useful for dimming, pwm control, etc..) Name - A string with 14 chars, that describes the output These structures are aggregated in two different arrays of size 10 each, this means you can configure up to 20 I/O's, 10 of each.

As it is the firmware is ready to communicate with a GroNode with masterID 0x01.

The firmware was also configured with one input, a button, and an output, a LED.

That configuration can be seen in SensorsTask.cpp. If you want to add more sensors or outputs you should start looking at this file.

At the top you'll see that we are defining the position inside the respective Input/Output array, and also on what physical Arduino pin you are connecting that sensor.

One button and one LED looks like this.

|500x167

After that we need to initialize our pins with the respective configuration.

That is done in the object constructor.

|500x138

After you make this configurations, and you know what kind of sensors and actuators you are dealing with, you should look at the SensorsTask state machine (GoSensorsTask()) and see that all reading or writing on this pins is exclusively made here.

|500x307

Your UserBot should show up in the software like this

|500x295

Firmware Config

The code you'll see below in the Green Boxes is commented in the firmware provided in our GitHub repository. We removed them from coment here so you can better understand what to change in order to add your inputs and outputs.

In the next example we are adding an extra button and an extra LED.

To do so you first need to configure the index array and the I/O respective pin.

|500x207

As you can see we added an extra button to pin A1 at index 1 and a extra LED to output 4.

Then we need to look at the sensor state machine and add the actual code to pull or push the data into the new IO's.

|500x482

If your sensor needs some kind of math before being send to the GroNode, here is were you made that math. Gronode doesn't handle raw values, for example if you have an analog temperature sensor, the values 0~1024 won't make any sense to the GroNode, you first need to do your sensor math and only then you save it in the input structure array.

This should be the result of your new configuration.

|500x296

GitHub repository is available for checkout, expect some updates in the next weeks.

Cheers,

Support us at https://hackaday.io/project/5921-grobots-opengrow Developer Blog: http://blog.opengrow.pt/ Follow us at https://www.facebook.com/OpenGrowEN Discover more here http://www.opengrow.pt/index.php/opensource/