text:
Unable to connect to Linux Environment (Linino AR9331 Interface) in Arduino Yun
I was trying to reset my Arduino Yun (WLAN button pressed for more than 30 seconds), but it just kept on blinking for about 10 minutes. Then I finally got impatient and restarted the Yun. After the restart, there was no WLAN (blue) or USB (white) LED blinking or glowing anymore. I am unable to connect through the Wifi network, the Yun does not create it's own Wifi network and unfortunately when connected via Ethernet, I can still not navigate to arduino.local or 192.168.240.1.
So I have a feeling that somehow only the AVR is still functioning (because I can still upload sketches) and nothing else.
I have updated the firmware to the latest version (OpenWrt-Yun 1.5.3). Is there a way to connect or reset, if the Ethernet does not work? Can I upload a sketch to check in the console if the Linino interface still functions.
Thanks in advance!

I have the same problem. what will be the solution? Please give me in steps. I am in final part of my project and it happened. Pls help me..

As suggested in the correct answer, try to upload the YunSerialTerminal example and open the Serial Monitor to see what's wrong? And if nothing works, you can try http://arduino.cc/en/Tutorial/YunUBootReflash tutorial. But it's a bit tricky I suppose.

Try uploading YunSerialTerminal example, opening the serial monitor and pressing the YUN RST button. You should see the linux side starting.
If it starts but it looks somehow bricked, you could try following the http://arduino.cc/en/Tutorial/YunUBootReflash tutorial.

Hello! Thanks! So I was able to upload the YunSerialTerminal example and I did see the linux start up. But it just gets stuck at the following line: [   32.150000] Kernel panic - not syncing: Attempted to kill init!
I think I'll try to go for YunUBootReflash. I am not very sure how I can try to fix boot-up issues with the linux on the Arduino.

So, it works now! I did not go for a complete re-flash though. I had extended the Yun disk space before - http://arduino.cc/en/Tutorial/ExpandingYunDiskSpace
But just removing the SD card made the linux boot up properly. I just formatted the SD card separately and put it back in. Everything seems to be in order. Thank you again!


text:
Power consumption issue. I made project using atmel-328p
I made project using atmel-328p. I want to run it over a year. I am using power_down mode & 5500 mAh li-ion battery still battery discharges in 1 day. I am using standard code as explain on arduino site.
code is:
String uniqueid;
char value;
volatile int NbTopsFan; //measuring the rising edges of the signal
uint32_t Calc;
int hallsensor = 2;    //The pin location of the sensor
int power = 4;
// ph sensor
define SensorPin 0          //pH meter Analog output to Arduino Analog Input 0
define Offset 0.00            //deviation compensate
unsigned long int avgValue;    //Store the average value of the sensor feedback
// temp sensor
OneWire  ds(8);
byte i;
byte present = 0;
byte data[12];
byte addr[8];
int HighByte, LowByte, SignBit, Whole, Fract, TReading, Tc_100, FWhole;

int wakePin = 3;                 // pin used for waking up
int sleepStatus = 0;             // variable to store a request for sleep
int countsleep = 0;                   // counter

void wakeUpNow()        // here the interrupt is handled after wakeup
{// execute code here after wake-up before returning to the loop() function
 }
void rpm ()     //This is the function that the interupt calls
{
 NbTopsFan++;  //This function measures the rising and falling edge of the
//hall effect sensors signal
}
void setup()
{
 pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
Serial.begin(9600); //This is the setup function where the serial port is
pinMode(power, OUTPUT);
//initialised,
 attachInterrupt(0, rpm, RISING); //and the interrupt is attached
//initialised,
  //and the interrupt is attached
// temp sensor pin 8
        if ( !ds.search(addr))
        {
           //       Serial.println("temp sensor is not connected");
        delay(1000);
        ds.reset_search();
        return;
        }
        if ( OneWire::crc8( addr, 7) != addr[7])
        {
       //      Serial.println("CRC not valid!");
       delay(1000);
       return;
        }
pinMode(wakePin, INPUT);

  attachInterrupt(1, wakeUpNow, LOW); // use interrupt 1 (pin 3) and run function

}

void sleepNow()         // here we put the arduino to sleep
{
  countsleep = 0;
ADCSRA = 0;

   set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here

    sleep_enable();          // enables the sleep bit in the mcucr register
                             // so sleep is possible. just a safety pin
  // turn off brown-out enable in software
  MCUCR = bit (BODS) | bit (BODSE);  // turn on brown-out enable select
  MCUCR = bit (BODS);        // this must be done within 4 clock cycles of above

 sleep_cpu ();

    attachInterrupt(1,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
                                       // wakeUpNow when pin 2 gets LOW

    sleep_mode();            // here the device is actually put to sleep!!
                             // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP

    sleep_disable();         // first thing after waking from sleep:
                             // disable sleep...
    detachInterrupt(1);      // disables interrupt 0 on pin 2 so the
                             // wakeUpNow code will not be executed
}

void loop()
{

  countsleep++;
  delay(1000);                           // waits for a second
// compute the serial input
  if (Serial.available())
  {
    String content = "";
    char character;
// to read serial data coming
        while(Serial.available()>0)
          {
              character = Serial.read();
              content.concat(character);
          }
      String uniqueidread = content.substring(0,16);
      String parameter = content.substring(16,17);
      String checkuuid = content.substring(0,3);
      String putinsleep = content.substring(0,5);
       if (uniqueidread == uniqueid && parameter == "5")
{         //    Serial.flush();
digitalWrite(power,HIGH);
 NbTopsFan = 0;      //Set NbTops to 0 ready for calculations
 sei();            //Enables interrupts
 delay (1000);      //Wait 1 second
 cli();            //Disable interrupts
 Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate

  digitalWrite(power,LOW);
          getTemp();
          delay(1000);
          getTemp();
          //   printTemp();
      Serial.print("Temp is: ");
           if (SignBit)
           {
                Serial.print(" - ");
           }
           if( Whole == 0)
           {
              Serial.print("temp sensor is not connected");
           }
           else
           {
              Serial.print(Whole);
              Serial.print(" C / ");
              Serial.print(FWhole);
              Serial.print(" F");
            }
              Serial.print(", Current Reading = ");
     Serial.print (Calc, DEC); //Prints the number calculated above
            Serial.print(" L/hour");
   phvalue();
            Serial.println("S=m");
              delay(100);
              sleepNow();
}

         if ( content == "sleep")
         {
          Serial.println("S=m");
          delay(100);     // this delay is needed, the sleep
          sleepNow();     // sleep function called here
         }
}

  if (countsleep >= 10)
  {
      Serial.println("T=m");
      delay(100);     // this delay is needed, the sleep
                      //function will provoke a Serial error otherwise!!
      sleepNow();     // sleep function called here
  }
}
      void getTemp()
          {
              int foo, bar;

              ds.reset();
              ds.select(addr);
              ds.write(0x44,1);

              present = ds.reset();
              ds.select(addr);
              ds.write(0xBE);

              for ( i = 0; i < 9; i++) {
                data[i] = ds.read();
              }

              LowByte = data[0];
              HighByte = data[1];
              TReading = (HighByte << 8) + LowByte;
              SignBit = TReading & 0x8000;  // test most sig bit

              if (SignBit) {
                TReading = -TReading;
              }
              Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
              Whole = Tc_100 / 100;          // separate off the whole and fractional portions
              Fract = Tc_100 % 100;
              if (Fract > 49) {
                if (SignBit) {
                  --Whole;
                } else {
                  ++Whole;
                }
              }

              if (SignBit) {
                bar = -1;
              } else {
                bar = 1;
              }
              foo = ((Whole * bar) * 18);      // celsius to fahrenheit conversion section
              FWhole = (((Whole * bar) * 18) / 10) + 32;
              if ((foo % 10) > 4) {            // round up if needed
                   ++FWhole;
              }
            }
void printTemp(void)
{
         Serial.println("");
         Serial.print("Temp is: ");
         if (SignBit)
         {
              Serial.print(" - ");
         }
         Serial.print(Whole);
         Serial.print(" C / ");
         Serial.print(FWhole);
         Serial.print(" F");
}
void phvalue()
{
    int buf[10];                //buffer for read analog
    for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
    {
      buf[i]=analogRead(SensorPin);
      delay(10);
    }
    for(int i=0;i<9;i++)        //sort the analog from small to large
    {
      for(int j=i+1;j<10;j++)
      {
        if(buf[i]>buf[j])
        {
          int temp=buf[i];
          buf[i]=buf[j];
          buf[j]=temp;
        }
      }
    }
    avgValue=0;
    for(int i=2;i<8;i++)                      //take the average value of 6 center sample
      avgValue+=buf[i];
    float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
    phValue=3.5*phValue+Offset;                      //convert the millivolt into pH value
    Serial.print(" pH:");
    Serial.print(phValue,2);
    Serial.print(" ");
}

Welcome to Arduino SE! Can you please elaborate - what your code does, what is the hardware involved, and even post your full code so we could help you

My hardware involve atmel-328p, xbee, temp sensor, water flow sensor & pH sensor. I used xbee to wake up atmel-328p using interrupt. When data receive on serial port of atmel using xbee interrupt break the sleep mode. My code is as follows:

I would suggest editing your question and adding that information, which is crucial for answering your question.

What else info should I provide to you?

We will need schematics of your circuit (preferably not a board wiring made with Frietzing - unless your setup is dead simple) and the relevant parts of your code. Please edit your question to add that information. Thanks!

The schematic should tell us all we want to know, but do you, by any chance, use an Arduino board, such as the Uno? What do you use as voltage regulator? Not a LM7805, I hope. If you do, that's all your mAh are being wasted.

This excellent answer by Anindo Ghosh will tell you more about how to really save energy in your '328 MCU projects.

I am not using voltage regulator. I am connecting 3.7 v li-ion battery directly to +5v & gnd of schematics.

Try doing some measurements. Remove some components and see which one uses what amount of power. Try removing all components to see if your sleep code works (which it maybe doesn't do correctly, as you're calling  sleepmode twice (sleep_cpu and sleep_mode)). PS I'd disable the brownout detection in the fuses. Disabling it using code is very difficult to do right, and the lithium cells protection will kick in way before the brownout detection, so there is no use for it in your case.

What clock frequency are you using? 16MHz? If so, you're running it pretty close to it's minimum voltage for that frequency. Not sure if it is an issue, but maybe your MCU is resetting or running erratically. Anyway, that's probably something to look out for.

I am using 8MHz clock frequency. Internal clock.

Use the divider to reduce your clock further.  Verify you are actually sleepibg.  Make sure none of your resistors or internal pullups have a voltage difference across them, otherwise they are little micro-heaters draining your battery.  Watch out for power lost to (or donated by!) communication/debug interfaces.

You need to first check the individual current consumption of all elements:

pH sensor,
temp sensor,
water flow sensor
xbee.

Since many of these just have an output pin in addition to +V & GND, this means those have a permanent current consumption that, overall, may possibly drain your battery.
You should then check the datasheets for all these components and see the minimum current consumption (and conditions for this consumption to be achieved).
If the total minimum current for these components is too high for your system, then you can possibly:

use an available ATmel digital output pin to power them (and unpower them just before switching the ATmel to low power mode); that's possible only if you stay within current limitations of the MCU (there are current limitation per pin, 20mA IIRC, and total current for the whole MCU)
if current consumption is above ATmel limits then you can still use the method above but add a MOSFET in-between so that you limit ATmel current consumption

I strongly advise you this link from Nick Gammon, which is comprehensive and complete.

Just found out I added this as an answer although I wanted it as a comment (issue of using smartphone with SE...) Sorry for that. I'll try to find time to edit the answer and add some more details then.

OK, Thanks a lot, Now I am trying to measure individual current consumption of all elements, n will update soon. Looking forward for your help and suggestions.

Still battery drains in 24 hours, Now I power only standalone Atmel-328 with 3.7 li-ion cell having 5500 mAh capacity.

I think you should proceed step by step; your current circuit and code are too complex to start with. Simplify them first then perform some checks. In particular, verify that you spend the expected time in power down mode.

Yes, sensor & xbee is draining my battery. I can override with sensor providing power through atmel digital pins. But how can i override xbee power loss because I am using as a external interrupt in my circuit to wake up IC.

For xbee check if there is a low power mode (just like for the atmel); if it exists, check how it can help.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
i2c of Atmega 328 on arduino uno not working
I am using Arduino uno board with Atmega 328 for i2c.
The ic is not showing any clock signal on its SCL line on oscilloscope, The same code when used with different new atmega 328, and same code. It is showing a good clock signal on oscilloscope.
The ic whose i2c is not working can be still programmed and can be used for other purposes like serial communication , adc etc.
So, is there any way by which i can confirm and surely say that i2c of my atmega 328 is fried up. And what can be the possible methods by which it can be fried up.

I think you just did it. I mean, if you tested the new '328 in the very same board and with the same code you had the faulty one, then I think your scope shots just confirmed that the I2C is fried.

Do you have a pull-up resistor attached the I2C lines?

Are you saying you swapped the processor chip on the Uno? Or your working test is a different board altogether? What pin on the Uno are you testing with your scope? Please post your test code.

I2C (SDA-SCL) line needs to be pull up (place resistor on both to 5v input from master- the uno), it works with the arduino code for master-slave I2C (uno on master-severino on slave) using the code from arduino website (just be sure you set the address for the slave on the slave sketch (any number 1-126), it works for me that way, my pull up resistor is 10kohm, the same goes for my breadboard, if this is not doing the trick, maybe there's something wrong (I wouldn't know the answer to, just tried the i2c yesterday) update : on august5th (today) I just finished reading i2c's on atmel site, it is a complex one, there are several factors on why something is doing something on your twi comm, post your code, and maybe I have an answer

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
What's taking up so much RAM in an almost empty sketch?
I wanted to check how much memory (RAM) is used by an "empty" sketch. Here is my code:
int freeRam()
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

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

void loop()
{
}

My result was that I have 1839 bytes of free RAM. I have an Arduino UNO, so there are 2048 bytes of RAM in total. Which means that 209 bytes are already taken. Wait, 209 bytes?! I started thinking and figured out that the Serial buffer must take some space. I've opened HardwareSerial.h and found this:
#if (RAMEND < 1000)
  #define SERIAL_BUFFER_SIZE 16
#else
  #define SERIAL_BUFFER_SIZE 64
#endif

I've changed SERIAL_BUFFER_SIZE to 16 to see what will happen. (I've tried decreasing it to 1, but then the serial communication didn't work properly and I wasn't able to display the amount of free RAM). After this modification my result is 1935. So now "only" 113 bytes are taken. But what is taking this memory? HardwareSerial has 2 buffers:
struct ring_buffer
{
  unsigned char buffer[SERIAL_BUFFER_SIZE];
  volatile unsigned int head;
  volatile unsigned int tail;
};

