Arduino Manager App code won't compile

Hi all,

My first post here, hoping I’m doing it right.

I have no coding background and learning this up right now.

I’m trying to monitor the batteries in my travel trailer.

I’ve been able to log the voltage using the datalogging shield from Adafruit.

I’ve also been able to monitor voltage on my phone using the Arduino Manager app.

However, when I merge both codes to log and monitor at the same time, it won’t compile.

Iget a bunch of “was not declared in this scope” errors.

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#include <IOSControllerForHM10.h>

// A simple data logger for the Arduino analog pins

// how many milliseconds between grabbing data and logging it. 1000 ms is once a second
#define LOG_INTERVAL  5000 // mills between entries (reduce to take more/faster data)

// how many milliseconds before writing the logged data permanently to disk
// set it to the LOG_INTERVAL to write each time (safest)
// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to
// the last 10 reads if power is lost but it uses less power and is much faster!
#define SYNC_INTERVAL 10000 // mills between calls to flush() - to write data to the card
uint32_t syncTime = 0; // time of last sync()

#define ECHO_TO_SERIAL   1 // echo data to serial port
#define WAIT_TO_START    0 // Wait for serial input in setup()

// the digital pins that connect to the LEDs
#define redLEDpin 1
#define greenLEDpin 0

/*IOSController Library initialization*/

IOSControllerForHM10 iosController(&doWork, &doSync, &processIncomingMessages, &processOutgoingMessages, &deviceConnected, &deviceDisconnected);

// The analog pins that connect to the sensors
const int voltageSensor = A0;

float vOUT = 0.0;
float vIN = 0.0;
float R1 = 20.0;
float R2 = 10.0;
int value = 0;
unsigned long VoltageLastMeasurementTime;

RTC_Millis RTC; // define the Real Time Clock object

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
  Serial.print("error: ");

  // red LED indicates error
  digitalWrite(redLEDpin, HIGH);

  while (1);

void setup(void) {
  // use debugging LEDs
  pinMode(redLEDpin, OUTPUT);
  pinMode(greenLEDpin, OUTPUT);
  Serial.println("Type any character to start");
  while (!Serial.available());
#endif //WAIT_TO_START

  // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  Serial.println("card initialized.");
  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile =, FILE_WRITE); 
      break;  // leave the loop!
  if (! logfile) {
    error("couldnt create file");
  Serial.print("Logging to: ");

  // connect to RTC
  if (!RTC.begin()) {
    logfile.println("RTC failed");
    Serial.println("RTC failed");
#endif  //ECHO_TO_SERIAL


void loop() {


  DateTime now;

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL - 1) - (millis() % LOG_INTERVAL));

  digitalWrite(greenLEDpin, HIGH);

  // log milliseconds since starting
  uint32_t m = millis();
  uint32_t stamp = (m + 1) / LOG_INTERVAL;
  logfile.print(stamp);           // seconds since start
  logfile.print(", ");
  Serial.print(stamp);         // seconds since start
  Serial.print(", ");

  // fetch the time
  now =;
  // log time
  logfile.print(now.year(), DEC);
  logfile.print(now.month(), DEC);
  logfile.print(, DEC);
  logfile.print(", ");
  logfile.print(now.hour(), DEC);
  logfile.print(now.minute(), DEC);
  logfile.print(now.second(), DEC);
  Serial.print(now.year(), DEC);
  Serial.print(now.month(), DEC);
  Serial.print(, DEC);
  Serial.print(", ");
  Serial.print(now.hour(), DEC);
  Serial.print(now.minute(), DEC);
  Serial.print(now.second(), DEC);

  value = analogRead(voltageSensor);
  vOUT = (value * 5.0) / 1024.0;
  vIN = vOUT / (R2 / (R1 + R2));
  logfile.print(", ");
  Serial.print(", ");

#endif // ECHO_TO_SERIAL

  digitalWrite(greenLEDpin, LOW);

  // Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card
  // which uses a bunch of power and takes time
  if ((millis() - syncTime) < SYNC_INTERVAL) return;
  syncTime = millis();

  // blink LED to show we are syncing data to the card & updating FAT!
  digitalWrite(redLEDpin, HIGH);
  digitalWrite(redLEDpin, LOW);


/**This function is called periodically and it is equivalent to the standard loop() function**/

void doWork() {

  if (millis() - VoltageLastMeasurementTime > 60000) {
    VoltageLastMeasurementTime = millis();
    Voltage = analogRead(Voltage_PIN);

  /**This function is called when the ios device connects and needs to initialize the position of switches and knobs**/

  void doSync(char*variable) {

    /* Start your code (doSync) */

    /* End your code */

  /**This function is called when a new message is received from the iOS device**/

  void processIncomingMessages(char *variable, char *value) {

    /* Start your code (processIncomingMessages) */

    /* End your code */


    This function is called periodically and messages can be sent to the iOS device

  void processOutgoingMessages() {

    iosController.writeMessage("Dedans", Dedans);
    iosController.writeMessage("Dehors", Dehors);
    iosController.writeMessage("Voltage", Voltage);

    /* Start your code (processOutgoingMessages) */

    /* End your code */

  void deviceConnected () {

    /* Start your code (deviceConnected) */

    /* End your code */

  void deviceDisconnected () {

    /* Start your code (deviceDisconnected) */

    /* End your code */

Any clue on what causes this?

Thanks in advance.

You have mismatched braces.

Was too simple for me to find I guess.

Thank you very much.