message:
Arduino DC motor causes disturbance. What can cause it?

I tried to fix this problem the whole weekend but, after no success I decided to post it here. I would really appreciate any help.

**The problem**

The Wi-Fi module activates the DC motor and lets it run for 3 seconds, but when the DC motor stops after that 3 seconds, the Wi-Fi module and display don't respond anymore.  It only works once.  (After I push the reset button the same thing happens.)

**Question**

**What causes this disturbance? Any advice on my circuit?** (I included a Fritzing Diagram because I am bad at drawing schematics)

[![Fritzing Diagram][1]][1]

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

    #include <SoftwareSerial.h>
    #include <LiquidCrystal.h>

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    SoftwareSerial ESP8266(9, 8); // RX = 8 en TX = 9

    #define DEBUG true

    boolean FAIL_8266 = false;
    int LED = 13; // led op 13

    int secondeAan = 3000;

    String my_AP_SSID = "myID";
    String my_AP_Pass = "myPass";

    void setup()
    {
      // -- stel led in --
      pinMode(LED, OUTPUT);

      // -- lcd scherm --
      lcd.begin(16, 2);
      lcd.clear();
      lcd.setCursor(0, 1);

      do {
        ESP8266.begin(115200); // start communicatie met esp8266

        //Wait Serial Monitor to start
        while (!Serial);

        lcd.clear();
        lcd.print("--- Start ---");

        ESP8266.print("AT\r\n");
        delay(500);

        if (ESP8266.find("OK"))
        {
          FAIL_8266 = false;
          sendData("AT+RST\r\n", 4000, DEBUG);
          sendData("AT+CWMODE=3\r\n", 2000, DEBUG);
          sendData("AT+CWJAP=\"" + my_AP_SSID + "\",\"" + my_AP_Pass + "\",9,4\r\n", 2000, DEBUG);
          sendData("AT+CIFSR\r\n", 2000, DEBUG);
          sendData("AT+CIPMUX=1\r\n", 2000, DEBUG);
          sendData("AT+CIPSERVER=1,80\r\n", 2000, DEBUG);

        } else {
          lcd.clear();
          lcd.setCursor(0, 1);
          lcd.print("Module have no response.");
          delay(500);
          FAIL_8266 = true;
        }
      } while (FAIL_8266);
    }

    void loop()
    {
      // Get the number of bytes (characters) available for reading from the serial port
      if (ESP8266.find("+IPD,"))
      {
        lcd.clear();
        lcd.print("Nieuwe connectie");
        // -- sluit connectie --
        motorToggle();
        sendData("AT+CIPCLOSE=0\r\n", 100, DEBUG);
        sendData("AT+CIPCLOSE=1\r\n", 100, DEBUG);
        sendData("AT+CIPCLOSE=2\r\n", 100, DEBUG);
      }
    }

    void motorToggle () {
      digitalWrite(LED, HIGH);
      lcd.clear();
      lcd.print("eten gegeven");
      delay(secondeAan);
      digitalWrite(LED, LOW);
      delay(200);
    }

    String sendData(String command, const int timeout, boolean debug)
    {
      String response = "";

      ESP8266.print(command); // send the read character to the esp8266

      long int time = millis();

      while ( (time + timeout) > millis())
      {
        while (ESP8266.available())
        {
          char c = ESP8266.read();
          response += c;
        }
      }

      if (debug)
      { lcd.clear();
        lcd.print(response);
      }

      return response;
    }

body:
There are a couple of things that could be causing your problems:

* The current draw of the motor, especially at start up. The motor may be drawing enough power to pull down the voltage at the processor causing it to crash, or

* You may be seeing transients as the motor starts and/or stops that are causing the processor to crash.

One way you could detect problems like this is to use the on-board LED as a heart beat or run indicator. You could either blink it in `loop()` or do something like turn it off just before starting or stopping the motor and then back on afterwards. If the blink stops or if the LED goes out then you know that the processor has stopped running.

As a general rule, except with the tiniest of motors, I'd suggest using the Arduino to control a transistor that controls the motor from its own power supply line (it could be the same supply as the one the feeds the Arduino, just don't run the motor power through the Arduino). That and the suggestions in the comments will go a long way towards isolating the Arduino from the motor and power disturbances it will cause.


sender: user

sender: assistant

body:
Thanks for the help everyone. I fixed it by using Capacitors. They suppress the noise that the dc motor produces. I found my information  [here][1]

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

  [1]: https://www.pololu.com/docs/0J15/9
  [2]: https://i.stack.imgur.com/dATTj.jpg


message:
Issue with Serial PINs (RX/TX) on Arduino

I have an issue with an Arduino Nano.

I want to communicate with it through the Serial-Port. Meaning I want to send and receive Serial commands. With USB and the "Serial Monitor" this works nice.
Now I have connected the COM-Port of the PC with Adruinos Digital Pins 0 and 1 (RX and TX) and a GND PIN. (3 Cables total).

Here is a minimal example of my Code:

    void setup() {
      Serial.begin(9600,SERIAL_8N1);
      Serial.println("Start");
    }

    void loop() {
      Serial.println("Hello World");

      delay( 1000 );
    }

**The Serial Monitor says:**

    Start
    Hello World
    Hello World
    Hello World
    Hello World
    ...

**Putty however says:**

    ▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒::
                                                         ▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒    ▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*

Putty is connected with
- BaudRate: 9600
- Data Bits:
- Stop Bits: 1
- Parity: None
- Flow Control: None

What is wrong here?

Update:
The PC has a 9-pin D socket ([Image][1])
This is connected to a RS232 to RJ45 connector ([image][2])
From the RJ45-Cable I used the Brown, Blue, and White/Green Cable to connect with the Arduino

  [1]: http://www.airyear.com/images/products1/202711.jpg
  [2]: http://ecx.images-amazon.com/images/I/41BucionchL._SY300_.jpg

body: RS232 is not TTL. You need a level converter. For more details see https://www.sparkfun.com/tutorials/215.


message:
Flashing dotStar LED

I have a DotStar LED strip that I want to make it blink (e.g., 1 second on, 5 second off in an endless loop).

I tried doing so via the script below but it does not work. Can someone please explain me how to do so?

Script:

    #include <Adafruit_DotStar.h>
    #include <SPI.h>

    #define NUMPIXELS 10

    #define DATAPIN    4
    #define CLOCKPIN   5
    Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);

    void setup()
    {
      strip.begin();
      strip.show();
    }

    void loop()
    {
      strip.show();
      strip.setBrightness(155);
      for (int i=0; i <= 10; i=i+1) {
        strip.setPixelColor(i, 255, 255, 255);
      }
      delay(1000);

      strip.setBrightness(0);
      delay(5000);
    }

body:
The basic idea of the program you're trying to write is:

    loop() {
      strip.show(); // Turn LED strip on.
      delay(1000);  // One second, argument is milliseconds.
      strip.setBrightness(0); //Turn LED strip off.
      delay(5000);
      strip.setBrightness(155); //Turn LED strip on.
    }

I haven't used the Adafruit DotStar library, so there may be details that I'm missing (like do you need to do a `strip.show()` after setting the brightness). But maybe this is enough to get you thinking about how to construct the program.

The real joy in hacking with something like this is the experimenting and the learning. Take the time to try to understand how you project works and to predict what will change as you modify the code and how you can tell if it is working the way you expect – that will get you a long way towards being a strong programmer.

When you're troubleshooting something new and/or unfamiliar, one thing that really helps is to break down the problem into simple steps. For example with this project a good first step would be to get the DotStart strip to turn on. Then see if you can get it to turn off. Build it up piece by piece.


body:
The authors of the library are not fans of the `setBrightness()` method and advise handling it yourself.

The following code should do what you want.

    #include <Adafruit_DotStar.h>
    #include <SPI.h>

    #define NUMPIXELS 60 // This should be the total number of LEDs in your strip

    #define DATAPIN    4
    #define CLOCKPIN   5
    Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);

    void setup()
    {
      strip.begin();
      strip.show();
    }

    void loop()
    {

      // loop through each pixel in the control array setting it to the colour mix you want.
      for (int i=0; i <= NUMPIXELS; i=i+1) {
        strip.setPixelColor(i, 25, 25, 25); // Even 25 on my strip gives reasonably bright flash
      }

      strip.show(); // Then push the control array to the strip
      delay(1000); // and leave it set for a while

    // Then do it again for the 2nd brightness in your scheme

      // loop through each pixel in the control array setting it to off.
      for (int i=0; i <= NUMPIXELS; i=i+1) {
        strip.setPixelColor(i, 0, 0, 0);
      }

      strip.show(); // Then push the control array to the strip
      delay(1000); // and leave it set for a while

    }


message:
RFID tag "location identification"

Can an RFID tag be used to identify a room? For example, I walk into a room, and the RFID receiver tells me that I am in say, the living room. Would it be possible for a tag to ping back the signal from a distance of 10ft? Or is there a similar technology like RFID that can extend to a much greater range?

body:
There are newer long range RFID solutions. You can do a google search on "Ultra Long-Range UHF Wireless RFID Sensors" for more information, but almost all of these systems are still proprietary (i.e. I'm not aware of any hobbyist breakout-boards based around UHF tags yet).

The Disney MagicBands are an exact use-case of your question: Their magic bands use a combination of 13MHz RFID tags, and a new UHF active tag (it requires a small battery). They use them to collect data on how people flow through their Walt Disney World facility.  What bathrooms see the most activity, and when, for example.  There is actually a pretty decent amount of information available about the technology used in the Disney Magicbands if you're curious about the technology.


message:
Arduino Uno Wire Transmission Issues

I am developing code to run a word clock and have noticed a slight problem. I am using a DS3231 to keep time, and using the `Wire` library to communicate with it. I ping the DS3231 every second to get the time and check a few other things. This is all working fine except when the clock loses power. It seems that occasionally upon loss of power to the Arduino, the time that that the DS3231 reports when it regains power, is incorrect.

My thought is that the power is getting cut in the middle of various `Wire.read()` commands and this is causing the chip to mess up and reset its own time, but I am not sure. The DS3231 has a battery backup attached to it, and that battery has only been plugged in for a month or two, so I don't imagine that is the problem.

I am wondering if anyone has an idea how I can deal with this potential problem, or if there is some way I can clear the `Wire` library before it starts up again.

I have put some sample code below to give an idea of what I am doing. There is of course much more code, but this is the only relevant part.

    #include "Wire.h"
    #define kClockAddress 0x68

    void readDS3231time(byte * second, byte * minute, byte * hour, byte * dayOfWeek, byte * dayOfMonth, byte * month, byte * year) {
      Wire.beginTransmission(kClockAddress);
      Wire.write(0); // set DS3231 register pointer to 00h
      Wire.endTransmission();
      Wire.requestFrom(kClockAddress, 7); // request seven bytes of data from DS3231 starting from register 00h
      *second = bcdToDec(Wire.read() & 0x7f);
      *minute = bcdToDec(Wire.read());
      *hour = bcdToDec(Wire.read() & 0x3f);
      *dayOfWeek = bcdToDec(Wire.read());
      *dayOfMonth = bcdToDec(Wire.read());
      *month = bcdToDec(Wire.read());
      *year = bcdToDec(Wire.read());
    }

    void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) { // sets time and date data to DS3231
      Wire.beginTransmission(kClockAddress);
      Wire.write(0); // set next input to start at the seconds register
      Wire.write(decToBcd(second)); // set seconds
      Wire.write(decToBcd(minute)); // set minutes
      Wire.write(decToBcd(hour)); // set hours
      Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
      Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
      Wire.write(decToBcd(month)); // set month
      Wire.write(decToBcd(year)); // set year (0 to 99)
      Wire.endTransmission();
    }

    void setup() {
      // put your setup code here, to run once:
      Wire.begin()
       // DS3231 seconds, minutes, hours, day, date, month, year
       //setDS3231time(0, 36, 10, 2, 21, 12, 15);
    }

    void loop() {
      // put your main code here, to run repeatedly:
      byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // retrieve data from DS3231
      readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
      delay(1000);
    }

