Aeroponics module without Pressure Tank for Nano. More...
#include "Arduino.h"
#include "avr/wdt.h"
#include "avr/boot.h"
#include "printf.h"
#include "Thread.h"
#include "StaticThreadController.h"
#include "SPI.h"
#include "RF24.h"
#include "SerialLog.h"
#include "Settings.h"
#include "src/Modules/AeroModule_NoTank.h"
#include "src/WirelessCommands_Aero.h"
Go to the source code of this file.
Functions | |
RF24 | Wireless (WirelessCEPin, WirelessCSNPin) |
Initialize the NRF24L01 wireless chip (CE, CSN pins are hard wired on the Arduino Nano RF) | |
void | setup () |
void | InitializeWireless () |
void | loop () |
Threads. | |
void | processTimeCriticalStuff () |
void | run1sec () |
void | run5sec () |
void | run1min () |
void | heartBeat () |
Wireless communication. | |
void | getWirelessData () |
void | getWirelessStatus () |
time_t | updateTime () |
Variables | |
bool & | Debug = *new bool |
bool & | Metric = *new bool |
char | LongMessage [MaxLongTextLength] = "" |
Temp storage for assembling long messages (REST API, MQTT reporting) | |
char | ShortMessage [MaxShotTextLength] = "" |
Temp storage for assembling short text messages (Log entries, Error messages,etc) | |
char | CurrentTime [MaxWordLength] = "" |
Buffer for storing current time in text format. | |
void * | ReceivedMessage = malloc(WirelessPayloadSize) |
uint32_t | ReceivedMessageTimestamp = millis() |
HardwareSerial & | ArduinoSerial = Serial |
< Component initialization | |
Settings * | ModuleSettings |
settings loaded from the EEPROM. Persistent between reboots, defaults are in Settings.h | |
AeroModule * | AeroMod1 |
Represents a Aeroponics tote with solenoid,pressure pump..etc. | |
Thread | TimeCriticalThread = Thread() |
Thread | OneSecThread = Thread() |
Thread | FiveSecThread = Thread() |
Thread | MinuteThread = Thread() |
Aeroponics module without Pressure Tank for Nano.
To change the default pin layout / startup settings navigate to: Settings.h
Runs autonomously on an Arduino RF-Nano or Arduino Nano with an nRF24L01+ wireless transceiver.
Supports wireless data exchange with the Main module
Definition in file Gbox420_Nano_Aero_NoTank.ino.
void getWirelessData | ( | ) |
< Updating internal timer
Definition at line 150 of file Gbox420_Nano_Aero_NoTank.ino.
void getWirelessStatus | ( | ) |
Definition at line 170 of file Gbox420_Nano_Aero_NoTank.ino.
void heartBeat | ( | ) |
Wireless communication.
Definition at line 141 of file Gbox420_Nano_Aero_NoTank.ino.
void InitializeWireless | ( | ) |
< Set the speed to slow - has longer range + No need for faster transmission, Other options: RF24_2MBPS, RF24_1MBPS
< RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit
< RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBm, and RF24_PA_MAX=0dBm.
< The number of bytes in the payload. This implementation uses a fixed payload size for all transmissions
< Not necessary, startListening should switch back to normal power mode
< Dump all previously cached but unsent ACK messages from the TX FIFO buffer (Max 3 are saved)
< Dump all previously received messages from the RX FIFO buffer (Max 3 are saved)
< Reset timeout counter
Definition at line 83 of file Gbox420_Nano_Aero_NoTank.ino.
void loop | ( | ) |
Threads.
< put your main code here, to run repeatedly:
< loop only checks if it's time to trigger one of the threads (run1sec(), run5sec(),run1min()..etc)
< If a control package is received from the main module
Definition at line 107 of file Gbox420_Nano_Aero_NoTank.ino.
void processTimeCriticalStuff | ( | ) |
Definition at line 116 of file Gbox420_Nano_Aero_NoTank.ino.
void run1min | ( | ) |
Definition at line 134 of file Gbox420_Nano_Aero_NoTank.ino.
void run1sec | ( | ) |
< reset watchdog timeout
< Blinks built-in led
Definition at line 121 of file Gbox420_Nano_Aero_NoTank.ino.
void run5sec | ( | ) |
Definition at line 128 of file Gbox420_Nano_Aero_NoTank.ino.
void setup | ( | ) |
< put your setup code here, to run once:
< Nano console output
< onboard LED - Heartbeat every second to confirm code is running
< New line
< logs to the Arduino serial, adds new line after the text (true), and uses no indentation (0). More on why texts are in F(""): https://gist.github.com/sticilface/e54016485fcccd10950e93ddcd4461a3
< Watchdog timeout set to 8 seconds, if watchdog is not reset every 8 seconds it assumes a lockup and resets the sketch
< fix watchdog not loading sketch after a reset error on Mega2560
< Copy a blank command to the memory block pointed ReceivedMessage. Without this ReceivedMessage would contain random data
< Loading settings from EEPROM
< Setting up wireless module
< Threads - Setting up how often threads should be triggered and what functions to call when the trigger fires
< 100ms, 0.1sec
< 1000ms
< Create the Aeroponics object
< This is the main object representing an entire Grow Box with all components in it. Receives its name and the settings loaded from the EEPROM as parameters
Definition at line 45 of file Gbox420_Nano_Aero_NoTank.ino.
time_t updateTime | ( | ) |
Definition at line 180 of file Gbox420_Nano_Aero_NoTank.ino.
RF24 Wireless | ( | WirelessCEPin | , |
WirelessCSNPin | |||
) |
Initialize the NRF24L01 wireless chip (CE, CSN pins are hard wired on the Arduino Nano RF)
Thread initialization
AeroModule* AeroMod1 |
Represents a Aeroponics tote with solenoid,pressure pump..etc.
Definition at line 35 of file Gbox420_Nano_Aero_NoTank.ino.
HardwareSerial& ArduinoSerial = Serial |
< Component initialization
Printing serial messages to the Arduino Serial output.
Printing serial messages to the Arduino Serial output and the esp-link Microcontroller Console (uC Console)
Reference to the Arduino Serial
Definition at line 33 of file Gbox420_Nano_Aero_NoTank.ino.
char CurrentTime[MaxWordLength] = "" |
Buffer for storing current time in text format.
Definition at line 28 of file Gbox420_Nano_Aero_NoTank.ino.
bool& Debug = *new bool |
Definition at line 24 of file Gbox420_Nano_Aero_NoTank.ino.
Thread FiveSecThread = Thread() |
Definition at line 41 of file Gbox420_Nano_Aero_NoTank.ino.
char LongMessage[MaxLongTextLength] = "" |
Temp storage for assembling long messages (REST API, MQTT reporting)
Definition at line 26 of file Gbox420_Nano_Aero_NoTank.ino.
bool& Metric = *new bool |
Definition at line 25 of file Gbox420_Nano_Aero_NoTank.ino.
Thread MinuteThread = Thread() |
Definition at line 42 of file Gbox420_Nano_Aero_NoTank.ino.
Settings* ModuleSettings |
settings loaded from the EEPROM. Persistent between reboots, defaults are in Settings.h
Definition at line 34 of file Gbox420_Nano_Aero_NoTank.ino.
Thread OneSecThread = Thread() |
Definition at line 40 of file Gbox420_Nano_Aero_NoTank.ino.
void* ReceivedMessage = malloc(WirelessPayloadSize) |
Definition at line 29 of file Gbox420_Nano_Aero_NoTank.ino.
uint32_t ReceivedMessageTimestamp = millis() |
Definition at line 30 of file Gbox420_Nano_Aero_NoTank.ino.
char ShortMessage[MaxShotTextLength] = "" |
Temp storage for assembling short text messages (Log entries, Error messages,etc)
Definition at line 27 of file Gbox420_Nano_Aero_NoTank.ino.
StaticThreadController<4> ThreadControl& TimeCriticalThread = Thread() |
Definition at line 39 of file Gbox420_Nano_Aero_NoTank.ino.