ring_buffer rx_buffer = { { 0 }, 0, 0};
ring_buffer tx_buffer = { { 0 }, 0, 0};

So when the SERIAL_BUFFER_SIZE is 16 they take exactly 40 bytes. What is taking the remaining bytes (113-40= 73 bytes)? I'm aware that stack frames take some memory - calling main() which calls setup() whichs calls freeRam() probably take a few bytes, but 73 still seems too much.

what version of arduino are you compiling this on?

my version is 1.0.6

First off, a sketch that uses Serial cannot really be considered an empty sketch as Serial drags along a lot of function definitions, at least one Serial class instance (more on Arduino Mega, for instance), plus probably some more global variables...
sizeof Serial may be interesting to display as Serial is not limited to the TX and RX buffers, as you seem to believe. Its class also has a couple of additional data members on its own, plus members inherited from its superclasses, Stream and Print.
In addition, the Arduino IDE comes with the various "utilities" which you normally can't get rid of, like the millisecond timer that uses at least 9 bytes (see reference in wiring.c file).
So in the end, even an empty sketch (even without Serial) takes some SRAM space for global variables.
I think there is some way, with avr-size, to check out, with fine details, the size of data (not accounting for the runtime stack) after the sketch has been fully built.
Arduino IDE already displays some of this static memory information (at the end of "verification").
For example, on my IDE (1.5.8) for Arduino UNO, a really empty sketch, once compiled is mentioned to use 9 bytes of SRAM. Actually those 9 bytes are for 3 global variables, used by the millisecond timer. This number, of course, does not account for runtime memory usage, in particular the stack.
Then, just adding Serial.begin(9600); makes it use 182 bytes (ie 173 more bytes than an empty sketch). So you get the culprit.

I investigated this at some length a while back. On this page about putting constant data into program memory I obsessively tracked down every last byte of memory used in a small sketch. This was the sketch:
#include "memdebug.h"

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  Serial.print (F("Free memory = "));
  Serial.println (getFreeMemory ());
  }  // end of setup

void loop () { }

memdebug.h came from Andy Brown - Debugging AVR dynamic memory allocation.
That particular sketch actually used even more RAM:
Free memory = 1702

So where did the 346 bytes go? Here:

34 bytes for the HardwareSerial instance (Serial)

64 bytes for the Serial transmit buffer

64 bytes for the Serial receive buffer

4 bytes for the Serial transmit buffer head and tail pointers

4 bytes for the Serial receive buffer head and tail pointers

9 bytes for keeping track of millis / micros

4 bytes for memory allocation (__malloc_heap_start, __malloc_margin)

128 bytes for the heap safety margin

6 bytes for a few nested function calls (main -> setup -> getFreeMemory)

16 bytes for the compiler vtable for HardwareSerial

4 bytes for variables __brkval and __flp (used in memdebug)

2 bytes pushed onto the stack in main (to save registers)

2 bytes pushed onto the stack in setup (to save registers)

4 bytes pushed onto the stack in getFreeMemory (to save registers)