body:
      Wire.requestFrom(kClockAddress, 7); // request seven bytes of data

Just because you request 7 bytes doesn't necessarily mean you get them. I suggest before reading the date and time you set all those variables to something invalid (like 0xFF). Then after reading, if you get 0xFF in any of them, ignore the entire lot.

---

> we are sending a start bit again, when we never sent a stop bit previosuly. ... Does this sound reasonable

Not really, because I2C doesn't have start and stop bits, it has *start condition* and *stop condition* which are specific changes to SDA and SCL which don't happen at any other times. See [I2C](http://www.gammon.com.au/i2c) for a description. I would be checking the data for validity, as I said. There is no other way of knowing for sure that a transmission wasn't interrupted. If you request 7 bytes of data, the library tells you that you got 7, even if you did not. However if it cannot even find the target device, it returns 0 as the number of bytes (you aren't testing for that anyway).

The very least you should do is test for a valid connection, eg.

    if (Wire.requestFrom(kClockAddress, 7) == 7)
      {
      // read the data
      }

That at least confirms that the clock chip responded in some way. Not checking error returns from function calls, where documented, is not wise.

Similarly when you send your command.

      Wire.endTransmission();

That should be:

    if (Wire.endTransmission() != 0)
      {
      // handle error here
      return;
      }

You have no tests in your code for either the sending or receiving to be working. And then you are unconditionally using the resulting time values. That's like opening a file, and reading it, without checking if the file exists.


message:
Use Arduino to transmit signal to a vibrating pager

I am an engineer at a machine shop. When a machine stops running, I want to be notified via a vibrating pager (like at restaurants). My plan is to attach the arduino board in the machine and when the machine stops (quits vibrating) I want it to trigger the vibrating pager that I have in my pocket. By what means can the arduino communicate with the vibrating pager to cause it to go off? SMS? Wifi? Bluetooth would likely be out of range. Other options?

body:
To do SMS through a GSM shield like https://www.arduino.cc/en/Main/ArduinoGSMShield with a dataplan, and the device should be accessible anywhere you can get reception.  With a wifi shield like https://www.arduino.cc/en/Main/ArduinoWiFiShield101 you could make it work within your wifi network.

Sparkfun's sales guide at https://www.sparkfun.com/pages/wireless_guide indicates there are a few bluetooth modules that reach 100m, so if your range is less than 100m, bluetooth is a possibility.


message:
Marlin Firmware troubles: <time.h> error

I am trying to upload the Marlin Firmware to my 3D printer's Arduino Mega 2560 and I am experiencing a problem. It keeps saying:

    qr_solve.cpp:7:18: fatal error: time.h: No such file or directory
     #include <time.h>
                      ^
    compilation terminated.
    Error compiling.

Please help as I'm lost as how to fix it, because I try to scroll up to see what is highlighted in red and I can't find anything.

body:
From [Gerben's link][1] to the googlegroups's thread, [Delta robot 3D printers › compiling jcrocholl's Marlin (Ubuntu)][2], as Francis Mallet points out, at the [bottom of the thread][3], it is necessary to change `<time.h>` to `"Time.h"`:

> I copied the content of the Time library right in the Marlin folder, then changed line 7 of qr_solve.cpp from #include <time.h> to #include "Time.h"

> The code compiled and everything seems to be working ok.

 So, to iterate, the line in `qr_solve.cpp`:

    #include <time.h>

becomes

    #include "Time.h"

Now, `Marlin.ino` should compile as expected.

Note that the latest version of Marlin, from [github.com/MarlinFirmware/Marlin][4] no longer suffers from this issue, but older versions of the software, such as [github.com/gpfwestie/kossel_2020_sintron][5] will do, due to [line 7, in `qr_solve.cpp`][6].

  [1]: https://arduino.stackexchange.com/questions/18893/marlin-firmware-troubles#comment35188_18893
  [2]: http://groups.google.com/forum/#!topic/deltabot/IknX0wamH2M
  [3]: https://groups.google.com/d/msg/deltabot/IknX0wamH2M/pIffvuv1CEYJ
  [4]: https://github.com/MarlinFirmware/Marlin
  [5]: https://github.com/gpfwestie/kossel_2020_sintron
  [6]: https://github.com/gpfwestie/kossel_2020_sintron/blob/master/Marlin-deltabot for Sintron Kossel mini/Marlin/qr_solve.cpp#L7


message:
How Master and Slave concept works with Bluetooth?

From what I understand the master has primary control over the slaves and communicates with them. A master must always be present as well, and can be connected to (up to) 7 slaves.

**Question**

 - If I have 2 arduinos with Bluetooth communicating with each other
   from within a radius of 80 meters or less, which arduino do I set as
   the **master** and which do I set as the **slave**? (what dictates which one should be set as master, etc.)

I want both arduinos to be able to transmit data to one-another (where neither has privilege over the other), so in my mind this is more like two slaves communicating. Both devices have the same controls on them and will effect the other devices the exact same way.

 - How does the **communication** process work exactly, and how should more
   arduinos be addressed if they are to be added with similar
   privileges?

body: Well, master/slave concept for Bluetooth resides on the protocol, not in the communications. On few words, this means Bluetooth Master is who has the ability to initiate connection with a peripheral (or slave), but onces connected both master and slave basically can interchange information without restriction (limited by application). If your bluetooth module or implementation has a SPP (serial port profile https://developer.bluetooth.org/TechnologyOverview/Pages/SPP.aspx) once the master finds and connect to the slave, information can flow in both ways like a chat (actually, chat application is the most common usage example of bluetooth modules)


message:
What does "Arduino compatible" mean?

I wanted to buy an Arduino (ATmega) 2560 (8 Bit MCU) via Amazon. But there was no Arduino visible. There was only a

  - [SainSmart 2560][3] and

![SainSmart 2560 image][4]

  - [SunFounder 2560][5]

![SunFounder 2560 image][6]

On both websides (SainSmart and SunFounder) there is the information that they are Arduino compatible. But all three boards (Atmel-orginal, SainSmart, SunFounder) do not look similar... There are differences. Is it possible to buy one of those boards without:

  - checking the datasheet differences
  - having problems with the Arduino Ethernet Shield !?

So, what is **compatible** ?

  [3]: http://www.amazon.de/SainSmart-Mega2560-ATmega2560-ATMEGA8U2-cable/dp/B00FLL8OZG/ref=sr_1_1?ie=UTF8&qid=1450723952&sr=8-1&keywords=arduino mega
  [4]: https://i.stack.imgur.com/2FJHj.png
  [5]: http://www.amazon.de/SunFounder-ATmega2560-16AU-Board-compatible-Arduino/dp/B00D9NA4CY/ref=sr_1_1?s=computers&ie=UTF8&qid=1450738573&sr=1-1&keywords=sunfounder 2560
  [6]: https://i.stack.imgur.com/ZsfiF.png

body:
Arduino is an open-source electronics platform. Lots of other manufacturers make Arduino-compatible boards, not just Arduino/Genuino. I have used both Arduino-branded and 3rd party manufactured boards without encountering any issues. I have not used boards by SainSmart or SunFounder, but they look compatible from a specifications perspective.

If you are worried about compatibility with the Ethernet Shield, you could always buy them as a pair (e.g. [SainSmart Arduino Mega 2560 + Ethernet Shield for Arduino UNO Mega Duemilanove R3 AVR PIC ATMEL Robot](http://www.amazon.de/SainSmart-Arduino-Ethernet-Shield-Duemilanove/dp/B00I1W25KM/ref=sr_1_2?ie=UTF8&qid=1450754865&sr=8-2&keywords=SainSmart+Ethernet+Shield+W5100)) just to be on the safe side.


body:
Arduino Compatible can mean many things, but most of the time it means that some company has made something they sell to a customer that supports development with the Arduino IDE.

The thing is that most Arduino Compatible units use the Atmel processors, but some use others too. Third party developers then make "board"-projects that you can add into the Arduino IDE.

Be aware though that you in some cases can run into issues if you dont do your homework, here are some of the issues you can run into:

 - Some "compatible" boards use different architectures, so even if you can do many things with the Arduino IDE, maybe some sensor libraries are not supported. (Might have to be hacked or updated)
 - Some "compatible" boards have different USB-circuits (if they have them at all)
 - Most of the boards you buy off aliexpress, banggood etc. do not come with instructions at all and some times they differ from the "original" design (might be better, might be "the same" or might be worse.).

I'm not trying to scare you off, but just my experiences. You can find a lot of fun things on those sites like clones of lilitiny with the AtTiny 85. One example is in my blog heer: http://mjelde.blogspot.no/2015/12/lilytiny-lilypad-attiny85-wearable-iot.html

The main issue with the clones I've had is that some times they differ in some ways that the first times will make you scratch your head. Like: ESP8266 is Arduino Compatible with the boards manager added ( https://github.com/esp8266/Arduino ), BUT: The input pins are not "correct" marked. So you should then add constants to "remap" them in your code.

Also the ESP8266 does only support 1V analog read, while many Arduinos support 5V. But you can "fix" this with an 16bit ADC (analog to digital converter). The ESP8266 only has 3.3V also, so you cant run sensors that "must" have 5V, without then giving them a different power circuit :)

The AtTiny 85 LilyTiny clone i bought in a pair of 2 from AliExpress works fine and works different than the rest of the Arduinos. Uploading to those for instance means you leave them disconnected and then you hit upload in the IDE. Then it says in the status window to connect it, which you then do.

Then it uploads. It has very few inputs, but it's very cute id say. Primarily it's made for wearable and of course it has a lot of short comings compared to a large arduino board. But you can of course use it to control RGB leds, etc.

Remember to always check specifications (3V vs 5V, how much analog read resolution can it handle, etc). There is the sensor vs board (some sensors work on both 3.3V and 5V, some work only on 5V, some only on 3.3V).

For going to 5V to 3.3V you usually use a voltage divider. Either you can buy pre made ones or you can make it based off three resistors and some math :-)


body:
The other answer seem to focus on "compatible" meaning "works with the IDE" but that's not what they mean here. "Compatible" in this context means "clone of the original".

You can count on these boards being functionally identical. The microprocessor and pinout are the same, which is what a shield cares about. The peripheral circuitry might vary slightly, but that's not a big deal. They might (as mentioned) have a different USB-Serial chip but that won't cause any issues once you install the appropriate drivers on your PC.


message:
Connecting ESP8266 with Arduino Uno - WiFi shield not present

I have an Arduino Uno and ESP8266. I want to connect and control an LED from a web server. I made a connection referring to this:

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

I uploaded the [WifiWebServer][2] code to the Arduino, and applied my router's credentials.

    char ssid[] = "Router SSID";      // your network SSID (name)
    char pass[] = "Router's WPA Password"; `

I'm getting a "Wifi Shield not present" message from the Serial Monitor. I even tried giving external 3.3v power supply to my ESP8266 module, but no change. What am I missing here? Can someone help me fix this issue?

  [1]: https://i.stack.imgur.com/KYbW1.png
  [2]: https://www.arduino.cc/en/Tutorial/WiFiWebServer

body:
The [WiFiWebServer tutorial][1] describes how to use the [ArduinoWiFiShield][2]. This shield is based on different WiFi hardware than the ESP8266 modules.

You need a WiFi library driving the ESP8266 modules instead, e.g [WeeESP8266][3].

Your favourite internet finding machine sure will find lots of similar libraries.

A different approach would be [ArduinESP][4] ([https://github.com/esp8266/Arduino][5]), which means to develop code to run on the ESP8266 module directly.

----

...aaaand please rethink your wiring. The ESP8266 modules are a pure 3.3V pets and your wiring connects a 5V logic signal directly to the ESP8266 and this may send your ESP8266 into the digital heaven with or without waving goodbye using blue smoke...

  [1]: https://www.arduino.cc/en/Tutorial/WiFiWebServer
  [2]: https://www.arduino.cc/en/Main/ArduinoWiFiShield
  [3]: http://docs.iteadstudio.com/ITEADLIB_Arduino_WeeESP8266/index.html
  [4]: http://www.arduinesp.com
  [5]: https://github.com/esp8266/Arduino


body:
You can program and upload code to ESP8266 using Arduino programming environment, reusing code and libraries with small changes. Check https://github.com/esp8266/Arduino for more information.

For most tasks ESP8266 may substitute Arduino board completely. It has more flash, more RAM and integrated WiFi, and is faster (80MHz).


body:
From your diagram, you appear to be using an ESP8266-01?

Another [ESP8266 AT command library][1] that may be of interest/use.

Note that the AT command libraries are very dependent on the version of the firmware that you have on the device.  Depending on when/where you bought the device, this firmware will vary significantly.  I've not had any of the libraries work correctly with current versions of the firmware.

Run the `AT+GMR` at command (using your serial terminal) to determine the firmware version.  If you're on Windows/PC updating the firmware to a previous version (the 0.9.x.x range seems to be the most stable according to my research) is relatively straightforward.  If you're on Mac, it's not as straightforward...

Official/current release of the firmware is available from [Espressif's Github repo][2].

There are plenty of directions on the net for getting firmware onto the ESP8266 for both Mac and Windows/PC.  YMMV as to their accuracy/ease of use.

Note that different versions of the firmware default to different baud rates.  Some default to 115200, others to 9600.  If you decide to use SoftwareSerial (rather than Serial, which your diagram suggests is what you're currently using) you'll need it to run on 9600.  I've not personally tested what Serial supports up to (but my understanding is that you can run up to 115200). Note that there are different commands for setting the ESP8266 AT command firmware baud rate depending on the firmware version/supplier.  The official SDK uses the `AT+IPR=9600` command.  This stores the baud rate to the device (i.e. you don't need to send it every time, just once and it's then persistent).

If you haven't already, I'd recommend you get the system working with a simple serial terminal program (CoolTerm, for example) before getting into Arduino-land.

Note that the ESP8266 does not reliably run from the 3v3 power rail on the Arduino. The ESP8266 requires up to 300mA, the Arduino is capability of around 50mA to my understanding.  Symptoms of insufficient power include random resetting of the device.  Best to run a separate 3v3 source to the ESP, or if you have a strong enough 5v supply, use a step-down converter.  Your diagram indicates you're using a standard Arduino, which runs 5v out of the serial pins (or digital outs), but your comments indicate you're running 3v3 (which means you're probably running a 3v3 Pro Mini or similar)?  If you're not running a 3v3 device, you'll definitely need to run a 5v-3v3 logic level converter (I can't link to examples due to not having enough reputation points—but these are relatively easy to get from SparkFun or similar.  I picked up a combined step-down converter with logic level converter which does both tasks.

Lastly, If you don't need the ADC from the Arduino device for your application (which it sounds like you don't given your project description) I'd **strongly** recommend you reconsider the advice from gmag11 and yeti re: running Arduino on the ESP8266.  It is much more stable, and the extra SRAM will make a big difference with processing/building HTTP request strings etc.  I wasted a *lot* of time (unsuccessfully) trying to get AT commands working before switching to Arduino on the ESP8266, which has been a breeze by comparison.

  [1]: https://github.com/ekstrand/ESP8266wifi
  [2]: https://github.com/espressif/ESP8266_AT


body:
Fritzing's wiring diagram has errors. 1) the serial connections wrong way around. You need to swap them so that
Arduino TX -> ESP Rx and
Arduino RX <- ESP Tx. Also 2) the ESP-01 require more than 200mA so supplying voltage reg cannot be provided from the Arduino 5V pin. It must be supplied by VIN with a supply able to provide 1A.


body:
[ArangaNathan][1] has posted [another Fritzing diagram][2] with the same errors as the opening diagram:

1. You can't drive the ESP8266 from the Arduino 3.3V pin as it can only supply 50mA but the ESP requires > 200mA to transmit properly.
2. All I/O wires between Arduino and ESP must be level shifted from 5V to 3.3V otherwise you will damage the ESP. It may not happen straight away, but it will happen.
3. If you wire Arduino Tx <-> ESP Tx and Arduino RX <-> ESP Rx you must remove the Arduino MCU chip completely before powering on, and use the Arduino IDE monitor to send commands to the ESP.
4. If you don't remove the MCU then you have to wire Arduino TX->RX and Arduino Rx<-TX.
5. If also you want to use the Arduino IDE in this mode (MCU installed) then you can't wire ESP TX/RX to D0/D1 and must use other pins instead (e.g. D2/D3) and SoftSerial to create another serial UART port.

  [1]: https://arduino.stackexchange.com/users/17192/aranganathan
  [2]: https://arduino.stackexchange.com/questions/18903/connecting-esp8266-with-arduino-uno-wifi-shield-not-present/20502#20502


body: For the esp you must use an external 3.3v power source (300 mA or more), and a logic level converter for the esp Rx (arduino Tx is in 5v logic).


message:
16 by 8 Keyboard matrix

I am working on a project, trying to construct an 80 button keypad. My problem is how to multiplex it so that i only feed the arduino with two sets of BCD or binary(whichever is easier) which are supposed to drive a 75 led display board simultaneously with a pair of 7 segments. The led display board is remote, which means i should drive the boards serially. The other 5 buttons remaining out of 80 are for other functions such as clear last number etc.
Please help!

---

Thank you very much guys. To answer FuaZe, it is 16*8 but will not use the whole 128 buttons. These extra buttons are for future expansion. The input should consist 16colums and 8 rows. The remote output board is a led matrix numbered from 1 to 75, arranged in a 15colums and 5rows. The same display board is to have a two digit 7seg display. The remote board is to be accessed serially so as to use few cables.
When I press a button on the matrix, say column 5 row 2 the number 20 should appear on the 7seg plus a correspondind diode on column 5 row 2 to light. In short if is a bingo board with numbers 1 to 75..

body:
Easiest would be to use 2 arduino's, which are connected in some way.
One of them should tell the other one what to do. I suggest you make the one reading the buttons the "master" and the other one it's "slave" device.

You could use 8 inputs, for each column and 10 outputs for each row.
Then you check all 8 inputs per column (pretty rapidly) and then you'll be able to read every button.

You could choose to either send changes or just every value to the slave device.

The slave device would have to do something similiar, but with 2 outputs, to address the right LED's/segments.

Alternatively you could use shift-registers.

There actually are a lot of tutorials on this to be found on the web.
You should check out "Arduino multiplexing" or "Arduino led cube" tutorials.


body:
Another option would be using both shift registers and port expanders, like Adafruit's [MCP23017 I2C Port Expander][1].

You can use that for the buttons, just get a few of them and hook them up on the I2C bus and you have over eighty pins for the price of 2! If you choose to use the previously stated expander, you will also benefit from Adafruit's library.

Then, use a shift register for your LEDs, using one of the pins that is not I2C.

Note: Pin expanders can handle input and output. Shift registers are only for output!

Good luck!

  [1]: https://www.adafruit.com/products/732


message:
Ethernet shield reset problems

I know there are multiple threads about ethernet shields not starting properly after power up and that there are versions that don't have those problems. But which versions are okay? Which versions do not require extra soldering/pin bending/physical resets?

How good are chinese rip-offs of those versions?

body:
If you don't want to make any modifications to the shield, and you don't want to make any modifications in code, then there really is only one option:

* Don't use cheap knockoffs, but buy a genuine Arduino one.

If you have a board that requires modifications to work properly and if you're unwilling to make those required modifications then you can not just magic it into working by waving your magic wand.


body:
I have worked with Ethernet Shields and modules. Most of them has reset issue. So I just put a 100nF Capacitor between the reset pin and ground pin. This solution works for most of the time.

This issue is there because the IC on board the shield does not have the power on reset option.

You can also tie the reset pin of your module with the reset pin of the Arduino.


message:
How to drive a 4bit GLCD?

i've got a huge (about 6 x 23 cm) graphics LCD. I used my multimeter and the datasheet the LCD driver chips (6 x KS0104 and 2 x KS0103) to get the pinout. It has the following pins: GND, M, FCS (not 100% shure), CL1, CL2, D0-3, VDD and a ground for the metal part.

My problem is that i dont know how i can drive a 4bit GLCD with an Arduino because i didnt found a library which can do this (e.g. OpenGLCD supports only the KS0104 which is an 8 bit controller)

body:
@MikaelPatel answered your question in the comments:

> That gives a total of 54K pixels. And with 4-bit per pixel, two pixels
> in a byte, 27K byte to store a packed off-screen bitmap. Even an
> Arduino Mega would have too little memory for that. This might explain
> why there are no supporting library for that device.


message:
serialEvents within a class

My .ino looks roughly like this

    #include "command.h"

    Command command;
    void setup() {
    }

    void loop() {
    }

command.h

    class Command
    {
        public:
            Command();
    };

command.cpp

    #include <Arduino.h>
    #include "command.h"

    Command::Command() {
      Serial.begin(9600);
    }

    void serialEvent() {
      while (Serial.available() > 0) {
        char inChar = (char)Serial.read();
        Serial.print(inChar);
      }
    }

The serial events don't seem to be happening. It works normally if I move the code out of the class.

body:
When you put the `Serial.begin` in the constructor and declare the `Command` object at file scope, the `Serial.begin` will occur *before* `setup()`.  Not recommended, perhaps not allowed.

If you do that, the compiler has to figure out that the `Serial` instance must be constructed before the `Command` instance is constructed.  It can't always figure out the correct order.

In general, this is why you see many classes with a `begin` or `init` method.  This allows the construction of file-scope instances to take place in any order, before `setup`.  Then `setup` does the `Command.begin()`, which finally calls `Serial.begin`, long after `Serial` has been constructed.

Also, using `SerialEvent` is no better than doing the polling in `loop()`.  If you're busy doing something else, `SerialEvent` does not get called.  If you need to handle characters in the background, in the RX interrupt, you might want to take a look at a modified version for the `Serial` object(s) I posted, [NeoHWSerial](https://github.com/SlashDevin/NeoHWSerial).  You can attach a routine to be called whenever a character is received.


body:
@slash-dev "...Also, using SerialEvent is no better than doing the polling in loop()." Are you sure about that? SerialEvent (and especially the ones on Teensy3) use hardware interrupts which can be handled in the midst of other operations; even delay() does not block interrupts (http://playground.arduino.cc/Code/AvoidDelay). It's hard to imagine multiple serial streams running at 100 kbaud or better (test reported in PJRC forum) and handling each character in the main loop even if that was all your program did. And why would you want to? There are good reasons interrupts exist.
**Update**: I'm not allowed to "comment" without 50 reputation. Thanks for the commit link... I can't imagine why HardwareSerial would not use interrupts... that is the default on all other platforms we've used for years.


message:
Does WiFiClient work on a Yún to send data over a certain IP and port to be received by a Python socket?

I haven't been able to get the example code from the page [WiFi:Client:connect()](https://www.arduino.cc/en/Reference/WiFiClientConnect) to work on my Arduino Yún. Is this not how I'm supposed to send data over WiFi to be read by something like a socket?

If not, how would I go about doing so? (This is the only solution I've found from the internet).

body: No, that code is only for the WiFi shield.  For the Yun you need to look at the [Bridge](https://www.arduino.cc/en/Reference/YunBridgeLibrary) library that is bundled with the IDE. It allows you to run commands and perform actions on the Linux based Atheros portion of the Yun which is what has access to the WiFi.


message:
Bootloader only works once with usb to serial module

When programming the Pro Mini using this USB-to-serial adapter the boot loader only works once. After the first programming the programmer is out of sync or not responding.

To be able to program the Pro Mini again I have to burn the bootloader using my Uno as an ISP.

Programming the Pro Mini through an Uno does not present the same problem.

Are the lock bits not being set properly or somehow overridden?

[![Usb to serial module][1]][1]

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

body: The module I had does not have a DTR signal. I mistook the RTS for DTR. Ordering correct module.


message:
How to read temperature from multiple DS18B20 faster?

I am writing an Arduino sketch to read temp data from multiple DS18B20 sensors and then write it to serial. The problem is, as I am connecting more sensors, the delay between my temp data is written to a serial increases (like 100ms for 1 sensor and 1s for 4 sensors). Can I somehow improve my sketch to read it faster?

Here is the sketch I am using:
(I am using DallasTemperature to simplify it all)

    #include <OneWire.h>
    #include <DallasTemperature.h>

    #define ONE_WIRE_BUS 10
    #define TEMPERATURE_PRECISION 8
    #define BAUD_RATE 9600

    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    OneWire oneWire(ONE_WIRE_BUS);

    // Pass our oneWire reference to Dallas Temperature.
    DallasTemperature sensors(&oneWire);

    // arrays to hold device addresses
    DeviceAddress devices[10];
    int devicesFound = 0;

    void setup(void)
    {
      // start serial port
      Serial.begin(BAUD_RATE);
      //Serial.println("Dallas Temperature IC Control Library Demo");

      // Start up the library
      sensors.begin();

      // locate devices on the bus
      Serial.print("Locating devices...");
      Serial.print("Found ");
      Serial.print(sensors.getDeviceCount(), DEC);
      Serial.println(" devices.");

      devicesFound = sensors.getDeviceCount();

      // report parasite power requirements
      Serial.print("Parasite power is: ");
      if (sensors.isParasitePowerMode()) Serial.println("ON");
      else Serial.println("OFF");

      for (int i = 0; i < devicesFound; i++)
        if (!sensors.getAddress(devices[i], i))
          Serial.println("Unable to find address for Device" + i);

      // show the addresses we found on the bus
      for (int i = 0; i < devicesFound; i++)
      {
        Serial.print("Device " + (String)i + " Address: ");
        printAddress(devices[i]);
        Serial.println();
      }

      for (int i = 0; i < devicesFound; i++)
        sensors.setResolution(devices[i], TEMPERATURE_PRECISION);
    }

    // function to print a device address
    void printAddress(DeviceAddress deviceAddress)
    {
      for (uint8_t i = 0; i < 8; i++)
      {
        // zero pad the address if necessary
        if (deviceAddress[i] < 16) Serial.print("0");
        Serial.print(deviceAddress[i], HEX);
      }
    }

    // function to print the temperature for a device
    String printTemperature(DeviceAddress deviceAddress)
    {
      float tempC = sensors.getTempC(deviceAddress);
      if (tempC < 10)
        return "0" + (String)tempC;
      else
        return (String)tempC;
    }

    // function to print a device's resolution
    void printResolution(DeviceAddress deviceAddress)
    {
      Serial.print("Resolution: ");
      Serial.print(sensors.getResolution(deviceAddress));
      Serial.println();
    }

    // main function to print information about a device
    void printData(DeviceAddress deviceAddress)
    {
      Serial.print("Device Address: ");
      printAddress(deviceAddress);
      Serial.print(" ");
      printTemperature(deviceAddress);
      Serial.println();
    }

    void loop(void)
    {
      if (devicesFound == 0)
      {
         Serial.println("No devices found.");
         return;
      }

      sensors.requestTemperatures();

      String sent = "";

      // print the device information
      for (int i = 0; i < devicesFound; i++)
      {
        sent += printTemperature(devices[i]);
        if (i != devicesFound - 1)
          sent += " ";
      }

      Serial.println(sent);
    }

body:
I would start by changing this section:

    String sent = "";

    // print the device information
    for (int i = 0; i < devicesFound; i++)
    {
      sent += printTemperature(devices[i]);
      if (i != devicesFound - 1)
      sent += " ";
    }

    Serial.println(sent);

This section should read and print the temperature directly instead of creating a string. The string handling is a large overhead and it does not allow Serial (UART) to work very much in parallel if the buffer is filled. The printTemperature() function is using a lot of strings (and heap operations).

Otherwise you have done what is possible; 1) reduce the conversion resolution (9-bits is minimum), 2) use single conversion request command to all sensors.

The alternative is to use alarm triggers and only read sensors with alarms.


body:
With 12 bits precision, DS18B20 may take up to 750 ms converting a temp.

Try using async reading, so you don't have to wait for the end of the process.

First you ask for a reading, later your read it

        DallasTemperature sensors(&oneWire);
        ...
        sensors.setWaitForConversion(false);  // makes it async
        sensors.requestTemperatures();
        sensors.setWaitForConversion(true);
        ...
        // Do something else while temp is been reading by the sensor
       ...
       float temp = sensors.getTempCByIndex(0);


message:
RGB Led - mixing colors using analogWrite

Currently I'm controlling an RGB LED with my Arduino Nano.

I'm mixing the colors using analogWrite

Though, the LED's don't light up at all for low analogwrite values and the difference between the levels is not visible (to me).

I'm using 100 Ohms resistors between the LED's, using a 680Ohms didn't seem to make a difference.

Analogwrite is working by toggling the LED's fast (PWM)? So not by lowering voltage? This is why I think it's weird that they don't light up at all, on low write values.

My sketch below:

    #include <SoftwareSerial.h>

    int r, g, b = 0;
    String command = "";
    const byte rxPin = 11;
    const byte txPin = 10;

    SoftwareSerial blueTooth (rxPin, txPin);

    void handleCommand() {
      r = rgbFromCommand("r=",";");
      g = rgbFromCommand("g=",";");
      b = rgbFromCommand("b=",";");

      if(r != -1){
        analogWrite(A2,r);
      }
      if(g != -1){
        analogWrite(A1,g);
      }
      if(b != -1){
        analogWrite(A0,b);
      }
    }

    int rgbFromCommand(String prefix, String postfix) {
      int idx = command.indexOf(prefix);
      int endIdx = command.indexOf(postfix,idx);
      if(idx>=0 && endIdx>=0){
        idx+=2;
        return command.substring(idx,endIdx).toInt();
      }
      return -1;
    }

    void setup() {
      pinMode(rxPin,INPUT);
      pinMode(txPin,OUTPUT);
      Serial.begin(9600);
      blueTooth.begin(9600);
    }

    void loop() {
      if (Serial.available() > 0) {
        // read the incoming byte:
        char incomingByte = Serial.read();

        if(incomingByte == '\n'){
          handleCommand();
          command = "";
        }else{
          command += incomingByte;
        }
      }
      if(blueTooth.available() > 0){
            // read the incoming byte:
        char incomingByte = blueTooth.read();

        if(incomingByte == '\n'){
          handleCommand();
          command = "";
        }else{
          command += incomingByte;
        }
      }
    }

body:
Analog pins aren't PWM pins. Instead you have to use the pins marked with a `~`

Pins that aren't PWM pins will be off with a value of 0-127 and on with a value between 128 and 255.


message:
Working with Seed BLE Shield and Adafruit Feather BLE

Long story short: I need to pair these devices:

 - Arduino UNO with Seeed BLE Shield
 - Adafruit Feather 32u4 Bluefruit LE.

The Seeed shield is configured and able to connect and communicate via the UART to an Android phone by HM BLE Terminal app from Google Play Store.

I can also connect the phone and Feather. The two independent connections work really well but a problem occurs when connecting the Seeed shield with Feather. <strike>Connection isn't troubling</strike> No errors are reported but I can't send/receive any data via the serial monitor (I'm using [bleuart_cmdmode][1] or [bleuart_datamode][2] from the Adafruit examples).

Basically my question is how to make them work: HM-11 module with BLE and the Adafruit board (nRF51822 chipset from Nordic).

  [1]: https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/tree/master/examples/bleuart_cmdmode
  [2]: https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/tree/master/examples/bleuart_datamode

body:
Although the nRF51822 supports Central (master) mode, the Adafruit Feather's firmware only support's Peripheral (slave) mode.

> The Bluefruit LE firmware from Adafruit is currently peripheral only,
> and doesn't run in Central mode, which would cause the module to
> behave similar to your mobile phone or BLE enabled laptop.
>
> At some point we might consider a new firmware image offering this,
> but since 98% of the uses cases for BLE involved running as a
> peripheral we've concentrated all of our development effort there for
> now.
>
> https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/faq#faq-2

The HM-11 on your Seeed shield **is** capable of Central (master) mode though. This means your Uno will play the part that your Android phone was playing when you connected the Feather to the terminal app.

To set your HM-11 to Central mode, run the following AT command.

    AT+ROLE1

[Example code for the HM-11](http://wiki.seeedstudio.com/wiki/Bluetooth_V4.0_HM-11_BLE_Module)

---

Alternatively, you could burn the S120 Soft Device and your own custom firmware onto the Feather's nRF51822. You can find all the docs, tools, and Soft Device images [on Nordic's website](https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF51822).


message:
Clearing SRAM in loop()

Very broad question here.  I don't know exactly what the problem is but I'll edit this post as we narrow down the possibilities.

I think I'm running into memory constraints.

I'm running a sketch that records two temperature values every 60 seconds and transmits them to an AWS RDB via wifi.  It works well for about two hours then stops.  I don't know if it's a memory constraint but I suspect that it is.  What other common problems (often overlooked by newbies) can cause a sketch to end after a couple hours of run-time?

Is there a simple way to add an instruction to a loop to clear the SRAM?

Arduino UNO + WiFi 101

Edit #1 12/24/2015:
It's the WiFi board.  It happily remains connected to my phone's hotspot but only lasts an hour or two on my home network.  Working on root cause...any ideas are welcome!

Edit #2 12/25/2015:
Tried to Wifi.disconnect() and reconnect with no luck.  Why do some networks kick the board off while others work just fine?  Will look into the watchdog.

body: Could you provide your sketch? At the rate you mentioned, 2 hours is merely 240 values and this shouldn't even matter since you are probably reassigning values to the same variables and not storing them in some growing array. Perhaps your WIFI shield merely gets disconnected from the network. How do you mean the sketch stops? Like you no longer receive the values in the database? More info is needed.


body:
The problem was solved with a "soft restart" loop. Posts #10 and #11 are all I needed:
[http://forum.arduino.cc/index.php?topic=49581.0][1]

  [1]: http://forum.arduino.cc/index.php?topic=49581.0


message:
Small, Power-Efficient wireless communication with ATTiny85

For a project that I'm working on I need an extremely small, power efficient wireless device (could be radio, or some other interface) to network between a series of ATTiny85s and a larger Arduino. The communication range only needs to be about 1 foot, max. I'm currently using wired I2C, so it would be excellent if someone could suggest a radio or another device that can use the two digital pins previously occupied by the SCK and SDA lines on the ATTiny. I have those two, along with one extra digital pin available for use.

This device needs to be extremely small - [this common NRF24L01][1] package is too big and its SPI interface uses too many pins.

Thanks for your help.

  [1]: http://www.miniinthebox.com/upgraded-2-4ghz-nrf24l01-wireless-transceiver-module-for-arduino-black_p683437.html

body:
An RF kit like [this one][1]. It's a 2-part kit, Tx and Rx separately -- each needing Vcc, GND and one pin. You need both on each ATTiny to be able to transmit and receive.

  [1]: http://www.elecfreaks.com/estore/315mhz-rf-link-kit.html


body:
I've also had good results with using the [Mchr3k - Arduino Manchester Encoding][1] library with those 315mhz RF kits. It has support for ATTiny85 as well.

  [1]: https://mchr3k.github.io/arduino-libs-manchester/


message:
Arduino Micro project with Bluetooth low energy

I created my project prototype with Arduino Micro and Adafruit Bluetooth low energy device.

Now I need to develop the prototype to production (like a small USB device). I just need Rx, Tx, 3V pin from Arduino Micro.

I started design with ATmega32U4, USB and BLE by using Fritzing IDE. I am confused with Arduino Micro parts like reset, bootloader and other pins. Is there any problem if I leave the unwanted pins from Arduino unconnected, for my project? Will it work correctly like a Arduino micro?

This is my first PCB design. Please help me to design a final PCB with the unwanted pins left unconnected.

body:
I have started to look at the Arduino Uno schematics, which are free on the website. To make an Arduino is very simple, just need the chip, crystal, a few capacitors and that's it.

Try to copy the same schematics then add the Bluetooth to the RX and TX pins, but be careful about the 3.3V as you don't want to fry your Bluetooth module :)


message:
Arduino hangs after less than a minute, but not on USB

I have arduino uno + ethernet shield + 9V/200mA adapter. I am trying to send some data with HTTP connection. When it's connected to USB it works perfectly, but when I plugged out USB, hangs (after less than a minute, it stops pinging).

I have tried [this][1]:

    EthernetClient.cpp

    int EthernetClient::connect(IPAddress ip, uint16_t port) {
      if (_sock != MAX_SOCK_NUM)
        return 0; // i changed to -1  as suggested on previous link

      for (int i = 0; i < MAX_SOCK_NUM; i++) {
        uint8_t s = socketStatus(i);
        if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT || s == SnSR::CLOSE_WAIT) {
          _sock = i;
          break;
        }
      }

and also example from library `Examples-library-WebClientRepeating`, but I get the same problem as in my code.
Is my adapter too weak?

This code is from Example WebClientRepeating:

    #include <SPI.h>
    #include <Ethernet.h>

    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED    };

    // fill in your Domain Name Server address here:
    IPAddress ip(193, 77, 60, 66);
    IPAddress subnet(255, 255, 255, 0);
    IPAddress gateway(193, 77, 60, 7);
    IPAddress myDns(193, 77, 60, 213);

    EthernetClient client;

    char server[] = "www.arduino.cc";
    //IPAddress server(64,131,82,241);

    unsigned long lastConnectionTime = 0; // last time you connected to the server, in millisecond
    const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
    // the "L" is needed to use long type numbers

    void setup() {
      // start serial port:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }

      // give the ethernet module time to boot up:
      delay(1000);
      // start the Ethernet connection using a fixed IP address and DNS server:
      Ethernet.begin(mac, ip, myDns, gateway, subnet);

      // print the Ethernet board/shield's IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
    }

    void loop() {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
      }

      // if ten seconds have passed since your last connection, then connect again and send data:
      if (millis() - lastConnectionTime > postingInterval) {
        httpRequest();
      }
    }

    // this method makes a HTTP connection to the server:
    void httpRequest() {
      // close any connection before send a new request.
      // This will free the socket on the WiFi shield
      client.stop();

      // if there's a successful connection:
      if (client.connect(server, 80)) {
        Serial.println("connecting...");
        // send the HTTP PUT request:
        client.println("GET /latest.txt HTTP/1.1");
        client.println("Host: www.arduino.cc");
        client.println("User-Agent: arduino-ethernet");
        client.println("Connection: close");
        client.println();

        // note the time that the connection was made:
        lastConnectionTime = millis();
      }
      else {
        // if you couldn't make a connection:
        Serial.println("connection failed");
      }
    }

**EDIT 1:**
Also when I plug USB in its start working with 9V power adapter.

  [1]: http://forum.freetronics.com/viewtopic.php?t=176

body:
The problem is that when you are using the external 9V power supply, you are relying on the Arduino's on-board regulator to provide the 5V power supply to both the Arduino and the Ethernet shield. This regulator has very limited current capacity — much less than the 500 mA that's available from a PC's USB port — and you're overloading it.

To avoid this problem, you should use a 5V plug pack with a USB connector to power your system.


body:
It may be that, for some reason, the library thinks Serial communication is working, but when the buffer of unsent characters gets full, it hangs waiting to complete a Serial.print() or Serial.println().

So, try commenting out all use of Serial.

For example change

      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }

to

      /*
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }
      */

and `Serial.println(...);` to `// Serial.println(...);`

This might happen if the system is started with USB working, and then USB is unplugged.


message:
Combine bits from two ports into a single byte

I'm attempting to read the values of 8 pins at a time into a byte.

The obvious answer to this seems to be the Port registers, however with the way the Arduino is wired, I'd have to split my read across two registers.

In this case, I need a way to combine the lower 5 bits of PORTB with the upper 3 bits of PORTD into a single byte.

For example, this is the physical layout with the data lines I'm attempt to read/write to and their corresponding port assignments.

                 SCSI
    DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
    |   |   |   |   |   |   |   |
    PB4 PB3 PB2 PB1 PB0 PD7 PD6 PD5
                AVR

From what I can gather I need to use some shift operators to achieve this,
perhaps something like:

    hi = PORTB & 3;
    lo = PORTD >> 3;

But I'm unsure if that's correct and then how I would combine them.

Is it possible to write a macro to make getting and setting this byte easier?

Is there a good learning resource on bit manipulation like this?

body:
Assuming PORTB and PORTD are correctly giving unsigned char values:

    result = (PORTB << 3) | (PORTD>>5)

would do it.

As a macro:

    #define SCSIBITS ((PORTB << 3) | (PORTD>>5))

Then use like this:

    result = SCSIBITS

To make it clearer which specific bits are being used, write:

    #define SCSIBITS (((PORTB & B00011111) << 3) | ((PORTD & B11100000) >> 5)))

It should be easier to see that the lower 5 bits of PORTB, and the upper 3 bits of PORTD are being used.

In the general case, where the values being manipulated are not unsigned char (should not be a problem in this specific case, but may be helpful to know), you might write:

    #define SCSIBITS ((unsigned char)((PORTB & B00011111) << 3) | ((PORTD & B11100000) >> 5)))

or:

    #define SCSIBITS ((((unsigned char)PORTB & B00011111) << 3) | (((unsigned char)PORTD & B11100000) >> 5)))

Here are a few links to bit-manipulation tutorials:
https://www.hackerearth.com/notes/bit-manipulation/
http://www.cprogramming.com/tutorial/bitwise_operators.html
http://www.tutorialspoint.com/ansi_c/c_bits_manipulation.htm


message:
Compare const char * to const char

Using ArduinoJson I have assigned a value such as;

    const char* id = root["id"];

in the original JSON id was "1"

    if (strcmp(id, "1") == 0) {
        // this executes
    }

I have an array of structs that I wish to compare the id against. The struct looks like;

    typedef struct  {
       char id[2];
       ....
    } Device;

I assign an id (1-9) into the struct id by

    _cmd.id[0] = '0' + (++DevicesPtr);
    _cmd.id[1] = '\0';
    Devices[DevicesPtr-1] = _cmd;

where _cmd is of type Device. Devices is an array with up to 8 entries
Now I try to find a match in the devices using the JSON id

    for (byte i = 0; i < DevicesPtr; i++) {
        if (strcmp(Devices[i].id, id) == 0) {
           // This code does not execute
        }
    }

I can't seem to get a match I have also tried (Devices[i].id == id)

body:
Try something like this:

    typedef struct  {
      char id[2];
      ....
    } Device;

    const int DEVICES_MAX = 8;
    Device Devices[DEVICES_MAX];

    for (int i = 0; i < DEVICES_MAX; i++) {
      Devices[i].id[0] = '1' + i;
      Devices[i].id[1] = 0;
      ...
    }

    for (int i = 0; i < DEVICES_MAX; i++) {
      if (!strcmp(Devices[i].id, id)) {
      ...
    }

Cheers!


body:
You can't compare a char and a string.. How can you compare apples and bananas?

Now, you have two ways to do your job.

1) do as @Mikael Patel suggests, so convert your `id`s into strings. This is fine because it will allow you to deal with multiple chars ids.

2) a more efficient way to do this (note that this works with just SINGLE CHARS IDS) is the following one:

    if (strlen(id) == 1) {
        for (byte i = 0; i < DevicesPtr; i++) {
            if (Devices[i].id == id[0]) {
               // This code will execute if ids match
            }
        }
    }

Note that id should be exactly 1 char long, otherwise the whole comparison as you thought is meaningless

With this solution you don't need multibyte id char in the struct definition, so you can just define

    typedef struct  {
       char id;
       ....
    } Device;

and, in the code,

    _cmd.id = '0' + (++DevicesPtr);
    Devices[DevicesPtr-1] = _cmd;


message:
Arduino Nano gives 7V on the 5V PIN!

I have an Arduino Nano which is Powered by an external Power supply. This is connected with VIN and GND. The voltmeter says, there are `12,12 V`

I have some components connected on the 5V PIN, which altogether draw max. `100mA`
Since some of the components are not working anymore, I started measuring...

I have disconnected everything, but the Arduino Nano Power supply. (`12,12V`)

When I now measure GND and the 5V PIN, the Voltmeter says **6,97V!** I guess this is why my components are giving up.

 - But why are there `6,97 Volts` all of the sudden?
 - Is my Arduino broken now?
 - Can I fix this?
 - How can this happen?

body: Of course the 5V regulator on the nano can be faulty. Another possibility is the 5V decoupling capacitor. If it goes open circuit the regulator will oscillate and the mean output voltage will be near half the input voltage. Most regs have a minimum decoupling cap value specified.


message:
FFT (or similar) library for the Arduino

I'd like to build a "low fidelity" spectrum analyzer to run on an Adafruit Trinket Pro. My primary goal is to intrigue my seven year-old niece with something that can be hacked. The plan is to pick up sound from a violin with a mic and use a set of 5 or 6 NeoPixels to represent octaves and use color for amplitude.

My first pass at this used [Amanda Ghassaei's frequency detection code][1]. It kind of worked, but seemed to be having problems with complex waveforms. After doing some more reading and looking at simple spectrum analyzers it seems that I'd do better using something like a FFT to collect the frequency information. It also seems that that might be stretching the capability of an Arduino…

Are there any FFT libraries that run well on the Arduino (over a range of about 200 to 4000 Hz)? Or are there other approaches that might work better?

[1]: http://www.instructables.com/id/Arduino-Frequency-Detection

body:
I havent used any of the libraries to make the FFT for my personal project, due to complexity. Instead I bought a spectrum chip, which returns 7 frequencies: MSGEQ7  ( 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and
16kHz ).

Otherwise if you are very keen on using a library, [this one][1] is very famous and fast for Arduino processors.

But again, if you dont need to have a precise band and the MSGEQ7 is good enough to detect what you want, go for it.

  [1]: http://wiki.openmusiclabs.com/wiki/ArduinoFFT


message:
How to make an SMS notification to my phone with Arduino Uno?

I am planning to make an SMS notification to my phone with Arduino Uno via a push of a button.

I have an Arduino Uno C520A Embedded System. Is it possible to do so with this model ? If yes, which WIFI module should I get ?

I just want to make an API request to the web through the push of a button.

body:
It is possible if your provider has a sms gateway e-mail-address. Just google which it is for your provider (e.g. number@tmomail.net for T-Mobile (US)). And there should be a lot of tutorial about how to send an email with an arduino.

Every wifi-module with arduino support will work if your WiFi is a standart 3.6Ghz. And yes it should work with any arduino compatible microcontroller.


body:
Arduino uno is only the processor, you will need a Ethernet shield or Wifi shield to connect to the internet.
I would suggest Ethernet as it is less pain to configure and no drop of connection.

Then you will need to buy a sms gateway, [this one][1] looks pretty cool as they have good http api.

By using the Arduino Ethernet sample, you will need to send a http request to the server when the button has been pressed.

  [1]: http://www.smsglobal.com/http-api/


message:
Creating a library for attiny85 out of working program

Apologies if this is the wrong sub-forum, the involvement of ATTiny and arduino places this into a strange category. Please correct me if I should post elsewhere.

It is important for this to be a library as small kids will be using this program and hardware for their own projects. Its kind of a rip on the LOLshield but it involves a lot more steps to integrate more lessons all at once.

My whole program takes 8 bytes of information and converts it to data for a shift register driving two multiplexers all driving an 8x8 LED matrix. It can also use multiple of these packets to make a slide show. I have it in a working state right now and would like to turn it into a library for easy use. I am a bit lost in this step as I had to create an interrupt timer and this makes it more complicated than the tutorial on the arduino website covers.

Also if someone could point me to a library for ATTiny85 that makes calling a timer interrupt easy then the rest of this project will likewise become easier.

Any help would be great! I will be continuing to look on online resources and will update should I figure it out.

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

> I had to create an interrupt timer ...

Be warned that there are things you should not do in interrupts, like delays, serial printing, etc.

---

## Code

In the interests of answering the question though, this works:

    // ATMEL ATTINY 25/45/85 / ARDUINO
    // Pin 1 is /RESET
    //
    //                  +-\/-+
    // Ain0 (D 5) PB5  1|    |8  Vcc
    // Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1
    // Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
    //            GND  4|    |5  PB0 (D 0) pwm0
    //                  +----+

    ISR (TIMER1_COMPA_vect)
      {
      digitalWrite (4, ! digitalRead (4));  //toggle D4 (pin 3 on chip)
      }

    void setup()
     {
      pinMode (4, OUTPUT);  // chip pin 3

      // Timer 1
      TCCR1 = bit (CTC1);   // Clear Timer/Counter on Compare Match
      TCCR1 |= bit (CS10) | bit (CS13);  // prescaler of 256
      OCR1C = 123;          // what to count to (zero-relative)
      TIMSK = bit (OCIE1A); // interrupt on compare

      }  // end of setup

    void loop()
      {
      // other code here
      }

---

You can tweak the time delay by changing both the prescaler and the counter in OCR1C. The prescaler gives you coarse tuning, which gets you into the ballpark of the delay time. The timer then counts up to give you the final delay.

---

## Prescaler values

From the datasheet:

[![ATtiny85 timer 1 prescalers][1]][1]

In my case I chose a prescaler of 256 which is or'ing together CS10 and CS13.

The delay is then:

    125 ns * 256 * 124 = 3.968 ms

Where 256 is the prescaler and 124 is what we are counting to. This is assuming an 8 MHz clock which gives a clock period of 125 ns.

---

## Flashing more slowly

If you put an LED on pin 3 and want to **see** the flashing, you need it much slower. For example:

    TCCR1 |= bit (CS10) | bit (CS11) | bit (CS12) | bit (CS13);  // prescaler: 16384

That toggles the pin every 254 ms, which is visible.

---

## Warning

On this chip Timer 1 is an 8-bit timer, so you cannot put more than 255 into OCR1C.

---

## More information

* [Timers](http://www.gammon.com.au/timers)
* [Interrupts](http://www.gammon.com.au/interrupts)

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


message:
How to send a pitch bend MIDI message using arcore?

I'm new to MIDI and started playing with an Arduino Leonardo and [arcore][1].
Based on the example code, I can easily send `noteOn/noteOff/controlChange` messages, but I can't seem to send a pitch bend message.

Having a look at [this table][2]:

    0xE0 Chan 1 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE1 Chan 2 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE2 Chan 3 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE3 Chan 4 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE4 Chan 5 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE5 Chan 6 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE6 Chan 7 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE7 Chan 8 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE8 Chan 9 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xE9 Chan 10 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xEA Chan 11 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xEB Chan 12 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xEC Chan 13 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xED Chan 14 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xEE Chan 15 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
        0xEF Chan 16 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)

I've tried to send a message like so:

    MIDIEvent pitchwheel = {0xe0, 127,127};
    MIDIUSB.write(pitchwheel);

but this didn't work and I'm not sure what I'm missing/doing wrong.

Any hints/tips will be helpful.

  [1]: https://github.com/rkistner/arcore
  [2]: http://www.onicos.com/staff/iz/formats/midi-event.html

body:
arcore creator Ralf Kistner provided the [answer][1]:

    // The pitch bend value is a 14-bit number (0-16383). 0x2000 (8192) is the default / middle value.

    // First byte is the event type (0x0E = pitch bend change).
    // Second byte is the event type, combined with the channel.
    // Third byte is the 7 least significant bits of the value.
    // Fourth byte is the 7 most significant bits of the value.
    void pitchBendChange(byte channel, int value) {
      byte lowValue = value & 0x7F;
      byte highValue = value >> 7;
      MIDIEvent event = {0x0E, 0xE0 | channel, lowValue, highValue};
      MIDIUSB.write(event);
    }

  [1]: https://github.com/rkistner/arcore/issues/19


message:
3.95 MCU Friend Arduino TFT LCD flickering

I got the 3.95" LCD from aliexpress which uses IL9488. I used the [MCUFRIEND_kbv][1] library. I am using an Arduino Mega as I need other GPIO to be used for other purposes. I can't use the Uno because of this limitation.

I have other modules like the DS3231, and ESP8266 connected to the Mega and this 3.95" LCD connected as well. ESP8266 is powered separately using a 12-5V converted supply. The Mega is powered using another source. The normal graphics test is working in the LCD. I am able to make it work with the Nano, Uno and Mega. Even for the Mega I am able to write customized messages.

What I intend to do is to update the time in the LCD which is received from the DS3231. It updates the LCD but I see a flickering issue here.

Every update (LCD display function is from the loop which sets the text when there is a second/time/hour difference in the time) seems like it draining more current as the one of the LED connected to Mega dims, the Rx/Tx LEDs also dim.

I am able to get the LCD refreshed but it shows a flickering. I powered the LCD 3.3V and 5V using another separate source but still the small flickering continues.

Moreover all these time I was connected to the Mega through the USB from the laptop. Once I unplug the USB, LCD starts and shows some update and again become white. This continues and an not able to see anything on LCD there after.

I am not sure why only when the Mega is connected to USB this LCD works and that too flickering but once the USB is removed the LCD is not working at all.

Can someone please do help me in this ?

  [1]: https://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865

body:
I think something is wrong with this LCD board. This is because in my case the display works sometimes perfectly with the ILI9481 driver but sometimes something hangs and the display starts to flicker. It looks like a chip charging problem. Anyway I solved the flickering problem by tuning the ILI9488 registers. Simply you have to change the `initlcd.h` for ILI9481 driver in UTFT library.

    enter code here

    case ILI9481:

    LCD_Write_COM(0x11);
    delay(70);

    LCD_Write_COM(0x38);//Idle Mode OFF
    LCD_Write_COM(0x13);//Normal mode

    LCD_Write_COM(0x36); // Memory Access Control  crucial
    LCD_Write_DATA(0x0A);

    LCD_Write_COM(0x55);
    LCD_Write_DATA(0x22);//High enhancment of CE ratio

    LCD_Write_COM(0xB1);
    LCD_Write_DATA(0x70);
    LCD_Write_DATA(0x10);

    LCD_Write_COM(0xB4);
    LCD_Write_DATA(0x10);

    LCD_Write_COM(0xB5);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x12);

    LCD_Write_COM(0xB6);  // Display Function Control
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x21);  // 0x42 = Rotate display 180 deg.
    LCD_Write_DATA(0x3B);

    LCD_Write_COM(0xC0);
    LCD_Write_DATA(0x1F);//0X1F
    LCD_Write_DATA(0x01);//0X10

    LCD_Write_COM(0xC1);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x10);

    LCD_Write_COM(0xC2);
    LCD_Write_DATA(0x00);//0X44 lower better
    LCD_Write_COM(0xC4);
    LCD_Write_DATA(0x00);//0X10

    LCD_Write_COM(0xC5);
    LCD_Write_DATA(0x00);//0X10
    LCD_Write_DATA(0x80);//optimum
    LCD_Write_DATA(0x80);//0X10

    LCD_Write_COM(0x3A);//Interface Pixel Format
    LCD_Write_DATA(0x55);

    LCD_Write_COM(0x2A);//Column Address Set
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x01);
    LCD_Write_DATA(0xDF);//320

    LCD_Write_COM(0x2B);//Page Address Set
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x01);
    LCD_Write_DATA(0x3F);//480

    delay(60);

    LCD_Write_COM(0x29);//Display ON
    delay(30);

    LCD_Write_COM(0x2C);//Memory Write
    delay(30);
    break;


