New to the arduino world but making the attempt to figure my way around a moteinoUSB transceiver and an arduino clone to a water level sensor. Attached is the code pieced together from a few different users. My most common error feedback seems to be: redefinition of 'void setup()'
I'm thinking it is probably a load of syntax errors but because I am unfamiliar ?
#define RF69_COMPAT 1 // Set to 1 if using RFM69 or 0 is using RFM12B
// Are we in Debug mode?
#define debug 0 // Set to 0 to save power, shuts down serial
// include libraries for RFM69 transceiver
#include <RFM69.h>
#include <RFM69registers.h>
#include <RFM69_ATC.h>
#include <RFM69_OTA.h>
// include libraries for FAT/Flash
#include <SPIFlash.h>
// include libraries power mgmt
#include <JeeLib.h>
#include <Ports.h>
#include <PortsBMP085.h>
#include <PortsLCD.h>
#include <PortsSHT11.h>
#include <RF12.h>
#include <RF12sio.h>
#include <RF69.h>
#include <RF69_avr.h>
#include <RF69_compat.h>
#include <RTClib.h>
// include libraries for motieno board
#include <Boards.h>
// include libraries emonCMS integration
#include <EmonLib.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
//
// All the radio stuff....
//
// Transmitting Frequency
RFM69 radio;
#define RF_freq RFM69_433MHZ
/*
Recommended node ID allocation
------------------------------------------------------------------------------------------------------------
-ID- -Node Type-
0 - Special allocation in JeeLib RFM12 driver - reserved for OOK use
1-4 - Control nodes
5-10 - Energy monitoring nodes
11-14 --Un-assigned --
15-16 - Base Station & logging nodes
17-30 - Environmental sensing nodes (temperature humidity etc.)
31 - Special allocation in JeeLib RFM12 driver - Node31 can communicate with nodes on any network group
-------------------------------------------------------------------------------------------------------------
*/
// Node ID
int nodeID = 25; // Node ID - should be unique on network - DIP switches can increment this ID by 1, 2 or 3.
// Network Group
const int networkGroup = 210; // RFM12B wireless network group - needs to be same as emonBase and emonGLCD
//
// Define where things are plugged in on the Moteino
//
// moteino pin allocations
//const int LED_RED = 9;
// Where is the ETAPE connected
#define ETAPE A0 // Where are we reading the resistance?
const int ETAPE_POWER = 7; // What GPIO pin will be powering the eTape?
// What is the CRUCIAL LEVEL of our pool water.
#define CRUCIAL_LEVEL 645 // You will need to test your eTape to get a setting that
#define POOL_OK_LEVEL 570 // works for you. In my case, 645 is about 4" on the tape for me
// Set up a timer (in minutes)
const int time_between_readings = 1; // How often do you want to measure and then transmit your readings to your Emonhub/Pi?
ISR(WDT_vect)
{
Sleepy::watchdogEvent(); // Attached JeeLib sleep function to Atmega328 watchdog -enables MCU to be put into sleep mode in
} //between readings to reduce power consumption
// Define what our RF payload will look like
typedef struct
{
int resistance;
int battery;
int level;
} Payload;
Payload pool;
SPIFlash flash(8, 0xEF30); //EF30 for 4mbit Windbond chip (W25X40CL)
//
// We run this ONE time on boot
//
void setup() {
// pinMode(LED_RED, OUTPUT);
pinMode(ETAPE_POWER, OUTPUT); // Set the pin powering the eTape to OUTPUT
}
pinMode(8, OUTPUT); // Added to make sure flash stays asleep and does not use power!
digitalWrite(8, HIGH);
// Initialize our RF
rf12_initialize(nodeID, RF_freq, networkGroup); // nodeID, RF_freq and networkGroup are taken from above
// if(IS_HIGHPOWER) radio.setHighPower(); // If we are using the RFM69HW version of the radio, set it to high power
// Tell thge wireless to take a nap until we need it again.....
rf12_sleep(RF12_SLEEP);
radio.sleep();
flash.initialize(); // Initialize the flash and then put it to sleep!
flash.sleep();
// Are we in debug mode? Output some information to the serial line....
if (debug)
{
Serial.begin(9600);
Serial.println("moteino_Pool_Water_Level_Sensor_ETAPE V1.0");
Serial.println("OpenEnergyMonitor.org");
Serial.println("RFM69HW Init> ");
Serial.print("Node: ");
Serial.print(nodeID);
Serial.print(" Freq: ");
if (RF_freq == RF12_433MHZ) Serial.print("433Mhz");
if (RF_freq == RF12_868MHZ) Serial.print("868Mhz");
if (RF_freq == RF12_915MHZ) Serial.print("915Mhz");
Serial.print(" Network: ");
Serial.println(networkGroup);
delay(100);
Serial.println();
Serial.print("You are currently configured to transmit data every ");
Serial.print(time_between_readings);
Serial.println(" minute(s).");
Serial.println();
Serial.println("Here is the data that we are transmitting:");
}
// Debug should look something like this
/*
moteino_Pool_Water_Level_Sensor_ETAPE V1.0
OpenEnergyMonitor.org
RFM69CW Init>
Node: 25 Freq: 433Mhz Network: 210
You are currently configured to transmit data every 1 minute(s).
Here is the data that we are transmitting:
ETape Resistance Level: 877 Ohms, Battery voltage: 3.20V
ETape Resistance Level: 873 Ohms, Battery voltage: 3.20V
ETape Resistance Level: 873 Ohms, Battery voltage: 3.20V
ETape Resistance Level: 873 Ohms, Battery voltage: 3.20V
ETape Resistance Level: 873 Ohms, Battery voltage: 3.40V
*/
// turn off non critical chip functions to reduce battery drain
reduce_power();
}
// Here is where we do the actual work....
void loop()
{
digitalWrite(ETAPE_POWER, HIGH); // Turn on the power to the eTape circuit
pool.resistance = analogRead(ETAPE); // read etape resistance
digitalWrite(ETAPE_POWER, LOW); // Turn off power to the eTape circuit
// Read our battery voltage
pool.battery = readVcc(); // read battery voltage