1 byte because the stack pointer starts at 0x8FF rather than 0x900
(That's 346 bytes accounted for)

What's a heap safety margin?

The heap and the stack grow towards each other (in opposite directions, one up, one down). Without a safety margin it would be possible to allocate room on the heap, with little or no "spare", and then crash soon afterwards when you call a function. Calling functions uses the stack, which would then encroach into the heap. Effectively the heap would get corrupted, if the stack didn't first (for example if you wrote to the memory in the heap, in the function you called). The heap safety margin gives a buffer zone to (try to) prevent that.


text:
Android <-> HC-05 <-> Arduino communication issue
My project involves Android (Samsung Galaxy 2) to Arduino (Uno) communication via HC-05.
HC-05 is connected to Arduino on pins 10,11 using SoftwareSerial lib.
I got this setup running for a while and was satisfied by the outcome - my bi-directional communication worked fine.
Issue:
I made a change to the communication protocol and now messages sent from Android to Arduino get corrupted. It happens under particular circumstances - when Arduino writes (streams) packets of data to Android and, at the same time, monitors the input from Android for a particular message which signals the end of communication. This message, when read from SoftwareSerial buffer, gets corrupted. This corruption is not consistent - it corrupts the packet in (seemingly) random way.
I've already run many tests and am pretty sure that this message is not corrupted on the Android side.
Questions:

Is there anything about HC-05 or SoftwareSerial lib which prevents
simultaneous bi-directional communication?
Can it be that input/output buffers interfere in some way?
How can I achieve reliable communication using the aforementioned HW and comm scheme?

P.S. I got pretty much code and am not sure what parts of it might be relevant to this issue. Will provide relevant parts per your request.
Thx

As mentioned by @alex.forencich, SoftwareSerial is not designed to support simultaneous bi-directional communication.
I found a link to AltSoftSerial library on Arduino site, and this lib seems to work properly in my setup.
To convert from SoftwareSerial to AltSoftSerial you need to change the pins that HC-05 is connected to (on Arduino Uno these are pins 8,9), and to make this minor change in the code:
//#include <SoftwareSerial.h>
//SoftwareSerial swSerial(10, 11);

#include <AltSoftSerial.h>
AltSoftSerial swSerial;

Another option is to use a separate chip to send and receive. An Attiny87 (picking a random example) has a UART and an SPI interface - it could receive the data via UART, send via SPI to the Arduino; then receive the data from the Arduino and send it via UART. Since the whole chain now has hardware support, you're going to have reliable communications. The data could be buffered on the AtTiny, and raise a signal to the Arduino to say when data is ready.
ATTiny chips are cut-down versions of the ATMega chips used on Arduinos, and they can be programmed over ISP. They can be had for a few dollars.
Yes, this is a lot of extra work.

Software serial ports are a hack and this is the result - random corruption, missed bytes, etc. The reason is that very precise timing is needed for both receive and transmit and it is very difficult to achieve this with the CPU, especially if you want to simultaneously receive and transmit. The problem is that the CPU has to either read the pin or update the pin at exactly the right moment, and the CPU can't do more than one thing at the same time. You can use interrupts, but it is still possible for the TX and the RX to conflict, and there is nothing you can do about it.
The solution is to either never run RX and TX at the same time, use a different serial protocol where this is not an issue (e.g. I2C), or use a hardware serial port. I would suggest using an Atmel XMEGA microcontroller - you can get these with 6 or more independent hardware serial ports.

Got your point - SoftwareSerial is not reliable in these circumstances. It led me to look for an alternative (I can't switch to other micro right now), and it seems that AltSoftSerial lib resolves my issues. Thanks!

Software serial isn't necessarily a "hack" in the microcontroller world; it's a perfectly fine way of doing things if you're careful with your programming. Nor does the timing need to be all the precise, especially for reads, and especially at lower data rates. A 16 MHz ATmega has plenty of horsepower to run several simultaneous 115,200 Kbps software serial links and do some other stuff at the same time, when programmed properly. The main issue here is really more that the Arduino libraries are focused on ease of use for hobbyists, rather being able to put together efficient code.

An alternative to software serial is to use hardware serial.
You can use hardware serial (i.e. supported in hardware by the chip) using pins 0 & 1. You will NOT! be able to do serial communications (e.g. programming your arduino) at the same time - I always make sure I have EITHER usb OR bluetooth serial connected at any given time. USB for power is ok.

This means that I won't be able to send "debug" messages into Arduino IDE when communicating, right? This makes this approach very restrictive (at least for Arduino Uno), since one of the reasons I use Arduino is for debugging the communication protocol and its implementation.

Yes and no - the "debug" messages would come in over Bluetooth. This may be enough. Yes, it is a tradeoff.

Actually, they'd go both over bluetooth and to a connected PC, in the later case mixed with whatever commands and framing keep the BT module happy.

Hey thought I'd pitch in.
I was having quite a few issues in trying to control an led using hc 05 from an android phone.
I was using SoftwareSerial. It didn't work.
The board is an arduino mega 2560.
Finally, I got it. SoftwareSerial turns digital pins to tx and rx com pins.
Make sure to use digital pins on the board to communicate when your using SoftwareSerial.
Hope it helps...


text:
Resetting an Arduino with a timer
I want to run an Arduino autonomously - but although I apply a watchdog sometimes the systems hangs and can only be restarted by physically interrupting the power-supply (or hitting reset). So I need an external source to do that either after x hrs or based on a condition.
Instead of using another Arduino with a MOSFET or relay I am asking myself if this couldn't be done smarter with a pure electronic component like a timer or a capacitor. I could set a pin of the Arduino on high while it is active and let this charge a capacitor or something similar - if the time/energy exceeds a certain amount (because it hangs) this would connect the reset-pin of the Arduino to ground.
Any idea how this could be achieved and what component should be used?

You can buy specific watchdog chips that do this job for you.  You could also probably craft something with a 555 timer which you start timing with a pulse from the MCU and each pulse resets its timing.

-1 for not proofreading at all

Best would be to fix the problem that's making the Arduino hang in the first place. Since you didn't post any code nor schematics, I can only guess that this may be a hidden bug in the code. In normal conditions, ATmegas and Arduinos can run for a long time without hanging. I have a ATmega328P based digital clock running for several months without resetting it.

Sorry for not posting the code - i have it on github link. Besides check on memory consumption etc. what makes me believe it's not a code issue is the fact that i have several of these (identical) devices and the error never seems to show a similar pattern, not in timing and not in shape... But of course i can be wrong, am definitely not an experienced programmer.

The following 555 circuit will produce a 170 ms low-going pulse every 24.2 hours.  You can adjust the values of the components using this calculator if you want different timing parameters.

Since the reset line of a microcontroller is configured for open-drain (meaning you can connect several inputs to it, which is a good thing since we are taking advantage of that), we need to drive it with a open-drain output.  That is what the buffer on the bottom of the circuit is for, to convert the push-pull output of the 555 to open-drain.  A typical buffer is one section of a 7407.

Awesome - really works well and exactly what i was looking for! BUT: would like to try another version where the 555 is used rather as a replacement for the "if anything goes wrong reset" watchdog, meaning: if program execution takes longer than 60sec reset (and while sleeping do nothing). My first attempt failed, tried to power the 555 circuit by a Pin of the Arduino and simply switch it off when sleeping. Any idea how this could be implemented as well?

@StephanNoller Good to hear that worked for you.  Re your new requirement, I would ask that as a new question.

Followed your advice - would be so grateful if you could have a look at this 555 question as well...

Here is the circuit I use which depends on a heartbeat from the arduino and resets the arduino if 8 pulses are missed and also enables the arduino code to know that an external watchdog reset occured

and the Arduino code which can be incorporated into your sketch

//Watchdog
#define ResetDetect 8       // watchdog detect pin, HIGH if a watchdog reset has occured
#define heartbeat 9         // heartbeat pin
int pulseState = LOW;       // pulseState used to set the heartbeat pin
long lastbeat = 0;          // will store last time the heartbeat pin was updated
long HeartBeatFreq = 500;   // interval at which to blink (milliseconds)
boolean ResetHappened;      // Set to true if a watchdog reset has occurred

void setup(){
  pinMode(ResetDetect, INPUT);    // set Watchdog Reset sensing pin as input
  digitalWrite(ResetDetect, HIGH);// and turn on pullup
  pinMode(heartbeat, OUTPUT);     // set the heartbeat pin as output:

    // Check if Restarting after Watchdog Reset
    // NB must come before heartbeat resets external counter
    int ResetSet = digitalRead(ResetDetect);
    if (ResetSet == HIGH){
      ResetHappened = true;
    }
    else {
      ResetHappened = false;
    }
}

void loop(){

  // Heartbeat resets external watchdog when pin goes high
  if ((long)( millis() - (lastbeat + HeartBeatFreq)) >= 0) {
    lastbeat = millis();
    // if the LED is off turn it on and vice-versa:
    if (pulseState == LOW)
      pulseState = HIGH;
    else
      pulseState = LOW;
    // set the LED with the ledState of the variable:
    digitalWrite(heartbeat, pulseState);
  }
}

If there are long running sections of code the 'heartbeat' could be put into a function and that function called in the appropriate places to avoid unintended timeouts/resets

Why not use the in-ship watchdog timer ?
I found in the Atmel ATmega328 (used for example in the official Arduino Uno board) official datasheet some references :
http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf

We can find on page #5 two blocks named "Watchdog Timer" and "Watchdog Oscillator" on the upper left corner. No need of additional circuits, soldering or any connections.
These blocks are bad documented on the Arduino official website but usable (I did it).
Some docs with code examples :

http://sysmagazine.com/posts/189744/
https://tushev.org/articles/arduino/item/46-arduino-and-watchdog-timer

Regards

I am indeed using these functions - but unfortunately - after working like intended for days - the device sometimes hangs nevertheless. That's why i am searching for a more safe fallback-solution now.

@StephanNoller What is your Arduino board type ? Mine is legacy Arduino Uno and I've not found any problem.
If you watch the sysmagazine link, the author give some explanation about a watchdog specific program hang ...:
http://sysmagazine.com/posts/189744/


text:
Lowest power possible in Arduino
I have googled all around and I know about some tricks to make ATmega328 not being a power hog. I am using Arduino Nano V3.0.
However, I didn't find out what is the minimal consumption possible with it?
My project consists of an Arduino that will wake up each 10 seconds and, by bluetooth (BT) will scan for existing devices, and if one specific device is not listed, it will lit a LED for 5 seconds and then go to sleep again.
In sum:

Sleep for 10 secs
Wake up
Scan for BT devices
If device ABC is in the list go to 1.
Lit LED
Delay 5 secs
Go to 1.

For bluetooth I will use NRF8001, because it is the most efficient BT module I know so far.
Can you give me some ideas of what tricks should I use to make this ATmega328 and BT module last like one year with a 500mAh battery? Has anyone tried this that can share his experience? Is ATmega328 the right uC for this? I am using it just because I already have code/libraries for it.

Creating the new tag 'nrf8001' requires at least 150 reputation. Try something from the existing tags list instead.

The best I've seen on Arduino power consumption: http://www.gammon.com.au/power You can get the ATmega current draw down to 100 nA in "power down sleep mode"; the rest depends on the other parts of your circuit and what percentage of the time you can stay asleep. You may want to rethink your LED: If you light a 20 mA LED for five seconds out of every 10 seconds, 50% "on" time, the LED alone will drain 500 mAh in 50 hours. The guy in the link found that flashing a LED for 5-10ms once a second was enough to make it visible.

It's worth checking if you may do better with an nrf51822 which is a combination processor & BLE, and no ATmega.

One year = 8765 hours. So average drain for 1 year life from 500 mAh = 500 mAh/8765h = 57 uA average. | An efficient modern LED is usefully bright at 1 mA and probably at 0.1 mA. [Best LEDs are 30 Cd+ at 20 mA so 150 mCd mean at 0.1 mA and your eye-brain sees more like the peak.  | 0.1 mA at 1% duty cycle for one year = 8765 x 0.1 x 1/100 = 8.765 mAh or about 2% of your battery capacity.

The issues regarding efficiency of power are:

The CPU speed
The Voltage
The Power Regulator (not supply)
The Peripherals

Address each one of these and don't over look any of them. Or any sub component. But note that some are more impacting than others.

while it is possible to lower the speed, It is more practical to just sleep. As you have indicated you are going to do.
Running at 3V instead of 5V is a big savings. Note that the 328 can run as low as 1.8V
DON'T use Linear Regulators. Most all Arduino's have a 7-12V to 5V(or 3.3V) Linear Regulator. This just burns the difference between the supply (aka battery) and the VCC, used.
pay attention to the peripherals. Likely this means getting rid of not needed devices. Example the USB to Serial chip that exists on the Nano. What is the lowest voltage can the radio run at? Must it run at a regulated voltage. Use the largest possible resistor values. Such as on pull ups. A 500K pull up will draw less current than a 10K. Where if too big any capacitance may slow it down. Which is likely acceptable.

One of the biggest savings is running directly off of the Battery without a Linear Regulator. Where the ATmega328P can run from 3V down to 1.6V. It would be recommend to use the Brown Out detector.
Also note that ALL batteries have a self discharge rate.  This will determine the maximum possible life of the battery, then minus your devices consumption.

Read the link in @j-g-faustus 's comment - very thorough. http://www.gammon.com.au/power - it starts with a stock board running at 50milliAmps and ends up at 0.002 milliAmps.
You will also need to find out the power consumption for your BT module - this may dwarf the power arduino's power consumption. The same goes for the LED.
Normal LEDs run at about (ballpark!) 20 milliamps - this means that on the coin battery mentioned by @Omer, 200milliAmp-hours/20 milliAmps = 10 hours of led light.
You can measure the power draw with a multimeter; stick your probes between the + of the battery and whatever the battery would normally connect to (you will have to disconnect the battery of course) - if using a 9v battery, plug in the negative, disconnect the positive, turning the snap connector 90 degrees; then you can put one probe on the battery, the other on the (open) snap connector. Measure Arduino awake + led on + BT connected and sending data. Measure again with everything off/idle/sleeping. Work out how much time it will spend in each state; this will give you an average number of milliamp-hours.

These are essentially notes in support of other answers:
One year = 8765 hours.
So average drain for 1 year life from 500 mAh
= 500 mAh/8765h
= 57 uA average.
To get one year on a 500 mAh battery you need to have average drain under say 50 uA
An efficient modern LED
is usefully bright at 1 mA and
probably very acceptable at 0.1 mA.
Best LEDs are 30 Cd+ at 20 mA
so 150 mCd mean at 0.1 mA
and your eye-brain sees more like the peak.
0.1 mA at 1% duty cycle for one year
= 8765 x 0.1 x 1/100
= 8.765 mAh
or about 2% of your battery capacity.

Easy Very Low Power BLE in Arduino covers using Arduino IDE and nRF52832 chips to code very low power projects, i.e. <100uA continuously, waiting for connection or while connected and sending data.
The <100uA current is at max tx power and can be further reduced by reducing Tx power and increasing the advertising and connection intervals.  Ignoring the LED, you should be able to get close to the 1year on a 500mAH battery.
Currently working on adding two small solar cells (50mm x 30mm) to extend battery life.  These cheap cells ($0.60) don't need full sun and work well in the shade or out of the sun near a window or under a desk lamp.

Lowest possible power consumption for an Arduino is 0mA - just disconnect it's Vcc :)
And seriously, when there are many factors involved, it is hard to include all of them into the proper equations, considering different factors that affect the current consumption such as temperature, humidity, quality and distance of the wires etc. Best would be to perform measurements of the power consumption for, say, several cycles of steps 1 to 7, and do the average.
Remember that the ATmega chip will draw more current depending on the voltage, so you might want to keep voltage as low as possible.
Here is a nice project of an ATtiny (Arduino alike) that runs on a coin CR2032 battery (~200mAh) for 220 days until it died, while wirelessly broadcasting the results and the measurements of the battery discharge rate, so you could actually achieve pretty good results working with a 500mAh battery.

For simple applications like this, you might find it more convenient to use a smaller board/MCU from the Arduino system. For example the Digispark uses an ATtiny85 rather than the standard ATmega328P. It's not clear that the MCU itself would use much less power (it's pretty much the same CPU core, after all, though you are powering less RAM) but the board has only the one MCU and the regulator on it. You can still power it from and program it via USB (at 5 V) for development, but for production use you can (as others have mentioned) provide 1.8 V power on the VCC line, ignoring the regulator, and you will not have to worry about the power usage of things like the USB interface (an FT232 on the Nano, but a whole second microcontroller on some other boards!) and other parts on the Nano.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How to "implement" an Arduino prototype?
I am starting with Arduinos, coming from the world of Linux (with the RPi as a bridge) and after having tested some setups I now wonder where to go next in implementation.
What I am trying to understand is whether it is recommended (time and cost-wise)

to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup?
or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?

I expect to build 5 or 6 of the same simple setups (to put in various places in my house).
Note: there is a similar question (with almost the same title) but it deals with the legal aspects of commercializing a setup.

You might be able to make it cheaper with a PCB, but I gather you've probably never done a PCB layout before? In that case you'd probably need to pay someone (likely much more expensive) or have a large learning curve and probably a few failed PCBs along the way. Either way it might be worth adding a few more details on how complex it is (or even better a circuit), there might be a few proto board techniques that are somewhere in between.

Isn't making a PCB pretty expensive? If the setups are that simple, you could just use a stripboard to make the circuits. Cheap and easy.

A lot depends on how complex your breadboarded circuit is. The natural permanent version of a breadboard is stripboard/Veroboard; if you don't need "shield" compatibility then Arduino Nano and its clones are probably a good choice.

Thank you for the answers, the stripboard/Veroboard will be the solution as my circuit will be very basic. Can you please turn your comment into an answer so that I can accept it?

If you can wait ~10 days, 3 boards from someone like OSH park might cost you $20 or so, depending on how big you make them.

Unfortunately, this is yet another improper migration from EESE.  The question is about electronics fabrication, and so belongs there where it was quite correctly asked.  It has been dumped here, where it is cut off from relevant expertise, purely due to bias against anything which tangentially mentions arduino, despite the fact that it is not in any meaningful way an Arduino question.

@ChrisStratton 1. Fear not :-). 2. Arduino's look fine to me when used appropriately. and there seem to be many places where they are appropriate but not used. - I'm just finishing a one off "Bubble Tube" controller for a school to replace an old expensive obsolete one that disintegrated (and program code for IC used not available). No prizes for guessing what the controller is based on.

with the breadboard

That phrase right there makes the solution a non-starter. Solderless breadboards are good for prototyping, but are too fragile for use in a final project.
As for whether or not you should use an actual Arduino or reduce the circuit to a minimum, that is between you and your wallet. It is possible to make a basic AVR board (including MCU) for under $6 in parts, but the time investment is not entirely trivial.

I started using an Arduino (Uno), and a solderless breadboard, to do my prototyping.
After the 2nd project, I started programming the Arduino, then pulling the AtMega chip off the board (if you have a through-hole chip rather than a surface mount one) and plugging that into my breadboard (you will need some supporting circuitry for this - a clock and a powersupply e.g. batteries). The AtMega has a larger range of voltages than the Arduino, and can be run up to 20mhz. You will need to jiggle some constants for this, or be ready for your delays to run quicker too.
I have since bought an USBISP (see Google), which can be hooked up to the Arduino board (there is a 6 pin header made for this, on the opposite side to the USB), or can be hooked up to specific pins. With this, I have started programming AtTiny chips - smaller, easier to set up, fewer pins to interface with, and really, really cheap!
All my long-term projects are on veroboard (see Google) - solder everything on, then cut it to the size you need. It's worth spending time before you solder working out your layout.
If you want to produce these in bulk, I would suggest getting some prototypes on veroboard first (you will, invariably, make changes once you start testing!), then when you're happy, you can copy the veroboard design (possibly tweaking it to optimize for greater flexibility), and order PCBs from a company that does this sort of thing.
Good luck!

What I am trying to understand is whether it is recommended (time and cost-wise) to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup? or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?

Given what is available in assembled form, using a complete commercial product per project would make most sense except where you are building in substantial volume.
Because ...
I am using Arduino Nano 3s from China which cost me $US3 each in quantities of 10 with free postage (takes 2 to 3 weeks to arrive here at the bottom of the world) and I see that the same people are now charging $2.85 each in 10's. There are numerous suppliers of similar products and I am only mentioning these as I have had good results from them and the quality is acceptable.
You would probably have trouble buying just the parts for the cost of a $3 assembled working Nano and you'd need to cost your time at $0/hour. Building your own for the experience, or if you are using many and you want a cut down subset and really must get the price well under $3 MAY make sense.
The same people also sell an Arduino Pro mini for $US1.85 in 10s free postage (ie $18.50 for TEN). You need to use a plug in USB module to program these via USB. I bought some of these as well - also good, but the convenience of the always available USB makes the Nano preferable (to me).
Note: USB cables cost extra !!! :-)