message:
ERROR: Timed out waiting for Arduino 101 - anything I can do?

I just received an Arduino 101 so I did the following in a wave of excitement...

 1. Connected the USB cable between it and my Macbook Pro
 2. Started the Arduino IDE version `1.6.7`
 3. Wrote a little bit of code
 4. Selected `Tools | Boards | Boards Manager...` and installed the `Intel Curie Boards` as per [Getting Started][1]
 5. Selected `Tools | Board: "Arduino 101"`
 6. Selected `Tools | port: "/dev/cu.usbmodemFA141 (Arduino 101)"`
 7. Selected `Sketch | Upload`

I was expecting something amazing, but I got the error:

    Starting upload script
    Payload: /var/folders/jr/5rmqcrqj58103d4p1f6_3sjr0000gn/T/build7c6ce067b9e8a57f9917c651ec494989.tmp/orientation.ino.bin
    Waiting for device...
    ERROR: Timed out waiting for Arduino 101.

Is there anything I can do to debug this or did I miss a step perhaps?

(I tried the good ol' turn it off and on again, including shutting the IDE down).

  [1]: https://www.arduino.cc/en/Guide/Arduino101

body:
If the path to your source file contains a space, it might be causing this error. For more information, and a workaround, see [this topic][1] in the Arduino forum.

  [1]: http://forum.arduino.cc/index.php?topic=368654.0


body:
Press the reset button next to the USB port. (either one, the master reset is between the DC jack and USB ).

This will cause the Arduino 101 to reboot and enter DFU mode for 5 seconds if it is connected on USB. The download will proceed when the Curie enters DFU.

The IDE uses a baud-rate signal over USB. It is a virtual serial port, so baud rate doesn't matter. But when the host side (Arduino IDE) switches the baud rate to 1200, the board will reboot and enter DFU mode for download. If it gets stuck for some reason and misses the message to reboot, you can just hit the reset button and accomplish the same thing.


body:
I was having the same problem: unable to upload a program to a brand new 101.  Now it works.

I can successfully load both BLE LED example programs and also the ReadTime program read via Serial Monitor.  (BTW, using the iOS MCP app, you need to send either 00 or 01 to turn the LED on/off.)

I am running a modern 64 bit laptop with USB 3.0 ports.  All ports work fine with either of two USB cables that I have.  So I don't believe the problem is related to USB cables or USB 2.0/3.0.

How did I fix it?  Well, I tried several things and I'm not sure which one fixed it, so perhaps someone can try these methodically and confirm the best fix.

1. Uninstall the Arduino IDE and manually deleted the Arduino15 folder in user\..\AppsData.

2. Restart laptop.

3. Download and install IDE 1.6.8.  (Earlier failed attempt was with current 1.6.9.)

4. Restart laptop.

5. Open IDE.  In Boards Manager, searched Intel, selected Curie boards, and install v1.0.4.  (Earlier failed attempt was with current 1.0.5.)

6. Restart laptop.

7. Open IDE.  Plug in 101 for the first time.  Device showed up normally in Device Manager.

8. Select proper port (COM5 for me) and proper board (101).  Select example file LED under CurieBle.  Click verify.  Looks good.  Click upload.  SUCCESS!  Can now see the 101 in nRF MCP, can turn LED on/off.  BLE functions now work with 5V USB charger. (but not 9V battery, guess that's not an option) When connected to laptop USB 3.0 port, the 101 now stays in COM5 the entire time, no longer cycling on/off when I try to upload.  No need to press either reset button during upload.

So the fix is either one of the software downgrades, or careful installation procedure.

Previously, I tried the dfu-utils updates but that didn't fix this problem.


body:
It's already documented in the arduino.cc, but I will just add here as reference:

> Linux only: some distributions need to be configured to perform the
> upload. After installing the core, execute
>
>     sudo ~/.arduino15/packages/Intel/tools/arduino101load/1.6.4+1.18/scripts/create_dfu_udev_rule
>
>
> inside a shell to gain upload permissions.

Reference: [Upload Procedure][1]

  [1]: https://www.arduino.cc/en/Guide/Arduino101#toc13


body:
I am running Ubuntu 18.04 and I had a similar problem but solved it in the end.

What worked for me was:

1. Update Arduino Curie driver in Boards manager to the latest version which is v 2.02 at the time of this post

2. Run the following command in terminal in order to grant execution rights:

        chmod +x ~/.arduino15/packages/Intel/hardware/arc32/2.0.2/scripts/create_dfu_udev_rule

3. Run the executable

        sudo ~/.arduino15/packages/Intel/hardware/arc32/2.0.2/scripts/create_dfu_udev_rule

4. Restart Arduino and try to reupload

### Edit for Debian testing
At the time of this edit, all the previous steps work for the Bookworm distribution, with the latest Arduino IDE version (1.8.19) and the latest Arduino Curie driver version (2.0.5). Just remind to adapt the previous path according to the driver version.


body:
I posted a fix here:

https://forum.arduino.cc/index.php?action=profile;area=showposts;u=1472279

I was really looking forward that this will be the fix for all Arduino 101 Error


body:
I was really persistent to look for ways on how to fix the Arduino/Genuino 101 Timeout Error, I searched different forums and read a lot of suggestions on how to fix the error, but still all failed, I know some of the 101 users already bricked their 101 or other just left it behind.
We are all aware that the Arduino 101 is already discontinued and even support is already stopped, Hence this little but powerful microcontroller is still out there and probably used by the some. Anyhow, to be straight to the point I finally I discovered the fix for the error.
Notice that when you insert your 101 to the USB plug it will read and install the device, checking it in the device manager will show the Arduino/Genuino 101 in "Other Devices" and a new COMPort (COMX) is added, then you install the Arduino IDE (regardless of the version), then install the Arduino 101 Board thru "Board Manager", the manager will install the Arduino 101 but it will not notify you that the driver for Arduino 101 is not installed due to error. So in short we are assuming that the driver for Arduino 101 is successfully installed. This is where the error lies. The software driver "dpinst-amd64" is not digitally signed and Windows is blocking to install unsigned drivers.
So what's the fix?
The fix here is still to install the "dpinst-amd64" since it is the driver needed to recognize your 101, the trick here is you need to install it in other way, not in your regular PC operation. You need to access the "disable signature enforcement" under the startup options (not safe mode). This startup mode will enable you to install unsigned drivers (I trust this Intel Curie driver since it was downloaded with the board). After installation restart your PC to its regular startup and plug-in again your Arduino/Genuino 101, this time the PC will now recognize the microcontroller and you can now upload sketches without the time out error.

For a step by step procedure:
1. Access Update and Security>Recovery>Advanced Startup
2. Your computer will eventually restart and will bring you to the Advanced Startup, access Troubleshoot>Startup Settings. Your PC will restart again and options for the startup will display, choose number 7 "disable signature enforcement"
3. Your PC will start. Locate "dpinst-amd64.exe" in C:>Users>YOUR USERNAME>AppData>Local>Arduino15>packages>Intel>hardware>arc32>2.0.4(latest version)>drivers>dpinst-amd64
4. During installation a message will prompt if you want to install the unsigned driver, just click install.
5. After installation restart your PC and your Arduino/Genuino 101 is good to go.
6. To confirm that your Arduino/Genuino 101 is installed go to Device Manager and you will see that the Arduino/Genuino 101 is not anymore in the Other Devices.

I hope this will help. :D I will try to make a video about this fix. :D
Thanks!

Regards,

Raf


message:
How to program AVR in Mac OS X?

In our college we are using a module developed by IIT Bombay (called FIREBIRD V[ver 5]). It has ATmega2560 and ATmega8 microcontrollers (master and slave) with bootloader.

The staff uses AVR Studio for programming. But since AVR Studio is supported only on Windows (and I have a Mac), I was looking for AVR programming in Mac. I downloaded Crosspack AVR. But I don't know how to proceed after this point. Also I downloaded TextWrangler (because I was told auto-suggestion is not available in TextEdit).

Also I have downloaded the Arduino IDE, and I don't know what is required or how to configure it to program AVR microcontrollers.

I searched on the web and nothing is clear (mostly they all depend on something to do with terminal and the command line).

I don't have Xcode installed in my Mac (I saw a relatively easy tutorial on how to set up Xcode for this purpose) and the file is 4GB. I am trying to work around using Xcode, but if it's the only nice way do let me know!

Pertinent suggestions would be helpful.

body:
If you don't want to use the Terminal and the command line, the Arduino IDE is your best option. Get yourself an AVR programmer (or an Arduino Uno to serve as programmer, with the ArduinoISP sketch uploaded), and code on it.

[![ArduinoISP sketch to upload to the Arduino serving as AVR programmer][1]][1]

Then connect your Arduino to your module via SPI. Select the correct processor and port.

[![Select Processor and Port][2]][2]

You can now upload the sketch:

[![Upload sketch via Arduino][3]][3]

  [1]: https://i.stack.imgur.com/L1uCn.png
  [2]: https://i.stack.imgur.com/JXf9N.png
  [3]: https://i.stack.imgur.com/iuvbk.png


body:
First, install and get familiar with version 1.6.x of the Arduino IDE. Then, under the sketchbook directory, within `hardware/nex/avr/` (create the directories if they don't exist) create the following files:

###boards.txt:

    # NEX Robotics Fire Bird V
    # Only ATmega2560@14.7456MHz supported for now

    nexfirebirdv2560m14.name=Fire Bird V ATMEGA2560 @ 14.7456 MHz
    nexfirebirdv2560m14.upload.tool=avrdude
    nexfirebirdv2560m14.upload.protocol=avr109
    nexfirebirdv2560m14.upload.maximum_size=129024
    nexfirebirdv2560m14.upload.maximum_data_size=8192
    nexfirebirdv2560m14.upload.speed=115200
    nexfirebirdv2560m14.bootloader.low_fuses=0xFF
    nexfirebirdv2560m14.bootloader.high_fuses=0xDA
    nexfirebirdv2560m14.bootloader.extended_fuses=0xFD
    nexfirebirdv2560m14.build.mcu=atmega2560
    nexfirebirdv2560m14.build.f_cpu=14745600L
    nexfirebirdv2560m14.build.core=arduino:arduino
    # This is not the real variant, but it will get the board running
    nexfirebirdv2560m14.build.variant=arduino:mega

###platform.txt:

    name=NEX Robotics Fire Bird V
    version=0.0.0

I have verified that an empty sketch will build, but do not have the hardware to test uploading. The `upload.protocol` value may need to be changed to `avr910` or `arduino` if the current value doesn't work. Make sure to restart the IDE after any changes to the configuration files.

Further improvements that can be done include:

- A real variant for the specific board
- Support for the on-board ATmega8 (for now just use one of the slave firmwares uploaded with avrdude)
- Support for the other AVR boards
- Support for the 8051 and ARM boards


message:
How do I get the Itead 3G shield to work?

I've tried a pretty standard code but the Serial Monitor yields zero response.

Using a standard Arduino Uno (tried a second one as well, just to be sure) and am now trying the second shield with this code:

    #include <SoftwareSerial.h>

    SoftwareSerial mySerial(2, 3); // RX, TX

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

    }

    void loop() // run over and over
    {
      if (mySerial.available())
        Serial.write(mySerial.read());
      if (Serial.available())
        mySerial.write(Serial.read());
    }

There is nothing coming back whatsoever in the serial monitor (yep, I checked the baud rate and tried several others).

Any ideas?

What should I be seeing if anything?

body:
> What should I be seeing if anything?

Usually, a GSM module will not send (unsollicited) messages. Everything it sends will be an response to an received message.

Try sending `AT` (with a new line/carriage return (depending on the GSM module)) to the GSM module, it will send something like `AT OK` or just `OK`

And you didn't set the pin directions (output/input), might be doen by the serial libraries, but beter be safe if you're not sure.

Also check your wiring (jumpers on UART multiplexer in this case?) and share it with us, Rx/Tx wiring often gets messed up :)
If your GSM module has a USB connection, you might even test it with a terminal (taking out the Arduino in the middle, thus any wiring/code between.)

I also suggest you change the name of the serial connection to the GSM to something like `gsmSerial` rather than mySerial (which could be anything).

Be sure the 3G shield has enough power (amperes), otherwise they might reset when attempting to make an connection.
(Put the external supply in the Arduino, rather than USB powered)


body:
I have one, and I haven't figured out how to get it to accept input, but have received responses.  Here are some things to try:

 - Make sure you have your jumpers set for D2 and D3.  Just telling software serial to look at 2 and 3 doesn't mean your board is jumpered that way.
    - Also, remember that Tx for the board = Rx on the arduino and in your code.  Software serial is (rx, tx), so (2,3) means your board will be jumpered with tx on 2 and rx on 3.

 - There are four LEDs on the board.  If all four aren't lit, the board is powered down, and won't do anything.
   - First, make sure your power switch is set right - "VCC Switch", by
   the USB connector, is set to the power level of your board.  I'm
   using an Uno at 5V, so for me that's set to 5V.
    - It's best to provide power through your barrel connector on your Arduino *and* connection through the USB.  GSM modules *are* power hogs.
    - With all of that plugged in, your board should show two lights, the first and third.
    - Now hit the "PWR" button.  The second light will come on dimly, then stronger.  Now the module has power.
    - Finally, the fourth light will come on when the module has detected network. At that point, the 5216 will start sending you messages.
 - You need to make sure your baudrate is set properly.  Anything less than a Mega can't handle communication at 115200, which is the default for the module.  At best, you'll set both Serial and SoftwareSerial for 115200 baud, and you'll get mostly correct characters from the board, but an occasional bad character.
 - Here are some great instructions for changing the default baudrate at [Github from some JeanBritz][1]
    - One caveat to those instructions: make sure you have your Itead board powered by the Uno *before* plugging into the mini USB.

Here's a bit of light at the end of the tunnel for you - [![what you'll see when it's sending properly.][2]][2]

  [1]: https://github.com/jeanbritz/ArduinoTestScripts
  [2]: https://i.stack.imgur.com/utotF.png


message:
Arduino Servo Free Rotation

I have a project where I use 22 servos. I attach all 22 of the servos in the setup and in the loop, I use `myservo.write()` command to make a particular servo move to a particular position.

The problem here is that, all the other servos become stiff at this point of time, even though I am not writing any value to those servos. By stiff I mean that the servo is holding at a particular random value. Which for most of the 22 servos is at or near 90°.

My question is how can I make a particular servo move, while allowing all the other servos to freely rotate. I think that when I attach a servo the program prevents the free rotation of the servo.

I was wondering if the signal to one of the servos is leaking to other servos because of an issue with wiring, but this is not the case. The other servos become stiff only when I attach them to the pins which have been "attached" as a servo in the program.

body:
When you `attach` a servo the Arduino starts generating the PWM waveform for its currently selected angle. When you `write` to the servo you just change the current angle and the waveform changes to match. That waveform is constantly being generated from the moment the servo is attached, and will always be generated.  That is how servos work.  They are not really designed to be back-driven by the load turning the cogs - it is the role of the servo to do the driving, not to be driven.

Depending on the servo you might actually damage the mechanics by driving it backwards like that.

The only way you can stop the servo from being actively driven is to detach the pin from the servo system so that it doesn't think there is a servo there any more.


message:
Basic C++ programming, how to pass constructor argument into class?

I'm having some programming problems.

So here's what's happening:

In my .ino file, I have a `tft` variable which holds the connection to a LCD. I want to make a class which can either automatically access that `tft` class contained in the .ino, or pass it into the constructor when it's created; so basically:

    // assuming this is the .ino:

    TFT_ILI9163C tft = TFT_ILI9163C(cs, dc, rst);

    MenuClass *menu = MenuClass();
    menu->init("Example", tft); // this should work and "menu" should now have access to the "tft" variable

Here's my Menu.cpp:

    // Menu class

    #include "Menu.h"
    #include <SPI.h>
    #include <Adafruit_GFX.h>
    #include <TFT_ILI9163C.h>

    String menName = "Unnamed";

    void MenuClass::init(const String name)
    {
     menName = name;
    }

    String MenuClass::getName() {
     return menName;
    }

    void MenuClass::draw() {
     tft.setCursor(2, 2);
     tft.print(menName);
    }

    MenuClass Menu;

body:
Assuming you want to require every instance of MenuClass should be associated with a TFT_ILI9163C display object, you could use something like this:

    // MenuClass.h

    class TFT_ILI9163C; // declare a class name which is defined in TFT_ILI9163C.h

    class MenuClass
    {
      private:
        // read-only private member initialized by constructor
        // (the m_ prefix is commonly used to denote class member values)
        TFT_ILI9163C* m_tft;

      public:
        // constructor
        MenuClass(TFT_ILI9163C* pTft) : m_tft(pTft) {};

      private:
        // private storage for the Name property
        String m_Name;
      public:
        // read the Name property
        String getName() {
          return m_Name;
        };
      public:
        // write the Name property
        void setName(String value) {
          m_Name = value;
        };

      public:
        void draw() {
          // the m_tft member is a reference to the display class
          m_tft->setCursor(2, 2);
          m_tft->print(m_Name);
        };
    }
    MenuClass Menu;

Note that there is only one constructor, and it requires a pointer to the TFT_ILI9163C display. The body of the constructor ` : m_tft(pTft) {};` initializes the private member `m_tft` with the constructor argument `pTft`, so  MenuClass member functions invoke TFT functions as `m_tft->fn(args);`  Since there is no "void constructor" `MenuClass(void)`, `m_tft` is effectively guaranteed to point to a valid TFT_ILI9163C instance.

Since it looks like you were using `menName` kind of like a class property, I rewrote that in the more commonly used m_propertyname style. Your `MenuClass::init()` was behaving like a name property setter; I'm not sure whether menu initialization requires anything else. This simple example has class MenuClass defined entirely inside the header file.

Usage is pretty similar to your example code, except now the MenuClass constructor requires a pointer to a previously constructed TFT_ILI9163C display instance:

    // Main application
    #include <TFT_ILI9163C.h>
    #include "MenuClass.h"
    // ... etc ...

    // the TFT_ILI9163C display instance
    TFT_ILI9163C tft = TFT_ILI9163C(cs, dc, rst);

    // an example menu that draws on the display
    MenuClass *menuFoo = new MenuClass(&tft); // use new to get pointer to new class instance
    // MenuClass *menuFoo = MenuClass(&tft); // cannot convert 'MenuClass' to 'MenuClass*' in initialization

    void setup() {
      // an example menu that draws on the display
      menuFoo->setName("Example");
      menuFoo->draw();
    }

If you wanted to pass the constructor an initial Name property value as well as the tft display pointer, you could define the constructor as

      public:
        // constructor
        MenuClass(TFT_ILI9163C* pTft, String name) : m_tft(pTft), m_Name(name) {};

You could even go a step further, and give the name argument a default value:

      public:
        // constructor
        MenuClass(TFT_ILI9163C* pTft, String name = "Unnamed") : m_tft(pTft), m_Name(name) {};

So with this modification, the expression `MenuClass(&myTFT)` is the same as the expression `MenuClass(&myTFT, "Unnamed")`, but you can still override the default value like `MenuClass(&myTFT, "DoSomething")`.

It is also perfectly legal to put statements inside the `{ }` block of the constructor, but in this example all of the work is accomplished by the `:memberName(value)` constructor syntax.

Edit: `MenuClass *menuFoo = new MenuClass(&tft);` thanks @BrettAM


message:
Can I use my phone's charger to connect arduino M0 pro R3 with computer?

I found out that the arduino M0 pro R3 needs either micro HDMI or micro USB.

Since I don't have any micro USB or HDMI adapters, can I use the Samsung galaxy USB/micro adapter to connect?

body:
Echoing what Gerben said, in order to wrap up this question:

* If the Samsung cable has a micro-usb on one end, and a usb-a on the other side, then I don't see why not.

* You just want to power it, not connect it to a PC? A regular USB port only supplies upto 500mA, so 1.5A is plenty.

* The allowed input voltage range for this pin is 6-20 V. source. So your 12v adapter is also fine.