message:
What's the smallest Arduino board with wifi capabilities?

The Photon from [Spark IO looks][1] super small. Are there smaller wifi enabled microcontrollers available that can be programmed with the Arduino IDE?

  [1]: https://www.spark.io/

body:
From your question it implies that *the Spark IO use the Arduino IDE - **it's not**.* It has two different IDE's, one is web based and the other is [downloadable][1]. In addition, it's not an Arduino per-se. It is based on the Wiring library, which is similar to the Arduino library but not exactly the same. And of course the MCU is not Atmel, but that is also the case with Intel's Galileo board.

As to the size question in hand - my believe is that the Arduino products are designed for prototyping, so the size of the product is less important. This is the case for several reasons:

* **Costs** -  the different Arduino products are pretty expensive for mass production.
* **Peripherals** - the Arduino boards come with different peripherals (such as the FTDI chip) which will probably be omitted in an end-user product, and which makes its size larger.
* **Pins** - almost every (official?) Arduino product comes with pre-built male/female header pins, which are excellent for prototyping but not for production, because of the large vertical space they take.

There are many more reasons, but you get the point.

When moving to production with an Internet of Things product, it makes sense to fabricate your own PCB, and design it with a small Atmel chip you used for prototyping (such as ATtiny85) and small Wifi chip, such as the [ESP8266][2]. [This is an example][3] for such fabricated PCB, although the size is not the 'smallest' possible.

However, for beginners, or a one-time project, it would absolutely make sense to use a pre-fabricated Arduino product, in a small scale that could provide both easy coding capabilities, various libraries and a WiFi included. For that purpose, the Spark IO seems to be at the bleeding edge at the moment - but you never know what will be there tomorrow...

  [1]: https://www.spark.io/dev
  [2]: http://www.mikrocontroller.net/attachment/231858/0A-ESP8266_Specifications_v4.pdf
  [3]: http://www.esp8266.com/viewtopic.php?f=8&t=390


sender: user

message:
Can the Sparkfun AVR pocket programmer bootload/program a 3.3 V ATmega328p

The product in question - https://www.sparkfun.com/products/9825 - operating at 5 V (and can also supply it to the device being programmed).

I need to program the bootloader onto a 3.3 V ATmega328p and don't have any level shifters immediately available. Thus the question. The "Hookup Guide" for the product (https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide) seems to suggest that it will work fine as long as the 3.3 V device being programmed isn't powered by the programmer. I wouldn't have thought it's the best idea in the world, but maybe I'm wrong.

So any practical experience?

Are the over voltage tolerances for input lines on Atmel devices good enough to handle the extra voltage?

I guess the output level from the device being programmed would be high enough to be buffered up to 5.0 V?

sender: assistant

body:
ATmega328p Operating Voltage is 1.8v-5.5v, as stated in the second page of the [datasheet (PDF)][1]:

![enter image description here][2]

So there should be no problem feeding it with a regulated 5v VCC while programming it, and then supplying it with 3.3v on normal use. Just make sure you do not leave any 3.3v devices (which are not 5v tolerant) connected to the ATmega328p during the programming of the chip.

Regarding the Sparkfun's Pro Mini 328 3.3v/8Mhz, you can read in the comments section of the Pro Mini page that customers successfully managed to power it with 5v without any issue. You can see [from the schematics][3] that the voltage regulator in use ([MIC5205][4]) has a max input voltage of 20v, so 5v should not pose a problem to power it up.