Related:
Some people have expressed reservations about buying Asian source Arduinos and suggest people should support either US fronted companies or the Arduino's originators.
I appreciate the merit of supporting the people who have put the effort into the system, but the system is very very consciously open source in all respects - and in fact code samples that come with the IDE are expressly Public Domain. (Documentation is CC by SA ...). If open source is to be truly meaningful it needs to be able to survive being truly so. Unlike many other products where Asian copies may have suspect IP legacies, the Arduino products are wholly legitimate (as far as I know).
I have not pored over them in detail (yet) but I note that the 5V voltage regulator on the Chinese ones is an LM1117 (LDO LM317-like) as opposed to the original LM2940. The USB bridge ICs are, as is well known, not "genuine" FTDI parts but Asian semi-equivalents which, with their own drivers, work well enough in this context.
You can certainly buy low cost rubbish versions from Asian sources, and part of the open source tradeoff is deciding where you do and don't get value for money overall.

"The same people also sell an Arduino Pro mini for $US1.85" I think you meant $18.5

@Marla - No & yes. They are $US1.85 each or $18.50 for 10 with free postage. The link is to a batch of 10.

I too have a box of Chinese Arduinos - they all work, perfectly, and are indeed cheap as, well, chips! I have some Italian ones too, I've lost track of which are which.


text:
Does the map() function works on an ATtiny85?
I have a working project on Arduino Uno.Now I want to shrink my project using an ATtiny85. Before purchasing an waiting for the shipment to arrive, I want to make sure that my whole code will run on ATtiny85.
specialy, will the map() function which is working on  an Arduino Uno ( ATMEGA328P-PU ),  work with a ATtiny85 Microcontroller?

You don't need to have the hardware in hand to try building code for it.

The map function uses integer arithmetic, and since the ATmega series and the ATtiny series use the same 8-bit AVR instruction set, there should be no difference when using it, and you are good to go from that aspect.
Consider that there are many other differences regarding I/O pins, storage etc. - that you might want to consider. Here is a good source for a basic comparison between the ATmega based Arduino to ATtiny85.

Here is the code that implements the map function


text:
Arduino + WizFi 210 (WiFi) HTTP POST
I would like to do an HTTP POST to Carriots. I saw a few tutorials.
Both of them are using ethernet instead of WiFi. I realize the ways of using Arduino WiFi shield and WizFi Shield are a bit different. What do I need to do to run a basic server using the WizFi Shield?
Code:
/******************************************************************
 WizFiShield Web Client Test Example
*****************************************************************/

// WizFiShield communicates using SPI, so include the SPI library:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SPI.h>
#include <WizFi2x0.h>
#include <WizFiClient.h>
#include <TimerOne.h>

#define SSID    "EricLeong3"        // SSID of your AP
#define Key     "ericChoong91"  // Key or Passphrase
// Wi-Fi security option (NO_SECURITY, WEP_SECURITY, WPA_SECURITY, WPA2PSK_SECURITY)
#define Security        WPA2PSK_SECURITY
#define APIKEY  "xxxxxxxxx" // Replace with your Carriots apikey
#define DEVICE  "fypSensors@eric3231559.eric3231559"

