message:
Simple network protocol to communicate between N slave arduino and 1 central arduino?

i am looking to communicate text ( 40 char for each message ) between N arduino and a central one ( Communication is one way slaves to Master).I am looking for wire communication with 1 to 5 m distance.Does anyone know the best approach to do that ?

Vincent

body:
You have quite a few options available to you as your requirements are filled by quite a few protocols, I am not going to list all. You can use things such as I2C, CAN, RS-485, RS-232.

You can find a few good examples from this [EE.SE][1] post from a search.

The CAN option is quite a good one for your application and is easy to set up and there are quite a few libraries available for the [common chip][2] MCP2525 and MCP2551. Yo can also get a 'shield' with this functionality from sparkfun.

The other options are discussed in the linked EE.SE post with regards to RS-485.

[I2C][3] can be implemented with the Wire library of arduinos and other libraries.

You can use RS-232, but I don't think it will be immune to noise at the distance you want, but you can still try. What you can do is use a multiplexer, such as this one [CD74HC4067][4], and use it to multiplex the TX line from each node to the RX of the master.

From SFE's site:

>  For example, you could use it to connect the TX pins of 16 devices to one RX pin on your microcontroller. You can then select any one of those 16 devices to listen to. If you want two-way communications, you can add a second board to route your microcontroller’s TX line to 16 device’s RX lines. By using multiple boards, you can create similar arrangements for I2C, SPI, etc.

You will probably want to add some sort of checksum/CRC to the data you send over the network too.

  [1]: https://electronics.stackexchange.com/questions/35773/communication-between-multiple-microcontrollers
  [2]: https://www.google.com/search?q=can controller IC&ie=utf-8&oe=utf-8
  [3]: https://en.wikipedia.org/wiki/I²C
  [4]: https://www.sparkfun.com/products/9056


sender: user

sender: assistant

body:
IMHO you should first decide your network topology.

If you want a "star" network, i.e. a network when every node is directly connected to the central one, you can use any protocol. Maybe even a multiplexed serial interface.

If you want a daisy chain interface or a bus one use can or RS485.

Personally I'd avoid I2C (it's good for on-board communication, but if the device is a few meters away the noise can break it).

My suggestion: use serial over half duplex RS485: you can get very low price physical interfaces. Since it is half duplex, only one can "speak", so the master first sends an address, then puts itself in listen mode and waits. The slave whose address was told puts itself in sending mode and sends the data.

This way you will have a bus (so you can simply attach a node to another node without having to place a wire till the masater) and you'll have a simple bus logic which will prevent the information to collide. And, most important, RS485 is very strong (up to 1km if I remember well).

CAN can (sorry) be simpler to use, since the anti-collision is "embedded" in the protocol, but it's a bit more complicated to use (you'll need a transceiver and to implement the whole logic in the microcontroller instead of using a dedicated peripheral like the serial interface).


message:
connection between Arduino Uno with nRF24L01 and notebook with wireless card

My project intend to command an Arduino UNO by my notebook without cable. I thought to use a RF Nordic nRF24L01 cabled on an Arduino UNO, and to use the wireless card of my notebook to send command to it. Is it possible? Any solution?
Is this hardware solution possible?

I need to send to Arduino four analog signals to setup the light of four led.

body:
Absolutely no. Can you connect your bluetooth headset to the wireless router? No because even if they share the same band they "speak" different protocols. So why could you do that with the nRF24L01?

If you want to communicate with your PC you have three options:

 1. Choose nRF24L01. In this case, since the PC does not have that device, you will need to make an adapter (the easiest one could be an USB adapter). You can connect a microcontroller to a USB to serial converter and to the nRF24L01 and use it as a bridge.
 2. Choose Wifi. Then you'll need a new transceiver for the arduino UNO you are using (maybe the ESP8266, which is around 2$) but can be a bit more complicated for just sharing data (I never used it, though, so I can be wrong).
 3. Choose bluetooth. Usually this is my preferred way to communicate with a board. Cheap (the HC-06 module is about 2-3 $) and easy to use (the interface is a plain serial).

Good luck ;)


message:
pass class internal function as callback

I am trying to pass a class internal function as a callback function within the class. The error behavior is similar to [this problem][1]. Whatsoever, I was unable to construct working code based on that question's answer.

I try to pass over a callback function from within the class,in order to create a finite state machine, inspired by the examples I found on adafruit regarding multithreading. The idea is, that each state can call his successor. The class itself then represents the state machine and I just will call its update function.

While the following code does not resemble this utility, it resembles the problem in a minimal example (based on [this larger codepiece][2]):

    class MyClass
    {
      const byte theAnswer = 42;
      void (*myCallback)();

      void setCallback(void (*callback)())
      {
        myCallback = callback;
      }

      public:

      void print_info()
      {
        Serial.println(theAnswer);
      }

      void call()
      {
        myCallback();
      }

       MyClass()
      {
        setCallback(&MyClass::print_info);
      }
    };

    MyClass AClassOfItsOwn();

    void setup()
    {
      Serial.begin(9600);
      while (! Serial); // Wait until Serial is ready
    }

    void loop()
    {
      AClassOfItsOwn.call();
      return;
    }

I get the following error code returned:

> ...testscript.ino: In constructor 'MyClass::MyClass()':
>
> testscript:25: error: no matching function for call to
> 'MyClass::setCallback(void (MyClass::*)())'
>
>          setCallback(&MyClass::print_info);
>
>                                          ^
>
> ...\testscript.ino:25:41:
> note: candidate is:
>
> ...\testscript.ino:6:12:
> note: void MyClass::setCallback(void (*)())
>
>        void setCallback(void (*callback)())
>
>             ^
>
> ...\testscript.ino:6:12:
> note:   no known conversion for argument 1 from 'void (MyClass::*)()'
> to 'void (*)()'
>
> ...\testscript.ino:
> In function 'void loop()':
>
> testscript:40: error: request for member 'call' in 'AClassOfItsOwn',
> which is of non-class type 'MyClass()'
>
>        AClassOfItsOwn.call();
>
>                       ^
>
> exit status 1 no matching function for call to
> 'MyClass::setCallback(void (MyClass::*)())'

----------
**fun times with polymorphism**

This is code we discussed during looking for a solution. I leave it here for future reference.

I tried creating an instance of this wrapper within the actual class to hold the callback, but that did not work either.

    class CallbackWrapper
    {
      void (*myCallback)();
      public:

      void call()
      {
        myCallback();
      }

      void setCallback(void (*callback)())
      {
        myCallback = callback;
      }
    };

    class MyClass : public CallbackWrapper
    {
      const byte theAnswer = 42;
      public:

      void print_info()
      {
        Serial.println(theAnswer);
      }

       MyClass()
      {
        CallbackWrapper::setCallback(&MyClass::print_info);
      }
    };

trying to store the callback function in a wrapping class (also not working, `'((MyClass*)this)->MyClass::CBW' does not have class type`)

    class CallbackWrapper
    {
      void (*myCallback)();
      public:

      void call()
      { myCallback(); }

      void setCallback(void (*callback)())
      { myCallback = callback; }
    };

    class MyClass
    {
      const byte theAnswer = 42;
      CallbackWrapper CBW();
      public:
      void print_info() { Serial.println(theAnswer); }
      void call() { CBW.call(); }
      MyClass()
      { CBW.setCallback(&MyClass::print_info); }
    };

An update on why I want to change the callback function during runtime. Here I try to randomly change the callback function:

    class MyClass
    {
      CallbackWrapper CBW();
      public:
      void do_this() { Serial.println("doing this"); }
      void do_that() { Serial.println("doing that"); }
      void call()
      {
        CBW.call();
        if (rand() > 0.5)
        {
          CBW.setCallback(&MyClass::do_this)
        }
        else
        {
          CBW.setCallback(&MyClass::do_that)
        }
      }
       MyClass()
      {  }
    };

For discussion with Michail

    class CallbackWrapper
    {
      public:
      void (*myCallback)();
      void call()
      { myCallback(); }

      virtual void setCallback(void (*callback)())
      {  }
    };

    class MyClass : public CallbackWrapper
    {
      public:
      void setCallback(void (*callback)())
        { myCallback = callback; }
      void do_this() { Serial.println("doing this"); }
      void do_that() { Serial.println("doing that"); }
      void call()
      {
        CallbackWrapper::call();
        if (rand() > 0.5)
        { setCallback(&MyClass::do_this); }
        else
        { setCallback(&MyClass::do_that); }
      }
       MyClass()
      {  }
    };

  [1]: https://arduino.stackexchange.com/questions/14480/pass-a-member-function-pointer-to-a-method-of-a-foreign-class-edb-lib
  [2]: https://learn.adafruit.com/multi-tasking-the-arduino-part-3/put-it-all-together-dot-dot-dot

body:
Unless you specifically limit yourself to one single class for a callback (i.e., include the class name in the function pointer specification) then you can ONLY use `static` member functions as callbacks.

`static` member functions appear as a normal function, not a member function, so don't have the implied `MyClass *this` as a first parameter.

If you want to allow member functions that aren't `static` you will have to make use of *polymorphism* and have a single *base* class that all classes which provide a callback function will inherit from.  Then you limit the callback function pointer to be members of that base class.

It is possible to do it if you are happy to limit to just one class, though the syntax is rather cryptic:

    class MyClass
    {
      const byte theAnswer = 42;
      void (MyClass::*myCallback)();

    public:

      void call() {
        (this->*myCallback)();
      }

      void setCallback(void (MyClass::*callback)()) {
        myCallback = callback;
      }

      void print_info() {
        Serial.println(theAnswer);
      }

      MyClass() {
        setCallback(&MyClass::print_info);
      }
    };

Using polymorphism you can only pass a callback function that is a member of the parent class, so it looks like that method may be out.


message:
Arduino Micro blue light dimms and turns off when I plug in my circuit

I have a PING Ultrasonic Sensor, Adafruit Absolute Orientation Sensor, and a Continuous rotation servo. All pins are connected to an Arduino Micro. However because the micro only has one 5V output, I used a rail from a breadboard. I connected the + & - leads from all the devices to the rail and then plugged in two leads connecting 5V and GND from the Micro to the rail. My goal was two send power from the Arduino Micro down the rail to all three devices.

I plugged in the Micro, and instead of seeing green lights on the sensor (powered on), the blue light on the Micro turned off and the servo twitched. I have no idea why. Do I need external power for the 5V?

body: This sounds like a lot to have connected to the Micro's 5v pin. Without knowing your exact model of servo, I would still believe you are hitting the current limit. Can you try unplugging the servo and see if the circuit functions without the servo? I would power the servo externally with a 5v supply.


message:
Corrupted files generated by Arduino with SdFat library. How to avoid that?