**EDIT**: [See Ignacio's answer][5]. My answer apply for **powering up** the Pro Mini **not for programming it with 5v signals and 3.3v VCC**. The **SJ1** jumper will need to be removed in order for the MIC5205 regulator to supply 5v instead of 3.3v.

  [1]: http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
  [2]: https://i.stack.imgur.com/dOffE.png
  [3]: https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf
  [4]: http://www.micrel.com/_PDF/mic5205.pdf
  [5]: https://arduino.stackexchange.com/a/6765/630


body:
With that combination of programmer and Arduino you have two possible options:

- Cut JP1 on the programmer and power the programmer from the Arduino. With this you will have to make sure that the Arduino is connected and powered up before you connect the programmer to USB.

- Cut SJ1 on the Arduino and allow it to be powered by the programmer at 5V. The Arduino itself isn't *required* to be powered at 3.3V, that's simply what the on-board regulator provides, so we cut SJ1 in order to isolate the regulator from the MCU. Note that any devices connected to the Arduino will need to support 5V operation in order to this to be safe.

It is not safe to put 5V at the output of the regulator, so you must make sure that does not happen.


body:
The Pocket AVR Programmer has a logic level shifting (74ACT125) on board, specifically for this situation. There is nothing wrong with powering the target with a separate power supply that the programmer. Why else would there be a "power target"/"No power" switch?

I don't see why other people would suggest cutting traces, when all you need to do is toggle a switch.


message:
Help with parts identification from arduino starter kit from aliexpress

Ordered an arduino starter kit from aliexpress [Link][1]

The parts list they provide (as a jpg on the order page) is vague and not very descriptive, I've gone through most of the parts and am down to three they did not list.

1. Capacitor? -- Looks to be a capacitor, labeled HDX and nothing else, rattles when I shake it.
![Unknown part #1 - HDX capacitor?][2]
2. Black LED -- I think this is a flame sensor; if it is, what's the difference between this and an infrared receiver (like a 1838B) or photoresistor?
![Unknown part #2 - flame sensor LED?][3]
3. They also list something as 'a digital control' near the bottom of the list, not sure what that is? Every other part from the list is matched up and I don't see anything different in the first picture (not parts list picture) from what I have received in the order.

  [1]: http://www.aliexpress.com/item/UNO-KIT-Upgraded-version-of-the-For-Starter-Kit-the-RFID-learn-Suite-Stepper-Motor-ULN2003/1042001423.html
  [2]: https://i.stack.imgur.com/4oTnn.jpg
  [3]: https://i.stack.imgur.com/OA9f2.jpg

body:
1. Those are tilt sensors. The rattling is a metal ball that contacts two pins inside, closing the connection.

2. The 1838B is a full module that partially decodes the received IR so that a MCU can fully decode the rest easily. What you have there is a bare phototransistor with an IR window on the top. You would use it for proximity or presence sensing. Instead of varying its resistance, it varies the amount of current it will pass.

3. Probably the single-digit 7-segment display, as opposed to the 4-digit display they have listed as "4 digital tube".


body:
I recently purchased the arduinotech module learning Kit and contains both components shown above. It does  mention an Infrared Photo Diode which it think is your "Black LED".

Thanks for the heads up on the HDX switches. Now I know what they are.:)


body: The HDX is a "Tilt Switch" Turns on/off depending on the angle.


message:
EFCom GPRS/GSM Shield

I have an EFCom GPRS/GSM Shield
http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield
and I am using it with a mega 2560. The problem is that the code in the wiki page

    //Serial Relay - Arduino will patch a
    //serial link between the computer and the GPRS Shield
    //at 19200 bps 8-N-1
    //Computer is connected to Hardware UART
    //GPRS Shield is connected to the Software UART

    #include <SoftwareSerial.h>
    SoftwareSerial mySerial(2, 3);
    void setup() {
      mySerial.begin(19200);               // the GPRS baud rate
      Serial.begin(19200);                 // the GPRS baud rate
    }

    void loop() {
      if (mySerial.available())
        Serial.write(mySerial.read());
      if (Serial.available())
        mySerial.write(Serial.read());
    }

makes use of software serial but mega 2560 cannot use software serial on pin 2, as in the arduino reference, thus I changed the pins to 50 and 51 and used external female-male headers to connect s_tx to pin 50 "rx" , and s_rx to pin 51 "tx", still no response with the AT command...

code after update is :

    #include <SoftwareSerial.h>
    SoftwareSerial mySerial(50, 51);
    void setup() {
      mySerial.begin(19200);               // the GPRS baud rate
      Serial.begin(19200);                 // the GPRS baud rate
    }

    void loop() {
      if (mySerial.available())
        Serial.write(mySerial.read());
      if (Serial.available())
        mySerial.write(Serial.read());
    }

Note that I am using the Arduino IDE serial monitor.

body:
Try to connect "Pin RX on Mega to Pin RX on Shield" an "Pin TX on Mega to Pin TX on Shield":

 - Pin 50 (Rx)  on Mega <==> Pin 2 GSM Rx on Shield
 - Pin 51 (Tx)  on Mega <==> Pin 3 GSM Tx on Shield

I use an Geeetech Shield with a Mega 2560 and connect RX to Rx and TX to TX. Works fine.

Another solution is to use Serial1 instead of using SoftwareSerial ...

First connect:

 - Pin 19 (Rx1)  on Mega <==> Pin 2 GSM Rx on Shield
 - Pin 18 (Tx1)  on
   Mega <==> Pin 3 GSM Tx on Shield

    //Serial Relay
    unsigned char buffer[64];  // buffer array for data receive over serial port
    int count=0;               // counter for buffer array

    void setup()
    {
      Serial1.begin(19200);
      Serial.begin(19200);
    }

    void loop()
    {
      if (Serial1.available())
      {
        while(Serial1.available())
        {
          buffer[count++]=Serial1.read();
          if(count == 64)break;
        }
        Serial.write(buffer,count);
        clearBufferArray();
        count = 0;
      }
      if (Serial.available())
        Serial1.write(Serial.read());
    }

    void clearBufferArray()
    {
      for (int i=0; i<count;i++)
      {
        buffer[i]=NULL;
      }
    }

You can use a Arduino IDE's Serial Monitor, [Serial Terminals(sscom32)][1] or [Bray++ Terminal][2] to send AT commands to the Shield, communicate with it.

I hope this information is helpful.

  [1]: http://musicshield.googlecode.com/files/sscom32E.exe
  [2]: http://sites.google.com/site/terminalbpp/


message:
Use website to communicate with Arduino WirelessProtoShield

I have a small office with wireless network, is it possible to make a wireless doorbell?

Practical example:

Arduino is connected to the main wireless network and has a static ip,
i have a website that connects through arduino using ftp to activate the "open door" function.

note: "open door" activates a motor to press the button, or i will hack the current doorbell to connect wires :D

body: Arduino wifi web server: http://arduino.cc/en/Tutorial/WiFiWebServer just modify the webserver to show a "open" button and to receive a post request and open the door.


message:
DS1307 RTC conflicts with DS18B20

I'm working on a project to output the temperature from a DS18B20 to a 16x2 LCD while logging the temperature to a CSV file using the Adafruit Data Logging Shield. I keep getting this error when verifying the code:

    RTClib-master/RTClib.cpp.o: In function `RTC_DS1307::now()':
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to 'Wire'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to 'Wire'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to
    'TwoWire::beginTransmission(int)'RTClib-master/RTClib.cpp.o: In function 'TwoWire::write(int)':
    /Applications/Arduino.app/Contents/Resources/Java/libraries/Wire/Wire.h:72: undefined reference to 'TwoWire::write(unsigned char)'
    RTClib-master/RTClib.cpp.o: In function 'RTC_DS1307::now()':
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:254: undefined reference to 'TwoWire::endTransmission()'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:256: undefined reference to 'TwoWire::requestFrom(int, int)'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:257: undefined reference to 'TwoWire::read()'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:258: undefined reference to 'TwoWire::read()'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:259: undefined reference to 'TwoWire::read()'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:260: undefined reference to 'TwoWire::read()'
    /Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:261: undefined reference to 'TwoWire::read()' RTClib-master/RTClib.cpp.o:/Users/grafton/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:262: more undefined references to 'TwoWire::read()' follow

When I comment `RTC_DS1307 RTC;` in the code (below) these errors go away, but of course I get errors related to an undefined RTC. I'm a newbie cobbling together code from various sources, so any help is greatly appreciated. Code follows:

    #include <LiquidCrystal.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #define ONE_WIRE_BUS 2
    #include <SD.h>
    #include "RTClib.h"

    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire);
    const int chipSelect = 10;
    File tempLog;
    RTC_DS1307 RTC;

    LiquidCrystal lcd(6, 7, 8, 9, 11, 12);

    void setup() {
      Serial.begin(9600);
       while (!Serial) {
        ;
      lcd.begin(16, 2);
      //         ----------------
      lcd.print("Current temp (F)");
       sensors.begin();
       }

    Serial.print("Initializing SD card...");
      pinMode(SS, OUTPUT);

      if (!SD.begin(chipSelect)) {
        Serial.println("Initialization failed!");
        while (1);
      }
      Serial.println("Initialization done.");

    tempLog = SD.open("templog.txt", FILE_WRITE);
    if (! tempLog) {
      Serial.println("Error opening templog.txt");
      while(1);
    }
    char filename[] = "LOGGER00.CSV";
      for (uint8_t i = 0; i < 100; i++) {
        filename[6] = i/10 + '0';
        filename[7] = i + '0';
        if (! SD.exists(filename)) {
          // only open a new file if it doesn't exist
          tempLog = SD.open(filename, FILE_WRITE);
          break;  // leave the loop!
        }

      Serial.print("Writing to: ");
      Serial.println(filename);
      tempLog.println("Data Logging File");
      tempLog.println("Date,Temp(F)");
      }
    }

    void loop() {
      sensors.requestTemperatures();
      float temperature = sensors.getTempFByIndex(0);
      lcd.setCursor(6, 1);
      lcd.print(temperature);
      Serial.println(temperature);
      //-----------------------------------------------------------

    String dataString = "";

    //date time stuff-------------------------------------------

    DateTime now = RTC.now();
      // log time
    // tempLog.print(now.unixtime()); // seconds since 1/1/1970
    //  tempLog.print(", ");
      tempLog.print('"');
      tempLog.print(now.year(), DEC);
      tempLog.print("/");
      tempLog.print(now.month(), DEC);
      tempLog.print("/");
      tempLog.print(now.day(), DEC);
      tempLog.print(" ");
      tempLog.print(now.hour(), DEC);
      tempLog.print(":");
      tempLog.print(now.minute(), DEC);
      tempLog.print(":");
      tempLog.print(now.second(), DEC);
      tempLog.print('"');

      tempLog.print(",");
      tempLog.print(temperature);
      tempLog.print(",");
      delay(500);

    tempLog.println(dataString);
    tempLog.flush();

    }

body: The RTC library requires the `Wire` library. Just put `#include <Wire.h>` in front of the line `#include "RTClib.h"`


message:
Using an Arduino as an input device

I had an idea to create a control panel using an arduino and some buttons. How would I go about making the arduino emulate an input device so that when I press a button connected to the arduino, it would cause the same effect as when a keyboard key was pressed? (I'm using arduino UNO, if it helps.)

Thanks in advance.

body:
The easy answer is to use a Leonardo, Micro, or Due instead. They already support USB HID functionality via <a href="http://arduino.cc/en/Reference/MouseKeyboard">`Mouse` and `Keyboard`</a>.

If you insist on using an Uno **R3** then you will need to reprogram the on-board ATmega16U2 to accept serial commands from the ATmega328P and generate the appropriate USB HID events.

If you're using an Uno or clone that doesn't have an ATmega16U2 as well then you're SOL and will have to write a program that runs on the computer that receives the commands via serial and translates them into HID events.


body:
I have successfully reprogrammed the UNO's R3 8U2 to support keyboard emulation, as to just this. Making dedicated user inputs for kiosks to Computers. I recommend [NicoHood's GitHub](https://github.com/NicoHood/HID) as it allows simultaneous Arduino Bootloader and Keyboard functionality, making it easy to reprogram the Arduino.

This along with using [Capacitive Touch Sensor](https://www.sparkfun.com/products/9695) connected to Copper tap under clear acrylic protecting printed graphics of buttons is very quick and easy to make. Very little machining.

Example of such code is found at [artemis-firmwares](https://github.com/wreality/artemis-firmwares/tree/master/ConsoleFirmwares) it was initially created with a different 8U2 method. Where next time we will use NicoHood's.

Note the stock keyboard send key command for the Arduino is limited. Where the above methods allows the code to send complete virtual keys supporting full emulation.


message:
I2C LCD Serial Interface Board not displaying text (wrong pins?)

I have a 1602 LCD screen that works fine on its own. However I wanted to free some pins by using an I2C / IIC LCD controller I purchased separately.

While the controller seems to be communicating with my Arduino UNO on the right address, I cannot get text to display. By default (no code) it seems the LCD will have 1 line of 16 solid "squares". When using address 27 in my code, the LCD will change to 2 lines of 16 squares (see photo below). The code also calls for the backlight to flash 3 times, which works. However I cannot get anything but 2 lines of squares. (Full code is at the bottom of this question).

I'm using the [LiquidCrystal_I2C library][1] by F Malpartida, which seems to be commonly used.
Is there a better library I should be using?

I'm wondering whether it's just the wrong pins being used in the code. All sketches I see online use the following pins:

    //                    addr,en,rw,rs,d4,d5,d6,d7,bl,blpol
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
    // Set the LCD I2C address

But all of the 1602 LCDs I see online have the same pins as mine, as you can see in my photo below:

![I2C LCD Controller][2]

These pins seem to be standard:
![1602 LCD Pinout][3]

To further confuse me, the pins on the LCD board start with 1 on the left, yet the default code's pins seem to start with 0! So I tried changing the code's pins to the numbers on the LCD board. The LCD no longer changes to 2 lines of squares and no longer blinks the backlight. I then tried subtracting 1 from each pin (to start from 0), same result. I then tried used the default pins minus 1, same result. Thus the default pins are somehow more correct?! What am I doing wrong?

Has anyone else gotten one of these I2C controllers to work for them, and if so, how?

Full code:

    /* YourDuino.com Example Software Sketch
     16 character 2 line I2C Display
     Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
     terry@yourduino.com */

    /*-----( Import needed libraries )-----*/
    #include <Wire.h>  // Comes with Arduino IDE
    // Get the LCD I2C Library here:
    // https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
    #include <LiquidCrystal_I2C.h>

    /*-----( Declare objects )-----*/
    // set the LCD address to 0x27 for a 20 chars 2 line display
    // Set the pins on the I2C chip used for LCD connections:
    //                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

    void setup()   /*----( SETUP: RUNS ONCE )----*/
    {
      Serial.begin(9600);  // Used to type in characters
      lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

    // ------- Quick 3 blinks of backlight  -------------
      for(int i = 0; i< 3; i++) {
        lcd.backlight();
        delay(250);
        lcd.noBacklight();
        delay(250);
      }
      lcd.backlight(); // finish with backlight on

    //-------- Write characters on the display ------------------
    // NOTE: Cursor Position: (CHAR, LINE) start at 0
      lcd.setCursor(0,0); //Start at character 4 on line 0
      lcd.print("Hello, world!");
      delay(1000);
      lcd.setCursor(0,1);
      lcd.print("HI!YourDuino.com");
      delay(8000);

    // Wait and then tell user they can start the Serial Monitor and type in characters to
    // Display. (Set Serial Monitor option to "No Line Ending")
      lcd.clear();
      lcd.setCursor(0,0); //Start at character 0 on line 0
      lcd.print("Use Serial Mon");
      lcd.setCursor(0,1);
      lcd.print("Type to display");

    }/*--(end setup )---*/

    void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
    {
      {
        // when characters arrive over the serial port...
        if (Serial.available()) {
          // wait a bit for the entire message to arrive
          delay(100);
          // clear the screen
          lcd.clear();
          // read all the available characters
          while (Serial.available() > 0) {
            // display each character to the LCD
            lcd.write(Serial.read());
          }
        }
      }

    }/* --(end main loop )-- */

  [1]: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
  [2]: https://i.stack.imgur.com/TIBSe.jpg
  [3]: https://i.stack.imgur.com/z1JTTm.jpg

body:
First of all, it looks like these wires aren't properly connected:

> ![enter image description here][1]

I haven't disassembled a female jumper before, so that might not be the issue. However, it seems likely that this could be a cause.

Also, you **need** to adjust the contrast by turning that trimmer (the blue thing that looks kinda like it has a screw in it). LCDs will either display nothing, a washed out version of the text, or blue boxes if the contrast is not set correctly. This is probably the cause.

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


body:
I bought the SainSmart 20x04 and I also had to change the address to `0x3F`.  My backlight jumper was missing, that little header at the right of the I2C board provides the backlight power.  Some code I found included this:

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);


message:
Arduino board to control microwave oven?

So I've taken apart an old microwave oven with a touch-sensitive LCD screen. I understand that I could die from playing around with this, so I've disconnected the high-voltage transformer and the magnetron. I'm also not going to remove any of the safety switches like the door switch. My question is, how is the microwave controlled? I'm thinking there is a computer chip somewhere in the circuit, and I'm looking to replace it with an Arduino board plus some extras, like AC relays and such. I'm curious as to how the microwave oven controls its functions, like power level, cooking time, and the beeping. Any advise as to how I could get started interfacing?

Is the power level controlled by PWM by any chance? Can you PWM alternating current?

body:
It's pretty much all proprietary. It can be done, but you'd have to replace all the circuitry with the Arduino, interfacing with the existing magnetic and mechanical devices and doing everything in your own code.

Power level is controlled by PWM, but it's *extremely* low frequency PWM, on the order of 0.05Hz (20s period). That's why there are two different sounds that come from the microwave when it's not at full power; one when the magnetron is active, and one when it is off.


body:
There is no power level in a microwave. It's just on or off. They lower the power by turning on the magnetron for a few seconds, and then off for a few second. You can actually hear this.

It's probably turned on by a relay, triac, or solid state relay. The magnetron is just requires a high voltage to work; nothing else.

The programmes, timing, and handling of the buttons is done by some microcontroller, similar to an arduino.


body:
If you want to learn more about AC power circuits start with relays (start with 5v or 12v dc as a lot safer , cheaper and easier) something like the spark fun power tail if you really do want to control 120V devices note its only on/off control, not different power levels. https://www.sparkfun.com/products/10747

You can generate AC from DC by using pwm at a lower voltage and driving a transformer
or a digital inverter. Can use an arduino to do it if you wanted to.
Use pwm function, then via optocouplers (to protect the arduino) to power mosfets or an h-bridge to drive a transformer. Can fairly easily produce 120V/240V output

Time to grab a good basic electronics book like Art of Electronics (should be able to find a pdf version)
3rd edition is finally getting published in 2015


message:
Which arduino should I start on to learn about it?

I'm pretty interested in arduino and the things I can learn from it. Being that I'm new into this I wanted to know which model I should get that would be easiest to learn on and why. What does this model come with, how much, and reputable place where one can purchase this.

body:
I would simply say: buy a [startkit][1] like this one.At the end it is not important which Arduino board you'll start. They are (almost) the same*. At the very beginning you can start with [Uno][2] or [Nano][3] and even [Leonardo][4] could be very good. Those boards are very similar and you can program them in the same. Even the pins location and designation is not really different.
The most important thing about Arduino is to understand how to work and program and interface such a board with the sensors. In this sense I would choose a Uno board (or even 2009) which is less expensive and very easy to find overall. I don't really know how much experience you have, but it is likely, at the beginning, that you invert polarities of batteries, you drain too much power, or you invert some pins and damage the microcontroller. In that case doesn't make sense to buy the last powerful mega expensive board on the mark. If you get a Uno you can do almost everything and have for the next month a lot to learn.

To change from Uno or Nano to the other board it is not very difficult. Once you understand the basis you can switch to every board you want. If you need more power and memory you can buy a Mega. If you need much more power you can buy a Due/Tre/etc...you need just an *upgrade* not everything from scratch to learn.

If you are really new to Arduino the best way is to buy such a learn package as I showed you above. That have everything you need to understand basic of programming till to RC-Servo movement and motor drivers.

Happy new year.

*: stay away for the moment from the Arduino Due/Tre/Zero/Yuan/.. series. they are too expansive and require a lot of attention (3.3V, max drain current from the pins, pull up, pull down...etc..). Here is the risk to get your board damaged within few time very high. And you'll spend a lot of time thinking that the board has some problems.

  [1]: http://www.amazon.com/Starter-Kit-learn-kit-Arduino/dp/B00MO9L5WC
  [2]: http://arduino.cc/en/Main/ArduinoBoardUno
  [3]: http://arduino.cc/en/Main/ArduinoBoardNano
  [4]: http://arduino.cc/en/Main/ArduinoBoardLeonardo


message:
Speeding up Girino gives strange readouts

I was reproducing the Girino (the [Instructable][1] by Caffeinomane) bundled with the Girinoscope (the [Java GUI][2] by Chatanga). The results worked well and I went on to see if the oscilloscope can go up to higher kS/s.

In short, originally only upto prescaler 8 works. I removed PWM pin and it works upto 4 but prescaler 2 strangely behaves. Here are the details:

I did a preliminary test on prescaler 32 (~38.5kHz). Settings as follows and the same in other tests.

 - The signal (the same hereafter) is generated by a 555 timer astable multivibrator running at 4.5V (3 AA batteries).
 - The circuitry was simply omitted. I just tied 3.3V of Arduino NANO / ATmega328 to digital pin 6 as the trigger level.
 - There is no +2.5V offset done by the original Girino. (The scale should be 0~5V and the signal is 0~4V)
![Prescaler 32 works][4]

So then I wanted to try if it can speed up more. The code optimization quoted by Chatanga allowed prescaler 8 and 16 (76.9kHz and 151.8 kHz).

In order to push it the poor Arduino to the limits, I disabled PWM pin in the original Girino which sets the trigger level with duty cycles (PWM from pin ~3 being fed into pin 6). It's because I simply used a fixed 3.3V trigger level.

Prescaler 4 is unlocked.
![Prescaler 4 works with code optimization and disabled PWM][6]

Ambitious I go on to test prescaler 2. The GUI did not provide this option so I simply set it in the Arduino code.
![Prescaler 2 strangely behaves (all full scale deflection)][7]

I thought it did not work. I noticed if the prescaler is exceeding the Arduino's capability, TXRX simply does not blink. But this time the TXRX is just blinking! To verify this, I shifted the wait duration.
![Prescaler 2 strangely behaves (all full scale deflection)][8]

In previous screenshots, the leftmost green line is dashed (probably because it's below fullscale deflection). But in the last two, be it offset or not, the line is solid.

The debug output is like this: (8bits 0~255 given by ADC)

 - many 0 then suddenly 255 thereafter. (matches the GUI output)

I suspect it's due to slow TXRX? How to solve this? Or anything I overlooked?

Hope that this overdetailed question does not sicken you.

  [1]: http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/?ALLSTEPS
  [2]: https://github.com/Chatanga/Girinoscope
  [4]: https://i.stack.imgur.com/egXFy.png
  [5]: https://github.com/Chatanga/Girinoscope/blob/master/doc/girino_optimization.md
  [6]: https://i.stack.imgur.com/uRUCs.png
  [7]: https://i.stack.imgur.com/RDuTS.png
  [8]: https://i.stack.imgur.com/hHCqG.png

body:
From the ATmega328P datasheet, section 29.8, "ADC Characteristics":

> Clock Frequency — Min.: 50kHz, Max: 1000kHz

With a 16MHz system clock this means that a /16 prescaler is the most the ADC is considered reliable under for a reasonable 10 bit result (for a *full* 10 bit result the maximum frequency is 200kHz, which corresponds to a prescaler of /80).

As the frequency increases the sample-and-hold circuitry of the ADC gets less time to do the "sample" part before conversion begins. As such any correctness goes out the window, certainly at the lower bits. The fact that you got any sort of result that you did at /4 is luck.

**TL;DR:** The ADC is too slow.


message:
Error Compiling on raspberry Pi - no error details provided in IDE

I've just cracked out my Franzis Arduino Tutorial Kit (Best Xmas Present EVER!) and I'm already stuck on my second program.

I successfully wrote and executed a basic 'blink' program, however when I wrote out the second program provided in the manual I get an 'Error Compiling' when trying to check the syntax or run the program.

I tried the obvious of unplugging the board and plugging it back in but this didn't work. When I search for help most forum posts refer to the error message, however I have no message, just the orange warning bar stating 'Error Compiling'

This is the code;

    // Franzis Arduino
    // My second Arduino program

    int ledPin = 13; //LED is connected with digital pin 13

    // The setup routine configures the digital port
    // This routine is executed only once at program start!

    void setup()
    {
      Serial.begin(9600);
      pinMode(ledPin, OUTPUT);
      Serial.printIn("Our second Arduino program");
      Serial.printIn();
    }

    // The main program is an infinate loop
    void loop()
    {
      Serial.print("5 + 188 yields");
      Serial.print(5+188);
      while(true)
      {
        digitalWrite(ledPin, HIGH); // Turn on LED
        delay(2000);                 // Wait for a second
        digitalWrite(ledPin, LOW);   // Turn off LED
        delay(2000);                 // Wait for a second
        continue;
      }
    }

And here's a screenshot of the error message (or lack of);

![enter image description here][1]

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

body: It's not `printIn`, but `println` (as in "print line").


message:
How to convert this prototype to finished product?

My prototype contains below components:

- Arduino Uno R3
- Bluetooth LE nRF8001 Break-out (https://www.adafruit.com/products/1697)
- MicroSD Break-out (https://www.adafruit.com/products/254)
- ADXL335 triple-axis Accelerometer

I think It's OK on paper (and presumably on a breadboard too). I'm trying to wrap my head around on how to convert it to a finished product that sits inside a plastic box.

**What are my options?**

For instance, can I create a single PCB that contains all the components? If not, how can I connect these multiple break-out boards together? Is soldering some wires on both boards to connect them is a viable option?

**Edit:**

My ultimate goal is to create a product that is for sale. So I mean something that can be mass-produced and can meet regulatory requirements.

This is why I was thinking about a single PCB. Arduino (or should I say ATMegaXXX?) is fairly simple to place on a custom PCB. So I was thinking perhaps I could "re-create" my break-outs (see above) on this PCB thus creating a single piece including all components and the microcontroller. For some reason this makes sense to me but I don't know how hard it is or if it is even possible.

body:
By "product", do you mean for sale? Giveaways to friends? One for yourself? How many do you expect to make? It isn't (monetarily) worth creating a board for one or five pieces unless you want to for reasons of aesthetics, reliability, demonstrating your skills to a potential employer, etc. OTOH, if you sell a product, it will to meet regulatory requirements in the jurisdiction(s) in which you intend to sell it. So the - admittedly unsatisfying - answer is: it depends. :)  (In other words, we need more information).

Chinese board houses advertise they can do small runs for quite reasonable prices, but expect to spin the board several times unless it's a pretty simple one. Not dissing their abilities or skills as I have no experience with any of them, but as a practical matter of communicating exactly what you want, the first time, to a business half a planet away, a business you might not be familar with yet, and someone with whom you might not share a native language. Even with those obstacles out of the way, boards can take several- to many spins to get to a first production revision.

For a small handful of boards (depending the size of a "handful"), hand-wiring on hobby PCBs or strip-boards can be effective and not too expensive.


body:
[First, you should read this this question here.][1]

The reasonable answer here varies a lot depending on how involved you want to get, and what volumes you want to sell at.

Fortunately, you're not using any breakouts with truly exotic parts. The nRF8001 is just a QFN part, which can be soldered by hand without too much trouble.

Speaking loosely, the process would look like this:

1. Design a PCB layout that contains everything.
14. (Optional) - Figure out if you want to put it in a enclosure of some sort.
14. (Optional) - Determine how you're going to have the enclosures produced or modified from an existing product. You can have a contract machine-shop do the work, but again, $$$$.
2. Send out to have PCB prototypes manufactured. I like [OSHPark][2], but there are [LOTS of options][3].
3. Assemble your boards.
4. Find out your prototype doesn't work.
5. Go back to step 1 (expect this to happen a few times)
6. Rent/Beg/Borrow some equipment to do EMC pre-qualification testing (for FCC).
7. Realize you have an EMC disaster.
8. Respin boards a few more times (e.g. go back to 1 again) to fix the pre-qualification EMC issues.
9. Feel like you have a decent layout, have it FCC tested.
9. Pay $10K+ for FCC testing.
11. If you're lucky, you passed, you now have a proper, FCC certified product.
12. Nope, go back to 1 again if you failed.
13. Do lot assembly, either manually (major time investment), or contract out (expensive!).

14. Sell your widget!

Note that you can contract out the prototype assembly, but doing so is *expensive*, even if you do it in china. The magic (or cursed, really) term here is "NRE", or non-reoccurring expenses/engineering. Colloquially, it's the "setup cost" of doing a production run. Sure, you may only pay $5-50 per-widget to have them assembled, but there will be a $1000+ base charge. This reflects the fact that the primary time-cost on the part of an assembly house to build your widget is setting up the production line, working up and debugging a pick-and-place routine, building test-setups, etc... Once everything is up and running, the actual per-unit cost is fairly marginal.

This is also why commercial electronic devices can be so cheap. They're made in truly enormous volumes, and that lets the companies amortize the NREs across the entire production run. NREs are basically the bane of any small electronics business. They're also basically *the* reason specialty widgets are so expensive. Places like spark-fun can get away with fairly cheap products because they have their own complete assembly line in-house, and even there, you're often paying 4X+ the cost of parts for just the IC on a PCB with a few cents worth of passives.

Since you seem to be new to PCB design, this is possibly not a great first project. It's doable, but expect it to cost 4X+ what you expect, and take 2X+ the time you planned. There are a LOT of facets to designing a proper product, and they each contain an entire field.

It'd probably be better off to start out with some simpler boards, maybe a through-hole-only arduino clone, or similar (though SOIC can be soldered without a hot-air station or anything).

---

Some assumptions I'm making:

 - If you're serious, you will *have* to lean SMT assembly practices. Through-hole only is not a viable stance anymore.
 - Expect to buy a lot of tools, and burn a lot of money in failed prototypes.
 - Expect 3 board revisions. **At minimum**, before you have something you can get tested. I could maybe do it in 2, if I got really, *really* lucky, but I doubt that would happen, and this sort of thing is my day-job.

[Hardware](http://danluu.com/hardware-unforgiving/) is [HARD](http://lemnoslabs.com/2014/01/why-hardware-is-hard/), and worse, it's completely unforgiving. If you're coming from a software engineering background, you basically have to discard all your assumptions, as they will actively hurt you.

Imagine a software project where "compiling" can take 4 weeks. That's hardware development.

  [1]: https://electronics.stackexchange.com/questions/6436/how-to-go-from-newbie-to-manufactured
  [2]: https://oshpark.com/
  [3]: https://electronics.stackexchange.com/questions/7003/best-one-off-diy-pcb-creation-technique/7014#7014


body:
**step1: Make the hardware**

 - Refer the schematics of arduino you are using and make your own pcb

 - Approach any PCB manufactures and deliver them your GERBER files with correct Bill of Materials.
 - You can easily make a single PCB. consider PCB with components on both sides, and multi stackable PCB only if the dimension of required PCB matters.
 - Try not to place nRF antenna and crystal for the micro controller close to each other.

**Step2: Firmware**

This step is about getting .hex file from arduino code and givin this to the same pcb manufacturer, with proper fuse values

 - Go to file->preferences in arduino
 - Check show verbos
 - open the temp file (type %temp% on RUN)
 - Compile your arduino code. this will generate a build folder inside temp
   folder Search for yourArduinoProjectName.hex inside that folder.

*This is the code you need  to get fuse bits*

    #include <avr/boot.h>;
    void setup() { Serial.begin(57600);

    cli();
    uint8_t lowBits      = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
    uint8_t highBits     = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
    uint8_t extendedBits = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
    uint8_t lockBits     = boot_lock_fuse_bits_get(GET_LOCK_BITS);
    sei();

    Serial.print("Low:  0x");
    Serial.println(lowBits, HEX);
    Serial.print("High: 0x");
    Serial.println(highBits, HEX);
    Serial.print("Ext:  0x");
    Serial.println(extendedBits, HEX);
    Serial.print("Lock: 0x");
    Serial.println(lockBits, HEX);    }
    void loop() { }

Or check the file

> C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt

to find the fuses.


message:
Arduino vs Old Computers

How does an arduino microprocessor compare to some of the older computers in RAM, and computational speed? Like how does it compare to the Intel 400 or the original IBM PC. I'm interested in both the Atmega328 and the 2560. Just how much better/worse is the arduino compared to an old computer?

body:
Similar capability in turns of processing power if you compare back 10 -20 years.

arduino is a micrcontroller not a microprocessor.

A good example is the pdp11 minicomputer and the ti msp430 micro controllers. They share the same instruction set (approx 90%) . Both can (or could) do realtime event handling but pdp11 was more for data processing. Though pdp11 didn't have integrated peripherals

see bottom of this page http://www.cpushack.com/CPU/cpu4.html


body:
The Arduino chip (usually Atmega328p-pu) is an AVR (Advanced Virtual RISC*)!!! It doesn't processor but a "full functional nano computer" a Microcontroller! The characteristics of Atmega328P-PU is an 8bit CPU with 2Kb RAM**, 1Kb ROM***  and 32Kb Flash. The CPU's max speed is 20 MIPS @ 20 ΜHz, double of Motorola 68020 (1988) and the half of ARM7 (1994) more fast than Intel i486DX (1991).
***electrically erasable Programmable ROM
**synchronous RAM or SRAM yes! is a type of RAM
*RISC=Reduced instruction set computer
<https://www.microchip.com/wwwproducts/en/ATmega328P>
<https://en.wikipedia.org/wiki/Instructions_per_second>


message:
TIMER1 CTC Interrupts not working with avr-gcc

I am attempting to program my arduino in plain C, and I've come across some very strange behavior. If I load the following code from the Arduino IDE, it works as expected and toggles Pin 6 every 100ms. However, if I compile it with avr-gcc and then load it with avrdude, no interrupts are run.
Here is the C code:

 #include <avr/io.h>
 #include <avr/interrupt.h>

 int main();
 void timer1_init();

 int main()
 {
  // connect led to pin PD6
  DDRD |= (1 << 6);
  PORTD |= (1 << 6);

  // initialize timer
  timer1_init();

  // loop forever
  while(1)
  {
   // do nothing
   // whenever a match occurs, ISR is fired
   // toggle the led in the ISR itself
   // no need to keep track of any flag bits here
   // done!
  }
 }

 // initialize timer, interrupt and variable
 void timer1_init()
 {
  /*cli();*/
  /*TCCR1A = 0;*/
  /*TCCR1B = 0;*/
  /*TCNT1 = 0;*/
  OCR1A = 24999;
  TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10);
  TIMSK1 |= _BV(OCIE1A);
  sei();
 }

 ISR (TIMER1_COMPA_vect)
 {
  // toggle led here
  PORTD ^= (1 << 6);
 }

And here is the Makefile I'm using to load it onto the arduino:

 CC = avr-gcc
 CFLAGS = -g -O0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106

 SOURCE = test

 all: load

 $(SOURCE): $(SOURCE).o
  $(CC) $(SOURCE).o -o $(SOURCE)

 hex: $(SOURCE)
  avr-objcopy -O ihex -R .eeprom $(SOURCE) $(SOURCE).hex

 load: hex
  avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:$(SOURCE).hex

 clean:
  rm -f *.o *.hex
  rm -f `find . -perm 755 | perl -pe 's/\.\n//g' | perl -pe 's/\.\/(\w+)\n/\1 /g'`

Is there something that the arduino ide automatically adds to it that makes it work? What am I missing?

Edit: Here is the make output:

 avr-gcc -g -O0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106   -c -o test.o test.c
 avr-gcc test.o -o test
 avr-objcopy -O ihex -R .eeprom test test.hex
 avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:test.hex

 avrdude: AVR device initialized and ready to accept instructions

 Reading | ################################################## | 100% 0.01s

 avrdude: Device signature = 0x1e950f
 avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
    To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: reading input file "test.hex"
    avrdude: input file test.hex auto detected as Intel Hex
    avrdude: writing flash (196 bytes):

    Writing | ################################################## | 100% 0.04s

    avrdude: 196 bytes of flash written

    avrdude: safemode: Fuses OK (E:00, H:00, L:00)

    avrdude done.  Thank you.

body: I just tried using arduino-mk https://github.com/sudar/Arduino-Makefile, and it worked, so I guess I'm just going to stick with that.


message:
Multiple Definition of "_Vectors"?

I'm working on an arduino project that uses the GSM Shield and the eHealthSensor from Cooking Hacks. However I ran into an issue in which the interrupt vectors from the header/cpp files used are being defined multiple time.

While I know where the definitions are, I am unsure as to how to circumvent this issue either by Arduino programming or modifying the files since I'm not too experienced in this field. Below are the code for the conflicting files.

Below are the vectors that are in conflict.

PinChangeInt.h

        #ifndef NO_PORTA_PINCHANGES
        ISR(PCINT0_vect) {
         #ifdef PINMODE
         PCintPort::s_PORT='A';
         #endif
         PCintPort::curr = portA.portInputReg;
         portA.PCint();
        }
        #define PORTBVECT PCINT1_vect
        #define PORTCVECT PCINT2_vect
        #define PORTDVECT PCINT3_vect
        #else
        #define PORTBVECT PCINT0_vect
        #define PORTCVECT PCINT1_vect
        #define PORTDVECT PCINT2_vect
        #endif

        #ifndef NO_PORTB_PINCHANGES
        ISR(PORTBVECT) {
         #ifdef PINMODE
         PCintPort::s_PORT='B';
         #endif
         PCintPort::curr = portB.portInputReg;
         portB.PCint();
        }
        #endif

        #ifndef NO_PORTC_PINCHANGES
        ISR(PORTCVECT) {
         #ifdef PINMODE
         PCintPort::s_PORT='C';
         #endif
         PCintPort::curr = portC.portInputReg;
         portC.PCint();
        }
        #endif

        #ifndef NO_PORTD_PINCHANGES
        ISR(PORTDVECT){
         #ifdef PINMODE
         PCintPort::s_PORT='D';
         #endif
         PCintPort::curr = portD.portInputReg;
         portD.PCint();
        }
        #endif

        #ifdef __USE_PORT_JK
        #ifndef NO_PORTJ_PINCHANGES
        ISR(PCINT1_vect) {
         #ifdef PINMODE
         PCintPort::s_PORT='J';
         #endif
         PCintPort::curr = portJ.portInputReg;
         portJ.PCint();
        }
        #endif

        #ifndef NO_PORTK_PINCHANGES
        ISR(PCINT2_vect){
         #ifdef PINMODE
         PCintPort::s_PORT='K';
         #endif
         PCintPort::curr = portK.portInputReg;
         portK.PCint();
        }
        #endif

        #endif // __USE_PORT_JK

GSM3SoftSerial.cpp

    // This is here to avoid problems with Arduino compiler
    void GSM3SoftSerialMgr::manageMsg(byte from, byte to){};

    //#define PCINT1_vect _VECTOR(2)
    //#undef PCINT1_vect

    #if defined(PCINT0_vect)
    ISR(PCINT0_vect)
    {
      GSM3SoftSerial::handle_interrupt();
    }
    #endif

    #if defined(PCINT1_vect)
    ISR(PCINT1_vect)
    {
      GSM3SoftSerial::handle_interrupt();
    }
    #endif

    #if defined(PCINT2_vect)
    ISR(PCINT2_vect)
    {
      GSM3SoftSerial::handle_interrupt();
    }
    #endif

    #if defined(PCINT3_vect)
    ISR(PCINT3_vect)
    {
      GSM3SoftSerial::handle_interrupt();
    }
    #endif

Any advice on how to fix this will be greatly appreciated.

If it helps, I am using an Arduino Mega 2560.

body: It's linking problem. More .o files included in linking declares identical global symbol eg. `ISR(PCINT1_vect)`. Ideally write own *makefile* and compile via standard *make*. As hack you can loook in *PinChangeInt.h* conditional parts and make global definitions not to avoid *ISR()*s, e.g. `#define __USE_PORT_JK`


message:
Serial Connection to Phone Line

I was hoping to create a cheap security system by connecting an Arduino to the phone line output of a base station.

Since the base station should call a phone number if the alarm is tripped I wouldn't have to do much hardware hacking so long as I can read/parse the output from the base station.

My question is can I read serial output from a phone line like this?

body:
Phone lines run off of the RS-232 telecommunications protocol which can run off -25v to 25v, which would completely destroy your Arduino. Luckily there is an IC made to help you with that. You can use the MAX3232 IC to convert RS-232 to TTL 5v or 3.3v (Same chip can do either). Look at providers like Digikey for just the chip or you can get a breakout from providers like SparkFun.

TL;DR Yes, but you need a special IC to not fry your Arduino.


message:
VCNL4000 Proximity/Light sensor

I want to use the VCNL4000 Proximity/Light sensor s.
http://www.adafruit.com/products/466?&main_page=product_info&products_id=466

In the package i've this 6 pin connector but the VCNL has 5 pins (i now i can connect it by myself with male jumper) but  what am i missing here? ![enter image description here][1]
I assume that it is not an "accident" that the thing has one more pin then the sensor ; )

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

body: You can just cut off the extra pin. Adafruit probably just had a bunch of 6 pin headers in their stock.


message:
Wiring VCNL 4000 Proximity Sensor

I was looking for wiring the VCNL 4000 Proximity Sensor.

I found this one http://bildr.org/2012/11/vcnl4000-arduino/

but there is used a sensor on a red board, which has other pins like mine (which has a blue board) see http://www.adafruit.com/products/466?&main_page=product_info&products_id=466

as I see SCL,DSA,GRND on both

the red has IR+ which is connected to the 5V . mine (blue one) has VIN. Is this meant to be the same and should it be connected to the 5V ?

Any hints?

I tried the following wiring but the following call does not finish.

3,3V TO 3,3V POWER

SCL TO SCL (Last pin on the digital side)

SDA to SDA (Beside SCL)

GND TO GND on the Analog side

Vin to 5V

     readVCNLByte(0x81); is called

i used the example code from adafruiut

body:
There seems to be a big difference between the Sparkfun and the Adafruit breakouts:

- Sparkfun breadkout needs 3.3V and 5V power as **inputs** as shown in their wiring circuit (in the first link you mentioned)
- Adafruit breakout needs only 5V as input but has a 3.3V regulator on it that provides the 3.3V to all its internal circuits that need it; it also has a 3.3V pin which is an **output** not an input as for the Sparkfun

Hence your wiring is wrong. The expected wiring is described in [Adafruit sample sketch][1]:

    // Example sketch for talking to the VCNL4000 i2c proximity/light sensor
    // Written by Adafruit! Public domain.
    // To use: Connect VCC to 3.3-5V (5V is best if it is available), GND to
    //         ground, SCL to i2c clock (on classic arduinos, Analog 5), SDA
    //         to i2c data (on classic arduinos Analog 4). The 3.3v pin is
    //         an ouptut if you need 3.3V
    // This sensor is 5V compliant so you can use it with 3.3 or 5V micros

In comments, `VCC` should read as `Vin` on the breakout.

Note that the comments mention `SDA` and `SCL` pins on `A4` and `A5` respectively, this is correct on Arduino UNO, but your wiring on the 2 leftmost pins of the digital pin header is also correct, as these pins are now replicated there on UNO and Leonardo. On Leonardo, the real pins for SDA/SCL are pins 2 and 3. If you don't have a UNO or Leonardo though, you should check where SDA and SCL can be found (that's generally described on [Arduino Product page][2] for your board).

Although wiring SDA/SCL on these 2 replicate pins is correct, I would rather recommend using A4 and A5 instead, so that you don't get the illusion that you can both use SDA/SCL and A4/A5 for something else at the same time.

This circuit uses **I2C** which means you should normally add pullup resistors to SDA and SCL wires; however, it seems that the Adafruit breakout already integrates them, so no problem here.

To sum up, and provided that you have a UNO or Leonardo, **your wiring is correct except that you should remove the wire between both 3.3V pins**.

This is shown below for UNO (I used the real pins for SDA and SCL so that you don't use them for something else later):

- Arduino UNO 5V  ---> Breakout Vin
- Arduino UNO GND ---> Breakout GND
- Arduino UNO A4  ---> Breakout SDA
- Arduino UNO A5  ---> Breakout SCL
- Breakout 3.3V left unconnected

For Leonardo it would be:

- Arduino Leonardo 5V  ---> Breakout Vin
- Arduino Leonardo GND ---> Breakout GND
- Arduino Leonardo D2  ---> Breakout SDA
- Arduino Leonardo D3  ---> Breakout SCL
- Breakout 3.3V left unconnected

I show you both UNO and Leonardo since you did not mention which board you use.

  [1]: https://github.com/adafruit/VCNL4000/blob/master/vcnl4000.pde
  [2]: http://arduino.cc/en/Main/Products


message:
Arduino power consumption issues

I'm working on an Arduino project involving an UNO.
I'm powering a 20x4 LCD screen and I am using all the ports on the Arduino, to the last.

All but four of them are pulled high at any given time, so by the time I'm done with pulling them all up the screen is going dim when powering via USB.
So I tried powering via an external 9V 600mA adapter, but that makes the Arduino overheat and eventually shut down.
I then tried another, 12V 500mA adapter, and that one doesn't even get my UNO to the end of the setup function, and it reboots repeatedly.

Anyone got good advice? Ideas?

body:
[The official arduino uno schematic](http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf) uses a [NPC1117](http://www.onsemi.com/PowerSolutions/product.do?id=NCP1117) voltage regulator. This is a linear one. This means that if you put 12V on it, and if your system requises 0.5A, you Will leak 0.5A on the 12V, and, if there is 5V on the output, 12V on the input, there is a 7V drop on the regulator, 7V * 0.5A = 3.5W that turns into heat.

To avoid overheating, the solution isn't to increase the input voltage, but to decrease it. If you have a 6.2V power supply, this will minimize overheating. At least 6.2V are required for the NPC1117 to provide a stable 5V.

An other option is to use a USB 5V power supply with an output current greater than 0.5A. This is often used with smartphones. This allows to bypass the NPC1117, but the power supply shall be exactly 5V (where exactly stands for less than 10% of over or undervoltage).

Also, please note:

> Arduino does not recommend bypass[ing the] Vin supply to directly supply 5V rail on the board as it will damage the NPC1117. See the first two line on page # 3 from the document link below. http://media.digikey.com/pdf/Data Sheets/Arduino PDFs/ArduinoEthernet.pdf
You can either do the soldering and remove NPC1117 chip before you apply 5V directly onto the board or find a higher current capability power supply with the output voltage between 7v-12V.


message:
About arduino serial communication

I've used the arduino uno with the python serial library months ago and some packets got lost in the way. I've been searching about serial communication for arduino and I've been thinking that I could use some parity systems and other things to guarantee that my packets will arrive. First of all, if I use the parity system of the arduino's serial library, how good it will be? I need to send packets like "this button was touched", but ALL packets must arrive, so if some packet fails, I need to send it again.

How to make it possible? I'm thinking about using the parity system of the arduino's library, but I don't think if it's gonna work well.

Can somebody point me some good text about it?

body:
There is no way to *guarantee* that all packets will arrive. The best you can do is to have the receiving system acknowledge receipt of all packets, with enough data within to verify the correctness of the packets.

UART parity is not a good method to verify correctness since it can only detect single-bit errors within a byte; two bit errors will verify correctly, and of course the entire byte may get dropped before it can even get to the receiver.

RFC 916, "RELIABLE ASYNCHRONOUS TRANSFER PROTOCOL (RATP)", describes a TCP/IP-like method of sending data reliably over an asynchronous medium. It's more wordy than just sending a byte containing status changes, but if you need reliability then you need more than that.


message:
Light LED when 2 others are disconnected

I need to make circuit in which orange LED will light only when yellow and red are disconnected. When one of buttons is pushed orange LED should turn off.

See my attempt at it below.

I am new to electronics so your help is very appreciated.

![Fritzing diagram][1]

**EDIT:**

After many atemps I managed to build this circuit as on left side of schematic (tested on live breadboard)

![schematics](https://i.stack.imgur.com/A31Fw.png)

but my primary goal is to make this work with RGB LED. I took Common Anode RGB LED for this and build circuit on right side of schematic. I do not have such RGB LED to test it live so I ask you to review if that schematic will work as it has few changes to one with 3 LED's. Thank you

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

**SOLUTION:**

Thanks to Bruce's help my circuit now works.

3 separate LEDs emulate common anode RGB LED (as I do not have one to test circuit)
Q2 is BC 560B transistor with CBE type pinout

![](https://i.stack.imgur.com/Ig8uq.png)

![](https://i.stack.imgur.com/8BtrL.png)

CODE:

    void setup() {
      pinMode(2,INPUT);
      pinMode(4,INPUT);
      Serial.begin(9600);
      digitalWrite(2,HIGH);
      digitalWrite(4,HIGH);
    }

    void loop() {
      Serial.println(digitalRead(2));
      Serial.println(digitalRead(4));
    }

body:
You want the green LED to be on *only* when the red and blue LEDs are both off. In other words, you want the voltage on the green LED to be LOW only when the voltages on the red and blue LEDs are both HIGH. That is a logical NAND function.

Your right-hand circuit with the RGB LED won't work because the transistor's collector is connected to the wrong place - it's shorting out the battery! Another problem is that the Arduino can only switch to Ground or +5V, so it can't replace a 'floating' switch.

You need a configuration that produces a logical NAND function. Your left-hand circuit is doing it, but won't work with a common anode RGB LED. So swap the transistor to a PNP  type, and add a couple of resistors to switch it on when either input goes low, like this:-

![enter image description here][1]

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


message:
WiFi UDP.endPacket() continuously fails

I am attempting to send data from my Arduino to my computer using the WiFi shield.  However, my code is erroring out on UDP.endPacket(), and I do not understand why.  Here is my code:

    #include <WiFi.h>
    #include <WiFiUDP.h>

    int status = WL_IDLE_STATUS;
    char ssid[] = "NETGEAR31"; //  your network SSID (name)
    char pass[] = "oddearth926";    // your network password (use for WPA, or use as key for WEP)

    char  ReplyBuffer[] = "acknowledged";       // a string to send back

    WiFiUDP Udp;

    void setup()
    {
      //Initialize serial and wait for port to open:
      Serial.begin(9600);

      // check for the presence of the shield:
      if (WiFi.status() == WL_NO_SHIELD)
      {
        Serial.println("WiFi shield not present");
        // don't continue:
        while (true);
      }
      // attempt to connect to Wifi network:
      while ( status != WL_CONNECTED)
      {
        Serial.print("Attempting to connect to SSID: ");
        Serial.println(ssid);
        // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
        status = WiFi.begin(ssid, pass);

        // wait 10 seconds for connection:
      }
      Serial.println("Connected to wifi");
      printWifiStatus();
      Serial.println("\nStarting connection to server...");
      if(!Udp.begin(8765))
      {
        Serial.println(F("failed"));
      }

      // if you get a connection, report back via serial:
    }

    void loop()
    {
      IPAddress ip(10,0,0,5);
      int port = 8766;
        // send a reply, to the IP address and port that sent us the packet we received
        if(!Udp.beginPacket(ip, port))
        {
          Serial.println(F("Failed beginning packet"));
        }
        Udp.print(ReplyBuffer);

        if(!Udp.endPacket())
        {
          Serial.println(F("Failed ending packet"));
        }
    }

    void printWifiStatus() {
      // print the SSID of the network you're attached to:
      Serial.print("SSID: ");
      Serial.println(WiFi.SSID());

      // print your WiFi shield's IP address:
      IPAddress ip = WiFi.localIP();
      Serial.print("IP Address: ");
      Serial.println(ip);

      // print the received signal strength:
      long rssi = WiFi.RSSI();
      Serial.print("signal strength (RSSI):");
      Serial.print(rssi);
      Serial.println(" dBm");
    }

And here is the log:

    Attempting to connect to SSID: NETGEAR31
    Connected to wifi
    SSID: NETGEAR31
    IP Address: 10.0.0.34
    signal strength (RSSI):-63 dBm

    Starting connection to server...
    Failed ending packet
    Failed ending packet
    Failed ending packet
    Failed ending packet
    Failed ending packet
    Failed ending packet

It will continue to spit out "Failed ending packet" until I stop it.  Any ideas?

body: Fixed by updating firmware on Wifi Shield.


message:
Uploading Temperature data (DHT22) to Thingspeak with an ENC28J60

So, I've gotten my module working pretty well. It logs data from the DHT22 and sends it to a 192 address on my LAN. However, I'd like to log and graph the data.

 I figured thingspeak is a decent platform for that. However, I have no experience doing so, and I'm not sure where to start. All the examples use the "official" arduino shield. I've only found ONE example bit of code, but it uses the Dallas One Wire temp module. [Link][1]

I'm in over my head, and have no idea how to switch from the One wire to the DHT22. Thanks for the help!

I'm using a clone arduino pro mini, 5V 16mhz, 328.

If there's a better platform than thingspeak, I'm open. All I want to do is graph and visualize the DHT22 sensor readings.

  [1]: https://xa.yimg.com/kq/groups/65275256/1011665768/name/Blank_Thingspeak_Ethercard.ino

body:
Try this:

    /*
    | Post temp. values from a DS18B20 to ThingSpeak using the Ethercard interface based on the
    | ENC28J60 chip.
    | Based on the Ethercard example from www.jeelabs.org
    | Phil Grant Jan 2014
    */
    #include <EtherCard.h>
    // change these settings to match your own setup
    #define APIKEY  "xxxxxxxxxxxxxxxx"

    //DHT Setup
    #include "DHT.h"
    #define DHTPIN 2     // what pin we're connected to
    // Uncomment whatever type you're using!
    //#define DHTTYPE DHT11   // DHT 11
    #define DHTTYPE DHT22   // DHT 22  (AM2302)
    //#define DHTTYPE DHT21   // DHT 21 (AM2301)
    DHT dht(DHTPIN, DHTTYPE);

    // ethernet interface mac address, must be unique on the LAN
    byte mymac[] = { 0xXX,0xXX,0xXX,0xXX,0xXX,0xXX };

    char website[] PROGMEM = "api.thingspeak.com";

    byte Ethernet::buffer[700];
    uint32_t timer;
    Stash stash;

    void setup () {
      Serial.begin(57600);
        dht.begin(); //Initializate DHT
      Serial.println("\n[webClient]");

      if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
        Serial.println( "Failed to access Ethernet controller");
      if (!ether.dhcpSetup())
        Serial.println("DHCP failed");

      ether.printIp("IP:  ", ether.myip);
      ether.printIp("GW:  ", ether.gwip);
      ether.printIp("DNS: ", ether.dnsip);

      if (!ether.dnsLookup(website))
        Serial.println("DNS failed");

      ether.printIp("SRV: ", ether.hisip);
    }

    void loop () {
      ether.packetLoop(ether.packetReceive());

      if (millis() > timer) {
        timer = millis() + 60000; //Transmit every minute
        delay(2000);  // Wait a few seconds between measurements.
      // Reading temperature or humidity takes about 250 milliseconds!
      // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
      float h = dht.readHumidity(); // Read temperature as Celsius (the default)
      char h_buffer[10];
      String Hstring = dtostrf(h,0,5,h_buffer); //Convert Humidity value to String

      float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true)
      //float f = dht.readTemperature(true);
      char t_buffer[10];
      String Tstring = dtostrf(t,0,5,t_buffer); //Convert Temperature value to String

        byte sd = stash.create();
        stash.print("field1=");
        stash.println(Hstring);
        stash.print("&field2=");
        stash.println(Tstring);
        stash.save();

        // generate the header with payload - note that the stash size is used,
        // and that a "stash descriptor" is passed in as argument using "$H"
        Stash::prepare(PSTR("POST /update HTTP/1.1" "\r\n"
                            "Host: $F" "\r\n"
                            "Connection: close" "\r\n"
                            "X-THINGSPEAKAPIKEY: $F" "\r\n"
                            "Content-Type: application/x-www-form-urlencoded" "\r\n"
                            "Content-Length: $D" "\r\n"
                            "\r\n"
                            "$H"),
                website, PSTR(APIKEY), stash.size(), sd);

        // send the packet - this also releases all stash buffers once done
        ether.tcpSend();
      }
    }


message:
Problem with while loops while detecting frequency of a signal

I just started to use the unusual part of Arduino language (avr) like interrupts, accessing registers, etc in Arduino IDE. I wrote a program to calculate the frequency of a digital signal using external interrupts.

The following code is to calculate timeperiod of a digital signal, the output of the color sensor (TCS3200) which depends on the color filter choosen via S2 and S3 pins, as in the code. That is, color sensor produces 50% duty cycle square pulses of frequency dependent on the power of the light incident on it. So when sensor faces red color, output signal's frequency in red color mode (by setting S2, S3 pins) is more than the frequency in blue and green modes. Thus we can detect the likeliness of the color which it faces w.r.t  R,G,B.

When this code is uploaded in the Arduino, it failed to print the values as expected in the serial monitor i.e. its stuck in while loops. But when `Serial.print(e)` statement in the while loops are uncommented, it is able to print the required time periods. I am unable to figure out the problem here, which is making Arduino to be inside the while loop when no statements are in it.

    // INT0 interupt is used i.e. digital pin 2
    int ti=0,tim=0,e=0,S2=4,S3=5;

    void Interruptinit() //initializing interrupt INT0
    {
      cli();
      EICRA =  0x02; //Control register
      EIMSK =  0x01; //Mask register
      sei();
    }

    void setup()
    {
      pinMode(2,INPUT);
      digitalWrite(2,HIGH); //enabling pull up register
      pinMode(S2,OUTPUT);
      pinMode(S3,OUTPUT);
      Interruptinit();
      Serial.begin(9600);
    }

    ISR(INT0_vect)
    {
      tim=micros()-ti;
      ti=micros();
      e++;
    }

    void loop()
    {
      digitalWrite(S2,0); digitalWrite(S3,0); //switching over red filtered photodiodes
      e=0;
      while(e<2)
      //Serial.print(e) //waiting till interrupt is addressed 2 times
      ;
      Serial.print("red:");
      Serial.print(tim);

      digitalWrite(S2,0); digitalWrite(S3,1); //switching over blue filtered photodiodes
      e=0;
      while(e<2)
      //Serial.print(e)
      ;
      Serial.print(" blue:");
      Serial.print(tim);

      digitalWrite(S2,1); digitalWrite(S3,1); //switching over green filtered photodiodes
      e=0;
      while(e<2)
      //Serial.print(e)
      ;
      Serial.print(" green:");
      Serial.println(tim);

    }

body:
Whenever you modify non-local variables in an ISR, it's important that they are declared as `volatile`. This tells the compiler that the contents may change unexpectedly, ensuring it doesn't use out-of-date cached copies somewhere else. If you don't do this, the code can behave in unpredictable ways, such as outputting the wrong value under some circumstances.

Since the variables are bigger than 1 byte, it's also necessary to disable interrupts around non-ISR code which uses them (e.g. in `loop()`). This is because interrupts could be triggered at any time, potentially half way through an operation which reads/writes them.

You can use `noInterrupts()` and `interrupts()` to disable/enable interrupt handling.


message:
Cheap 2-5mb memory to use with arduino

I'm looking for a storage solution for small files that would be moved into a small sensor running arduino-like processor.

Ideally the single memory unit would be cheap (in 1-10 cents range), but the memory can be very limited (several megabytes).

The closest I've got so far is small SD Memory card, but the smallest 4GB ones cost several dollars (at least bought in quantities < 100). Anything else I should be looking at?

body: On ebay you can buy 2nd hand Nokia SD cards from old mobile phones which are 128MB or so and very cheap.


body:
I assume that, if this is a cost sensitive item, you need a reliable supply of multiples (so looking for small SD cards on e-bay isn't a viable solution).

Does it need to be non-volatile storage? If it does't you may be able to find small 8-bit wide RAM chips at a pretty good price. If it needs to be non-volatile, you might look at individual flash chips. I found [this one][1], an 8-bit by 512 KB Serial-SPI flash chip for £0.19 (about $0.28 US) in single units and £0.176 if you can by 100 at a time. I would expect DRAM chips and chips with a simpler interface to be less expensive (but you might end up spending more on interfacing the chips so it might end up as a wash).

If you're able to consider a variety of processor chips it might be worth looking for something that has adequate storage on chip. That might be the most cost effective way to get the space.

[1]: http://uk.rs-online.com/web/p/flash-memory-chips/8228473P/


message:
Can I program Arduino with Python?

I know that I can program Arduino with python but is it possible to make every project, which can be completed by normal IDE?

body:
Not really, since python is an interpreted programming language.
If you are not new to the microcontrollers' world and have same experience, maybe [this Board][1] is you what you want. More powerful than Arduino and completely programble using Python 3.

[Topic: Can I use Python to program Arduino?][2]

  [1]: https://micropython.org/
  [2]: http://forum.arduino.cc/index.php?topic=192552.0


body:
I imagine you want to use python because you are already familiar with it, know your way around the syntax, etc. But I would advice against this line of thinking, because microcontrollers need a little more of "low-level" thinking (given the limited resources they generally have) and because of that, it's probably best if you learn some C/C++.

The arduino programming framework provides some not-so-low-level libraries and tools (like the arduino IDE itself) to make it easy for non-C programmers to learn C-like programming.

However, if you want to use python as a proof of concept or anything else, sorry about the misunderstanding! :)


body:
The direct answer is almost certainly not.

There are some auspicious developments so that you might be able to adapt a specific open source Python package, but the resulting software would require a special Arduino board with an MCU chip with much more SRAM and a higher clock speed than we usually see on Arduino boards.

**Discussion**

I have looked several times and have never found anything.

I did find a "stripped down" implementation of a Python 3.3 interpreter called [Micro Python][1]. The software was developed hand in hand with MicroPy, an ARM-based single board computer (also described at the MicroPython website). MicroPy is closer to a Raspberry Pi or Beaglebone than an Arduino. However, the software environment is less complex because the MicroPy doesn't require a Linux-based or other operating system.

The base Micro Python package software package seems to require about 110KB of SRAM to boot up and expects a 1 MB SD chip with a boot record and MicroPython on it.

The Micro Python software was released under the MIT open source license so, in theory, a clever person could adapt it for the Arduino if they built a board with a really powerful chip SD socket.

Although the Micro Python/MicroPy package is very appealing, I don't think I would head down the path. I would rather be programming for hardware that is available from more than one source.

Another potential issue is that the Micro Python implementation uses a mark and sweep garbage collector which might tie up the processor for 4 msec at time. Depending on your application a 4 msec busy period might not be acceptable.

  [1]: http://micropython.org


message:
Using MULTIPLE shields on Arduino Uno R3

I'm very new to using Arduino!  I'll be using Ocean Controls KTA 259 thermocouple multiplexing shield AND a Sparkfun microSD shield on my UNO--to log temperature data for a study I'm doing.  The KTA 259 has a library and the integral SD library should work for the SD shield.
Q1:  I believe they *physically* connect no problem, but how can I be sure there are no pin conflicts, disastrous or otherwise?  In other words--what conditions **MUST** I avoid using shields and multiple shields?
Q2:  Can (or must) a single data pin be used by both shields, eg from thermo as output to SD as input, or does Arduino juggle all that?
Q3:  Can (or must) a single function, eg CS, be mapped onto the same pin on BOTH shields, or do they have to be separate allowing Arduino to handle that?
Thank you; I appreciate the help!

body:
Q1: If its a well established source of Arduino compatible boards you can be pretty confident (in my experience) that there are no design flaws regarding pin use.  A search on comments by other developers will also help confirm that for you further.

When you go to multiple shields you would need to look at fanout (driving more than one input from an output).  The reverse problem is even more of an issue: driving one input from several outputs.  In other words, an input on the Arduino would be connected to output pins on two shields providing different signals.

Q2: The answer relates to how I ended in Q1.  By avoiding the use of certain pins on a shield the conflicting inputs could be avoided.  The headers would simply pass through the signal.  I don't think there is any rule that a shield has to use or touch every pin.

Q3: I'm not quite sure what you are asking in this question.


body:
You will have to consult a source like this one: http://shieldlist.org
There are no simple rules for which pin conflicts are OK and which ones are not, it all depends on the concrete protocol (i.e. I2C is designed for all bus participants to share lines, while in SPI, each participant needs their own select line, while the other lines are shared).

In your concrete case, both shields you want to use are addressed by SPI, which means D13 (SCK) and D12 (MISO) are shared between the shields by design, while they MUST have different slave select pins. In your case, the SS pin for the microSD shield is fixed as D8, while the one for the KTA shield seems to be selectable, so either D9 or D10 should be OK.

Peripherals generally don't have facilities to become an SPI master, so all data has to be transferred through the Arduino.


body: I have used these ***exact* two shields** myself and can confirm they definitely work together. I can find my datalogger code to confirm if desired.


message:
Washing machine controlled by Arduino for homebrewing

So, this question might sound a bit silly at first glance (no, I know, it sounds flat out insane), but not all that silly at second.

I have heard once about a guy who transformed some (presumably old-ish) washing machine into his own personal home-brewing apparatus. It is quite some idea if you think about it. Washing machine can easily solve most issues people have with homebrewing. It can carefully control and adjust temperature throughout the long and complicated process of brewing, it can stir, it can pump in fresh water.

Main question is, how to control washing machine to do what I want it to do.  Most automatic washing machines already have some controllers, but I don't see much chance in trying to simply reprogram them (Am I wrong?). **Arduino seems like best choice for its simplicity and expandability. However I am still fairly new to Arduino and have trouble imagining how would connecting everything from washing machine (motor, pump, maybe water and temperature sensors) to Arduino actually look like.**

*So is it even possible? Are there any projects to "bounce of"?* (I couldn't find any, but maybe I looked for wrong projects) *Should I expect any major problems?*

body:
There is [an article by Atmel][1], talking exactly about this (not for homebrewing, though). They provide a [link to a PDF file][2] that describe in detail a project involving Arduino and a re-created washing machine.

Note that it seems to be some kind of Bachelor graduation project, and that the students seem to build an entire washing machine. They control the rotor using an Arduino, and even provide the code (and a brief history about washing machines..).

Apart from building the entire machine, there are two main directions here as I see it:

1. Manipulate the existing washing machine's control board using Arduino. The bad news are the it would require some reverse engineering of the existing controller, because, per my understanding (and I'm not an expert on the subject) there is no one standard and any manufacturer seems to use it's own propriety control board (similar to Microwaves or Dishwashers). The good news are that an expert could probably do it, either by dumping the controller memory and examining the hex code or by using JTag.

2. Another way to go here is interfacing the electrical hardware itself; [see this instructable][3] where the guy connected the Arduino in parallel to the start button, by thus allowing an alternative way to start.

As for a beginner, it would make more sense to go for the latter; in-parallel connection with an existing hardware button should be a fairly comprehensible task. Consider the hazards of working with a high voltage/power device such as washing machines. I must say that on first glance such a project doesn't seem fit a novice, but I would be the last one to hold an enthusiast's back. And if you know any, I would suggest asking supervision from someone with a strong EE background.

  [1]: http://blog.atmel.com/2013/10/17/let-arduino-control-your-dishwasher-or-washing-machine/
  [2]: http://grietinfo.in/projects/MAIN/EEE2013/cd-3-projectdocumentationpdf.pdf
  [3]: http://www.instructables.com/id/Washing-machine-countdown-timer-Arduino/


message:
Reading atomic radio clock

i have some data logging to do. And i want some what accurate time meaning accuracy has to be +/- 1 minute.

I have considered a RTC, but then i thought. When i was 10 i got a watch that kept time from this radio clock. And if it is possible 20 years ago to make a clock that updates automatically in such as small form factor, then i should be able to do it with my arduino today.

Does anyone know of a guide/solution with components where i can read this atomic radio clock?

body:
So, the first consideration goes to the radio propagation aspect. Every country does things a little different with their radio clocks. And you might only have good signal a few times a day. For a nice overview, check out a solution for the [German DCF77][1]. If you're totally set on using a radio clock, time-nuts has discussed in the past ripping open a $10ish clock to get at the fun parts of a [WWVB receiver][4], so that's one overview of the pool you're diving into.

For myself I've skipped past the terrestrial time keeping and went straight to GPS. Find a receiver that provides a pulse-per-second and attach that to an interrupt and process it alongside the timestamp; you can see how I've gone about that in both [code][2] and [final product][3].

I think GPS is both easier and more precise than the alternatives, assuming you're above ground and can pick up satellites. I think of RTCs as something to tell me the day and the year, while GPS can tell me the second. But you could consider ripping the antenna out of a cheap bedside radio-controlled clock and using that to set an RTC, careful to consider whether you want a cheap RTC (DS1307) that drifts a minute per day or a slightly more expensive RTC (DS3231 or ISL1220) that drifts a minute per month. (Rough numbers of course.)

  [1]: http://blog.blinkenlight.net/experiments/dcf77/the-clock/
  [2]: https://github.com/ptudor/jemma-clock
  [3]: https://www.tindie.com/products/ptudor/jemma-clock/
  [4]: http://comments.gmane.org/gmane.comp.time.nuts/38831


message:
How to send Json to a webservice from pc/RPI with live data from Arduino(serial)

I'm making a project where my plan is to take sensor input from the Arduino, and then pass that info (by serial/usb connection) through either a laptop or a Raspberry Pi and convert it to Json and send it to a webservice in asp.net c#, where it gets stored in a database, and then the data can be shown on a website, so the visitor can see live data from the Arduino sensor on the site and also be able to see what the sensor measured yesterday, last month, or the average for a extended period of time, or a graph.

It might be easier to illustrate what I'm talking about:

![enter image description here][1]

The PC / RPI part is optional, it can be using either one.

There are a few options, as I see it, as to which methods could work. But I am unsure about how to implement them and what programs to use for it.

First one is to log data to a file on the PC/RPI and then have some shell script either listen for changes and then combine a Json string with the newly added info to the file and send it of to the webservice.

Second one is to somehow take the Serial data from the Arduino and have some shell script or program listen for any data coming from the Arduino and converting it to Json, and sending it of to the webservice. The pro's by this method would be omitting the extra "file-step", but it would make the system more vulnerable to any interruptions in the connection.

Does anyone have experience with doing something like this? Or maybe have an idea how I can do what I'm trying to do ? Or just a nudge in the right direction, as to which approach you think is best, or what programs I could/should use.
Any help is very much appreciated!

Best regards
Daniel

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

body:
I'm kind of tackling the same thing at the moment.

I have been using MQTT for a while for things like this. Including on an Netduino, an Arduino, and today a LEGO NXT.

But it is TCP based. I have been wanting to use serial, not TCP (ethernet) for a while, and when the need came for the NXT, it was time to write my own bridge to existing code.

I runs on the same host as the MQTT broker, but listens to a serial port, and mirrors the data to a TCP MQTT broker.

The code is turning out to be much simpler than I expected, I should have done this months ago.

Nxt Side

    while (true)
 {
  float x, y, z;
        DIMUreadGyroAxes(IMU, x, y, z);

  char json[128];
  sprintf(json, "PUBnxt/Gyro,{\"x\":%f,\"y\":%f,\"z\":%f}\n", x, y, z);
  nxtWriteRawHS(json, strlen(json), 0); // wireless serial over xbee
  wait1Msec(50);
 }

PC side

     void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort p = sender as SerialPort;
            while (p.BytesToRead > 0)
            {
                string line;
                try
                {
                    line = p.ReadLine();
                }
                catch (IOException)
                {
                    throw;  // +++timeout
                }
                // parse it, it should be CMDtopic[,payload]
                if (line.Substring(0, 3).Equals("PUB"))
                {
                    int commaIdx = line.IndexOf(',', 3);
                    string topic = line.Substring(3, commaIdx - 3);
                    string payload = line.Substring(commaIdx + 1);
                    Console.WriteLine("{3}: {0}, publish topic({1}) payload({2})", p.PortName, topic, payload, DateTime.Now.ToLongTimeString());
                    Mqtt.Publish(topic, System.Text.Encoding.UTF8.GetBytes(payload));

                }
                else if (line.Substring(0, 3).Equals("SUB"))
                {
                    string topic = line.Substring(3);
                    Console.WriteLine("{0}, subscribe topic({1})", p.PortName, topic);
                    throw new NotImplementedException("MQTT Subscribe not implemented yet");
                }
                else
                {
                    //Debugger.Break();   // ignore it, framing error
                    Console.WriteLine("{0}, Data dropped", p.PortName);
                }
            }
        }

You might also want to look at [data.sparkfun.com][1]. A similar, complete concept, already existing.

  [1]: https://data.sparkfun.com/


message:
Fade LED strip using proximity and map() function

I'm using a sonar sensor to detect proximity, and need to control the brightness of an LED strip in direct relationship to the distance detected. For example, as someone moves toward the sonar, the strip needs to dim.

I'm using map() to do it now crudely but it's way too abrupt and I'm not sure how best to achieve the effect I'm looking for. Ideally, as the person moves toward the light, it very smoothly fades out in relationship to the person's movement/pace.

Initial thoughts / questions:

-- Can I use a more refined number type to set the LED brightness other than int?
-- Do I need to do something more complex where I detect the delta in the person's movement and use the loop to fade the LED from one value to another? Seems complicated...

Any help / ideas on this would be much appreciated! Existing code is below if it helps.
Claudia

    //variables needed to store values
    long pulse, inches, cm;

    //LED VARIABLES
    int frontPin = 6;    // front strip connected to PWN pin 5
    long interval = 8000; // interval at which to do something (milliseconds)
    int val;

    void setup() {
      //This opens up a serial connection to shoot the results back to the PC console
      pinMode(frontPin, OUTPUT);
      pinMode(pwPin, INPUT);
      Serial.begin(9600);
    }

    void loop() {
        //Used to read in the pulse that is being sent by the MaxSonar device.
      //Pulse Width representation with a scale factor of 147 uS per Inch.

      pulse = pulseIn(pwPin, HIGH);
      //147uS per inch
      inches = pulse/147;
      //change inches to centimetres
      cm = inches * 2.54;

      if (inches < 36){
        detect();
      }
    }

    void detect(){
      Serial.print(inches);
      Serial.print("in, ");
      Serial.println();

      val = inches;
      val = map(val, 6, 36, 0, 255);

      analogWrite(frontPin, val);
      Serial.print("mapped value is ");
      Serial.print(val);

      delay(500);

    }

body:
The biggest problem is that by forcing the code to use integral inches you've restricted it to 31 discrete values. And since the brightness response of a PWMed LED is non-linear you effectively have *very* large steps in brightness when the LED is dim.

`pulseIn()` has *much* more flexibility with regards to its range so use the raw value directly instead of converting it to "pretty" values.

    val = map(pulse, ..., ..., 0, 255);


message:
How to send data to sim900 only once in loop()

I am trying to communicate with a client(PC) from my arduino (set up as a server with a sim900 module connected via UART). I have successfully got it to register its IP address with a dynamic DNS provider (no-ip.com) and set up a TCP server using the AT+CIPSERVER command for the sim900. All this is done in setup(). After that in loop() it waits for a client to connect. The moment a client connects the problem arises. The code is:-

    void loop()
    {
      while(Serial.available() <= 0);
      int x=0;
      char server_recv_string[30];
      while(Serial.available()>0)
      {
        server_recv_string[x] =  Serial.read();
        delay(10);
      }
      Serial.println(server_recv_string);
      sendATcommand2("AT+CIPSEND",">","ERROR",1000);
      sendATcommand2("I hear you\x1A","SEND OK","ERROR",5000);
      while(Serial.available()>0)  // I dropped this in to clear out the input buffer.
      {                            // Doesn't help
        Serial.read();
        delay(10);
      }
      Serial.flush();
    }

The sendATcommand2 is a function as given below. I don't think that has any fault in it because it seems to work fine for all the other commands in setup. However this is the code:-

    int8_t sendATcommand2(char* ATcommand, char* expected_answer1,
        char* expected_answer2, unsigned int timeout){

        uint8_t x=0,  answer=0;
        char response[100];
        unsigned long previous;

        memset(response, '\0', 100);    // Initialize the string

        delay(100);

        while( Serial.available() > 0) Serial.read();    // Clean the input buffer

        Serial.println(ATcommand);    // Send the AT command

        x = 0;
        previous = millis();

        // this loop waits for the answer
        do{
            // if there are data in the UART input buffer, reads it and checks for the answer
            if(Serial.available() != 0 && x < 100){
                response[x] = Serial.read();
                x++;
                // check if the desired answer 1  is in the response of the module
                if (strstr(response, expected_answer1) != NULL)
                {
                    answer = 1;
                }
                // check if the desired answer 2 is in the response of the module
                else if (strstr(response, expected_answer2) != NULL)
                {
                    answer = 2;
                }
            }
        }
        // Waits for the asnwer with time out
        while((answer == 0) && ((millis() - previous) < timeout));

        return answer;
    }

The when I monitor it on the serial terminal I get infinite sends to my client. Its like this:

     AT+CIPSEND
     I hear you

     AT+CIPSEND
     I hear you

     AT+CIPSEND
     I hear you

     AT+CIPSEND
     I hear you

     // And on and on and on.

Any idea why this is happening? If you guys need any more information, please do tell me.

Thanks

Taz

body:
You can use a boolean variable to decide if you are going to execute the send command. You can set the variable to true in the setup and to false after the command is executed.

If you introduce the send call inside an *if (your boolean variable == true)*, it will only be executed in one loop iteration.

You can execute it again anytime you like setting the variable to true at any moment.


message:
Reading keyboard input

I'm using Serial.read(); to read keyboard input from the serial monitor.
It only sends the characters after hitting enter or clicking the "send" button.
Is there a way to read keyboard input without having to use "enter"?

body: Not with the Serial Monitor built into the Arduino IDE. It is possible to use an external terminal program with buffering disabled though.


message:
How can I increase resolution for current sensor?

I purchased a ACS711 Hall effect-based linear current sensor (http://www.pololu.com/product/2197) and when i read the input it's basically always the same. After doing some research I think it's because there is only a 10bit AD converter and since the current is only changing a little bit it's not enough to catch the change. For my situation I'm pulling around 40-90ma idle and when the motor turns on it jumps up so I want this sensor to see that but it only jumps up to about 120ma. Any tips on how to fix this? Maybe a different sensor? Can I use an amplifier to boost the analog signal?

body:
In default configuration, the Arduino's ADC has a range of 0v-Vcc (5v or 3.3v depending on the model). If you are sure your input voltages will always be way lower than Vcc, spreading the ADC's resolution over that range is a waste of accuracy. What you need to do is to **[properly configure your analog reference voltage][1]**.

Basically, this is a way of telling your Arduino "instead of spreading your ADC's bits over a range of 0v to Vcc, just cram all that accuracy between 0v and `[refVoltage]`."

So:

 - Measure the highest analog output your sensor will give.
 - Setup a voltage divider to output a little more than that
 - Connect the voltage divider's output to the AREF pin
 - in `setup()`, declare `analogReference(EXTERNAL);`

And that's basically it. As noted, in this specific case you'd probably be better off buying another sensor altogether. However, you won't always have that luxury, and knowing how to set the analog voltage reference always comes in handy.

  [1]: http://arduino.cc/en/Reference/AnalogReference/


body:
First, let's look at where you are now.  The sensor you have reports current changes at 110mV per amp.

That means 40mA => 4.4mv, 90mA => 9.9mv, and 120mA => 13.2mv -- all very small voltages and small changes in voltage.

Let's work backward, tho.  A 5V Arduino in typical ADC mode has a resolution of about 5 mV (5 V / 1024 counts), whilea 3.3V Arduino would have a resolution of about 3.3 mv).  Divide those step sizes by 0.11V/A sensitivity and you'll see that a different of 1 count on the ADC will represent about 45ma (5V Vcc) or 30 ma (3.3V Vcc).  But there is always inaccuracy and noise, so it's going to be hard to reliably distinguish between 90mA and 120 mA (using your figures).

You can improve that somewhat by switching to a sensor with higher sensitivity (and lower maximum range) like https://www.pololu.com/product/1185 which improves the sensitivity to 185 mV per amp.  The step size of the ADC converters would translate to about 26 mA (@5V) or 17.5 mA (@3.3V).  That's still pretty tight.

You **might** be able to manage with the more sensitive sensor and a 3.3V Arduino - if you use capacitors to filter out the electrical noise on the sensor to ADC input, and you average multiple readings in your code to further smooth the values.  But it would be marginal.

So you need to amplify the sensor.  Yes, you could do that with an external amplifier, like an op Amp.  A transistor is more difficult because you need it to stay fairly linear which gets trickier, and you may need more than one stage - so an op amp is easier.

There's another tricky factor - you need to compare the voltage from the sensor to some reference - Vcc/2 for your sensor, and 2.5V for the more sensitive one.  The current is proportional to the difference between the sensor reading and that reference (the current going one way for sensor output above reference, the other way for sensor output below reference).

I'll mention another option - you could use an Arduino Mega or Leonardo.  These chips offer the option of differential inputs (one pin goes to the signal, and one to the reference), and they have built in selectable amplifiers with up to 200x amplification.  That should give you plenty of resolution, without needing to use external active analog circuitry.

You will still need to filter the sensor output to smooth spikes from the motor (current spikes translated to voltage spikes by the sensor).  You may need to also filter the Arduino Aref input with a cap.

Suppose you were to use an Arduino Mega or Leonard with the sensor you have.  You'd want a Vcc/2 reference, which could simply be two identical resistors (say 10K ohm) between Vcc and Ground as a voltage divider (and maybe a cap to ground for filtering).  You would still probably need to calibrate by finding the ADC value for no current as your reference and subtract that from the reading you get when current is flowing.