WizFi2x0Class myWizFi;
WizFiClient myClient;
TimeoutClass ConnectInterval;
boolean Wifi_setup = false;

///////////////////////////////
// 1msec Timer
void Timer1_ISR() {
  myWizFi.ReplyCheckTimer.CheckIsTimeout();
}
//
//////////////////////////////

void setup() {
  byte retval;
  Serial.begin(9600);
  Serial.println("\r\nSerial Init");
  // initalize WizFi2x0 module:
  myWizFi.begin();
  ConnectInterval.init();
  // Socket Creation with Server IP address and Server Port num
  myClient =  WizFiClient("82,223,244,60", 80);
  // Timer1 Initialize
  Timer1.initialize(1000); // 1msec
  Timer1.attachInterrupt(Timer1_ISR);
  myWizFi.SendSync();
  myWizFi.ReplyCheckTimer.TimerStart(3000);
  Serial.println("Send Sync data");
  while(1) {
    if(myWizFi.CheckSyncReply()) {
      myWizFi.ReplyCheckTimer.TimerStop();
      Serial.println("Rcvd Sync data");
      break;
    }
    if(myWizFi.ReplyCheckTimer.GetIsTimeout()) {
      Serial.println("Rcving Sync Timeout!!");
      // Nothing to do forever;
      for(;;)
      ;
    }
  }
  ////////////////////////////////////////////////////////////////////////////
  // AP association
  while(1) {
    retval = myWizFi.associate(SSID, Key, Security, true);
    if(retval == 1) {
      Serial.println("AP association Success");
      Wifi_setup = true;
      break;
    } else {
      Serial.println("AP association Failed");
    }
  }
}

void loop() {
  Serial.println("apleleee ");
  uint8_t retval;
  retval = myClient.connect();
  if(retval == 1) {
    String json = "{\"protocol\":\"v2\",\"device\":\""+String(DEVICE)+"\",\"at\":\"now\",\"data\":{\"Air Temperature\":\"58\",\"Humidity\":\"59\"}}";
    Serial.println("Connected! ");
    //myClient.write((byte *)"GET /search?q=WizFi210 HTTP/1.0\r\n\r\n");
    myClient.write((byte *)"POST /streams HTTP/1.1");
    myClient.write((byte *)"Host: api.carriots.com");
    myClient.write((byte *)"Accept: application/json");
    myClient.write((byte *)"User-Agent: Arduino-Carriots");
    myClient.write((byte *)"Content-Type: application/json");
    myClient.write((byte *)"carriots.apikey: ");
    myClient.write((byte *)APIKEY);
    myClient.write((byte *)"Content-Length: ");
    byte thisLength = json.length();
    myClient.write(thisLength);
    myClient.write((byte *)"Connection: close");
    myClient.write((byte *)"");
    myClient.write((byte *)"{\"protocol\":\"v2\",\"device\":\"");
    myClient.write((byte *)DEVICE);
    myClient.write((byte *)"\",\"at\":\"now\",\"data\":{\"Air Temperature\":");
    myClient.write((byte *)"58");
    myClient.write((byte *)",\"Humidity\":");
    myClient.write((byte *)"59");
    myClient.write((byte *)"}}");
  } else
    Serial.println("Connection Failed");
  }

The response I get on the serial monitor
Serial Init
Send Sync data
Rcvd Sync data
AT

Rcvd Reply: [ERROR]
[ERROR]
Timeout  with ERROR reply
AP association Failed
AT

Rcvd Reply: õAT
õAT
-1

Rcvd Reply: [ERROR: INVALID INPUT]
[ERROR
INVALID
INPUT]
-1

Rcvd Reply: AT
AT
-1

Rcvd Reply: [OK]
[OK]
ATE0

Rcvd Reply: ATE0
ATE0
-1

Rcvd Reply: [OK]
[OK]
AT+XDUM=0

Rcvd Reply: [OK]
[OK]
AT+BDATA=1

Rcvd Reply: [OK]
[OK]
AT+WD

Rcvd Reply: [OK]
[OK]
AT+WM=0

Rcvd Reply: [OK]
[OK]
AT+WPAPSK=EricLeong3,ericChoong91

Rcvd Reply: Computing PSK from SSID and PassPhrase...
Computing
PSK
from
SSID
and
PassPhrase...
-1

Rcvd Reply: [OK]
[OK]
AT+NDHCP=1

Rcvd Reply: [OK]
[OK]
AT+WA=EricLeong3

Rcvd Reply:     IP              SubNet         Gateway
    IP              SubNet         Gateway
IP
SubNet
Gateway

Rcvd Reply:  192.168.1.42: 255.255.255.0: 192.168.1.1
 192.168.1.42: 255.255.255.0: 192.168.1.1
192.168.1.42
192.168.1.42
255.255.255.0
255.255.255.0
192.168.1.1
192.168.1.1

Rcvd Reply: [OK]
[OK]
AP association Success
apleleee
AT+DNSLOOKUP=82,223,244,60,3,5