I got:

- https://www.arduino.cc/en/Main/ArduinoBoardDuemilanove

- http://wiki.iteadstudio.com/Stackable_SD_Card_shield_V3.0 (set to 5V logic)

with this [sketch][1] using SPI/SdFat+OneWire/DallasTemperature+EmonLib and no matter what I try I got corrupted files like [this][2].

I even haven't attached my sensors yet :(
I have tried with 3 SD cards so far, each formatted with [SD Memory Card Formatter](https://www.sdcard.org/downloads/formatter_4/) and each one has this problem.

There is a separate question like that ([Corrupted files generated by Arduino with SD library. How to avoid that?](https://electronics.stackexchange.com/questions/57714/corrupted-files-generated-by-arduino-with-sd-library-how-to-avoid-that)) but it concerns SPI confict but here SD is my only SPI device on the bus.

Any ideas?

  [1]: http://pastie.org/10691360
  [2]: http://pastie.org/10691362

body: This SD shield has CS on D4, not D10


message:
Running light, without delay, and a potentiometer

I am just getting hands on to my Arduino Uno.

I am have finished the blinking light tutorial, managed to read a potentiometer, build a running light with delays and as well a binary counter.

Now I build a small project with 5 LEDs and a potentiometer to configure a running light and change the speed of the running light with the potentiometer.

The LEDs are connected to the pins 13 to 9 and the potentiometer is connected A0 and 5V.

I also managed to program it without a delay function, but I think it is rather ugly.

Is there a better way of doing this like I did it?

    int led1 = 13;
    int led2 = 12;
    int led3 = 11;
    int led4 = 10;
    int led5 = 9;
    //the delay
    int pause = 1500;
    //count to decide which LEDs are HIGH and which are LOW
    int count = 0;
    // will store last time LED was updated
    unsigned long previousMillis = 0;

    // the setup routine runs once when you press reset:
    void setup() {
      // initialize the digital pin as an output.
      pinMode(led1, OUTPUT);
      pinMode(led2, OUTPUT);
      pinMode(led3, OUTPUT);
      pinMode(led4, OUTPUT);
      pinMode(led5, OUTPUT);

      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // the loop routine runs over and over again forever:
    void loop() {

      unsigned long currentMillis = millis();

      // read the input on analog pin 0:
      pause = analogRead(A0);
      float voltage = pause * (5.0 / 1023.0);

      // print out the value and teh corresponding voltage you read:
      //Serial.println("Value: %d and Voltage: %f", pause, voltage);
      Serial.print("Value: ");
      Serial.println(pause);
      Serial.print("Volts: ");
      Serial.println(voltage);

      if (currentMillis - previousMillis >= pause) {
        // save the last time you blinked the LED
        previousMillis = currentMillis;

        if (count == 0) {
          digitalWrite(led1, HIGH);
          digitalWrite(led2, LOW);
          digitalWrite(led3, LOW);
          digitalWrite(led4, LOW);
          digitalWrite(led5, LOW);
        }
        else if (count == 1){
          digitalWrite(led2, HIGH);
        }
        else if (count == 2) {
          digitalWrite(led1, LOW);
          digitalWrite(led3, HIGH);
        }
        else if (count == 3) {
          digitalWrite(led2, LOW);
          digitalWrite(led4, HIGH);
        }
        else if (count == 4) {
          digitalWrite(led3, LOW);
          digitalWrite(led5, HIGH);
        }
        else if (count == 5) {
          digitalWrite(led4, LOW);
        }
        else if (count == 6) {
          digitalWrite(led4, HIGH);
        }
        else if (count == 7) {
          digitalWrite(led5, LOW);
          digitalWrite(led3, HIGH);
        }
        else if (count == 8) {
          digitalWrite(led4, LOW);
          digitalWrite(led2, HIGH);
        }
        else if (count == 9) {
          digitalWrite(led3, LOW);
          digitalWrite(led1, HIGH);
        }
        else if (count == 10) {
          digitalWrite(led2, LOW);
          digitalWrite(led1, HIGH);
          count = -1;
        }
        count++;
      }
    }

body:
Your Serial.print()s will print on every iteration of loop() even if that iteration doesn't operate on the LEDs. You'll be swamped with output on the terminal.

One improvement I'd make would be to get rid of the counter and the if/else if/.../else if segment. Rotate a bit through a byte variable for as many bit-positions as you have LEDs. Then call a function with that byte, that will set each LED on or off according to the state of its respective bit.

One more improvement can be had if you rotate the bits through bit positions 1 to 5 (in this case) of your byte variable, because you made the fortunate or perhaps intentional assignment of LED's to digital I/Os that are adjacent bits in PORT-B! One single `PORTB = [your byte];` statement could set all 5 LEDS simultaneously.

Update:
PORTB is a register in the UNO's Atmega328p MCU, one of three (PORTB, PORTC, and PORTD) that connect to all of the I/Os on the UNO (or any other '328 based MCU board). By setting the (up to) 8 bits in one port, a single assembly-language instruction can set that many I/Os simultaneously. It is incredibly efficient. The downside of doing that instead of calling digitalWrite() is that the sketch is then tailored to that particular processor. digitalWrite() uses more program memory and execution time (by a lot, especially when setting multiple I/Os), but keeps your sketch processor independent; digitalWrite() knows which processor it was compiled for and how to translate a Digital I/O number to a physical external pin on that processor, so you don't have to.

For those interested in the low level details of the hardware, they are in the processor's [datasheet][1].

  [1]: http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf


body:
You can put the LED pin numbers into an array.  After each delay period, turn off the current LED, increment the count, and turn on that LED.  For example:

<!-- language: lang-C -->

    // Sketch re: http://arduino.stackexchange.com/questions/19605/running-light-without-delay-and-a-potentiometer

    // Set constants for pins with LEDs
    enum { led1 = 13, led2 = 12, led3 = 11, led4 = 10, led5 = 9};

    // Make an array with the LED pin numbers
    byte ledPins[] = { led1, led2, led3, led4, led5 };

    // # of entries in ledPins:
    enum { numLeds = sizeof(ledPins) / sizeof ledPins[0]};

    //count to track which LEDs are HIGH and which are LOW
    int count = numLeds-1;  // Will roll over to 0

    // To store last time LED was updated
    unsigned long previousMillis = 0;

    void setup() {
      // initialize digital pin outputs
      for (byte i=0; i<numLeds; ++i)
        pinMode(ledPins[i], OUTPUT);

      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // loop() runs over and over again forever:
    void loop() {
      unsigned long currentMillis = millis();
      // read input on analog pin 0:
      int deli = analogRead(A0);
      float voltage = deli * (5.0 / 1023.0);

      // Print out the value and corresponding voltage you read:
      // Serial.println("Value: %d and Voltage: %f", pause, voltage);
      Serial.print("Value: ");
      Serial.println(deli);
      Serial.print("Volts: ");
      Serial.println(voltage);

      if (currentMillis - previousMillis >= deli) {
        // Save the last time we blinked the LED
        previousMillis = currentMillis;

        // Turn off current LED, turn on next one
        digitalWrite(ledPins[count], LOW);
        count = (count+1) % numLeds;
        digitalWrite(ledPins[count], HIGH);
      }
    }


body:
Completed now.

@all: Thank you very much.

@JRobert: Thanks a lot for the very good explanation
@jwpat7: Thanks for the code, it helped me a lot.

    // Sketch re: http://arduino.stackexchange.com/questions/19605/running-light-without-delay-and-a-potentiometer

    // Set constants for pins with LEDs
    enum {
      led1 = 13, led2 = 12, led3 = 11, led4 = 10, led5 = 9};

    // Make an array with the LED pin numbers
    byte ledPins[] = {
      led1, led2, led3, led4, led5 };

    // # of entries in ledPins:
    enum {
      numLeds = sizeof(ledPins) / sizeof ledPins[0]};

    //count to track which LEDs are HIGH and which are LOW
    int count = numLeds-1;      // Will roll over to 0

    // To store last time LED was updated
    unsigned long previousMillis = 0;

    //direction forward
    boolean forward = true;

    void setup() {
      // initialize digital pin outputs
      for (byte i=0; i<numLeds; ++i)
        pinMode(ledPins[i], OUTPUT);

      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // loop() runs over and over again forever:
    void loop() {
      unsigned long currentMillis = millis();
      // read input on analog pin 0:
      int deli = analogRead(A0);
      float voltage = deli * (5.0 / 1023.0);

      // Print out the value and corresponding voltage you read:
      // Serial.println("Value: %d and Voltage: %f", pause, voltage);
      // Serial.print("Value: ");
      // Serial.println(deli);
      // Serial.print("Volts: ");
      // Serial.println(voltage);

      if (currentMillis - previousMillis >= deli) {
        // Save the last time we blinked the LED
        previousMillis = currentMillis;

        if(forward){
          // Turn off current LED, turn on next one
          digitalWrite(ledPins[count], LOW);
          count = (count+1) % numLeds;
          digitalWrite(ledPins[count], HIGH);

          if(count == numLeds-1 ){
            forward = false;
            count = 0;
          }
        }
        else {
          digitalWrite(ledPins[count + numLeds-1], LOW);
          count = (count - 1) % numLeds;
          digitalWrite(ledPins[count + numLeds-1], HIGH);

          if(count + numLeds-1 == 0){
            forward = true;
            count = 0;
          }
        }
      }
    }

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/DcB7w.jpg


message:
Arduino cluster functionality - feasibility advice for arduinos to communicate using variable-length long strings?

My apologies. This is my first time on this site and I wasn't even aware that it wasn't some sort of discussion forum until receiving the automated response message to my already submitted vague and open-ended question.

**Thank you Nick Gammon** for pointing out Wanago's very interesting project, and I am sorry I did not provide enough information to show the difference in requirements. His solution is quite strictly structured and rigid (not just physically). But I wish to provide a solution that might allow anyone to fairly easily create an ad-hoc collection of any available arduino compatible hardware - which could also allow use of ESP devices for additional functionality if wished, but would not require ESPs as a means of connecting nodes. There may be a better solution than your RS485 Rolling Master for connecting nodes, but yours is the best solution I have yet seen so far, and not least because of the minimal resources required.

**Thank you JBulmer** for your clear overview and assessment, which does now give me a point of focus. In order to pursue this, I must try to aquire sufficient skills to add some form of multiple-chunk protocol layer on top of Nick Gammons Rolling Master protocol. I don't know if I'll manage it because I'm a hacker not a programmer, therefore I would appreciate  if I could give my reasons for trying, because I would very much value your opinion as to whether you think it would be worth my efforts or not.

Nicks protocol already provides auto-negotiating of nodes and takes care of most fault-tolerance type issues. I believe it auto-detects nodes and assigns them IDs which are stored in each individuals EEPROM, so he has already taken care of most of the connectivity side of things.

And I think the main reason for him using a defined message length was in order for all nodes to be able to poll in timeslot sequence for opportunity to transmit as master, which means it ought to be possible to somehow sync up re-constitution of split message blocks.

So apart from the protocol extension for handling of long strings, I don't see any other major obstacles which I can't imagine a solution for in principle even if not yet aware of how. I hasten to add that I am pushing myself way out of my comfort zone to try to achieve this because I think (though perhaps wrongly) that it might offer much benefit to ordinary arduino amateurs (such as myself) who I feel arduino is mainly aimed at. So the following example is not any specific requirement of mine, just something to illustrate some of the potential that could be offered to non-professionals - hopefully after the initial scene-setting, things can become more apparent...

The majority of arduino project examples use the serial monitor as a quick and easy way for user interaction, which can then be expected to need customising for more practical methods of input and output - but clustered nodes communicating serially might allow many project examples to be used almost as is.

An Infra-Red sender makes a good starting point. The IRremote library IRsendDemo.ino monitors the serial port for a keypress then calls a send routine, eg: irsend.sendSony. The incoming serial trigger could be made to be anything the user wished to use as a command, such as MyIRblaster, and could also include an equivalent text string of any required parameters for appropriate data conversion before use, ie:  MyIRblaster Sony(0xa90, 12)
All this can be developed and tested in independent isolation using the serial monitor, then when happy, add a 'common' block of RS485-based cluster-talk code, allowing any other node the ability to then send it a MyIRblaster command and parameter to action when needed.

As the IR arduino is using the IRremote library anyway, we may as well also give it an IRread capability, which wouldn't even require any associated trigger command.

It would be an advantage to be able to save IR signals somewhere though, but trying to squeeze on additional SD and FAT libraries as well as IRremote might be a step too far, so perhaps better just to add a separate SD node for storage. The SD node could have a file of saved IR codes, perhaps each with an asscociated corresponding simple text description such as TVmute, and have a suitable command+parameter capability added such as "SendBlaster (name)". This would allow any node to issue eg: "SendBlaster TVmute" to the SD node which in turn could issue a corresponding MyIRblaster Sony(0xa90, 12) command to the IR node.

And similarly to action any other types of node functionality for that matter - it would be relatively trivial to add some relays to the IR node if wished, and make the node recognise a "Relay (name)" command+parameter for instructing it to control any relay as required.

But it would also be just as easy (if not easier from a software point of view) to add a separate Relay node if wished. And similarly, even a Trigger node perhaps offering 64 channels of interupt-driven inputs - which also wouldn't need to recognise any incoming command, just simply be able to issue perhaps a 'Triggered' command plus appropriate triggered channel number as a lookup instruction to the SD node. Every trigger input could be assigned its own corresponding list of responses in its config file entry, which could include any of the functionality that any of the nodes could respond to.

Adding new functionality to the cluster would be as simple as adding another command keyword to a relevent nodes list of commands to be parsed for, which when matched would branch to an appropriate internal function.

So adding a "WriteLOG" command to the SD node (and having it parse for an accompanying "Details" parameter) could provide a facility for every node to be able to record events to an event log just by sending the serial command "WriteLOG (details)"to the SD node.

Commands don't have to be external, they could include any locally recognised macro-type commands for accessing any of the internal capability. So for instance the SD node could recognise a "Pause (duration)" instruction to invoke a non-blocking delay if wished. This could allow the SD node to send multiple IR code commands with pauses between each transmission. It might also recognise a 'No_Retrigger (duration)' timer to prevent unwanted repeat triggering of PIRs etc.

To better appreciate the potential now, we could create a config file on SD that contains an appropriate channel entry # for every trigger input we might wish, be it IR receives, PIRs, switch contacts or whatever.
The channel #3 doorbell entry could be something like this...

# 3  Doorbell,  No_Retrigger (3mins),  MyIRblaster (TVmute),  Relay (Porchlight) (ON),  Relay (Doorbell) (ON),  Pause (3secs),  Relay (Doorbell) (OFF),   MyIRblaster (TVun_mute),  Pause (5mins), Relay (Porchlight) (OFF).

If the SD node receives a 'Triggered Doorbell' instruction it simply parses the corresponding #3 entry and sends any extracted commands out for the other nodes to action as appropriate. In this case it would ignore subsequent PIR retriggering for 3 minutes, send commands to mute the TV, turn on the porch light, ring the doorbell for 3 seconds, unmute the TV, then turn the porch light off after 5 minutes.
It could also easily include simple local conditional logic to only turn the Porchlight when dark etc, which could allow option for appropriate qualifiers to a commands parameters, ie: Porchlight (ON) (IF_dark).

PIR sensors could select CCTV cameras, or even send IR commands to point a PTZ cam to preset positions, and all using just the same cluster functionality being used above.

A voice node might be added to givie an "Announce (message)" command, then add appropriate config entries to provide appropriate voice announcements for any triggered events.

Even amateurs could evolve quite sophisticated flexible ad-hoc systems without needing any rocket science, and without hardware constraints other than needing cheap RS485 adapters and sufficient memory for running the protocol and parsing out any commands plus conversion of any parameters.

Although the SD node in the example above is tending towards becoming a systems co-ordinator, it is still just essentially another cluster peer node. But perhaps there could be good grounds for trying to modify Nicks Rolling Master to take advantage of what benefits an SD intelligent controller might offer, such as newly connecting nodes automatically obtaining assigned IDs plus other 'characteristics' and 'behaviour' from the centrally managed SD config file.

I'm willing to roll up my sleeves and prepare for the long slog if the concept is considered realistic and worthwhile, but I would certainly welcome informed opinion as to whether it might be or not.

-------Original---------

I am looking into the feasibility of linking multiple Arduinos together to form a cluster of Arduino and ESP8266 nodes capable of sending sequences of plain text commands plus optional parameters to each other.

This could offer a mechanism for any node to be able to access the functionality of any other node without having local burden of that functionality.

For instance, only the SDcard node would require the libraries and overheads for accessing a centralised config file on SD card, but any of the other nodes could request appropriate entries from the config file whenever needed, or have ability to write event entries to a log file.

Similarly for an InfraRed node and its IR libraries, allowing any other node to send it plain text commands and parameters to transmit any required IR code even though the other nodes don't have local IR functionality themselves.

Basically, each individual arduino might just be considered a black box that does something useful and can be programmed to respond to certain external text commands (so in fact any other platforms with similar blackbox functionality could also easily be integrated to the cluster if wished).
Each node would parse an incoming string for a command that matched any of it's own local list of recognisable commands (ie: IRsend [code]) then branch as appropriate with any extracted accompanying parameters.

A cluster could be built up to include any and all required arduino functionality even though all of that functionality could never be squeezed onto any single arduino.

So an automation cluster could include things like voice announcements, web access, X-10 firecracker control etc just by including the appropriate nodes. Then tomorrow a voice recognition node might be easily added - needing to do nothing more than just issue appropriate text commands to also invoke any already existing functionality.

In principle, anyone could have the capability for doing almost anything they might wish, so although I don't know if this cluster functionality idea can be practically achieved or not, but the possible potential offers much incentive for trying.

And Nick Gammons excellent [RS485 Rolling Master article](http://www.gammon.com.au/forum/?id=11428) brings the possibility so tantalisingly close... but it uses fixed-length messages to achieve it's clever self-negotiating fault-tolerance, and I'm afraid I don't know enough to be able to merge variable-length long string capability with his enticing communications system.

So I would appreciate any suggestions, even just informed advice telling me to forget it because it cannot be done (cos at least then I'd be able to get some sleep!).

Thanks,
Robin Baker.

body:
Someone (Wanago) has done a similar project [here](http://forum.arduino.cc/index.php?topic=61643.0). However instead of ESP8266 he used I2C which sounds more practical to me.

See images:

[![Stack of processors][1]][1]

[![Another stack of processors][2]][2]

He had the same basic idea - each board has a specific task, and the work is shared between them.

  [1]: https://i.stack.imgur.com/nDEyq.jpg
  [2]: https://i.stack.imgur.com/WUcnC.jpg


body:
Many communication systems use fixed-length, or limited-length, data exchange at the lower levels. For example, the ethernet network, under TCP/IP, has a maximum package size of 1526 bytes.

However, that doesn't prevent us moving large chunks of data, e.g. a DVD across the Internet.

A common approach is to use a [layered protocol suite][1]. Each layer is responsible for providing a service to the higher layer by using the service of the lower layers.

We talk about layered protocols because it provides a powerful, yet simplified way of thinking about communication problems. Rather than get bogged down in lots of detailed issues which need to be solved to work, we try to organise the problem into simpler and simpler solutions. Eventually things which we can implement without too much difficulty can be built, then higher layers are built from the simpler capabilities of lower layers.

The highest level of your protocol would provide the sort of service you need. In this case, you want to be able to send long-ish string messages, so the highest level would do that by using a mid-level fixed-length service.

In its turn the mid-level fixed-length service might provide error-free fixed-length messages using a still-lower-level service which can move fixed-length messages, but can't correct some types of errors.

(This is just an illustration of the idea, please don't take this as a concrete suggestion on how to implement anything.)

So, don't think "I don't know enough to be able to merge variable-length long string capability with his enticing communications system"

Instead, ask the simpler question, "how could I use that existing fixed-length communication system to send variable length strings?"

The answer might be pretty simple if the underlying system guarantees the order that messages are received. For example, send a count of the message length (in one or more messages) then send that number of bytes. The receiver knows how much to expect, and needn't act to interpret the data until it is received.

Then how to tell the difference between the command and its parameters? The command might be the first 'parameter' in the string, and parameters come after it.

The way I interpret your question, there may be several problems beyond sending variable length strings. There are potential problems like: adding or removing nodes, nodes failing, allocating 'names' to services on nodes (so commands can be sent to the appropriate node), etc.

However, the fundamental problem of sending long strings over a fixed-length communication channel is straightforward, and can be solved in a few different ways (I mentioned one, above).

  [1]: https://en.wikipedia.org/wiki/Protocol_stack


message:
Visual Micro without .ino files

I am using the visual micro extension for Visual Studio 2015.  I would like to not use any .ino files since I'm trying to setup cppcheck which doesn't recogonize .cpp files, and its just what I'm used to.  However when I change my project.ino file to project.cpp the compile option is no longer available (I assume its looking for a .ino file).  Is there a project setting I can change to fix this?

body:
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:

<!-- language-all: lang-C++ -->

    #include <Arduino.h>

... to the start of the .cpp file.

More information: [How to avoid the quirks of the IDE sketch file pre-preprocessing](http://www.gammon.com.au/forum/?id=12625)

---

To clarify the question about libraries ...

You do need to put into the .ino file an include for any libraries used in the project. For example:

    #include <Wire.h>
    #include <SPI.h>
    #include <EEPROM.h>

This effectively triggers the Arduino build process to link those libraries into the final executable file.

Related, my reply in this thread: <https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-do-i-actually-need-to-use-the>


body:
As you have found, Visual Micro will not consider the project to be an Arduino project if you do not have a "project_name.ino" included in the project

A cheat is to create a "project_name.cpp" and include it in the project. This will cause the .ino to be ignored during compilation.

EDIT: The project_name.cpp takes priority during compile, therefore the .ino just becomes a dummy. However the .ino will still be used for intellisense. The cpp should be #included in the .ino along with any libraries you want discovered by intellisense.

The Visual Micro release yesterday includes automatic "library in library" discovery which means you would no longer need to put all lib #include's in the project_name.ino. (tip: you can [switch the "deep search" feature off][1] for each project via the Visual Micro menu. It slows the compile down with large libraries)

[![enter image description here][2]][2]

  [1]: http://www.visualmicro.com/post/2016/01/14/How-to-improve-compile-times-dramatically.aspx
  [2]: https://i.stack.imgur.com/kcK3T.png


message:
How do I install Arduino drivers?

I need to install my Arduino drivers, but Windows 8.1 doesn't seem to like Arduino, and it greys out the update driver button. Therefore I can't select the drivers from the drivers folder in my Arduino IDE folder.

There are drivers that need to be installed. But Windows 8.1 greys out the `update driver software` button. Also, it refers to Arduino Uno as an `unknown device`. How do I install the Arduino drivers and make Windows let me install the drivers?

body: Often reinstall the latest arduino IDE with Windows Administrator rights helps (use right click execute as administrator).


body:
The IDE package usually ships with the driver(at-least the latest one). <br>
Go to **Program Files** in **C:** and find the **Arduino** folder and you should find a folder named **Drivers**. Inside you will find an application named **dpinst-x86**. Run it and you should be good to go!


body: If the arduino is undetected in PC go to control panel-device manager - connect the arduino and some COM port will appear click it and troubleshoot make sure your PC is connected to internet and then you will be able to see your com port in arduino ide.


message:
Due : DMAC BTSIZE trimmed modulo 8192?

On Arduino Due, I set-up DMA transfers using direct control of memory mapped hardware registers.

There is a 16-bit BTSIZE field in CTRLA which indicates the number of (width sized) transfers.  If I specify larger than 8191, the value of btcount is trimmed to 13 bits after the DMA channel is enabled.  I set chunk size src/dest to 1.

The [ATMEL data sheet for the sam3x][1] (linked from the [due page][2]) does not mention this 'limitation' (section 22.7.16), or possibly I'm using it wrong.

What reference is canonical and correct for the DMAC (dma controller)?

----

As noted in the links in the comments, multi-buffer transfer can work around this, but since I don't know why it works or fails, it's hard to decide if that solution will work in all cases.

  [1]: http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf
  [2]: https://www.arduino.cc/en/Main/ArduinoBoardDue

body:
I'll quote the answer given in [this link](http://community.atmel.com/forum/synchronous-serial-controller-ssc-or-i2s-using-dma-controller-sam3x8e-incomplete-data-transfer) to help make this question more useful for future people who search this problem.

> The dmac.h file in asf library has a macro named DMA_MAX_LENGTH set to 0xFFF = 4095. We tried changing it to higher values but still Buffer Transfer size (BTSIZE) register was showing only values till 4095. This seemed to us to a hardware limitation of the DMAC in Atmel SAM3x8E (which we did'nt see mentioned in the datasheet). So this closed the option of single buffer transfer for us and we moved to multi-buffer transfer
>
> It was a simple way out (even though I took some time to figure it out :P ) - *Use multi-buffer transfer with contiguous source address!* (see table 22.4 Row 3)


message:
RF24 Stalls Arduino Program with powerDown

I have an ATtiny85 and an Arduino Uno both using NRF24L01 chips to communicate with one another. The ATtiny85 is powered by a CR2032 coin cell. I am using tmrh20's fork of the RF24 library which can be found [here][1]. Here's the problem I'm encountering:

Under the current code posted, the Uno will receive about 80 packets of data (80 packets times 2 seconds per packet is about 160 seconds of time) before the ATtiny will simply stop sending, and the Uno receives no more data. I can tell that it's the ATtiny, because I've got a DMM hooked up to it. Normally, my DMM tells me that the ATtiny is drawing less than 0.005mA of current, but at the instance of the stall the DMM reads approximately 1.4 mA of current draw, which makes sense because under normal conditions with no sleep the ATtiny draws about 1mA, and the radio not in power down mode and not transmitting draws 0.4mA.

I've spent quite some time trying everything from setting the clock speed to a different value (it's at 1MHz) to changing the power amplifier value. The only thing I've tried that makes an impact is getting rid of the powerUp and powerDown function calls. Once these are removed everything works perfectly transmission-wise, except the only issue is that the whole system is drawing 0.4mA constantly, which is too much.

I don't think the coin cell is a problem considering the system works when the powerUp and powerDown calls are removed. Here's my code:

Reciever:

    #define CE_PIN 7
    #define CSN_PIN 8

    #include <SPI.h>
    #include "RF24.h"

    RF24 radio(CE_PIN, CSN_PIN);

    byte address[11] = "SimpleNode";
    unsigned long payload = 0;

    void setup() {
      while (!Serial);
      Serial.begin(115200);
      radio.begin(); // Start up the radio
      radio.setAutoAck(1); // Ensure autoACK is enabled
      radio.setRetries(15,15); // Max delay between retries & number of retries
      radio.openReadingPipe(1, address); // Write to device address 'SimpleNode'
      radio.startListening();
      Serial.println("Did Setup");

    }

    long counter = 0;

    void loop(void){
      if (radio.available()) {

        radio.read( &payload, sizeof(unsigned long) );
        if(payload != 0){
            Serial.print("Got Payload ");
            Serial.print(payload);
            Serial.print(" - ");
            Serial.println(counter);
            counter++;
        }
      }

    }

Transmitter:

    //Sleep
    #include <avr/sleep.h>

    const int sleepSecs = 2;

    //Radio
    #define CE_PIN 3
    #define CSN_PIN 3 //Since we are using 3 pin configuration we will use same pin for both CE and CSN
    #include "RF24.h"
    RF24 radio(CE_PIN, CSN_PIN);
    byte address[11] = "SimpleNode";
    unsigned long payload = 0;

    void setup() {
      //Setup radio
      radio.begin(); // Start up the radio
      radio.setAutoAck(1); // Ensure autoACK is enabled
      radio.setRetries(15,15); // Max delay between retries & number of retries
      //RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
      radio.setPALevel(RF24_PA_HIGH);
      radio.openWritingPipe(address); // Write to device address 'SimpleNode'

      //Setup sleep
      setup_watchdog(6);
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); //Power down everything, wake up from WDT
      sleep_enable();
    }

    volatile int watchdog_counter = 0;

    ISR(WDT_vect) {
      watchdog_counter++;
    }

    void loop() {
      sleep_mode(); //Go to sleep!

      if(watchdog_counter >= sleepSecs)
      {
        ADCSRA |= (1<<ADEN);
        radio.powerUp();
        watchdog_counter = 0;

        payload = 123456;
        radio.write(&payload, sizeof(unsigned long) ); //Send data to 'Receiver' every second

        radio.powerDown();
        ADCSRA &= ~(1<<ADEN); //Disable ADC, saves ~230uA
      }
    }

    //Sets the watchdog timer to wake us up, but not reset
    //0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms
    //6=1sec, 7=2sec, 8=4sec, 9=8sec
    //From: http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/
    void setup_watchdog(int timerPrescaler) {

      if (timerPrescaler > 9 ) timerPrescaler = 9; //Limit incoming amount to legal settings

      byte bb = timerPrescaler & 7;
      if (timerPrescaler > 7) bb |= (1<<5); //Set the special 5th bit if necessary

      //This order of commands is important and cannot be combined
      MCUSR &= ~(1<<WDRF); //Clear the watch dog reset
      WDTCR |= (1<<WDCE) | (1<<WDE); //Set WD_change enable, set WD enable
      WDTCR = bb; //Set new watchdog timeout value
      WDTCR |= _BV(WDIE); //Set the interrupt enable, this will keep unit from resetting after each int
    }

  [1]: http://tmrh20.github.io/RF24/classRF24.html

body: After looking at the RF24 header file, I suggest you call `radio.stopListening()` right before you call `write()`. Also add a delay of 5 ms after `write()`. It would be nice to know the exact point at which the program got stuck; add `digitalWrite(13, HIGH)` inside the IF block, after `powerDown()` and again outside the block, immediately after `sleep_mode()`, but with a LOW argument instead, so you can know if the problem is that the AVR stops waking up at some point or if its the radio methods that is blocking, for some reason.


body:
A delay after the `powerUp()` made the program work for longer, but it still stalled. More delays after `write()` only exacerbated the issue. The only thing that I've done to get this to work is to put the sending code in the watchdog ISR itself. However, this is limited to only around 4 seconds max per sent packet because this is the watchdog's max value, but that's OK for my application.

This leads me to believe that somehow the watchdog is interfering with sending, so possibly disabling it and reenabling after sending could have some effect if anyone else is having this problem.


message:
How to install Arduino IDE on Raspberry Pi

How do you install the Arduino IDE on the Raspberry Pi running an ARM version of Ubuntu or Raspbian? There doesn't seem to be any [official ARM release][1]. Both distros have an "arduino" package in their standard repos, but it only includes an ancient 1.0 version that's missing a lot of features.

  [1]: https://www.arduino.cc/en/Main/OldSoftwareReleases#00xx

body:
Arduino at http://playground.arduino.cc/Linux/Raspbian recommends:

    sudo apt-get update && sudo apt-get install arduino

but indeed warns that the version is old:

> Note: This will install an old version of Arduino, and may not support
> some of the newer boards. You can not download a newer version from
> the website, because there is no ARM version. -- [Arduino wiki on Raspbian][1]

Looking at the raspbian respository at http://archive.raspbian.org/raspbian/pool/main/a/arduino/ currently lists 1.0.5

There are folks working newer versions of Arduino for ARM at https://github.com/arduino/Arduino/issues/3334 but it isn't finished yet.

  [1]: http://playground.arduino.cc/Linux/Raspbian


message:
Trying to understand compilation error message

C:\Users\Field\Documents\Arduino\Adafruit_TCS34725-master\examples\tcs34725autorange\tcs34725autorange.ino:2:31: fatal error: Adafruit_TCS34725.h: No such file or directory

     #include "Adafruit_TCS34725.h"

                                   ^

    compilation terminated.

exit status 1
Error compiling.

body:
You are trying to use a library, but it is either not installed, or is installed in the wrong location. A library, in this context, is code that supports a sensor or some other hardware or that accomplishes a task. We call them libraries because we can share and reuse them – like borrowing a book from a library.

It looks like you're trying to get the Adafruit TCS34725 color sensor going. The official source of the library is in the [Adafruit's GitHub repository for the TCS34725][1] and there is a link at the bottom of the README for how to install a library. I'll bet that will get you back on track.

[1]: https://github.com/adafruit/Adafruit_TCS34725


message:
bluetooth module with stk500_recv() error

I am trying to dow what is demonstrated in this [tutorial][1]. I have altered the original setup a little by adding a level converter to not fry the Bluetooth module and resistors for the LEDs, as well as using only 2 instead of four LEDs (which I adjusted for in code later). other than that I am using the exact same setup, code,and procedure. Yet when I try to run my code on the Arduino. I get the error below. I believe it is due to using Tx/Rx and serial at the same time but I really don't know anything about this. Should I add more libraries?
Should I change the wiring shown in the tutorial link? It seems like I need to use Tx/Rx

    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xce
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xce
    avrdude: stk500_recv(): programmer is not responding

Here is the code I used from tutorial:

<!-- language: c -->

    //Coded By: Angelo Casimiro (4/27/14)
    //Voice Activated Arduino (Bluetooth + Android)
    //Feel free to modify it but remember to give credit

    String voice;
    int
    led1 = 2, //Connect LED 1 To Pin #2
    led2 = 3, //Connect LED 2 To Pin #3
    led3 = 4, //Connect LED 3 To Pin #4
    led4 = 5, //Connect LED 4 To Pin #5
    led5 = 6; //Connect LED 5 To Pin #6
    //--------------------------Call A Function-------------------------------//
    void allon(){
         digitalWrite(led1, HIGH);
         digitalWrite(led2, HIGH);
         digitalWrite(led3, HIGH);
         digitalWrite(led4, HIGH);
         digitalWrite(led5, HIGH);
    }
    void alloff(){
         digitalWrite(led1, LOW);
         digitalWrite(led2, LOW);
         digitalWrite(led3, LOW);
         digitalWrite(led4, LOW);
         digitalWrite(led5, LOW);
    }
    //-----------------------------------------------------------------------//
    void setup() {
      Serial.begin(9600);
      pinMode(led1, OUTPUT);
      pinMode(led2, OUTPUT);
      pinMode(led3, OUTPUT);
      pinMode(led4, OUTPUT);
      pinMode(led5, OUTPUT);
    }
    //-----------------------------------------------------------------------//
    void loop() {
      while (Serial.available()){  //Check if there is an available byte to read
      delay(10); //Delay added to make thing stable
      char c = Serial.read(); //Conduct a serial read
      if (c == '#') {break;} //Exit the loop when the # is detected after the word
      voice += c; //Shorthand for voice = voice + c
      }
      if (voice.length() > 0) {
        Serial.println(voice);
    //-----------------------------------------------------------------------//
      //----------Control Multiple Pins/ LEDs----------//
           if(voice == "*all on") {allon();}  //Turn Off All Pins (Call Function)
      else if(voice == "*all off"){alloff();} //Turn On  All Pins (Call Function)

      //----------Turn On One-By-One----------//
      else if(voice == "*TV on") {digitalWrite(led1, HIGH);}
      else if(voice == "*fan on") {digitalWrite(led2, HIGH);}
      else if(voice == "*computer on") {digitalWrite(led3, HIGH);}
      else if(voice == "*bedroom lights on") {digitalWrite(led4, HIGH);}
      else if(voice == "*bathroom lights on") {digitalWrite(led5, HIGH);}
      //----------Turn Off One-By-One----------//
      else if(voice == "*TV off") {digitalWrite(led1, LOW);}
      else if(voice == "*fan off") {digitalWrite(led2, LOW);}
      else if(voice == "*computer off") {digitalWrite(led3, LOW);}
      else if(voice == "*bedroom lights off") {digitalWrite(led4, LOW);}
      else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);}
    //-----------------------------------------------------------------------//
    voice="";}} //Reset the variable after initiating

  [1]: http://www.instructables.com/id/Voice-Activated-Arduino-Bluetooth-Android/?ALLSTEPS

body: How did you upload the sketch? With the Bluetooth module still connected? In that case please disconnect it and the upload. Connect again after the upload.


message:
Arduino Google speech api

I'm currently experimenting with my arduino Uno. I control it via an mobile (android) but wanted to just use a microphone on the board so I don't need to carry my mobile around. It is possible to record flac files from a mic and send it to Google speech api and get a return? And then maybe output it via the synthesis.

So it is possible to do this on an arduino uno and with C. If doesnt is there any other way I can go? I could buy a raspberry pi but I don't an whole operating system like linux installed. So any thoughts?

body:
You can use a special voice recognition shield (for example: [EasyVR Shield 3.0 - Voice Recognition Shield]) to integrate a simple and basic voice recognition. I think it's a very fast and easy prototyping way...

For the use of the more complex Google Speech Recognition I would use a more powerful microcontroller (such as Raspberry PI or something like that)...

[EasyVR Shield 3.0 - Voice Recognition Shield]:https://www.sparkfun.com/products/13316


message:
Saving byte array in PROGMEM instead of SRAM

For an ethernet project I do, I need to store the Ethernet Shield's MAC address.
I store it like that:

    byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };
That works OK, but in my project I need all the SRAM available, so every byte of memory is important. I've used the F() macro and PROGMEM everywhere, but I couldn't manage to store the MAC byte array in the PROGMEM.

How can I store it in PROGMEM? Is it even possible?

body:
<!-- language-all: lang-C++ -->

See [Putting constant data into program memory (PROGMEM)](http://www.gammon.com.au/progmem) for tips about putting stuff into PROGMEM. However personally I wouldn't get too excited about saving 6 bytes.

---

Example code:

*Declare data globally:*

    const byte mac [6] PROGMEM = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };

*Get a copy for use into a temporary variable:*

      char foo [6];
      memcpy_P (foo, mac, sizeof foo);


message:
Adafruit libary and CC3000 shield

I have a Arduino Uno and a CC3000 shield. When I run the example code for Webclient from Adafruits libary it works perfect.

When I switch out address for reading a corresponding text file from my own server the code completes sporadically. The output in the serial window stops at differens places every time.

Does anyone have any idea how I can fix this?

The Adafruit points to this URL: http://www.adafruit.com/testwifi/index.html
While mine points to this URL: http://a.sjsd.li/test/test.html

body: Perhaps the CC3000 isn't waiting long enough for the whole response to come in. Try increasing the variable `IDLE_TIMEOUT` in the Web_Client sketch, near the top. Change its value to 10000 and see if you get the whole response this time.


body:
I have arrived at a solution that works for me. Instead of using Adafruit library I have adopted [Sparkfuns library][1].

Some adjustments in the setup for the pins:

    #define CC3000_INT      3   // Needs to be an interrupt pin (D2/D3)
    #define CC3000_EN       5   // Can be any digital pin
    #define CC3000_CS       10  // Preferred is pin 10 on Uno
    #define SD_CS           4   // Chip select for SD card

Then some adjustemnt in the block for the HTTP request:

    client.print("GET /index.html HTTP/1.1\r\n");
    client.print("Host: ");
    client.print(server);
    client.print("\r\n\r\n");
    client.println();
    Serial.println();
This is not a solution for the Adafruit libary. But it helped me to continue my project.

  [1]: https://github.com/sparkfun/SFE_CC3000_Library


message:
Ping IP address using ESP8266 connected to Arduino

I want to make a system using NeoPixels, an Arduino and an ESP8266 module to ping IP addresses on my network to determine if certain people are on our Wi-Fi (I'll be pinging mobile phones).

I'm finding it hard to find any help as to how to ping IP addresses from an Arduino using the ESP8266 module. I did find the [ICMP Ping library][1], but it uses the Ethernet shield, and I'm quite new to Arduino so I don't even know if I could modify the library in any way.

If anyone could help me on my way, that'd be great!

  [1]: http://playground.arduino.cc/Code/ICMPPing

body: From what I could find, it seems theres a command for pinging a server. It returns the number of milliseconds taken for the server to respond. The command is: `AT+PING="web site"` or `AT+PING=<ip addr>`, from 2 separate sources. You'll have to test them to see which (if not both) is correct.


body:
Not all devices (including) phones respond to ICMP Ping. This may differ for each (mobile) OS and version and phone make and model. But assuming your phone does respond to ping...

If you use the ESP with just the default firmware (a waste of a perfectly capable microcontroller), then indeed use the AT+PING command from the other answers.

If you use the ESP directly, you may be out of luck. Both the nocemcu lua firmware and the arduino api for esp seem to lack icmp ping functionality.


body:
This answer does not answer your question, but it implements the device you are describing. Unfortunately I don't have enough reputation to comment, so I will post it as an answer.

As people said before, ping is not a reliable option to scan the network. On Linux you can use dedicated (software) tools to scan the network, but even they struggle to reliably detect (some) mobile devices. So I wanted my router to do the work for me (at least it should reliably know which devices are logged into the Wi-Fi, right?).

Fortunately I have a Fritz!Box that provides an API to communicate with. Based on that API and an ESP8266 I build such a device you described in your question: [[15min] Weasley Clock / Who is Home Indicator - based on TR-064 (beta)](http://www.instructables.com/id/Who-Is-Home-Indicator-aka-Weasley-Clock-Based-on-T).

To do that I wrote a library for Arduino to uses that API: [Aypac/Arduino-TR-064-SOAP-Library](https://github.com/Aypac/Arduino-TR-064-SOAP-Library).


message:
Details on OV7670

I am thinking of working on a project based on a camera module OV7670. I am making a security system using an arduino where detected motion (I am also using a PIR sensor) will trigger the camera module. I wanted to get all kinds of information needed to work with the camera module in this kind of project.

I am not expecting a very long answer rearding everything about the module. The most important points and maybe a few references would be enough. It would also be helpful if programming reference for the camera module is also provided.

body:
[This post][1] is a link to a blog that describes the pinout and connections, along with some general information. They also have a link to [an "ArduCAM" library][2] with [an example][3] utilizing your camera model.

  [1]: http://www.arducam.com/camera-modules/0-3mp-ov7670/
  [2]: https://github.com/ArduCAM/Arduino/tree/master/ArduCAM
  [3]: https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV7670_Camera_Playback/ArduCAM_OV7670_Camera_Playback.ino


message:
Powering 3.3v sensors from a coin cell

I want to build some small wireless temperature measurement boards, to sprinkle around the house. I'd like to power these from a single coin cell battery (CR2032).

For these I'd like to use the DS18B20 sensor. These sensor require a minimal voltage of 3v. A coin cell will however only provide 3v when it's full, and will drop to around 2.6v when 90% discharged.

From what I've read the DS18B20 will give [some strange results](http://openenergymonitor.org/emon/node/2303) when the supply voltage is below 3v. Also the [precision can be off](http://openenergymonitor.org/emon/node/2331), when the supply voltage isn't regulated.

(The ATMega328p and NRF24L01, I plan to use, will work just fine at voltages down to 2v, so only the DS18B20 requires 3.3v.)

So I've come up with the following solutions:

 1. Use two coin cells, and a (low quiescent current) voltage regulator. (Disadvantage: takes more space, more batteries, slightly more expensive.)
 2. Use a boost regulator. (Disadvantage: even more expensive, and a lot more complex (for me at least).)
 3. Implement a voltage doubler to power the DS18B20 when needed (every 15 minutes). To regulate the voltage I'd add a 3.3v zener diode to the output. (dirt cheap to implement)

I tend to lean toward option 3, but my question is, could it even work?

Is there something to look out for?

Or is there an even better solution?

**edit** I was planning to use the Dickson doubler circuit.

[![voltage doubler][2]][2]

  [2]: https://i.stack.imgur.com/J6gVP.png

body:
You're missing out option 4, which is the option I would personally go for:

* Use a different temperature sensor.

A quick parametric search on Microchip (my favourite, I'm a Microchip fanboy after all...) I find quite a nice one - the MCP9844.

>  Microchip Technology Inc.’s MCP9844 digital temperature sensor converts temperature from -40°C and +125°C to a digital word. This sensor meets JEDEC Specification JC42.4-TSE2004B1 mobile Platform Memory Module Thermal Sensor Component. It provides an accuracy of ±0.2°C/±1°C (typical/maximum) from +75°C to +95°C.
>
> Operating Voltage Range (V): +1.7 to +3.6

**However** it is only available as a TDFN which makes prototyping difficult, although it is one of my two preferred footprints for real building - the other being variants of QFN.

I am sure you can search other makers for similarly specified chips that will do the job without the need for fancy boosters or doublers or the expense of multiple batteries etc.

One of the first steps of any design is the component identification. Often the chip or component that many people automatically reach for because it's the first one they used, or it's the one people most often talk about, may not be the right tool for the job. It pays to shop around a bit and look to see if there is something better that will fit the bill and save cost and time in the long run by ending up with a simpler system.


message:
Arduino drawing a bitmap on nokia 5110 lcd

Hello I finally got my nokia 5110 lcd working, I have tested it by displaying bitmap images other people have made. I made my own image and then used lcd assistant to turn it into an array. First look at my code.

    #include "U8glib.h"

U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6);  // CLK=8, DIN=4, CE=7, DC=5, RST=6

int x = 5;
int y = 5;

int level = 5;

const uint8_t rook_bitmap[] U8G_PROGMEM = {
0x7E, 0x82, 0x04, 0x8E, 0x7A, 0x42, 0xB4, 0x24, 0x08, 0xD8, 0x48, 0x08, 0x08, 0x0C, 0x02, 0x22,
0xD9, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1E, 0x11, 0x21, 0x22, 0x14, 0x3B,
0xD4, 0x25, 0x29, 0x68, 0xA8, 0xA8, 0x74, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

void draw(void) {
  // graphic commands to redraw the complete screen should be placed here
  u8g.drawBitmapP( 5, 5, 3,18, rook_bitmap);

 }

void setup(void) {

}

void loop(void) {
  // picture loop
  u8g.firstPage();
  do {
    draw();
  } while( u8g.nextPage() );

 // y++;
  // rebuild the picture after some delay
  delay(1000);
}

The part that goes wrong is at u8g.drawBitmapP(5,5,21,18, rook_bitmap);
I know it is to do with the 21 and 18 being wrong because I don't know where to get those numbers. Is it the width and height of the image when it is in paint.net or what is it?

body:
The 21 and 18 are the dimensions of the image. It's not just pixels though.

The first number (21) is the number of *bytes* in a row of the image - that is one eighth of the width in pixels.  The width *must* be a multiple of 8.

The second number is the number of rows in the image - basically the height in pixels.

The two numbers, when multiplied together, must equal the number of bytes in your array.

From [the documentation:](https://code.google.com/p/u8glib/wiki/userreference#drawBitmap)

>**Description**
>
>Draw a bitmap at the specified x/y position (upper left corner of the bitmap). Parts of the bitmap may be outside the display boundaries. The bitmap is specified by the array bitmap. A cleared bit means: Do not draw a pixel. A set bit inside the array means: Write pixel with the current color index. For a monochrome display, the color index 0 will usually clear a pixel and the color index 1 will set a pixel.
>
>**Arguments:**
>
> * u8g : Pointer to the u8g structure (C interface only).
> * x: X-position (left position of the bitmap).
> * y: Y-position (upper position of the bitmap).
> * cnt: Number of bytes of the bitmap in horizontal direction. The width of the bitmap is cnt*8.
> * h: Height of the bitmap.

----

It would appear your image data is complete gibberish.  This is what I decode it to be:

     ######  #     #  #
     ###   # # ####  #    #
      # ## #  #  #     #
       ## ##   #  #    #
       #      ##     #
     #   #  #  ## #####

            #        ####
    #   #   #    #   #   #
      # #   ## ###    # # ##
    # #  #  #  # #     # ##
       # # #   # # #  # ###
      ##    ##


message:
Link Arduino Uno to Particle Photon

I'm working on a prototype with a Particle Photon, but I've realized the required number of pins is bigger than the number of pins on my photon.

I thought I could have an Arduino Uno wired to some sensors, and link the Arduino to the photon via a Software Serial from the Arduino (as its serial pins will already be busy) to the Serial pins of the photon.

Is it possible, and is there a better way to solve my problem?

body:
If you just need to get more inputs you could use multiplexing. The multiplexing method is more robust than software serial will be. How to do this is explained [here][1] and [datasheet for the commonly used cd4051 here][2]

You don't specify what kind of sensors you will use. if the sensors are i2c or similar it is possible to daisychain (multiplex too) them.

  [1]: https://cityos.io/tutorial/1958/Use-multiplexer-with-Arduino
  [2]: http://www.ti.com/lit/ds/symlink/cd4053b-mil.pdf


message:
Long Distance Communication with Arduino

I am reading the value of six potentiometers with a TX Arduino and receiving that data and applying those numbers to a motor using serial. It is working fine through TTL but I am going to need to do this over a 60 ft tether.

I have done a little research and see that I could use RS 232 but that the maximum you should go with that is 50 ft, which will not work if I'm not mistaken. I have also seen RS 485 which will give us 4000 ft, which is overkill but will work. However, that only offers one-way communication, if I'm not mistaken. What I'm wondering is which protocol should I convert it to, and how I would have to adjust my RX and TX code.

TX code:

    /*
      Transmitting Code
      Reads potentiometers and sends them through serial
    */

    int data [10];     // to send bytes
    int start [2];
    int pot0Pin = A0;  // analog pin used to connect the potentiometer
    int pot0;          // variable to read the pot0ue from the analog pin
    int pot1Pin = A1;
    int pot1;
    int pot2Pin = A2;
    int pot2;
    unsigned char checksum0;
    unsigned char checksum1;
    unsigned char checksum2;

    void setup() {
      Serial.begin(9600);
      Serial1.begin(9600);
      pinMode(19, INPUT);
      pinMode(18, OUTPUT);
    }

    void loop() {

    // READ THE POTENTIOMETERS:

      pot0 = analogRead(pot0Pin);   // reads the value of the potentiometer (pot0ue between 0 and 1023)
      data[0] = pot0 & 0xFF; //least significant 8 bit byte
      data[1] = (pot0 >> 8); //most significant 2 bits

      pot1 = analogRead(pot1Pin);
      data[2] = pot1 & 0xFF;
      data[3] = (pot1 >> 8);

      pot2 = analogRead(pot2Pin);
      data[4] = pot2 & 0xFF;
      data[5] = (pot2 >> 8);

    // CREATE CHECKSUMS:

      checksum0 = ~(data[0]+data[1]) + 1;

      checksum1 = ~(data[2]+data[3]) + 1;

      checksum2 = ~(data[2]+data[3]) + 1;

    // WRITE VALUES AND CHECKSUMS TO SERIAL:

      Serial1.write(data[0]);
      Serial1.write(data[1]);

      Serial1.write(data[2]);
      Serial1.write(data[3]); //bytes sent

      Serial1.write(data[4]);
      Serial1.write(data[5]);

      Serial1.write(checksum0);

      Serial1.write(checksum1);

      Serial1.write(checksum2); // send the checksum

     delay(10);        // delay in between reads for stability

    }

RX code:

    /*
      Receving Code
      Reads bytes from Transmitting Code and put thems back together
      Applies the read bytes to our motor control board
    */
    unsigned char val[10];    // variable to read the value from the analog pin
    int motorVal;
    int coolVal;      // 0-1024 received from serial
    int coolVal1;
    int coolVal2;
    unsigned char checksum1;
    unsigned char checksum2;
    unsigned char checksum3;
    unsigned char checkit1;
    unsigned char checkit2;
    unsigned char checkit3;
    int directionPin = 8;
    int PWM_out_pin = 9; // works on pins 2 - 13 and 44 - 46

    void setup() {
      Serial.begin(9600);
      Serial1.begin(9600);
    //  Serial1.begin(9600);
      pinMode(10, INPUT);
      pinMode(18, OUTPUT);
      pinMode(8, OUTPUT);
      pinMode(9, OUTPUT);
    }

    void loop() {

      if (Serial1.available()>5) {

        val[0]=Serial1.read();         // least significant 8 bits
        val[1]=Serial1.read();         // most significant 2 bits

        val[2]=Serial1.read();
        val[3]=Serial1.read();

        val[4]=Serial1.read();
        val[5]=Serial1.read();

        checksum1=Serial1.read();
        checksum2=Serial1.read();
        checksum3=Serial1.read();// get the checksum last

        checkit1 = val[0]+val[1]+checksum1;
        checkit2 = val[2]+val[3]+checksum2;
        checkit3 = val[4]+val[5]+checksum3;

      if (checkit1==0);  {
        coolVal = val[1]<<8 | val[0]; }

      if (checkit2==0);  {
        coolVal1 = val[3]<<8 | val[2];}

      if (checkit3==0);  {
        coolVal2 = val[5]<<8 | val[4];
        }

        Serial.print(coolVal);
        Serial.print(" ");
        Serial.print(coolVal1);
        Serial.print(" ");
        Serial.println(coolVal2);
        delay(10);

      }

    // FOR MOTOR 1 (more will be added once we achieve successful serial):
      if (coolVal > 550) {
        digitalWrite (directionPin, HIGH);
        motorVal = map(coolVal, 550, 1023, 0, 1023);
        analogWrite (PWM_out_pin, motorVal / 4); }

      if ((coolVal < 550) && (coolVal > 500)) {
        digitalWrite (directionPin, HIGH);
        analogWrite (PWM_out_pin, 0); }

      if (coolVal < 500) {
        digitalWrite (directionPin, LOW);
        motorVal = map(coolVal, 0, 500, 1023, 0);
        analogWrite (PWM_out_pin, motorVal / 4); }

    }

body:
You're right that 60' exceeds the spec for RS-232. That said, distance specs are often quite conservative (as they should be, the spec is a promise that it will work and needs to account for marginal components and an unfavorable environment). I think the 50' limit for RS-232 was more observed in the breach than in practice. So for starters I'd be inclined to see if you could get 60' using RS-232 – I'd be kind of surprised if it didn't work.

Since reliability is important you're doing the right thing by checksumming and checking the data. If the checksum you use is good, it will go a long ways towards letting you detect corrupted data. Then, even if you are using a less than perfect underlying medium (e.g., RS-232 over a long distance), you can improve reliability by ignoring any corrupted values you receive. What that won't protect you from is a major data loss – for example a cut in your cable or a very noisy environment where most of your messages are getting lost. To defend against that you need a mechanism that also acknowledges your transmissions.

So, at this point you've got a choice – you could keep thinking of what might go wrong and designing solutions, or you could see if you could build on existing work. One thing you might want to look at is using something like the [SLIP][2] (**S**erial **L**ine **IP**) protocol which was developed to run TCP/IP over a dialup modem back in the dark ages of the Internet. I found, but haven't tried out, a couple of implementations for the Arduino:

- [SerialIP Library for Arduino][3] - a "proof of concept" version on the Arduino Playground.
- [Open Sound Control over SLIP][4] - newer, but not sure how hard it would be to extract out the SLIP part.

RS-485 is (can be) bi-directional, you just need a transmitter and receiver at each end. Another approach would be to use a [4-20 mA current loop][1].

You might also want to look into making the controller wireless. That would get you some added convenience (at the expense of a tether to help you find where you put the box) as well as a reliable two-way communication protocol.

[1]: http://www.bapihvac.com/content/uploads/2010/07/Understanding-4-20-mA-Current_Loops.pdf
[2]: https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol
[3]: http://playground.arduino.cc/Code/SerialIP
[4]: https://github.com/sepal/Arduino-Serial-SLIP-OSC


body:
You can do two-way communication with RS485. I have a [page about RS485](http://www.gammon.com.au/forum/?id=11428) with schematics and code, including calculating checksums.

You don't have to use twisted cable, that would just add to the reliability. You would need 4 cores (power, ground, A and /B) however if the other end was self-powered (ie. a battery) then you could skip that. There has been a bit of debate about whether the ground wire is needed (assuming you don't send power) but it is probably sensible to include it.

The page I linked above also describes a rolling master system, where each node has a chance to "talk" to other nodes. This demonstrates that you can send and receive on the same pair of wires.

In my test of the rolling master (using UTP cable) I had it working over 40 meters (ignore the figure on the schematic). So your 50 feet range should be easily achievable.

[![RS485 connection][1]][1]

  [1]: https://i.stack.imgur.com/I5ZZa.png


message:
Arduino U8glib: how to display text?

I have a Nokia 5110 screen using u8gliv. I have it displaying an image and I can get it to display text:

       u8g.setFont(u8g_font_osb18);
       u8g.drawStr(0, 20, "PRESS START");

The problem is that this font size is way too big. How can I make it smaller? Do I have to use different fonts? If so how do I do that?

body:
Just choose a smaller font. You know, I showed you the documentation earlier. You really should read it, because it contains all the information you need.

For instance, here is the section on the available fonts: https://code.google.com/p/u8glib/wiki/fontgroup - each section contains a link to download the font group which of course you will need to do before you can use it.

You might find something like:

    u8g.setFont(u8g_font_fixed_v0);

more to your liking. And don't forget to download it via the link above first.


message:
Difference between /dev/ttyACM0 and /dev/ttyS0 (Arduino IDE ports under Linux)

I use the Arduino IDE to upload sketches to my Arduino Uno. My OS is Linux Ubuntu 14.04 LTS. The Arduino IDE has two ports by default for communication with the Arduino Uno:

    /dev/ttyACM0
    /dev/ttyS0

 1. What is the difference between these two ports ?
 2. What does "ACM0" and "S0" mean ?
 3. Are there configuration files somewhere in the OS folder structure that describe the parameters of these ports ?

I know that when I select `/dev/ttyACM0`, I am able to send data to my Arduino Uno. However it does not work when I select `/dev/ttyS0`.

I just want to better understand what these ports are exactly.

body:
`/dev/ttyACM0` is a USB [communication device][1] (CDC) of sub-type "abstract control model" (ACM). That is what the Arduino is.

`/dev/ttyS0` is a hardware serial port - the (typically) 9-pin D connector on the back of your computer.

If you want to use `/dev/ttyS0` (why would you?!) you will require a special cable that converts the RS-232 voltage signals from the 9-pin D connector into the right TTL level signals for the Ardiuno and wire it in to the right pins on the board.

  [1]: https://en.wikipedia.org/wiki/USB_communications_device_class


message:
Use ESP8266 as WiFi client connected to Arduino Pro Mini

So i'm trying to use the [PubSubClient Library][1] on my arduino mini pro, but I'm connecting to the internet via wifi using an ESP8266.

Using a mini means I have to use software serial to connect to the ESP, but I've ran into a problem. I can't find anywhere such as `ESPWiFiClient` to use with the examples from the PubSubClient library where they use `EthernetClient`.

Is there any available libraries that can emulate EthernetClient with an ESP module over software serial?

  [1]: https://github.com/knolleary/pubsubclient

body:
Ditch the Pro Mini.  Upload your Arduino code to the ESP directly. There's a GitHub repo with the details. ESP for Arduino IDE has a ton of libraries. I'm sure you'll find it there.

But if you're bent on using the Pro Mini,  you'll have to use AT commands over serial to control it or flash a custom firmware into the ESP using Lua or something. And Pro Mini can use its hardware serial just like a Uno does.


message:
Communication between Arduino and XBee

I have two XBee Pro S2Bs: one is plugged in to a USB explorer, and; the other is plugged into an Arduino Wireless Protoshield, which is connected to an Arduino Uno.

My XBee connected to the explorer is configured as the *coordinator* in AT mode, and the XBee connected to the Arduino is configured as a *router* in AT mode. As a side note, I tested the network with a second USB explorer, and I was able to communicate between both XBees.

I uploaded the following code to the Arduino (which is just a sample I pulled off the internet somewhere):

<!-- language: c -->

    char rx_byte;

    void setup()
    {
        Serial.begin(9600);
    }

    void loop()
    {
     if (Serial.available() > 0)
     {
      rx_byte = Serial.read();
      Serial.print("You Typed: ");
      Serial.println(rx_byte);
     }
    }

Once I upload the code and turn on the serial monitor for the Arduino (using either the Arduino IDE or Visual Micro, with the Arduino plugged in via USB), and turn on the serial monitor on for the XBee connected to the USB explorer (using the serial monitor in XCTU), I get the following results:

 - If the wireless proto shield has its switch set to USB mode, then I can send data from the Arduino serial monitor to the serial monitor in XCTU, but the Arduino serial monitor doesn't receive data that is typed into the XCTU serial monitor.

 - If the wireless proto shield has its switch set to Micro mode, then I get mostly the opposite result.  I can send data from XCTU serial monitor to the Arduino serial monitor, which the result is returned to the XCTU serial monitor, e.g., if I type "X" in XCTU serial monitor, both serial monitors say "You Typed: X".  However, if I try to send data through the Arduino's serial monitor, neither serial monitor displays anything.

What I would like to do is be able to type in either serial monitor and have the data displayed in both serial monitors, like you would expect in a simple chat program.

Can someone see where I have gone wrong and/or how to get to the correct result?

body:
Check out https://learn.sparkfun.com/tutorials/xbee-shield-hookup-guide/example-communication-test
Essentially you need to set up Software Serial for your xbee to communicate on a couple of digital pins, instead of using hardware serial. When using hardware serial (the RX and TX pins) only one device works on it at a time, hence why you can't use the xbee and the serial monitor at the same time.


message:
Bluetooth connection to HC-05 paired but not connected (in Linux)

I have an Arduino Uno connected to an HC-05 Bluetooth sender/receiver chip. I am trying to create a Bluetooth connection between my Acer laptop running under Ubuntu 14.04 LTS and the HC-05 chip.

Ubuntu detects the HC-05 chip, as can be seen below.

    phodor@ubuntu: hcitool scan
    Scanning ...
        11:22:33:44:55:66   HC-05

I am able to create a pair between my laptop Bluetooth device and the HC-05 chip. However, I am unable to create a connection with that pair from the Ubuntu interface. The "Connection" button cannot be clicked on, as you can see on the figure below.

I tried creating a connection using the terminal, but after that the terminal still did not detect any connection.

    phodor@ubuntu: sudo hcitool cc 11:22:33:44:55:66
    [sudo] password for phodor:
    phodor@ubuntu: hcitool con
    Connections:

I also checked that my computer Bluetooth device was working.

    phodor@ubuntu: hcitool dev
    Devices:
        hci0    AA:BB:CC:DD:EE:FF

Any idea why the connection cannot be created ? Any idea on how to do it using the Ubuntu interface or the terminal ?

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/dCsJp.png

body:
you can try this website for more information

http://wiki.micropython.org/official-accessories/Bluetooth-module-HC05


body:
You can find the answer in the [Bluetooth connection to HC-05 paired but not connected][1]

Step;

1.Once you have paired the HC-05 as you've described, bind the device by entering;

    sudo rfcomm bind 0 "MAC address" 1

2.To trigger the connection & display the data using minicom, run;

    sudo minicom -D /dev/rfcomm0

You'll notice that port /dev/rfcomm0 will be available from the arduino IDE as well.

3.To exit minicom, press ctrl+A and then X.

  [1]: https://askubuntu.com/questions/721954/bluetooth-connection-to-hc-05-paired-but-not-connected/1350834#1350834


message:
Arduino String problem

Hello I am using the u8glib library to draw text on the string but it keeps giving me an error with the string

<!-- language: c -->

     String name1 = "";
     ...
     void draw(){
      u8g.setFont(u8g_font_micro);
      u8g.drawStr(22, 37, name1);
     }

why dosnt this work?

Here is the error:

> C:\Program Files (x86)\Arduino\libraries\U8glib/U8glib.h:200:16: note:
> no known conversion for argument 3 from 'int' to 'const
> __FlashStringHelper*' no matching function for call to 'U8GLIB_PCD8544::drawStr(int, int, String&)'

body: Like the documentation says, that method doesn't take a `String` object. Call the `c_str()` method of the `String` object and pass that instead.


body:
String is evil and should be avoided at all costs (http://hacking.majenko.co.uk/the-evils-of-arduino-strings)

The author of u8glib knows that and has refused (quite rightly) to implement them.

You should not use String either.  If you really *must* for some obscure reason then you will have to pass the internal "C string" reference to the `drawStr` function instead of the whole String object:

    u8g.drawStr(22, 37, name1.c_str());

The *only* reason people use String is because they are too lazy to learn the proper way of handling textual data in C.


message:
Gboard 800 (SIM900 + ATmega 328)

Greetings dear reader!

I have some trouble storing my IMEI code inside a variable. It always returns an error: "void value not ignored as it ought to be".

Since then I tried to write it to the serial line by just running the `gsm.SimpleWriteln("AT+GSN");` AT command, but I am stuck at storing this displayed value inside a variable. Does anyone here know a way to store a serial value into a variable? I just want to send the IMEI code as an identifier to the cloud application...

Thanks in advance, your response is really appreciated.

The code:

    #include "SIM900.h"
    #include <SoftwareSerial.h>
    //#include "inetGSM.h"
    //#include "sms.h"
    //#include "call.h"

    //To change pins for Software Serial, use the two lines in GSM.cpp.

    //GSM Shield for Arduino
    //www.open-electronics.org
    //this code is based on the example of Arduino Labs.

    //Simple sketch to communicate with SIM900 through AT commands.

    //InetGSM inet;
    //CallGSM call;
    //SMSGSM sms;

    int numdata;
    char inSerial[40];
    int i=0;
    boolean startUp = false;

    void setup() {
      Serial.begin(9600);
      Serial.println("GSM Shield testing.");

      //Start configuration of shield with baudrate.
      //For http uses it is recommended to use 4800 or slower.
      if (gsm.begin(9600)) {
        Serial.println("\nstatus=READY");
        getIMEI();
      } else Serial.println("\nstatus=IDLE");
    };

    void loop() {
      //Read for new byte on serial hardware,
      //and write them on NewSoftSerial.
      serialhwread();
      //Read for new byte on NewSoftSerial.
      serialswread();
    };

    void serialhwread() {
      i=0;
      if (Serial.available() > 0) {
        while (Serial.available() > 0) {
          inSerial[i]=(Serial.read());
          delay(10);
          i++;
        }
        inSerial[i]='\0';
        if(!strcmp(inSerial,"/END")) {
          Serial.println("_");
          inSerial[0]=0x1a;
          inSerial[1]='\0';
          gsm.SimpleWriteln(inSerial);
        }
        //Send a saved AT command using serial port.
        if(!strcmp(inSerial,"TEST")) {
          Serial.println("SIGNAL QUALITY");
          gsm.SimpleWriteln("AT+CSQ");
        } else {
          Serial.println(inSerial);
          gsm.SimpleWriteln(inSerial);
        }
        inSerial[0]='\0';
      }
    }

    void serialswread() {
      gsm.SimpleRead();
    }

    void getIMEI() {
      long IMEI = gsm.SimpleWriteln("AT+GSN"); // IMEI code
      Serial.println(IMEI);
      return IMEI
    }

body:
The `SimpleWriteln()` function just sends an instruction. It doesn't return anything.  Once you have sent the instruction to retrieve the IMEI you then have to actually *read* the IMEI.

However, fortunately, there is a function that does it for you:

    char imei[20];
    gsm.getIMEI(imei);

The IMEI should now be in the C string `imei`. What you do with it then is up to you.


message:
Do I have to use an RTC to build a clock?

While I was researching ideas for an Arduino clock, I found several clocks that incorporated an RTC (Real Time Clock) module.

I don't know why it is used in some clocks.

So, here are my questions:

 - How does an RTC module work?
 - Do I have to use it "like a rule" (is an RTC necessary or unnecessary) in my clock?

body:
> How does a RTC module works?

It counts. As simple as that. Once a second it ticks and counts up. It also remembers - most have a battery backup and will continue ticking when you turn the main power off.

> I have to use it "like a rule" (if it is necessary or unnecesary) in my clock?

If you want accuracy and continuation, yes.  An RTC is designed to tick at (as close as reasonably possible) once per second. Trying to do that with just an Arduino is incredibly difficult. The ceramic resonator on an Arduino is not as accurate as the quartz crystals used with an RTC. After a week you may find you are an hour out.


body:
> How does a RTC module works?

It is a specialized counter. It counts seconds, minutes, hours, days, months and years, properly handling such annoying problems as leap year, different days in months, etc.

Additionally it allows powering with a battery, so that clock ticks even when the device is not powered on, until battery discharges.

Usually RTC is clocked at 32768Hz using standarized quartz crystal.

> I have to use it "like a rule" (if it is necessary or unnecesary) in my clock?

Unless your microcontroller has RTC built-in, you should use an external one. There are many RTCs with I2C interface.

Built-in timer available in Arduino is not accurate enough and cannot tick when you remove power. Inaccurate counter will cause your clock to drift considerably and no backup power forces your clock to be connected all the time.

You can check out this example to see how to hook up:
https://iobtoolkit.com/docs/tutorials/i2c_terminal_mcp7940n.html

Disclaimer: i'm the author of IOB, but you don't need to use it. It's just a nice analysis of a rather popular RTC.


body:
RTC modules are used because they make it easier to keep accurate time. They do this by maintaining time when the system is shut down or rebooted (by way of a battery or some other mechanism for keeping running independently of the host system) and by providing a time base that is, usually, more accurate than that of the host.

Another way to keep very accurate time (potentially better than you can get with all but the best RTC modules) is to get your time from a GPS or from the Internet using NTP. If you're going to use a GPS anyway or need an Internet connection then either of those approaches are very good ways to go. If you don't, then they are considerably more expensive than an RTC module.


body:
For this "rule", and for many "rules" like this, the answer is "it's more of a guideline" (usually "it's not required, but may be easier that way").

Keeping time requires 3 things: an accurate "tick", a way of knowing the time initially, and counting the time since then.

The (16mHz) clock on the Arduino will give you a reasonably accurate "tick" - on the order of 50 parts per million. That means, over a million seconds, your clock will drift about 50 seconds. This works about (ballpark) 1 minute per fortnight. Is this accurate enough? This depends on what you are using it for.

The next thing on the list is knowing the time initially. If you buy a RTC, it may be set to the right time, or it may not. Even if it is "set", it may not be set to your timezone. Setting these is pretty easy. It will need to be set every time the clock (be it a RTC or your homebrew clock) loses power. For this reason, RTCs usually have a battery back up. How will your clock get it's time when it starts up? Note that, if your project is network connected, you may be able to get the clock from the internet - this will also mean the drift of your clock will not be an issue - you can retrieve it once per day, so it will never drift more than 4 seconds before it gets corrected.

The final thing that it needs (and the easiest) is a way of counting the time. This is probably the easiest - use the millis() function. Note that this overflows (resets to 0) after 4294967296 milliseconds - about once every 50 days. Millis() will tell you the number of milliseconds since the Arduino last rebooted. If you want your clock to run more than 50 days, you need to be prepared to that. This will happen part way through a second.

Note that this will give you milliseconds, and, fairly easily, seconds, minutes, hours. If you want the day (of the month), then you need to keep track of which month and year, since the length of each month will vary, as will leap days.


body:
I built a clock designed a while ago by Geoff Graham, who [synchronized to a GPS](http://geoffg.net/GPS_Synchronised_Clock.html) around every 24 hours, and used the internal clock in-between. The GPS corrected for drift in the internal clock (and, of course, gave you the time accurately in the process).

This is more expensive than a RTC, but more accurate. If you also had an RTC it would drift less during the day. Or, you could read from the GPS all the time and not have an RTC.

I made a [GPS clock](http://www.gammon.com.au/forum/?id=11991) myself which does that - just shows the GPS time.

[![GPS clock][1]][1]

Higher-contrast image:

[![GPS clock face][2]][2]

Internals:

[![Inside GPS clock][3]][3]

---

This is [another project](http://www.gammon.com.au/forum/?id=12106) that uses an RTC clock chip (indicated on photo):

[![Temperature sensor][4]][4]

However if you go for just an RTC chip you can expect it to drift over time. They are more accurate than counting processor ticks (and survive a power outage because of the backup battery) but are not as accurate as the GPS.

Those clock chips are pretty cheap. I got 30 of them for $10 from eBay.

  [1]: https://i.stack.imgur.com/aWQyV.jpg
  [2]: https://i.stack.imgur.com/NhA5R.jpg
  [3]: https://i.stack.imgur.com/r9MOy.jpg
  [4]: https://i.stack.imgur.com/2EZ5o.png


message:
İs there any way different way than GND's Arduino

İ'm making  a project on my arduino uno when i figured out i had no more GND left to finish the circuit. İs there any other way to optimize, use pins as input maybe. İ tried whit other websites, however, they weren't much of a use. Can you show an example also.

Thank you sooo much in advance,

Dario

body:
Dario,

There are only 3 ground pins on the Arduino Uno, but don't be afraid to "breakout" these pins with wire. It doesn't matter if you connect multiple component grounds together, as long as they are connected to ground with no resistance between them, the circuit will close.

Strip board and pin headers will help you here, try this: http://www.instructables.com/id/Home-Made-Arduino-Prototype-Shield/


message:
Connecting Arduino To mains

How would iconnect my Arduino Mega to house Mains, without buying a transformer, and having to make a whole setup for that.  Can i just use a regular phone adapter?  Or is 1 Amp too large (or 2 Amps).

body:
Amps tell you how much current you can draw from the power supply, or "how much it can do".

You can hook up 3Amps power supply to a device that draws 1Amp and it will work ok, still having 2 amps of reserve.

You must pay attention to power supply **voltage** and keep it in specified range.

Arduino Mega has recommended input voltage of 7-12V, so you must deliver at least 7V. There are plenty of cheap wall power supplies with voltage regulation from 1.5V to 12V.

How much current it will draw depends on your application, but I doubt that you can suck more than 0,5-1A in a typical application.