Rcvd Reply: [ERROR: INVALID INPUT]
Token: [ERROR

May I know what's wrong with the code? Why does it show a token error instead of success? What I am trying to do is posting an HTTP POST request to Carriots, which is a place to do my m2m things. I am still wondering which part I am missing. I referred to few sources such as
http://forum.carriots.com/index.php/topic/61-wireless-gardening-with-arduino-cc3000-wifi-modules/page-2
https://github.com/Wiznet/WizFiShield

Welcome to Arduino SE. I'm sorry we can't provide general tutorials here. Is there a specific issue you're struggling with?

@PeterR.Bloomfield I had edit the question.hopefully i can get some help here

What he meant was asking for a tutorial somewhere is generally not accepted since we strive to be the information, not a collection of links. I edited your question to narrow it down a bit...

The library provides an example for a server.
Here's what it looks like:
/******************************************************************
 WizFiShield Web Server Test Example

 A simple web server that shows "Hello World" string

 Circuit:
 WizFi2x0 connected to Arduino via SPI

 RST: pin 2  // Output
 DRDY: pin 3  // Input
 CSB: pin 4  // output
 MOSI: pin 11  // output
 MISO: pin 12  // input
 SCK: pin 13  // out

 Created 27 Sep. 2012
 by James YS Kim  (jameskim@wiznet.co.kr, javakys@gmail.com)

 Modified 27 May. 2013
 by Jinbuhm Kim  (jbkim@wiznet.co.kr, jinbuhm.kim@gmail.com)
*****************************************************************/

// WizFi210 communicates using SPI, so include the SPI library:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SPI.h>
#include <WizFi2x0.h>
#include <WizFiClient.h>
#include <WizFiServer.h>
#include <TimerOne.h>

#define SSID    ""        // SSID of your AP
#define Key     ""  // Key or Passphrase
// Wi-Fi security option (NO_SECURITY, WEP_SECURITY, WPA_SECURITY, WPA2PSK_SECURITY)
//#define Security        WPA_SECURITY

#define MAX_SOCK_NUM    4

unsigned int SrcPort = 80;

WizFi2x0Class myWizFi;
WizFiClient myClient[MAX_SOCK_NUM];//(SIP, ServerPort);
WizFiServer myServer(SrcPort);

boolean Wifi_setup = false;

///////////////////////////////
// 1msec Timer
void Timer1_ISR()
{
  myWizFi.ReplyCheckTimer.CheckIsTimeout();
}
//
//////////////////////////////
void setup() {
  byte retval, i;

  Serial.begin(9600);
  Serial.println("\r\nSerial Init");

  for(i=0; i<MAX_SOCK_NUM; i++)
    myClient[i] =  WizFiClient();

  myWizFi.begin();

  // Timer1 Initialize
  Timer1.initialize(1000); // 1msec
  Timer1.attachInterrupt(Timer1_ISR);

  myWizFi.SendSync();
  myWizFi.ReplyCheckTimer.TimerStart(3000);

  Serial.println("Send Sync data");

  while(1)
  {
    if(myWizFi.CheckSyncReply())
    {
      myWizFi.ReplyCheckTimer.TimerStop();
      Serial.println("Rcvd Sync data");
      break;
    }
    if(myWizFi.ReplyCheckTimer.GetIsTimeout())
    {
      Serial.println("Rcving Sync Timeout!!");
      return;
    }
  }

  ////////////////////////////////////////////////////////////////////////////
  // AP association
  while(1)
  {
    byte tmpstr[32];

    retval = myWizFi.associate(SSID, Key, Security, true);

    if(retval == 1){
      myWizFi.GetSrcIPAddr(tmpstr);
      Serial.println("WizFi2xo AP Associated");
      Serial.print("MY IPAddress: ");
      Serial.println((char *)tmpstr);
      Wifi_setup = true;
      break;
    }else{
      Serial.println("AP association Failed");
    }
  }

  if(myServer.begin())
    Serial.println("Server Listen OK");
  else
    Serial.println("Server Listen Failed");
}

void loop()
{
  uint8_t retval, i;
  byte rcvdBuf[129];

  memset(rcvdBuf, 0, 129);

  if(Wifi_setup)
  {
    myWizFi.RcvPacket();
    for(i=0; i<MAX_SOCK_NUM; i++)
    {
      if(myClient[i].available()){
         retval = myClient[i].read(rcvdBuf);
         if(retval > 0)
         {
           Serial.print("CID[");
           Serial.print((char)myClient[i].GetCID());
           Serial.print("]");
           Serial.println((char *)rcvdBuf);

           if((rcvdBuf[retval - 1] == 0x0A) && (rcvdBuf[retval - 2] == 0x0D) && (rcvdBuf[retval - 3] == 0x0A) && (rcvdBuf[retval - 4] == 0x0D))
           {
             Serial.print("Receiving Completed");
             myClient[i].write((byte *)"HTTP/1.1 200 OK\r\n");
             myClient[i].write((byte *)"Content-Type: text/html\r\n");
             myClient[i].write((byte *)"\r\n");
             myClient[i].write((byte *)"Hello World !\r\n");

             delay(100);
             myClient[i].disconnect();
           }
         }
       }
    }
  }
}

Using the WizFiServer class, it seems to assign a WizFiClient instance to each HTTP socket connection. It can then call clientName.write( /* Data to be sent to client */ ); and clientName.read(); to get values.
Once it is done with the client, it can free up resources by calling clientName.disconnect();.


text:
SIM900 GRPS Shield Power down over issue AT+CIICR cmd(Bring Wireless Coms)
I'm trying to get the TinySine SIM900 GPRS Shield working to get data over the GPRS network, using Arduino MEGA.
I'm Able to register my SIM with this Shield and even , but as soon as I sent the command AT+CIICR to Bring up the Wireless Coms, the Shiled powers down, all LEDs are OFF except the Red one.
What is the source of the Problem?
Thanks

Maybe you could start with showing the code of your sketch so we have a chance to see what might not be correct?

The SIM9000 shield requires up to 2 Amperes to operate its wireless functions. Thus it must be powered from an external 9 Volt power supply, and the supply should be able to supply at least 2 Amperes, preferably more.
The shield will thus not work if powered through the Arduino, or using a low current external supply. The current draw for initial setup is low, hence registration of the SIM might be fine. Enabling wireless pushes the current draw beyond what your supply can cope with. This is shutting your setup down.
Replace (or use) a 2 Amperes or better 9 Volt DC power supply, feed this power to the shield, not the Arduino, and attempt your code again.
Note that there are some changes required in using an Arduino Mega instead of the Uno with the TinySine GPRS shield, which are described in the help files and on some example videos on YouTube.


text:
Arduino screws up trivial program involving enum
Behold this insanity:
enum WhatArduinoIs {
  Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed
};

void TellMe(WhatArduinoIs pls) { }

void setup() { }
void loop() { }

I'm pretty good at C++, so I'm fairly sure that should compile. However I get this error:
sketch_jan21b.ino:3:13: error: variable or field 'TellMe' declared void
sketch_jan21b.ino:3:13: error: 'WhatArduinoIs' was not declared in this scope
Error compiling.

I've encountered the Arduino "IDE"'s propensity for insane and totally unrobust modification of programs before. Specifically when you #include libraries Arduino only magically adds the relevant C++ files if the #include is in your main sketch. #include <LiquidCrystal.h> in another C++ file? Link errors.
I suspect in this case it is Arduino magically trying to add function declarations to the start of the file so their order doesn't matter. I.e. it turns the file into this:
void TellMe(WhatArduinoIs pls);

enum WhatArduinoIs {
  Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed
};

void TellMe(WhatArduinoIs pls) { }

void setup() { }
void loop() { }

That obviously doesn't work. How can I tell Arduino to leave my damn program alone?

You can workaround the issue by putting your enum and function into a namespace. You can even take advantage of C++ unnamed namespaces if you like:
namespace
{
  enum WhatArduinoIs {
    Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed
  };

  void TellMe(WhatArduinoIs pls) { }
}

void setup() { }
void loop() { }

It's annoying (as are many things in the Arduino IDE), but it seems to work.
If you're more experienced with programming then you might want to consider using a 3rd party IDE with an Arduino plugin, such as Eclipse. The Arduino IDE is really only designed for beginners.

Or even something like Geany with (or without) Ino.

Thanks! I was going to say the only thing worse than Arduino's IDE is Eclipse, but I think actually I think even Eclipse might be better! I strongly prefer Qt Creator - I use that for mBed. I may have to finally set up Arduino in it. The problem is many details of Arduino's build system are hidden in Arduino.exe so it is a pain to set up any other IDE. Didn't know Eclipse had an Arduino plugin though.

There is also the free Atmel Studio Ide. It supports professional programming features like multiple source files, SVN and the AVR dragon debugger.

This is something that is getting fixed. Try the IDE linked here https://github.com/arduino/Arduino/pull/2729. The sketch will compile just fine.

Or you could just use a plain Makefile. There are a couple of generic Arduino Makefiles floating around, that do almost all the IDE does, except messing with your source.

You seem to be correct about what the arduino IDE is doing to your sketch.
Arduino will not preprocess any .h or .cpp files, so you could use a second file. you could also break the IDE's function locating regex with a dummy throw() statement like this:
void TellMe(WhatArduinoIs pls) throw() { }

The dummy throw allows it to compile for me on 1.5.8

All you need is a function prototype. I have a detailed explanation at Classes and objects: how many and which file types I actually need to use them?
So, this compiles:
enum WhatArduinoIs {
  Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed
};

void TellMe(WhatArduinoIs pls);  // prototype
void TellMe(WhatArduinoIs pls)
  {
  }
void setup() { }
void loop() { }

Off-site reference: How to avoid the quirks of the IDE sketch file pre-preprocessing


text:
Arduino PWM Frequency - Pros and Cons of Modifying
I am interested in using an Arduino Uno to produce an analog signal by running PWM through an RC low-pass filter.
I'll be controlling a highly dynamic object and need a clean voltage signal to avoid instabilities.  Per this calculator on RC designs, it's suggested that one strategy to reducing voltage ripple is to increase the PWM frequency.
With PWM configured to a default of 980Hz for pins 5 and 6, and PWM of 490Hz for the remaining pins, I've decided that this will create too much voltage ripple for my filter.  I've found resources that describe how to configure the registers to increase the PWM frequency rather drastically.
My question is very simple: Are there any disadvantages to using a higher frequency PWM?  Why is the default set to be so slow?
Thank you!

Aside from the clock (if using timer0), the only consequence seems to be in how the components you drive with the PWM handle the frequency. Some might heat up a bit more, and/or jitter less. Burning lasers may yield slightly different results.Ignacio makes a good point about servos, too.

A PWM frequency of 490Hz means a period of approximately 2.041ms. This allows a high period of 2ms, which is the maximum pulse length required by a large number of inexpensive servos. Obviously if your design uses no servos then this is not a consideration.
Timer 0 itself is used for the various Arduino timing functions (delay(), millis(), etc.), so if you change the frequency used for timer 0 then those functions will no longer have accurate results.

timer 0 is used for pins 5 and 6. So you better go with pins 9 and 10 (timer 1), or 3 and 11 (timer2), as to not break functions like delay, millis etc.


text:
Replacing the Voltage regulator of a fried Arduino
I accidentally fried my Arduino. I found this Instructable. The symptoms are the same. The board not powering on connecting USB source and the over current protector was heating up. So I removed the voltage regulator as mentioned in the Instructable. But the problem is the pins 1 and 2 of where the regulator used to be are still shorted out. That is even after removing the regulator, the pins seem to be somehow internally shorted. I tried checking the continuity on another working Arduino and found it to be not shorted. What seems to be the problem?

The problem that something else on the board is fried as well. Maybe the MCU itself. It would be easier to buy a new one, I guess...

You should try running it off a separate 5V supply to see if the other parts are damaged as well.

@IgnacioVazquez-Abrams As I understand, the Vout of the regulator (i.e. 5V) pins are shorting, so it is impossible to connect external 5V to such a setup unless the short is resolved.

What board are you using? Mega like in the instructable? Try checking the caps. Are there any visible anomalies? Charred traces e.g.

I checked if the MCU was damaged by installing it on another board and found it to be not damaged - @EugeneSh. I am Using Arduino UNO not Mega. I found no visible damage.

I know it's an old thread, but others are likely to have this problem.  If you check the open source schematics, there are a couple of nearby capacitors that connect pin 1 (GND) to pin 2 (+5V) of the regulator.
I would check C2 and PC2 (top right of the diagram) as well as C1 (top left of schematic diagram), and any other components you can find that bridge the rails between +5V and ground.  Capacitors are more likely to fail shorted than many other components.  You will have to remove at least one pin of each capacitor to test it since you don't know where the short is, or you can simply remove capacitors until the short goes away.


text:
Sending data from processing to arduino
I have problem to send data from processing to arduino mega.
Processing Code :
import processing.serial.*;

Serial myPort;

void setup()
{
println(Serial.list());
String arduinoPort = Serial.list()[0];
myPort = new Serial(this, arduinoPort, 9600)
}

void draw()
{
byte a= 3;
myPort.write(char(a));
}

Arduino Code :
#include <Servo.h>
#include <Wire.h>

Servo myservo1;
Servo myservo2;

void setup()
{
Serial.begin(9600);
myservo1.attach(9);
myservo2.attach(10);
myservo1.write(90);
myservo2.write(90);

}

void loop()
{

if(Serial.available()>0){
myservo1.write(70);
myservo2.write(70);

}

}

Code is really simple, processing send a value to trigger arduino mega turning 2 servo
motors.
But it doesn't response at all..
Please help if anyone has any clue.
Thanks :))

Some things to try: 1) Send the output from Processing to a terminal to check that Processing does what you think it should do. 2) Send the "correct" text to the Arduino from a terminal to check whether correct text will cause the proper response. 3) Put one or more LEDs on your board and light them when significant things happen such as receiving any text, attempting to control the motors, etc. 4) Keep on testing smaller and smaller parts of the system until you identify something that behaves differently than you intended it to. Fix that and try again.

Thanks a lot Robert! Finally I realized its because I didnt add delay after every time sending data to arduino..


text:
How do I connect two slaves of same type in I2C?
I am not experienced about I2C communications, but I do happen to have two HMC5883L magnetometer modules that I wish to connect to a single arduino. It uses I2C protocol, and hence the slave device will have a fixed address. Now Can I change the address of one of my sensors so that the Arduino can differentiate between the two? (I seem to find no way out by reading the datasheet)
Thanks in Advance
Siddharth Jha
P.S. Can an MPU 6050 module be used to find angle of rotation in X-Y plane (Parallel to the ground)?

Just take a look at the datasheet for this component. Typically, when a component is likely to exist in several instances on the same I2C bus, then that component has a way to select one among a few addresses; that's typically done through little switches on the board (or possibly by soldering a short somewhere on the PCB).

The problem is with the magnetometer:
"The HMC5883L has a fixed I2C address, you can only connect one sensor per microcontroller!"
Wiring and Test
Also, it says it in the specs on page 2:
 I2C Address
8-bit read address 0x3D
8-bit write address 0x3C
3-Axis Digital Compass IC HMC5883L
Low cost magnetometers appear to have fixed I2C addresses. One solution would be to get a different one in addition to yours. For example, the MAG3110 has I2C address 0x0E and the FXMS3110CDR1 has I2C address 0x0F.
Xtrinsic MAG3110 Three-Axis, Digital
Magnetometer
More information on this page:
How to connect multiple of the same device to an Arduino using I2C?
P.S. You are more likely to get an answer to your second question by posting it separately (and help others in the process).

You can't change the address. You could connect it to some other pins, and bit-bang the I2C protocol.
Or connect the vcc of the unit to an arduino pin, so you can turn it on and off.

Enabling only one device is a good idea; doing it by switching Vcc usually isn't.  In addition to possible startup time, generally speaking IOs should not exceed the supply voltage except where it is documented that is allowed.

Good point. You could add a some buffer logic, but that would make it a bit more complicated.


text:
Are Arduino's truly OSH?
I keep reading how Arduinos are "open source", but my understanding of OSH is that all its components must be open source.
Arduino uses an Atmel 8-bit CPU - but Googling this shows the Atmel is proprietary!?
So I ask: how can Arduino be OSH if it's chief component - its Atmel CPU - is proprietary?!?

I don't think a discussion of the nuances of the term OSH really belongs here; Maybe on the arduino forum?

Thanks @BrettM (I'd upvote your comment if I had the rep to do so) - sorry, I thought this was an Arduino "forum" (well, Q+A site). Also, I'm not really asking about the nuances of OSH, I am straight-up accusing Arduino of advertising as something that it's not! If I say, "I am selling a car, and the price is $10." And then you get to the lot, and the car is actually $10,000, that's false advertising.

Either way this site is not really for open ended discussion questions. The Arduino forum would be better for this kind of question.

I just scanned over the TAPR and CERN open hardware licenses and I didn't see such a provision. My quick take on OHLs is that they are specifications for building the hardware - and therefore, information - not the hardware itself. And it only makes sense when we consider the incredibly expensive and complicated (from an experimenter's point of view) infrastructure that is a chip foundry necessary to create the kinds of hardware we take for granted and have reduced to commodity parts, CPUs, & MCUs being a prime example.
Thus "Arduino" is an open source specification for building microcontroller boards or board-sets based on ATMEL MCU chips, as well as the products of the Italian company SmartProjects. That is why there are so-called Arduino clones, otherwise, why wouldn't any clone of an Arduino be an Arduino?

Thanks @JRobert (I'd upvote you if I had the rep to do so). However I'mnot quite following you: are you saying that the Arduino designs are actually what is open source, and that in reality, whatever company makes Arduinos uses licensed/proprietary hardware to implement these designs? Thanks again!

My read of the licenses is that the physical device - an Arduino or compatible, in this case - is built of many components, some (many?) of which are proprietary but that he designs and specs for building it are open.


text:
Using NodeJS, socket.io and Adafruit HUZZAH CC3000 breakout board to control Arduino wirelessly?
I'm looking to build my a wirelessly controlled lamp and have a few questions. Would I be able to use the Adafruit HUZZAH CC3000 breakout board to receive commands from a website and control a connected lamp?
I just set up a NodeJS server with webpage on my PC and using socket.io and Firmata I was able to communicate with the Arduino using the webpage over a serial connection. Could I set up similar implementation except instead of communicating over serial I'd communicate using Wifi? Would I need to host a web server on the Wifi board itself to communicate with the Arduino or is there some way to just use the wifi board as a communication between external site and Firmata?

A good source would be Adafruit's website. They detail many projects involving this board, here is one that lights up a tree: https://learn.adafruit.com/wifi-controlled-led-christmahanukwanzaa-tree?view=all

I happen to have received the CC3000 shield yesterday and have been playing with it today...
What do you mean by "receive commands from a website"?
If you mean "can it serve a simple website and act upon HTTP requests" (e.g. requests to http://arduino.local/on would turn a lamp off and http://arduino.local/off would turn if off), then yes it can. You make the HTTP requests using javascript's XMLHTTPRequest if you want to be able to communicate from within a web page without having to re-render a page.
There is an example sketch of an HTTP server included in the CC3000 library that would get you started. Note that the example HTTP server sketch can only handle one HTTP request/response at a time.
You will obviously also need some way of controlling a relay of you want to control a lamp.
Update: Since you updated your question to include how you are currently communicating:
I'm not familiar with socket.io or Firmata, but I'm guessing socket.io is a way of getting your web client (browser) to talk directly Firmata which talks to your Arduino over the USB-Serial connection? If so, then I'm not sure if it's possible to use the Firmata protocol over wireless, but it is possible for the CC3000 to act as a generic TCP server and act on data that it receives wirelessly, so it might be possible to communicate between socket.io and the TCP server. The EchoServer sketch shows how to set up a TCP server to receive raw data.
If you're only turning a lamp on/off you basically only need to control 1 pin. Isn't Firmata a bit overkill for that? Be careful about sketch size. I'm not sure how big Firmata compiles to, but the wireless library with some kind or server is over 22,000 byes (of a possible 32,000) on an Uno, so you might struggle to fit both on.

Added some detail to my question about sockets specifically.

@VianEsterhuizen: Updated my answer now you put more detail in your question, but I'm not sure how much help it will be now as I'm not familiar with some of the technology that you are using.

Have you heard of aREST.io? There is a wifi library that supports the CC3000 (http://arest.io/wifi/) that sounds like it might do a similar thing to Firmata

That looks interesting but I'm really hoping to get this working with sockets. This is really good backup plan though.


text:
How are Arduino's OSH if Atmel AVR is proprietary?
I keep reading how Arduinos are "open source", but my understanding of OSH is that all its components must be open source.
Arduino uses an Atmel AVR CPU - but Googling this shows the Atmel is proprietary!?
So I ask: how can Arduino be truly OSH if it's chief component - its Atmel CPU - is proprietary?!?

I think the point of OSH is that anyone can use and modify the design, not that it can be created from sticks and stones.

Thanks @IgnacioVazquez-Abrams (+1) - however when you say "use and modify the design", what (exactly) are you talking about? If the CPU is proprietary, then what parts of Arduino's "design" can be used/modified?!?

Arduino is based on AVR (most boards, not all actually) but is more than just the single MCU chip. Hence the board itself is OSH. As Ignacio mentioned, one is not supposed to recreate an MCU from scratch (who would want to do that by the way?). In this sense we can say that Arduino is OSH.

The power steering, the voltage regulation, the connection footprint, etc.

@smeeb The Arduino design files can be found here: http://arduino.cc/en/Main/arduinoBoardUno  Look for the schematic and the EAGLE files.  Those files are Arduino "design", and since they are open they can easily be modified.  The AVR is a component in the Arduino, but I would say the AVR's design is not part of the Arduino design.

The components are necessarily going to be proprietary.  There is no feasible way around this.  If you wanted to design a new open source microcontroller from scratch with no proprietary components, it would set you back several billion dollars.  The software used to design integrated circuits costs hundreds of thousands of dollars to license and represents billions of dollars of investment.  Production of the chips themselves takes place in wafer fabs that cost billions of dollars to build, and represent billions of dollars of investment in process technology and semiconductor physics research.  The equipment and process technologies are very closely held trade secrets.  If you are OK with proprietary production, then you can submit GDSII design files (developed with your own open source IC design software) to fabs such as TSMC for production, but the line setup costs will run in the hundreds of thousands of dollars.
Bottom line: you have to draw the line somewhere as to what is acceptable to be 'open' and what is not.  Open source hardware generally means the board-level design files and firmware sources are available, and generally nothing more.
Interestingly, there are many open source CPU designs available.  Sun's OpenSPARC is an open design, you can download the RTL description of the CPU core and modify it.  However, convering RTL to a chip requires IC design software or implementation on a proprietary FPGA with a proprietary development environment.

That is only physical production party. You still have to design the CPU internals and test them.

An 'Arduino' is open source in that you can see the schematics, go out and buy any required components (including the AVR), and change the design however you like.
The AVR is not part of what Arduino owns, it is a simply a component which they have built their design around. You could if you so choose replace that component with something else like a PIC for example, or any other programmable microcontroller for that matter. Granted if you made such a change you would also have to change the software, but then if you change the hardware even to another AVR you would have to change the software so in that sense it isn't really a limiting factor.

There is a good practical question and interesting issues raised here, but this part:
"my understanding of OSH is that all its components must be open source."
I would say your understanding is wrong, where did you get that from?
The design (i.e. how to arrange components) must be open source. Ideally the components would be Open Source too, but practicality dictates that components must be bought "off the shelf". IOW, overall the design should aim for "as Open Source as much as possible".
The thing about hardware is that to realize a design components must be bought, and those components often contain proprietary IP. Of course, the same problem applies to Open Source Software, to run it I need to buy a CPU from Intel, AMD, etc.
So while all open source designs must rely on some proprietary IP as a base platform, the practical question is how easily can the design be moved to another platform (portability), and how easily a component can be substituted (fungibility).
There is only one source of AVR chips and that is Atmel. Other components, like a 3.3V regulator can be easily substituted with other.
The Arduino core software does not rely solely on AVR architecture, in principle it is portable to any CPU platform, in practice any platform that is targeted by GCC. The fact that some Arduinos are not AVR e.g. Due, shows that.

Open-source hardware is fundamentally different from open-source software in that you cannot make a copy of OSH for free. If you want to build an Arduino, you will need all the components it's made of, and even the simplest components like diodes are proprietary, just like the AVR chip. Neither can be home-made and both are proprietary designs.
The important thing about OSH is not that it's made of free components, but the fact that information about how it's made is freely available. The abundance of Arduino shields and addons is not due to availability of free AVR cores, but to the fact that anyone has access to the information needed to make their board Arduino-compatible. BTW, that's how personal computers gained the dominant position on the market: IBM has published detailed specifications including schematics of their IBM PC (albeit not under a free license), enabling other companies to make compatible hardware, and later on, PC clones.
Last but not least, the open-source aspect of Arduino is by no means limited to the hardware. The core library was written in portable way, which made it possible to run it on a wide range of hardware cores. There are even FPGA boards featuring Arduino connectors (1, 2, 3), which can run Arduino software on soft-cores such as F32C or NIOS.


text:
Where Can I Find a 12v Solder-less Breadboard Power Supply?
I am trying to find a 12 V input and 12 V output breadboard power supply but I can't find one. I am making an Arduino-controlled lock but the Arduino cannot power the lock strike by itself so I need to use a separate power supply. The link to make things clearer:
http://www.instructables.com/id/Arduino-RFID-Door-Lock/#step0

If your input is 12V then why do you need a 12V output?

To be a able to use it with a breadboard, I am using a 120vac to 12vdc switching adapter to power the breadboard power supply.

What's wrong with just using wires?

I want to separate the power from the outlet to positive and ground.

... What is that supposed to mean?

I plug the switch adapter into the outlet and into the breadboard power supply. From there i can use 12v of power from my breadboard since it connects into the sockets of the breadboard.

I can't find a power supply that outputs 12v

That's odd as you said you already using a 12v switcher.  Apparently you are misusing "power supply" to describe some other function.  Be more specific about what this mystery item should do - imagine for a minute you are managing an engineer who will create this new invention from scratch: what is the requirement?

Do you want a DC barrel jack on a board with wires or breadboard pins?

https://www.sparkfun.com/products/114 this is basically what i want, but i want it to output 12v.

There is nothing special about a power supply that connects to a breadboard directly versus one that connects via wires.

@IgnacioVazquez-Abrams so does that mean that a dc barrel jack would work?

Provided you connect a regulated power supply to it.

@IgnacioVazquez-Abrams thank you, if you put that as an answer i will accept it.

Could that be a typo in the first sentence of your question, and you meant a 120v input, 12v output supply? That would explain a lot of the confusion that followed...

There is nothing special about a "breadboard power adapter" that isn't served by a normal regulated supply. Simply use wires or a barrel jack or some other connector to connect any regulated supply to the breadboard as desired.

They sell 5V/3.3V breadboard supplies on eBay for $3-$5 shipped from China. Buy one and rewire/modify it to bypass the voltage regulator

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Can Arduino's open design be "scaled" to 64-bit CPUs?
If Arduino is OSH that simply uses 8-bit Atmel AVR MCU as a design component, then can Arduino somehow be tweaked to work with a 64-bit CPU/MCU? If so, what might this entail?

If you mean the software, yes in principle though such processors may not have great direct I/O.  If you mean the board layout, perhaps though cost would be prohibitive for any small actor wanting to exercise the openess, and the alarming trend of not releasing real data sheets to the public may be an issue.  Have you truly exhausted the potential of inexpensive to work with 32 bit MCU's?

It has already been ported to a 32-bit Arm - the Arduino Due - 84mhz, Cortex M3.
To port it to a 64-bit CPU, someone would need to create a design for the PCB, and set up an appropriate build/compile system for it.
Having said that, a 32-bit CPU is an awful lot of power for this sort of thing - I suspect that if a 32-bit Arm isn't enough, then what you're really looking for is a full-blown PC. A Cortex M3 can handle 4GB of memory, and can run a version of Linux (uCLinux, since the M3 does not have a memory management unit, MMU, and the standard Linux kernel needs this). The Due would be unable to run even uCLinux, due to limited memory.
In fact, the Raspberry Pi is also a (700mhz Cortex A8) 32-bit CPU; I imagine that a little bit of tweaking could make the Arduino IDE compile & upload for the Raspberry Pi. This would fall into the category of "Because I can".
Note: The Raspberry Pi is not opensource, I know. Neither is the Arm in the Arduino Due, nor the AtMega that is at the heart of the Arduino Uno.


text:
connection issues with 3 arduinos any suggestions?
I have 3 arduinos that I want to program on, all of them with their own cable and I have tried to connect them to my laptop on several different usb ports, my usb ports work with mouses so that's unlikely to be the problem. However I just cannot connect to them they just don't appear under /dev/ttyACM* and the arduino IDE cannot find them either. I'm running ubuntu 14.04 any suggestions for finding out what is likely to be wrong with my system or the arduinos?
For some odd reason they now all appear to be seen as /dev/ttyACM* but they now all give me a
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

error
Anybody have any idea how to fix? The arduino's do not have any wires in them except usb (nothing in reset or any other pin), I'm on ubuntu so the drivers shouldn't be an issue? And pin 13 flashes when I reset the arduino.

Are these Arduino clones?

One is an official arduino one is a funduno and one is a "uno" (no other marking)

Take a look at this video - Check and see if they are bricked https://www.youtube.com/watch?v=RZH_qGautqM

I'm working from ubuntu 14.04 not from windows so I don't think that tutorial will work

Do you have access to a Windows Machine?

Yes but that requires some extra wait

Its a quick check to see if the FTDI to 232 is bricked. I am not sure if this is your issue, but it was for me. My MAC couldnt read my cloned arduinos.

Absolutely no need to waste time with windows (you would learn less there anyway) Look in dmesg when connecting and compare lsusb output with and without them connected.  Note that many chips will show up as /dev/ttyUSBn not ttyACMn.  In theory you could be missing drivers or lack a udev rule for permissions, but ubuntu should be set up right by default.

it's been a while but a long time later I found that the cable I was using was broken. A different cable worked.

That has happened to me a lot.  Broken cable, charge-only cable, ...


text:
Send one bit out per clock pulse received using direct port manipulation?
I want to send one bit of a byte out per 'rising edge' received to an Arduino digital input. I am addressing the outputs using direct port manipulation (to achieve maximum speed), and I would like to do the same for input.
So I'm calling a function called bitBang in my main loop, sending the ready line high before moving into the function:
//Send control
PORTB |= _BV(PORTB2);
bitBang(controlByte);
PORTB &= ~_BV(PORTB2);

What I would like to do upon entering the function is listen for a rising edge to appear on the digital input port using the direct port syntax and iterate through the byte setting the data line high or low depending on the bit's value.
How can I achieve this in the most efficient way possible?

Use the SPI facility.

You could do a while loop on the bit state, or an inline asm version thereof.  Consider declaring your function inline too.  But are you sure you can't accomplish your need using the hardware of the ATmega's SPI engine?

@Chris Stratton I need to send a ready line high to the peripheral device which will send clock pulses in to the arduino which will send data out. Is this achievable with SPI?

Possibly... Depends on the details and if you can use the SPI pins, but generally clocking out data in response to a clock input is what a slave mode SPI engine does.  The ready output could be a GPIO controlled in software after the SPI is armed.

Search for bit bang SPI since this is essentially what you're doing.

Example bit-banged SPI using port manipulation:

bitBangedSPIfast.h :
#include <Arduino.h>

class bitBangedSPIfast
  {
  // addresses of output ports - NULL if not applicable
  volatile byte * const mosiPort_;
  volatile byte * const misoPin_;
  volatile byte * const sckPort_;

  // bit masks for above
  const byte mosiBit_;
  const byte misoBit_;
  const byte sckBit_;

  // addresses of data direction register ports
  volatile byte * const mosiDDR_;
  volatile byte * const misoDDR_;
  volatile byte * const sckDDR_;

  // bit masks for above
  const byte mosiDDRBit_;
  const byte misoDDRBit_;
  const byte sckDDRBit_;

  // delay for clock being high
  unsigned long delayUs_;

  public:
    // constructor
    bitBangedSPIfast (
          // output ports
          volatile byte & mosiPort,
          const    byte mosiBit,
          volatile byte & misoPin,
          const    byte misoBit,
          volatile byte & sckPort,
          const    byte sckBit,

          // data direction register ports
          volatile byte & mosiDDR,
          const    byte mosiDDRBit,
          volatile byte & misoDDR,
          const    byte misoDDRBit,
          volatile byte & sckDDR,
          const    byte sckDDRBit,

          const unsigned long delayUs = 1)
       :
         mosiPort_ (&mosiPort),
         mosiBit_  (1 << mosiBit),
         misoPin_  (&misoPin),
         misoBit_  (1 << misoBit),
         sckPort_  (&sckPort),
         sckBit_   (1 << sckBit),

         mosiDDR_     (&mosiDDR),
         mosiDDRBit_  (1 << mosiDDRBit),
         misoDDR_     (&misoDDR),
         misoDDRBit_  (1 << misoDDRBit),
         sckDDR_      (&sckDDR),
         sckDDRBit_   (1 << sckDDRBit),

        delayUs_ (delayUs) { }

    void begin ();
    byte transfer (byte input);

  };  // end of bitBangedSPIfast

bitBangedSPIfast.cpp :
#include <bitBangedSPIfast.h>

void bitBangedSPIfast::begin ()
  {
  if (mosiPort_)
    *mosiDDR_ |= mosiDDRBit_;    // output
  if (misoPin_)
    *misoDDR_ &= ~misoDDRBit_;   // input
  *sckDDR_ |= sckDDRBit_;        // output
  }   // end of bitBangedSPIfast::begin

// Bit Banged SPI transfer
byte bitBangedSPIfast::transfer (byte c)
{
  // loop for each bit
  for (byte bit = 0; bit < 8; bit++)
    {
    // set up MOSI on falling edge of previous SCK (sampled on rising edge)
    if (mosiPort_)
      {
      if (c & 0x80)
        *mosiPort_ |= mosiBit_;
      else
        *mosiPort_ &= ~mosiBit_;
      }

    // finished with MS bit, get read to receive next bit
    c <<= 1;

    // read MISO
    if (misoPin_)
      c |= (*misoPin_ & misoBit_) != 0;

    // clock high
    *sckPort_ |= sckBit_;

    // delay between rise and fall of clock
    delayMicroseconds (delayUs_);

    // clock low
    *sckPort_ &= ~sckBit_;

    // delay between rise and fall of clock
    delayMicroseconds (delayUs_);
    }  // end of for loop, for each bit

  return c;
  }  // end of bitBangedSPIfast::transfer

Example usage:
#include <bitBangedSPIfast.h>

bitBangedSPIfast bbSPI (PORTD,  5, PIND,  6, PORTD, 7,    // MOSI port (D5), MISO pin (D6), SCK port (D7)
                        DDRD,   5, DDRD,  6, DDRD,  7);   // MOSI ddr  (D5), MISO ddr (D6), SCK ddr  (D7)
const byte mySS =  8;  // slave select

void setup (void)
  {
  bbSPI.begin ();
  pinMode (mySS, OUTPUT);
  }  // end of setup

void loop (void)
  {
  char c;

  // enable Slave Select
  digitalWrite(mySS, LOW);

  // send test string
  for (const char * p = "Hello, world!" ; c = *p; p++)
    bbSPI.transfer (c);

  // disable Slave Select
  digitalWrite(mySS, HIGH);

  delay (100);
  }  // end of loop

Reference
SPI - Serial Peripheral Interface - for Arduino


text:
Openlog + Lilypad Simple board - not writing to SD card
I'm desperately trying to get my openlog to work and write data out to a micro SD card with no luck.
I'm using a battery-powered lilypad arduino simple board and have attached L-shaped female headers to to the openlog to plug it right in. I am also using an FTDI breakout with the lilypad to download code and that is working. I think i have matched the RX and TX properly by flipping the openlog over as it pictured in the images attached. I'm using the example code included on the sparkfun openlog page just to test:
https://github.com/sparkfun/OpenLog/blob/master/firmware/examples/OpenLog_Test_Sketch/OpenLog_Test_Sketch.ino
There are no lights lit on the openlog which might indicate a power issue - but it's super unclear.
Any ideas or help very welcome!

Are you sure all the pins match up, except for TX/RX?

In your picture you are using a 32  gig card. In addition to being expensive overkill, that is probably SDXC and may not be something the logger supports.

It's not overkill, it's a card I already had using it in camera. That's not the issue - it's not getting power.