body:
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?!?

title: Are Arduino's truly OSH?

Answers: 1

body:
I just scanned over the [TAPR][1] and [CERN][2] 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?

  [1]: http://en.wikipedia.org/wiki/TAPR_Open_Hardware_License#Conditions
  [2]: http://www.ohwr.org/documents/294


body:
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?

title: Using NodeJS, socket.io and Adafruit HUZZAH CC3000 breakout board to control Arduino wirelessly?

Answers: 2

body:
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.

body: 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


body:
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](http://en.wikipedia.org/wiki/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?!?**

title: How are Arduino's OSH if Atmel AVR is proprietary?

Answers: 4

body:
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.

body:
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.

body:
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.

body:
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](https://en.wikipedia.org/wiki/IBM_Personal_Computer#Third-party_products) 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](https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems) of hardware cores. There are even FPGA boards featuring Arduino connectors ([1](https://www.eevblog.com/forum/microcontrollers/cyclone-v-gx-starter-kit-the-ultimate-arduino/), [2](http://www.aloriumtech.com/xlr8/), [3](http://papilio.cc/)), which can run Arduino software on soft-cores such as [F32C](http://www.nxlab.fer.hr/fpgarduino/) or [NIOS](https://github.com/dimag0g/nios_duino).


body:
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

title: Where Can I Find a 12v Solder-less Breadboard Power Supply?

Answers: 2

body: 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

body: 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.


body: 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?

title: Can Arduino's open design be "scaled" to 64-bit CPUs?

Answers: 1

body:
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.


body:
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.

title: connection issues with 3 arduinos any suggestions?

Answers: 1

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


body:
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?**

title: Send one bit out per clock pulse received using direct port manipulation?

Answers: 1

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

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](http://www.gammon.com.au/spi)


body:
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!

![enter image description here][1]
  [1]: https://i.stack.imgur.com/QB15O.jpg

![enter image description here][2]
  [2]: https://i.stack.imgur.com/5AMaF.jpg!

title: Openlog + Lilypad Simple board - not writing to SD card

Answers: 0


body:
I was trying to make my arduino uno r3 to work on my Linux machine (including the IDE), but it wouldn't. At first I thought it was a software problem. Added myself to different groups and did everything, people discussed on the forums. It didn't work. It wasn't recognized by the computer at all. I reinstalled. Nothing again. Thought it was a hardware problem of my computer. Tried with dad's (Windows 7 machine). Didn't work. Then I saw that the two leds (TX and RX) are not blinking, neither are lit. I started doing a research on the internet but everybody suggests doing the loopback test from the IDE. My Arduino Uno R3 is not recognized by the computer, therefore the IDE. Is there any way to check if it's dead or if it's a minor problem?

Edit: I read a lot on the case last night and I reach to the conclusion that my ATmega16u2 (the usb-serial chip, I'm sure it is 16u2 and not 8u2, it's written on the chip itself) might be dead. Tried to reflash the firmware but cannot get it in DFU mode (as it says in this article click here). dfu-programmer (the Linux application) throws the following error: `dfu-programmer: no device present`. What to do?

title: Arduino Uno R3 not recognized by computer, TX and RX not blinking, neither are lit. Is it dead?

Answers: 3

body:
Before you can access serial TX/RX on Arduino make sure USB to serial converter on the board is working. To check it (on Linux) do the following:

1. Open the terminal, type 'dmesg' and press 'enter'. You will see some output with timestamps (number in square brackets). Note the timestamp of the last line. Run dmesg several times to make sure nothing writes to it and you still see the last timestamp.

2. Plug your board into USB port and run dmesg once again. You should see something like the output below. The first line is the last line of dmesg prior to plugging in the Arduino, the second line is actual detection. The board I used in this example is 2560, UNO will give you similar output. If you can see this output your board is recognized just fine. If you can't see it then either the USB to serial chip (just another AVR MCU) on the Arduino or USB host in your PC or both are defective.

<pre>
    [279152.351690] systemd-logind[867]: New session c51 of user lightdm.
    [280362.732094] usb 3-2: new full-speed USB device number 3 using uhci_hcd
    [280362.931266] usb 3-2: New USB device found, idVendor=2341, idProduct=0010
    [280362.931275] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
    [280362.931282] usb 3-2: Product: Arduino Mega 2560
    [280362.931288] usb 3-2: Manufacturer: Arduino (www.arduino.cc)
    [280362.931293] usb 3-2: SerialNumber: 64938323331351213172
    [280362.986579] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
    [280362.988470] usbcore: registered new interface driver cdc_acm
    [280362.988473] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
    [280362.732094] usb 3-2: new full-speed USB device number 3 using uhci_hcd
    [280362.931266] usb 3-2: New USB device found, idVendor=2341, idProduct=0010
    [280362.931275] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
    [280362.931282] usb 3-2: Product: Arduino Mega 2560
    [280362.931288] usb 3-2: Manufacturer: Arduino (www.arduino.cc)
    [280362.931293] usb 3-2: SerialNumber: 64938323331351213172
    [280362.986579] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
    [280362.988470] usbcore: registered new interface driver cdc_acm
    [280362.988473] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
</pre>

body:
1. Delete your Arduino IDE, but store your libraries if you need in future.
2. Download Arduino ERW 1.0.5 from here: http://forum.arduino.cc/index.php?topic=118440
3. Try your steps again with your connections belong to your schematic.

body:
There is a chance that your bootloader is not working anymore. You can burn a new bootloader to the device with another Uno, there are nice [guides on the Arduino-Website][1].

  [1]: http://arduino.cc/en/Tutorial/ArduinoToBreadboard


body:
I tried to modify the example in the following page, by replacing the given string with a 56 bytes one after making all the suitable changes to read(), write() and max_payload_size(increased to 64 bytes), payload_size() parameters/methods in the RF24 library.

http://shanes.net/another-nrf24l01-sketch-string-sendreceive/

The problem is the receiver truncates the string to 32 characters. Is 32 bytes a hard limitation for payload with the nrf24l01+ radio? If so how to I modify the receiver in above example problem to receive the entire string?

title: Increasing payload size above 32 bytes using nRF24L01+

Answers: 1

body:
If you look at the [specification or datasheet](https://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P) for the nRF24l01+, you will see that the 32 byte payload is the maximum that the device can handle.

For example:

![spec][1]

If you need to transmit anything larger than 32 bytes, you will need to develop a protocol that splits up your data into chunks of 32 bytes or less and sends the data in several packets.

The actual protocol you design is up to you, but a simple technique might be using the first packet to send a count of the number of data packets to expect and then simply send those packets, each with a part of your data and reassemble it at the receiving end.

You may need to design something more robust so you don't get confused by lost packets or bad data. The larger your payload, the more chance of transmission errors, so it might be an idea to experiemnt with the payload size to get the best throughput for your particular application.

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


body:
I want to transfer data from my smartphon to the Arduino by using the audio jack of my smartphone. For this I need verry high reading frequencys.

I have used

    bitClear(ADCSRA,ADPS0);
    bitSet(ADCSRA,ADPS1);
    bitClear(ADCSRA,ADPS2);

to boost analogread to ~10microseconds, which would be enough. But somehow I am still wasting 5.4 ms at the beginning of the transmission.

The only thing between signal start and first analogread is a start of a for loop:

    while(analogRead(A0)<50) (true); //wait for start of transmission
    for(i = 0; i<500;i++){
    data[i]=analogRead(A0);
    }

But does starting a for loop take 5.4 ms?
Do you have any ideas?

title: Increasing analogread speed on the Arduino Uno

Answers: 2

body:
It sounds like you could benefit from interrupt handled free running sampling, doing that should get you sampling rates up to the maximum listed on the 328's datasheet, 76.9 kSPs. Although, that's at a reduced resolution. [This site][1] explains better, under the section "Free running sampling".

  [1]: http://meettechniek.info/embedded/arduino-analog.html

body:
I did some further analysis on the signal and the problem was not the Arduino. It did everything quick and correct.
The problem was my smartphone. I used androids AudioTrack class and somehow it did cut off parts of the signal. This could be "fixed" by increasing the length of the signal. I just added 0's at the beginning and end.


body: Please help me. There is a conflict when I put GSM and Bluetooth module in one MCU. The problem is when I use the GSM, the Bluetooth will not respond and vice-versa.

title: integration of GSM module and Bluetooth using arduino

Answers: 0


body:
I'm currently using an Arduino Uno (R3), but want to switch to Leonardo for the USB-ability. The Uno can work from the USB's 5V. Looking at the Leonardo's schematic it seems the only input to the voltage regulator is from the power connector. This makes sense as it's a 5V regulator which needs > 5V in. But I don't see the MOSFET which connects the USB's 5V to the board's 5V, like there's one on the UNO.

So, does the Leonardo need the separate power input connected?

title: Does Leonardo need a separate power supply?

Answers: 1

body: Power steering is performed by the assembly labelled "+5V AUTO SELECTOR" at the bottom of the page. The voltage at VIN is halved and then compared with the board's 3.3V output in order to determine whether or not to enable USB power via T1.


body:
I want to collect data (both Humidity & Temperature) from 80 sensors. let's say I have 80 "DHT 11 Humidity & Temperature" sensors (for ex. in a warehouse) and one Arduino Uno R3 pack. It's clear that arduino has no so many pins to connect. I'm sorry that I don't know if it's possible. If so, what can I use to achieve this?
Thank you all for your suggestions.

title: Connecting multiple DHT 11 sensors

Answers: 1

body:
Analog multiplexers are one way, but they tend to have a significant resistance when on, and this could cause the protocol not to work.
For 80 channels you need 7 bits addressing. Say you have an 8-input multiplexer, then a 3-bit address indicates which of the 8 inputs is selected. Use 10 of these, all with the three address lines connected, and you have 10 outputs from 80 inputs.
Next, use a 16-input multiplexer to select which of the 10 inputs you want to use. For this multiplexer you need 4 address lines. Together with the other 3 address lines you have 7 address lines, enough to select 1 of up to 128 sensors. But I repeat, this approach may not work if the multiplexer's resistance is too high.

A more robust (albeit more expensive) is to use analog switches to connect/disconnect each sensor. Analog switches (Analog Devices has a lot of them) have on-resistances down to < 1 ohm, so the sure should be OK for the application.
To control the long series of switches you could use a daisy chain of 74HC595 shift registers, which only requires a couple of I/Os on your controller, but gives you virtually unlimited outputs.


body:
i am building an outdoor sensor with a combination of a custom Arduino board and a battery (+solar charging). I experience strange behavior when the temperature falls below a certain value (i can reproduce it by putting it in the freezer), regardless which type of battery i am using. The custom Arduino runs without power-regulation, straight from the 3.7volts the battery can provide.
How can i prevent this to happen? I guess a little heating would be not really a solution as i am trying to consume as less energy as possible.
Would a (step up) regulator possibly help? Any other ideas?

---Update---
Thanks to your comments here i figured out, that the AVR 328p should not be operated below a voltage of 3.7v if run at 16Mhz. As i am running with a 3.7v LiPo Battery that could easily explain my problem i guess. My first try to decrease the processor speed to 8Mhz with a Prescaler worked, but the GSM Fona does not seem to like it. So i would like to try something in between like 10Mhz or 12Mhz. As the prescaler does not support this, my question is: can i just use another crystal or would i have to modify something in the code/bootloader as well?

title: Arduino on battery getting unstable if temperature falls

Answers: 3

body:
It's most likely that the cold weather is messing with your batteries. I don't know what battery types you've tried, but [this site][1] says that Lithium batteries (Not Li Ion, but standard single use, expensive, lithiums) hold up well in very cold and very hot environments. For rechargeable batteries the site recommends NiMH batteries. Of course, we all know that lead acid batteries hold up well in cold (Or else our cars wouldn't start!), so those are also a viable option. Lead acids can be purchased in somewhat small forms, but they may still be too big for your purposes.

For the other part of your question, yes a regulator will help. It's rarely acceptable to run directly off a battery without a regulator. Since your application is low power you'll want to use an efficient switching regulator (Search for modules, not individual chips). Remember that a battery's output changes based on its charge level, temperature, current draw, and other things I'm likely forgetting. Using a regulator mitigates these effects as regulators are less affected by temperature and current draw than the battery that supplies it (Hopefully).

So to summarize: Use Lithium batteries, or NiMH if you need to recharge, or Lead Acid if you need a ton of capacity and size isn't a limit. Then get a switching regulator module. Best of luck with your project!

  [1]: http://www.rei.com/learn/expert-advice/batteries.html

body: When using battery, always use a step-up converter, something like LTC3525 or NCP1402. A direct connection of unregulated battery voltage to an analog input can give you a good information on the remaining capacity while the step-up converter still provides stable 3.3V for operation.

body:
To answer your modified question:

Running the ATmega328p at 16Mhz with 3.7v is out of spec - see [this EESE answer][1] for reference or the ATmega datasheet - so the obvious solution would be to lower its speed to 8Mhz.

But since you also mentioned that there is an additional GSM breakout board involved (Adafruit Fona), which expects UART (in auto-baud mode) Rx/Tx connection, it might not be that trivial. Further exploration of the Fona library's source code reveals that it has several hard-coded delays (see `Adafruit_FONA.cpp::begin`, for example), but its core seems to be implemented inside the `Adafruit_FONA::readline` method, which uses an underlying `Stream`, which in turns comes from a Software/Hardware serial object, as shown in the `FONAtest.ino` example that comes with the library.

From my experience, Software/Hardware serial should work fine on 8Mhz, except maybe when [using high baud rates][2], which is solvable.
The hard-coded delays doesn't look like they should cause actual damage except for delay, but you could cut them in half just to see if you can make the library work.

Additional aspect that you should consider is the comment from Adafruit's Fona product page, regarding pin **Vio**:

> This is the pin that you MUST drive with an external voltage from
> 3V-5V to set the logic level converter

So, despite that from the datasheet, the Fona seems to have a voltage regulator, you might still want to consider adding a decoupling capacitor between Vcc and Gnd of your battery, to  mitigate transient current draws from any component in your circuit.

  [1]: https://electronics.stackexchange.com/questions/58818/programming-3-3v-atmega328-running-at-16mhz
  [2]: http://forum.arduino.cc/index.php?topic=212962.0


body:
I was trying to interface my hex keypad with Arduino. I declared rows as input and columns as output. When I initialize three of the four columns as HIGH and one as LOW, and detect the button pressed as LOW in the corresponding row, it works fine. That is, it detects the button when its corresponding row and column is LOW. But, when I reverse the condition, i.e. when I try to detect the button pressed when its corresponding row and column is high while others are low, it does not work as expected.

I really want to know why is this happening?

The code that works:-

    int row[]={6,7,8,9};
    int col[]={10,11,12,13};
    int i,j;
    int col_scan;
    void setup()
    {
       Serial.begin(9600);
       for(i=0;i<=3;i++)
       {
          pinMode(row[i],OUTPUT);
          pinMode(col[i],INPUT);
          digitalWrite(col[i],HIGH);
       } }
    void loop()
    {
       for(i=0; i<=3; i++)
       {
          digitalWrite(row[0],HIGH);
          digitalWrite(row[1],HIGH);
          digitalWrite(row[2],HIGH);
          digitalWrite(row[3],HIGH);
          digitalWrite(row[i],LOW);
          for(j=0; j<=3; j++)
          {
      col_scan=digitalRead(col[j]);
      if(col_scan==LOW)
      {
         keypress(i,j);
         delay(300);
      }}
       }}
    void keypress(int i, int j)
    {
       if(i==0&&j==0)
          Serial.println("1");
       if(i==0&&j==1)
          Serial.println("2");
       if(i==0&&j==2)
          Serial.println("3");
       if(i==0&&j==3)
          Serial.println("A");
       if(i==1&&j==0)
          Serial.println("4");
       if(i==1&&j==1)
          Serial.println("5");
       if(i==1&&j==2)
          Serial.println("6");
       if(i==1&&j==3)
          Serial.println("B");
       if(i==2&&j==0)
          Serial.println("7");
       if(i==2&&j==1)
          Serial.println("8");
       if(i==2&&j==2)
          Serial.println("9");
       if(i==2&&j==3)
          Serial.println("C");
       if(i==3&&j==0)
          Serial.println("*");
       if(i==3&&j==1)
          Serial.println("0");
       if(i==3&&j==2)
          Serial.println("#");
       if(i==3&&j==3)
          Serial.println("D");
    }

the code that doesn't work:-

    int row[]={6,7,8,9};
    int col[]={10,11,12,13};
    int i,j;
    int col_scan;
    void setup()
    {
       Serial.begin(9600);
       for(i=0;i<=3;i++)
       {
          pinMode(row[i],OUTPUT);
          pinMode(col[i],INPUT);
          digitalWrite(col[i],LOW);
       } }
    void loop()
    {
       for(i=0; i<=3; i++)
       {
          digitalWrite(row[0],LOW);
          digitalWrite(row[1],LOW);
          digitalWrite(row[2],LOW);
          digitalWrite(row[3],LOW);
          digitalWrite(row[i],HIGH);
          for(j=0; j<=3; j++)
          {
      col_scan=digitalRead(col[j]);
      if(col_scan==HIGH)
      {
         keypress(i,j);
         delay(300);
      }}
       }}
    void keypress(int i, int j)
    {
       if(i==0&&j==0)
          Serial.println("1");
       if(i==0&&j==1)
          Serial.println("2");
       if(i==0&&j==2)
          Serial.println("3");
       if(i==0&&j==3)
          Serial.println("A");
       if(i==1&&j==0)
          Serial.println("4");
       if(i==1&&j==1)
          Serial.println("5");
       if(i==1&&j==2)
          Serial.println("6");
       if(i==1&&j==3)
          Serial.println("B");
       if(i==2&&j==0)
          Serial.println("7");
       if(i==2&&j==1)
          Serial.println("8");
       if(i==2&&j==2)
          Serial.println("9");
       if(i==2&&j==3)
          Serial.println("C");
       if(i==3&&j==0)
          Serial.println("*");
       if(i==3&&j==1)
          Serial.println("0");
       if(i==3&&j==2)
          Serial.println("#");
       if(i==3&&j==3)
          Serial.println("D");
    }

title: Interfacing Hex keypad with arduino

Answers: 1

body:
To use unipolar switches as inputs, you need pulling resistors to give the input pin a defined value when the switch is open.

The ATmega has software configurable internal pullups.  Even if these are not configured, implementation detail may (or may not) yield a very weak *unreliable* pullup effect.

There is no configurable pulldown on the ATmega.  To operate in that direction (with a switch to high) you would need external pulldown resistors.

A few matrix keyboards include diodes, to combat some of the confusion which results when multiple keys are pressed in a simple matrix.

Also, you should add a tiny delay between driving and reading, in order to allow for capacitive delay.


body:
I need to read 5 analog pins simultaneously , is it possible?

note that:

analogRead(1);

analogRead(2);

analogRead(3);

will not work this case

title: Simultaneous input output in arduino mega

Answers: 1

body:
No, it is not. The ADC in the MCU is only capable of sampling a single analog channel at a time.

If you require sampling more than one channel at a time then you will need to use one or more external ADCs that are capable of sampling multiple channels, or multiple ADCs each dedicated to a single channel.


body:
I can't get the min,max range to function properly. Monitoring the serial, only gives out ~50 difference from the min. I then added truerandom.ino to try to fix, but no help.

    const int ledPin = 13; // the number of the LED pin
    // Variables will change:
    int ledState = LOW; // ledState used to set the LED
    long previousMillis = 0; // will store last time LED was updated
    // the follow variables is a long because the time, measured in miliseconds,
    // will quickly become a bigger number than can be stored in an int.
    //long interval = random(800, 8000); // interval at which to blink (milliseconds)
    void setup() {
    // set the digital pin as output:
    pinMode(ledPin, OUTPUT);
    Serial.begin(9600);
    }
    void loop()
    {
    // here is where you'd put code that needs to be running all the time.
    // check to see if it's time to blink the LED; that is, if the
    // difference between the current time and last time you blinked
    // the LED is bigger than the interval at which you want to
    // blink the LED.
    long interval = random(800,8000);
    unsigned long currentMillis = millis();
    if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
    ledState = HIGH;
    else
    ledState = LOW;
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
    Serial.println(interval);
    }
    }

Added truerandom.ino still ~50 range:

    // TrueRandomSeed.ino
    //   This example sketch shows how to provide a truly random seed value to the built in
    //   library pseudo random number generator.  This ensures that your sketch will be
    //   using a different sequence of random numbers every time it runs.  Unlike the
    //   usually suggested randomSeed(analogRead(0)) this method will provide a much more
    //   uniform and varied seed value.  For more information about the basic technique used
    //   here to produce a random number or if you need more than one such number you can
    //   find a library, Entropy from the following web site along with documentation of how
    //   the library has been tested to provide TRUE random numbers on a variety of AVR
    //   chips and arduino environments.
    //
    //   https://sites.google.com/site/astudyofentropy/project-definition/
    //           timer-jitter-entropy-sources/entropy-library
    //
    //   Copyright 2014 by Walter Anderson, wandrson01 at gmail dot com
    //

    #include <avr/interrupt.h>
    #include <avr/wdt.h>
    #include <util/atomic.h>
    // The following addresses a problem in version 1.0.5 and earlier of the Arduino IDE
    // that prevents randomSeed from working properly.
    //        https://github.com/arduino/Arduino/issues/575
    #define randomSeed(s) srandom(s)

    volatile uint32_t seed;  // These two variables can be reused in your program after the
    volatile int8_t nrot;    // function CreateTrulyRandomSeed()executes in the setup()
                             // function.
    const int ledPin = 13; // the number of the LED pin
    // Variables will change:
    int ledState = LOW; // ledState used to set the LED
    long previousMillis = 0; // will store last time LED was updated

    void CreateTrulyRandomSeed()
    {
      seed = 0;
      nrot = 32; // Must be at least 4, but more increased the uniformity of the produced
                 // seeds entropy.

      // The following five lines of code turn on the watch dog timer interrupt to create
      // the seed value
      cli();
      MCUSR = 0;
      _WD_CONTROL_REG |= (1<<_WD_CHANGE_BIT) | (1<<WDE);
      _WD_CONTROL_REG = (1<<WDIE);
      sei();

      while (nrot > 0);  // wait here until seed is created

      // The following five lines turn off the watch dog timer interrupt
      cli();
      MCUSR = 0;
      _WD_CONTROL_REG |= (1<<_WD_CHANGE_BIT) | (0<<WDE);
      _WD_CONTROL_REG = (0<< WDIE);
      sei();
    }

    ISR(WDT_vect)
    {
      nrot--;
      seed = seed << 8;
      seed = seed ^ TCNT1L;
    }

    void setup()
    {
      CreateTrulyRandomSeed();
      randomSeed(seed);
      pinMode(ledPin, OUTPUT);
      Serial.begin(9600);
      // The preceeding two function calls will take approximately 0.5 second to execute if
      // nrot is set to 32 ... the rest of your setup code should FOLLOW from here.
    }

    void loop()
    {
      long interval = random(800,8000);
    unsigned long currentMillis = millis();
    if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
    ledState = HIGH;
    else
    ledState = LOW;
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
    Serial.println(interval);
    }
    }

title: Random(min,max) Function only giving ~50 range no matter what the values?

Answers: 2

body:
I suspect it actually is generating other values and it's your program logic that's at fault.

Here's what I think you meant your program to do:

 1. Generate a random interval.
 2. Wait until that interval has elapsed.
 3. Start again with a new interval.

Here's what's actually happening:

 1. Generate a random interval.
 2. Check if that interval has elapsed.
 3. Whether or not it has elapsed, generate a new random interval anyway.

Note that you're generating a new random interval **every time round `loop()`**. This means your condition just keeps trying new random intervals until one happens (by chance) to be less than the amount of time that's elapsed since the last interval. You're only outputting the interval when that occurs, and evidently it happens on average at least every 50ms.

You can test this theory by outputting `interval` to serial as soon as you've generated it (i.e. before the `if` statement). I think you'll find it will flood the serial monitor with a huge range of values.

Fixing the problem should be pretty easy. Just generate your first `interval` value during `setup()`. After that, only generate a new random `interval` value when the old interval has elapsed (i.e. inside the `if` block). Don't do it every time round the main loop.

body:
I had the same problem (random, milliseconds), and in my case what I needed to make was a toy, able to Blink its eye (LED) in a more human way, with variable intervals, so I used the basic "blink without delay" and tweaked until I got a result I wanted.
This is my first post here so I hope I'm doing it correctly. Here is the code that worked for me:

    const int ledPin =  13;      // the number of the LED pin
    unsigned long previousMillis = 0;        // will store last time LED was     updated

     long interval = 4000;           // starting interval at which to blink   (milliseconds)

    void setup() {
    Serial.begin(9600);
    // set the digital pin as output:
    pinMode(ledPin, OUTPUT);
    }

    void loop()
    {
    digitalWrite(ledPin, HIGH);

    unsigned long currentMillis = millis();

    if(currentMillis - previousMillis >= interval)

    {
      // save the last time you blinked the LED
      previousMillis  = currentMillis;
      interval = random((3, 14) * 1000);

    Serial.println("Blink");
    Serial.println(interval);  // Just so I can confirm if the effect seems natural
    digitalWrite(ledPin, LOW);
    delay(250);
    digitalWrite(ledPin, HIGH);
     }
    }


body:
I am working on a project using an Arduino as a web server.

Code:

    webFile = SD.open("index.htm");
    if (webFile) {
      while(webFile.available()) {
        client.write(webFile.read());
      }
    webFile.close();

This sends data line by line, leading to a long time to load the webpage. Is there a faster way to load this page?

title: How can I speed up reading of an SD card?

Answers: 2

body:
Well I have two ideas on the SD card side, though neither really seem *great* to me they could still help you. I read on the Arduino forum that the SD card R/W speeds generally come out to 600kB/s, I'm not really sure why, the Arduino SPI can go up to 8 MB/s and I didn't think there would be that much protocol/data-handling in SD.

 1. Sector R/W - As Chris Stratton said, this is an obvious method, it's probably much faster to do sector reads. You may have to greatly change your code to implement it, but I imagine you'd see performance increase in the end. Apparently there's an [unofficial library][1] for it, though it seems to impart some potentially serious limitations.
 2. RAM - This is the second thing that came to mind when thinking about the problem is that you could use external RAM, when not handling network transfers (Idling, should be most of the time) the Arduino transfers data to external SRAM which you add. [SPI RAM][2] is most likely the easiest to implement, but not likely to be any faster than an SD card. [Parallel RAM][3] is going to be difficult to implement, you'll likely need to write your own class/library, but it could be much faster than SPI RAM or an SD card.

I'm not actually sure if either of these would be any faster, it's all just theory and I hope others will share their thoughts. If you have trouble finding the download link for the SD Card library, it's right [here][4]. In that ZIP folder there's a file called *SDCARD*, just move that folder into your Arduino libraries folder on your computer.

  [1]: http://forum.arduino.cc/index.php?topic=52871.0
  [2]: http://www.mouser.com/ProductDetail/Microchip-Technology/23LC1024-I-P/?qs=sGAEpiMZZMt9mBA6nIyysHsFd6bhl6Edtfzw23Aiprk=
  [3]: http://www.mouser.com/ProductDetail/Alliance-Memory/AS6C4008-55PCN/?qs=sGAEpiMZZMtm4RFapVkzrPhqi0UYYSDeBu6Rrbtf4UA=
  [4]: https://code.google.com/p/mysudoku/downloads/detail?name=SDCARDsectors.zip&can=2&q=

body:
maybe you should use SdFat library; a library which is almost the same as the standard SD library, but also it can support Long Filenames.

I did some tests with read and write; it is most of the times > 60% faster!!
https://github.com/greiman/SdFat


body:
I have an arduino UNO with atmega 328 whose microcontroller got burnt. I bought a new atmega328. I have another working arduino with atmega8. I followed the instructions in http://arduino.cc/en/Tutorial/ArduinoToBreadboard but I got a little confused.

I burnt the bootloader into my new atmega328 using atmega8 arduino as described in the link above. Now, can I replace my old atmega328 with this new bootloaded atmega328 to upload sketches to it? Or should I follow the steps described in the link to upload sketches?

title: How do I replace a burnt atmega328 with a new atmega328(bootloaded) in arduino?

Answers: 1

body: Once the bootloader has been burned to it, the chip can replace the one that is currently on the Arduino board. Simply follow normal DIP removal and insertion procedures to replace it.


body:
I have an arduino UNO with atmega 328 whose microcontroller got burnt. I bought a new atmega328. I have another working arduino with atmega8. I followed the instructions in http://arduino.cc/en/Tutorial/ArduinoToBreadboard but I got a little confused.

I burnt the bootloader into my new atmega328 using atmega8 arduino as described in the link above. Now, can I replace my old atmega328 with this new bootloaded atmega328 to upload sketches to it? Or should I follow the steps described in the link to upload sketches?

title: How do I replace a burnt atmega328 with a new atmega328(bootloaded) in arduino?

Answers: 2

body: Once the bootloader has been burned to it, the chip can replace the one that is currently on the Arduino board. Simply follow normal DIP removal and insertion procedures to replace it.

body:
You can use the 328p as usual (for an Arduino), once the bootloader is burned.

Background: You just used your Atmega8 as an ISP (In-System-Programmer) to get a bootloader onto your new 328p. The bootloader now enables the 328p to be programmed via serial port.


body:
Im planning a project that involves sending data from a door phone to an android phone and vice versa using the [RN-52](https://www.sparkfun.com/products/11678) chip from sparkfun. Because of the nature of the project it is necessary to be able to send and receive audio simultaneously, is this possible? I've done some googling and it seems to me impossible because of sink/source, since you cant have both at the same time (using A2DP).

Can this be done with another profile I don't know of?

Even if that were to work, can the chip handle two way communication?

Is this project feasible with BT, or should I be looking at WIFI-communication instead?
Ultimately it would be nice to be able to use BT because of costs.

Edit: Can I use bluetooth hands free profile? This profile is (AFAIK) intended to send audio to and from a phone (amongst other functionality). The chip does support HFP/HSP, can this work?

title: RN-52 - Bluetooth Audio Module two way communication with Android

Answers: 0


body:
I would like to use a 555 circuit as an external watchdog for my Arduino project. The project is a cellular tracker that goes to sleep for an hour, wakes up and does some measurements, uploads them and then goes to sleep again. The 555 should take care that the active period does not take too long because the systems hangs, and in that case trigger a reset. My first thought was to power the 555 circuit with a PIN of the Arduino so that it only goes on when the system is awake and is turned off while sleeping.
But this does not work as the reset line has to stay high even while sleeping and if i turn the 555 off reset would also go low. Could a Mosfet help? Any other ideas?

title: Using 555 as an external Watchdog

Answers: 1

body:
ok guys - found the answer: this post here at electronics-stackexchange gave the right hint: [Watch-Dog Timer][1]. And my gut feeling was right as well - i simply use a NPN-Mosfet that is being triggered by an Arduino-PIN (which easily can be done while sleeping as well as sleeping means waking up every 8seconds anyway) that connects the capacitor to ground and therefore discharges the guy. Awesome.
This solution can be used as a real fallback in case of whatever happens, while operating the system with built in watchdog-functions while everything is ok.

  [1]: https://electronics.stackexchange.com/questions/18/watch-dog-timer-arduino


body:
i have a climate control software which reports data back through the web browser.  Everything seems to be working however I am running into an issue where

1 - after a bit it seems the page doesnt refresh completely and instead displays a long list of the same webpage, so i have like 30 pages of the same thing as you scroll down

2 - when i woke up in the morning i could not load the page at all

What i am wondering is how can i get this to be stable and reliable so that the climate control software / sensors can run non-stop.

Currently as long as i dont use the ethernet shield reporting everything else seems to work great, i leave it on for 12 -20 hours and it still runs, but not with the ethernet reporting.

any help wold be apreciated thanks.

this is my code:

    //Define Start
    #define NOTE_D2  73 //sound note for beep
    #define DHTPIN 2
    #define DHTTYPE DHT22
    #define DHT2PIN 3
    #define DHTTYPE2 DHT22
    #define MAGENTA //Define a color for screen
    #define sclk 8 //screen pin
    #define mosi 5 //screen pin
    #define cs   6 //screen pin
    #define dc   7 //screen pin
    #define rst  rstpin  // you can also connect this to the Arduino reset
    #define ANALOG_IN 0 // for cds light sensor

    //Define End
    //Include start
    #include <DHT.h>//dht sensor library
    #include <Adafruit_GFX.h>    // Core graphics library
    #include <Adafruit_ST7735.h> // Hardware-specific library
    #include <SPI.h>//needed to run screen
    #include <Wire.h>
    #include "RTClib.h"
    #include <Ethernet.h>
    //Include end
    //declare start
    DHT dht2(DHT2PIN, DHTTYPE2);
    DHT dht(DHTPIN, DHTTYPE);
    int powerswitch1 = A0;
    int powerswitch2 = A1;
    const int ledPin =  A2;
    const int ledPin2 =  A3;
    Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk);
    char* myString = { "OFF" };//relay1 on / off status
    char* myString2 = { "OFF" };//relay2 on / off status
    const int chipSelect = 4;
    RTC_DS1307 RTC;
    byte mac[] = {
      0x90, 0xA2, 0xDA, 0x00, 0x23, 0x36 }; //MAC address found on the back of your ethernet shield.
    IPAddress ip(192,168,1,40);
    //decalare end
    EthernetServer server(80);

    void setup() {
    pinMode(ledPin, OUTPUT);
    pinMode(ledPin2, OUTPUT);
    tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
    tft.fillScreen(ST7735_RED);//make screen red
      pinMode(powerswitch1, OUTPUT);
      pinMode(powerswitch2, OUTPUT);
      Serial.begin(9600);
      Wire.begin();
      RTC.begin();
    if (! RTC.isrunning()) {
        Serial.println("RTC is NOT running!");
        // following line sets the RTC to the date & time this sketch was compiled
     //   RTC.adjust(DateTime(__DATE__, __TIME__));
      }

    // get time to display "sensor up time"
      uint16_t time = millis();
     // tft.fillScreen(ST7735_BLACK); //black screen
      time = millis() - time;

    Serial.println(time, DEC);

      Ethernet.begin(mac, ip);
      server.begin();
      Serial.print("server is at ");
      Serial.println(Ethernet.localIP());
    }
    void loop(){
      //Tone Start
     tone(9, NOTE_D2);
     delay(65);
     noTone(9);
    //Tone End

    //clock start
      DateTime now = RTC.now();

        Serial.print(now.year(), DEC);
        Serial.print('/');
        Serial.print(now.month(), DEC);
        Serial.print('/');
        Serial.print(now.day(), DEC);
        Serial.print(' ');
        Serial.print(now.hour(), DEC);
        Serial.print(':');
        Serial.print(now.minute(), DEC);
        Serial.print(':');
        Serial.print(now.second(), DEC);
        Serial.println();

     //hour conversion to 12 hour start
       int x;
       int timeresult;
       x = (now.hour());
       if (x > 12) {
       timeresult = x - 12;
       }
       else
       {
        timeresult = x;
       }
       Serial.println(timeresult);
        //hour conversion to 24 hour start
    //clock end
    //sensor 1 start
     //Serial.println("read DHT22 #1");
     float h = dht.readHumidity();
     float t = dht.readTemperature();
     float f = dht.readTemperature(true);
     //sensor 1 end
     //sensor 2 start
     //Serial.println("read DHT22 #2");
     float h2 = dht2.readHumidity();
     float t2 = dht2.readTemperature();
     float f2 = dht2.readTemperature(true);
     //sensor 2 end
     //temp average begin
     //Serial.println("average calculation");
     float havg = (h + h2) / 2;
     float favg = (f + f2) / 2;
     float tavg = (t + t2) / 2;
     //temp average end

    //Relay 1 Start
     if (h < 42) //top threshold
     {
      if (h < 39) //bottom threshhold
      {
       digitalWrite(powerswitch1, HIGH);
       // Turn the Powertail on
       Serial.println("Switch ON");
    digitalWrite(ledPin, HIGH);
       myString = "ON";
      }

     }
     else
     {
                    myString = "OFF";
      digitalWrite(powerswitch1, LOW);    // turn the Powertail off
    digitalWrite(ledPin, LOW);
      Serial.println("Switch OFF");

     }
    //Relay 1 End
    //Relay 2 Start
     if (f < 60) //top threshold
     {
      if (h < 60) //bottom threshhold
      {
       digitalWrite(powerswitch2, HIGH);
       // Turn the Powertail on
       Serial.println("Switch ON");
    digitalWrite(ledPin2, HIGH);
       myString2 = "ON";
      }

     }
     else
     {
                    myString2 = "OFF";
      digitalWrite(powerswitch2, LOW);    // turn the Powertail off
    digitalWrite(ledPin2, LOW);
      Serial.println("Switch OFF");

     }
    //Relay 2 End
    //Screen start

    delay(500);

    tft.fillRect(20,19,80,140, ST7735_RED);//clear text
    //(left wall,top wall px from top,right wall,bottom wall px from top)
    tft.drawRect(20,19,80,140, ST7735_RED);//cleartext
    //active text
    tft.setCursor(35, 20);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(f);
    tft.setCursor(35, 40);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(t);
    tft.setCursor(35, 60);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(h);
    tft.setCursor(25, 120);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(timeresult);
    tft.setCursor(50, 120);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(now.minute(), DEC);
    tft.setCursor(75, 120);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(now.second(), DEC);

    //static text

    tft.setCursor(105, 20);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println("F");
    tft.setCursor(105, 40);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println("C");
    tft.setCursor(105, 60);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println("%");
    tft.setCursor(52, 80);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(myString);
    tft.setCursor(105, 80);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println("H");
    tft.setCursor(52, 100);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(myString2);
    tft.setCursor(105, 100);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println("T");
    tft.setCursor(52, 140);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println(millis() / 1000);
    tft.setCursor(105, 140);
    tft.setTextSize(2);
    tft.setTextColor(ST7735_WHITE);
    tft.println("-");

    tft.print(millis() / 1000);
    //Screen end

     EthernetClient client = server.available();
      if (client) {
        Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println("HTTP/1.1 200 OK");
              client.println("Content-Type: text/html");
              client.println("Connection: close");  // the connection will be closed after completion of the response
       client.println("Refresh: 5");  // refresh the page automatically every 5 sec
              client.println();
              client.println("<!DOCTYPE HTML>");
              client.println("");
              client.println("");
              /////CSS
                client.println("");
              ///CSS

              client.println("
");
              client.println(""); //how to change color adruino version

                client.println("
");
                client.println("<text4>");
                client.print("Sensor 1");
                client.println("</text4>");
                client.println("
");
                client.println("<text1>");
                client.print(h);
                client.print(" %\t");
                client.println("</text1>");
                client.println("
");
                client.println("<text2>");
                client.print(f);
                client.println(" °");
                client.println("F");
                client.println("</text2>");
                client.println("
");
                client.println("<text2>");
                client.print(t);
                client.println(" °");
                client.println("C");
                client.println("</text2>");
                client.println("
");
                client.println("
");
                client.println("
");
                client.println("<text4>");
                client.print("Sensor 2");
                client.println("</text4>");
                client.println("
");
                client.println("<text1>");
                client.print(h2);
                client.print(" %\t");
                client.println("</text1>");
                client.println("
");
                client.println("<text2>");
                client.print(f2);
                client.println(" °");
                client.println("F");
                client.println("</text2>");
                client.println("
");
                client.println("<text2>");
                client.print(t);
                client.println(" °");
                client.println("C");
                client.println("</text2>");
                client.println("
");
                client.println("
");
                client.println("
");
                client.println("<text5>");
                client.print("Humidifier: ");
                client.println("</text5>");
                client.println("<humidifier>");
                client.print(myString);
                client.println("</humidifier>");
                client.println("<text5>");
                client.print("Heater: ");
                client.println("</text5>");
                client.println("<heater>");
                client.print(myString2);
                client.println("</heater>");
                client.println("<text6>");
                client.println("
");
                client.print(millis() / 1000);
                client.println("</text6>");
                client.println("<text6>");
                client.print(timeresult);
                client.print(":");
                client.print(now.minute(), DEC);
                client.print(":");
                client.print(now.second(), DEC);
                client.println("</text6>");
                 client.println("
");
                  client.println("
");
              client.println("");
              client.println("");
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            }
            else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        Serial.println("client disonnected");
      }

    delay(3000);

    }

title: Arduino Uno + Ethernet shield stability question

Answers: 3

body:
I would go for a memory issue - try to rewrite your code in a way that consumes less memory, the easiest first step is to avoid any Serial.printl("String"); and replace that with Serial.println(F("String"));. But in general you are using a lot of String objects which should be avoided if possible (try to use char() instead).

To check memory consumption of your sketch you can use a function like this and log the values from specific points in the code:

    int freeRam () {
   extern int __heap_start, *__brkval;
   int v;
   return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
 }

body: I used to encounter weird issues, e.g. starting a new instance of a program with Arduino Yun. The issue in the end was power supply, a large capacitor before the voltage regulator has solved the problem. What do you use for power supply?

body: I have had to program in a reset for the network connection on quite a few of my ethernet projects.  I am not entirely sure the cause, but adding a close connection; open connection to run every x minutes seems to have helped prevent both the duplicating content and the timeout issues.


body:
From what I understand, the Pro Trinket has "Optiboot" which allows it to detect which boot loader you are trying to use, one for USB and one for FTDI. When it's in this "bootloader state" the red LED on pin 13 buses for 10 seconds before it starts to run the program I've programmed.

Can I remove this Optiboot functionality? Would that entail permanently choosing a single boot loader/interface?

One problem I have with this is that along with the LED on 13, it causes the LED strip I have attached to pins 9, 10, 11 to blink. I would also really like to not have to wait 10 seconds to start running code.

Here's the page on Adafruit's site that talks about the [bootloader\[s\] on the Pro Trinket][1].

Thanks!

  [1]: https://learn.adafruit.com/introducing-pro-trinket/starting-the-bootloader

title: How to remove Adafruit Pro Trinket bootloader flashing startup sequence

Answers: 4

body:
You could take the [Pro Trinket bootloader source code][1] and tweak it to your needs, [burn it][2], and make sure you have patience and debugging skills.

From the author's (Frank Zhao) source code, it seems that this is the 10 seconds loop you are referring to, located in **main.c**, line #456:

    if ( ((usbHasRxed != 0) && (timeout > USBBOOTLOADER_TIMEOUT)

The `USBBOOTLOADER_TIMEOUT` variable which is defined to `10` at the top of that file, line #70:

    #define USBBOOTLOADER_TIMEOUT 10

 and is progressed after 'roughly' 1 second, at line #496:

    // roughly 1 second
 #if (F_CPU == 12000000)
  if (t1ovf > 183) {
  #elif (F_CPU == 16000000)
  if (t1ovf > 244) {
  #endif
   t1ovf = 0;
   timeout++;
  }

  [1]: https://github.com/adafruit/Adafruit_ProTrinket_Bootloader
  [2]: http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader

body: I'd be careful to remove that section because these ten seconds are not only where the board detects which bootloader to use but also when it is accepting a new sketch at all. So if you'd get rid of that, you wouldn't be able to upload new sketches anymore i guess.

body:
Just program the pro trinket using ISP. (not using the USB connector). For example by using an [Arduino as a ISP-programmer](http://arduino.cc/en/Tutorial/ArduinoISP).

If you are brave, you could change the bootloader to only run when the reset button was pressed, and not at power-up. I've done exactly that for the regular trinket ([see my github](https://github.com/beargun/Adafruit-Trinket-Gemma-Bootloader/commit/4451cecf7ebcce8abb9f5a1e9c8c9ab3fe591a3d))

body:
**It is actually much simpler than the other answers suggest. There is no need to remove/overwrite the bootloader.** You can just disable the bootloader by setting the appropriate fuse bit.

In order to do so, you need an ISP programmer. As you might know, you'll loose the ability to upload code though USB/FTDI. But you can restore that ability at any time, just by resetting the appropriate fuse bit to its original value.

## Step 1: Connect your trinket through an ISP programmer

There is no ISP header on the trinket, but you can easily build one or just use jumper wires to connect the individual pins directly to the programmer. [Pinout can be found at learn.adafruit.com](https://learn.adafruit.com/introducing-pro-trinket/pinouts). You need to connect MISO, MOSI, SCK, RST, VCC and GND.

## Step 2: Determine current fuse configuration

    avrdude -c usbtiny -p m328p

*If you're using a different programmer than the USBTinyISP, replace `usbtiny` with the appropriate identifier. List possible values by specifying a bogus identifier, eg. `avrdude -c foo`.*

Among some other things, avrdude should return a line containing the current fuse values. It should look similar to the following:

> avrdude: safemode: Fuses OK (E:FD, H:D0, L:FF)

We're interested in the *high* fuse (H:D0). `D0` indicates that the bootloader is enabled. Actually, any even number means the bootloader is enabled.

## Step 3: Calculate new fuse value

We want to set the `BOOTRST` bit of the *high* fuse. It is the least significant bit of the fuse, which equals the number 1. So all we need to do is increment the value by 1.

In the example, the new fuse value is `D1`.

*If you are unsure how to calculate the fuse value, you can use the [Fuse Calculator](http://www.engbedded.com/fusecalc/). Choose ATMega328P as your device, enter the fuse values as reported by avrdude at the very bottom under "Current settings", then click apply. Uncheck `BOOTRST` in the "Manual fuse bits configuration" section, then you will see the new fuse value in the bottom section, where you entered the original value.*

## Step 4: Program new fuse value

    avrdude -c usbtiny -p m328p -U hfuse:w:0xd1:m

Again, replace `usbtiny` with the identifier of your programmer. If you calculated a different value than `D1`, replace `0xd1` with your approriate value. **However, if your original value for the high fuse was `D0`, then your new value _is_ `D1`.**

## Done!


body:
I'm currently working on a Arduino Mega (GPS + IMU + SD card logging + BT). I need the Mega for extra memory and serial port.
I would like to transition to something with a smaller form factor now. I need help with suggestions for a smaller form factor board/version of Mega.

Any suggestions?
I can't really find anything.

The only small size yet meeting requirements (in terms of memory) option seems to be a [Microduino][1] -
but I'm not whether all the libraries (SDfat etc.) will work on this.

  [1]: https://www.microduino.cc/module/view?id=53d7037cb6c69d00003ede53

title: Smaller version of the Mega

Answers: 3

body:
The ATmega1284P provides 128kB of flash, 16kB of SRAM, 4kB of EEPROM, and 2 USARTs in a 40/44/49-pin package. Mighty 1284P provides Arduino support for the '1284P.

There aren't too many actual boards that feature it, but it can be used very easily on a breadboard or custom PCB with a programmer.

body: The link uses the same chip that Ignacio recommended.  The libraries will need some minor edits, but many of the standard ones do have a 1284P fork.  It is mostly just redoing pin assignments, or adding the 1284P to the board definitions.  I am working on a similar project and have gotten the 1284P to work with SDfat, a bunch of standard GPS libraries, and TinyGPS++ .

body:
Look for "Mega2560-CORE" on ebay.

Some information:
http://www.inhaos.com/product_info.php?products_id=88


body:
I have a Freeduino USB 1.1 board with atmega 8l-8pu microcontroller on it. When I try to upload program, it shows error:

    avrdude stk500_getsync() not in sync: resp 0x00

I have tried reset and the red led blinks which I think suggest bootloader is working fine.

On Arduino IDE, I have set Arduino Uno and correct port which is shown in device manager.

One weird problem that I noticed is that no matter which USB port I connect to, it says COM9 on device manager. Is that something to look into?

Any ideas?

title: Freeduino avrdude stk500_getsync() not in sync

Answers: 1

body:
There could be many reasons for the problem you have got.

1) Try to program your Board with any other device you have got. If you are trying to program it with PC try to do it using Laptop.

2) Plug your board to any other port. Then Right Click My Computer and Select Manage--> Device Manager and find the port where your Freeduino is connected. Then Select that port in  your Arduino IDE.

Solution 1 worked for me!


body:
I am using the Ethernet Shield on top of the Arduino Uno. I want to use this setup to access  webpages. But I am unable to access because the ethernet connection is present in a University which requires a proxy server with authentication. I am unsure of what extra code to include so as to get past the proxy which requires authentication.
Can anyone help in solving this problem?

title: Proxy and Authentication in Arduino Uno

Answers: 1

body:
Any semi-reputable authentication mechanism would be performed over HTTPS, which is an encrypted connection - this would require an SSL library to be installed for use along with the normal Ethernet and HTTP libraries, and I don't believe the arduino really has the processing capability to make connections like this feasible.
Unfortunately this is one of those cases where a more sophisticated device may be more appropriate.... (like a Beaglebone Black, or a Raspberry Pi.)

It is possible that you could add headers into the HTTP connection packet to either bypass proxy authentication, or include a cookie that has already undergone authentication and is cached by the proxy. How you do this is almost entirely down to how your proxy works. You may also find this doesn't work unless you spoof the MAC address of your device to match that of the machine used to fulfill the authentication.

It is entirely possible to set up a system to share the internet connection (act as a router) between two adapters - so you end up making connection requests to webpages, but the authenticated proxy only sees requests coming from your system (this is kind of how mobile phone tethering works, when you access the internet on a laptop or tablet through your smartphone's internet connection).

**If** the proxy supports unencrypted authentication, it may be possible to pass through username/password details in plaintext (or Base64 encoded) in [Basic access authentication][1], which is what HTTP (and HTTPS) often uses - but this is unsafe on HTTP and is **VERY** unsafe when any part of the connection is publicly transmitted - like when using wifi, for example. (Doesn't matter if the wifi is encrypted - as on a university network, everyone who can connect to the wifi can see your wifi traffic (typically).)

If you're going to be using your own personal university login credentials to do this, make sure you always use ethernet to do it, not wifi, and if possible, obtain a second username/password explicitly for connecting this way - you don't want to have to hard-code your own personal username and password into source code that you have to give to anyone.

Here's a few links to get you started:

 - [HTTP Spec: Proxy-Authorization and Authorization headers][2]
 - [How to use authentication in an HTTP Proxy?][3]
 - [Wikipedia: X-Forwarded-For][4]

  [1]: http://en.wikipedia.org/wiki/Basic_access_authentication
  [2]: https://stackoverflow.com/questions/10023636/http-spec-proxy-authorization-and-authorization-headers
  [3]: https://superuser.com/questions/334912/how-to-use-authentication-in-an-http-proxy
  [4]: http://en.wikipedia.org/wiki/X-Forwarded-For


body:
I found some code that works to transmit the required signal to an RX-2B RC receiver, the code works great from my Uno but when I tried to run it from my Yún nothing happens.

The code has definitely uploaded as I tested with an LED and the pin is getting a HIGH voltage written to it.

Does anyone have any idea what the issue might be? Code below.

Thanks.

    /**
    * Control Realtek RX2 (RX2 -G) RC Receiver with Arduino
    *
    * @author Mircea Diaconescu, Octomber 28, 2013
    * @source https://github.com/dimircea/
    * GPL v3 License
    *
     * Many cheap RC toys are based on TX2 / RX2 transmitter / receiver ICs.
     * This Arduino sketch allows to replace the TX2 based Remote Control with Arduino.
     * Just one single pin is used from the Arduino board.
     *
     * Connect Arduino pin 10 to the solder point where the toy antenna is connected or         to the toy antenna cable.
     * One can replace pin 10 with other free digital pin available on the Arduino board.
         *
     * TX-2B/RX-2B datasheet: http://www.datasheetarchive.com/dl/Datasheet-    035/DSA0017137.pdf
     */

    /** Functions (aka W1) - as defined by the IC datasheet */
    #define COMMAND_ENDCODE         4
    #define COMMAND_FORWARD        10
    #define COMMAND_FORWARD_TURBO  16
    #define COMMAND_TURBO          22
    #define COMMAND_FORWARD_LEFT   28
    #define COMMAND_FORWARD_RIGHT  34
    #define COMMAND_BACKWARD       40
    #define COMMAND_BACKWARD_RIGHT 46
    #define COMMAND_BACKWARD_LEFT  52
    #define COMMAND_LEFT           58
    #define COMMAND_RIGHT          64

    //output pins
    #define ANTENNA_PIN 9

    /** Initialize the Arduino data and pin */
    void setup() {
     pinMode( ANTENNA_PIN, OUTPUT);
    }

    /** Loop code */
    void loop() {
     // add here your commands to control the RX2 module...
     // for test purposes, here a continuous forward command is sent

     sendCommand( COMMAND_FORWARD);

    }

    /** Send command to the RX2 IC */
    void sendCommand( int command) {
     int w1 = 0, w2 = 0;

     /** start code sequence 4 x W2, ~625Hz, Duty Cycle 75% */
     for ( w2 = 0; w2 < 4; w2++) {
       digitalWrite( ANTENNA_PIN, HIGH);
       delayMicroseconds( 1200);
       digitalWrite( ANTENNA_PIN, LOW);
       delayMicroseconds( 400);
      }

     /** function code sequence, n x W1, ~1.25KHz, Duty Cycle 50% */
     for ( w1 = 0; w1 < command; w1++) {
       digitalWrite( ANTENNA_PIN, HIGH);
       delayMicroseconds( 400);
       digitalWrite( ANTENNA_PIN, LOW);
       delayMicroseconds( 400);
     }
    }

title: Works on Uno but not on Yun

Answers: 1

body:
A Yun is like a Leonardo with a CPU running GNU/Linux at its side. If your sketch works with a Leonardo, it's likely to work with a Yun.

Uno has a different MCU and thus not every sketch will just work, especially those using the hardware serial. You'll have to convert them.


body:
I'm new in the Arduino Community and I'm facing a problem when I try to use a PS2 Keyboard and an LCD Display (16x2) on an Arduino Uno with a Wifi shield.

I would like to write something with the keyboard and display it in the LCD before sending it to a webservice.

Here is my problem:

- When I use the keyboard and the display on my Arduino WITHOUT the wifi shield --> All is OK. I can write on the display the key that has been pressed.
- When I use the keyboard and the display on my Arduino WITH the wifi shield --> All is OK until I write something on the display. As soon as I write on the display with the function lcd.print(), the keyboard does not work anymore (it detect the character '2' every time I press a key).

It's very surprisingly because if I dont use lcd.print(), the keybord works without any problem.

Here is a part of my code:

    #include <LiquidCrystal.h>
    #include <PS2Keyboard.h>

    LiquidCrystal lcd(12, 11, 2, 5, 6, 8);
    PS2Keyboard keyboard;

    const int DataPin = 9;
    const int IRQpin = 3;

    void setup(){
      keyboard.begin(DataPin, IRQpin);
      lcd.begin(16, 2);
    }

    void loop(){
      checkKeyboard();
    }

    void checkKeyboard(){
      if (keyboard.available()) {

        char c = keyboard.read();

        // check for some of the special keys
        if (c == PS2_ENTER) {
          Serial.println();
        } else if (c == PS2_TAB) {
          Serial.print("[Tab]");
        } else if (c == PS2_ESC) {
          Serial.print("[ESC]");
        } else if (c == PS2_PAGEDOWN) {
          Serial.print("[PgDn]");
        } else if (c == PS2_PAGEUP) {
          Serial.print("[PgUp]");
        } else if (c == PS2_LEFTARROW) {
          Serial.print("[Left]");
        } else if (c == PS2_RIGHTARROW) {
          Serial.print("[Right]");
        } else if (c == PS2_UPARROW) {
          Serial.print("[Up]");
        } else if (c == PS2_DOWNARROW) {
          Serial.print("[Down]");
        } else if (c == PS2_DELETE) {
          Serial.print("[Del]");
        } else {
          Serial.print(c);
          displayText(c);
        }
      }
    }

    void displayText(char c){
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Pressed key:");
      lcd.setCursor(0,1);
      lcd.print(c);
    }

Does somebody know how to solve this problem?

Thank you very much in advance :)

Edit: Here are the pins that I use on the board :

- Arduino pin 2 -> LCD pin 11
- Arduino pin 5 -> LCD pin 12
- Arduino pin 6 -> LCD pin 13
- Arduino pin 8 -> LCD pin 14
- Arduino pin 11 -> LCD pin 6
- Arduino pin 12 -> LCD pin 4
- Arduino pin 3 -> Keyboard IRQ
- Arduino pin 9 -> Keyboard Data

title: Arduino Uno + Wifi Shield + PS2 Keyboard + LCD Display

Answers: 3

body:
You must verify which pins the wifi shield is using and see if they aren't used also by the LCD.
Can you provide further details on the wifi shield ?

body:
As you say, I can't use pins 10, 11, 12, 13 because they are used for the SPI.

-> So, I tried to use the pins 4 and 7 instead of 11 and 12.

The problem is that the pin 7 is used by the Wifi shield (Handshake) and I have no other free digital pin.

-> So, I tried to use an analog pin instead of the pin 7 and ..... it works very well.

Here is my final solution :

- Arduino Pin 2 -> LCD Pin 4 (RS)
- Arduino Pin 3 -> Keyboard IRQ
- Arduino Pin 4 -> LCD Pin 11 (D4)
- Arduino Pin 5 -> LCD Pin 12 (D5)
- Arduino Pin 6 -> LCD Pin 13 (D6)
- Arduino Pin 7 ->
- Arduino Pin 8 -> LCD Pin 14 (D7)
- Arduino Pin 9 -> Keyboard Data
- Arduino Pin 10 ->
- Arduino Pin 11 ->
- Arduino Pin 12 ->
- Arduino Pin 13 ->
- Arduino Pin 14 (= Analog 1) -> LCD Pin 6 (E)

body:
Sorry I do not have enough reputation to place a comment.

@Valentin from the link, you provided, to the wifi shield it states that it uses pins 11 ,12 and 13 on the UNO which will give you a conflict on pins 11 and 12 with the LCD. Not sure why that manifests as an apparent keyboard error though:

From the linked page:
>Arduino communicates with both the Wifi shield's processor and SD card using the SPI bus (through the ICSP header). This is on digital pins 11, 12, and 13 on the Uno and pins 50, >51, and 52 on the Mega. On both boards, pin 10 is used to select the HDG204 and pin 4 for >the SD card. These pins cannot be used for general I/O. On the Mega, the hardware SS pin, >53, is not used to select either the HDG204 or the SD card, but it must be kept as an output or the SPI interface won't work.

Again sorry this is not a full answer but thought it may help.


body:
Would it be possible to instead of passing a state via a REST browser:

    digital/13/1

to set an int value? For example, if in the sketch if I would name an int: 2, could I set this to 48 via REST?

If so, how?

title: Arduino Yun, pass int data true REST

Answers: 1

body:
Check out the [TemperatureWebPanel][1] example: you'll see that you can make your own REST APIs and pass any values your sketch can handle.

  [1]: http://arduino.cc/en/Tutorial/TemperatureWebPanel


body:
I just received my first [Arduino board][1] which is essentially a Leonardo (ATmega32U4) customized to include a NFC reader (PN532).

When I plug it in, the PWR LED comes on steady, the D13 LED flashes a few times, and then the STA LED blinks once and only the PWR LED is left on. I can upload a basic sketch to the correct Serial Port, but the Serial Monitor is always empty.

I have noticed that, when uploading the sketch, the RX/TX LEDs stay off (which I thought was a sign of uploading/downloading data). I figured this was the root of my issue so I tried to look into it further. Running `lsusb` does not find the device and `dmesg` does not show any information when (un)plugging the device.

I also tried on a Windows install, but couldn't install the Leonardo drivers since Device Manager wouldn't register any unknown USB/Arduino devices.

Do you think my board is dead on arrival or am I doing something wrong?

---

**Update:**

I just uploaded the Blink tutorial sketch and it uploaded "successfully" but I noticed no differences. Please note that I don't have an external LED attached, but am looking at the board's LED on pin 13. This pin already flashes a few times (as mentioned above) on a reset, so I modified the delay times and still noticed no change.

![uploaded sketch][2]

I am uploading using board Leonardo, as recommended for my hardware, and the serial port /dev/ttyS0. I thought this was the right port because I remember not seeing it at first, but on second thought I had a permission issue at first (which is now resolved) causing me to not see the port.

*So it looks like my board is* ***not*** *detected by my computer and I'm successfully uploading sketches to a meaningless port.* Any troubleshooting options for me? I've tried different USB ports and am, as of recently, plugging my board into external power (9V). The only thing I can think of that on my end is that I'm using a Y-cable for my USB connection (I have a normal Mini-USB coming tomorrow via Amazon) since it is all I had. I can also confirm that this USB connection ***does*** power the board when plugged in.

  [1]: http://www.elecfreaks.com/wiki/index.php?title=NFC_Bridge
  [2]: https://i.stack.imgur.com/bbb6n.png

title: Arduino board not recognized by Linux (dmesg, lsusb, etc.)

Answers: 1

body:
So, to summarise the comments trail; the blinking lights at power-up are the normal boot sequence for the Leonardo,  indicating the processor is good, and that power is reaching the board; the device seen should be /dev/ttyACM0 or some other number; dmesg wasn't recording a plug-in event as the cable was not good.

We still don't quite know why the IDE thought it had sent a program to /dev/ttyS0, but presumably the level of interaction is much less (ie, none) via RS232 serial? Which explains why it said it had uploaded a test program when, in fact, it hadn't!

And replacing the USB cable has solved the problem - excellent news!


body:
I'm trying to use 3 pins as capacitive pins along side the [Mozzi][1].

I had several attempts and so far the closest I had was using code from the [ADCTouch library][2] straight into the main code, but with the current implementation (removing averaging and taking less samples to speed things up) it's only fast enough to process 1 pin and I'd like to use 3.

Here is my implementation so far:

    /*  Based on the Gain Example changing the gain of a sinewave,
        using Mozzi sonification library.

        Demonstrates the use of a control variable to influence an
        audio signal.

        Circuit: Audio output on digital pin 9 on a Uno or similar, or
        DAC/A14 on Teensy 3.0/3.1, or
        check the README or http://sensorium.github.com/Mozzi/

        Mozzi help/discussion/announcements:
        https://groups.google.com/forum/#!forum/mozzi-users

        Tim Barrass 2012, CC by-nc-sa.
    */

    #include <MozziGuts.h>
    #include <Oscil.h> // oscillator template
    #include <tables/sin2048_int8.h> // sine table for oscillator

    // use: Oscil <table_size, update_rate> oscilName (wavetable), look in .h file of table #included above
    Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin(SIN2048_DATA);

    // control variable, use the smallest data size you can for anything used in audio
    byte gain = 255;

    //ADC Touch setup
    int sampleCount[3] = {0};
    int values[3] = {0};

    void setup(){
      startMozzi(); // start with default control rate of 64
      aSin.setFreq(4200); // set the frequency
    }

    void updateControl(){
      if(gain > 3){
        gain = gain - 3 ;
      }else{
        gain = 0;
      }
      //begin ADCTouch
      pinMode(A4, INPUT_PULLUP);

      ADMUX |=   0b11111;
      ADCSRA |= (1<<ADSC); //start conversion
      ADCSRA |= (1<<ADIF); //reset the flag

      pinMode(A4, INPUT);

      values[0] = mozziAnalogRead(A4);
      sampleCount[0]++;
      //end ADCTouch

      if(sampleCount[0] == 64){//wait for 64 samples
        if(values[0] > 500) {//did we get a touch with all these samples ?
          gain = 255;//amp it up
        }
        sampleCount[0] = 0;//reset count
      }

    }

    int updateAudio(){
      return (aSin.next()* gain)>>8; // shift back to STANDARD audio range, like /256 but faster
    }

    void loop(){
      audioHook(); // required here
    }

The issue is as soon as do the pinMode calls for the second pin I'd like to use (A5) so I'm guessing pinMode needs to work faster. To use `pinMode(INPUT_PULLUP)` and `pinMode(INPUT)` calls for pins A4,A5 and digital 10, now can I write this using direct port manipulation ?

(I'm new to avr/arduino internals and slowly getting the grips with this).

  [1]: http://sensorium.github.io/Mozzi/
  [2]: http://playground.arduino.cc/Code/ADCTouch

title: How can I make pinMode calls faster?

Answers: 1

body:
First, figure out which port and pin you're using. Then, manipulate them.

    DDRC &= ~_BV(PC5);
    PORTC |= _BV(PC5);

...

    DDRF &= ~_BV(PF5);
    PORTF |= _BV(PF5);

...

    DDRF &= ~_BV(PF0);
    PORTF |= _BV(PF0);


body:
I recently purchased a W5100 based ethernet shield for my arduino Uno, and looks like [this][1]. I had been following the guide [here][2], and connected the pins accordingly - 5V to 5V, GND to GND, MOSI to 11, MOSO to 12, SCK to 13, and SS to ten.

 I booted up a default sketch (webServer, under Ethernet), and plugged in and ethernet cable. - PWR, LINK, SPD,and FDX all lit up, with Rx blinking for first 10 or so seconds. I then go to the IP specified on the arduino sketch, and nada. Also, my router doesn't show the shield under the attached devices.

Therefore, I figure it's a problem with my connections. Can anyone help me? Googling has only brought my lots of info about shields, and little info on these modules.

  [1]: http://yourduino.com/sunshop2/images/products/large_243_Ethernet-W5100-3-1024.jpg
  [2]: http://arduino-info.wikispaces.com/Ethernet

title: W5100 module hookup help - Not a shield

Answers: 1

body:
First, if you cannot connect to arduino by ethernet, use Serial Monitor and add some Serial.println to your code to log what is going - what part of program Arduino is executing.

W5100 module has no automatic reset module as opposed to Ethernet shield.
So try to connect W5100 RST pin to for example D8 and reset module in setup.

Here you are example from my (working) project:

    const int W5100_RESET_PIN = 8;

 void setup() {
   Serial.begin(SERIAL_SPEED);
   Serial.println();
   Serial.println(F("node starting..."));
   pinMode(W5100_RESET_PIN, OUTPUT);
   digitalWrite(W5100_RESET_PIN, LOW);
   delay(100);
   digitalWrite(W5100_RESET_PIN, HIGH);
   // give the Ethernet shield a second to initialize:
   delay(3000);
 #ifdef USE_DHCP
   Serial.println(F("DHCP..."));
   while (Ethernet.begin(mac) == 0) {
  Serial.println(F("DHCP failed."));
  delay(10000);
   }
 #else
   Serial.print(F("static IP..."));
   Ethernet.begin(mac, IPAddress(MY_IP));
 #endif
   Serial.print(F("local IP:"));
   Serial.println(Ethernet.localIP());
   Serial.println(F("node started."));
 }

Also after setup if your arduino lost ethernet connection and cannot get it again, you can try to reset w5100 and initialize Ethernet again.


body:
I have a SparkFun Red board (Arduino Uno R3) with a SparkFun CC3000 shield attached. I am trying to post data to the "data.sparkfun.com" service in order to test a basic Wifi data logger. I am using the AdaFruit CC3000 library for the sketch.

The problem is am having is that immediately after a power off and reset, the HTTP Get is successful. However, when the loop runs again, the post fails. Usually on the 2nd attempt. I have had a few times where it has looped 2-3 time before failing. But it always fails. If I reset the board with the push button or by disconnecting the serial monitor and reconnecting, it still fails to send the HTTP request.

I have checked my ram usage, and it doesn't appear to have any sort of leak in that regards. I have spent days looking online for similar issues, and can't seem to find anything related.

To make this all the more confusing, the board just seems to freeze, it doesn't give any sort of error on anything. And the freeze seems to happen at different places, nothing seems consistent.

Would someone mind checking my sketch code, seeing if there is anything glaring; maybe I have a bad board?

        #include <Adafruit_CC3000.h>
        #include <SPI.h>
        #include <avr/wdt.h>

        ////////////////////////////////////
        // CC3000 Shield Pins & Variables //
        ////////////////////////////////////
        // Don't change these unless you're using a breakout board.
        #define ADAFRUIT_CC3000_IRQ   2
        #define ADAFRUIT_CC3000_VBAT  7
        #define ADAFRUIT_CC3000_CS    10
        #define IP_ADDR_LEN     4   // Length of IP address in bytes

        #define SensorPin A0

        ////////////////////
        // WiFi Constants //
        ////////////////////
        #define WLAN_SSID "Hayes"
        #define WLAN_PASS "123456"
        #define WLAN_SECURITY WLAN_SEC_WPA2
        #define timeout 30000
        #define website "data.sparkfun.com"
        #define publicKey "MGg93JbM8LFJAQxG3jK0"
        #define privateKey "nz9M8WZVaXU7WXz4VnlX"
        #define NUM_FIELDS 1

        // Initialize the CC3000 objects (shield and client):
        Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,
                                 ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);

        /////////////////
        // Phant Stuff //
        /////////////////
        const String fieldNames[1] = { "value" };
        String fieldData[1];
        uint32_t ip = 0;

        //////////////////////
        // Input Pins, Misc //
        //////////////////////

        void setup()
        {
          wdt_disable();
          Serial.flush();
          Serial.begin(115200);
          Serial.println(F("\nInitializing..."));
          if (!cc3000.begin())
          {
            Serial.println(F("Couldn't being()! Check your wiring?"));
            while (1);
          }

          //Connect to WiFi network
          Serial.print(F("Connecting to WiFi network... "));
          Serial.println(String(WLAN_SSID));
          cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY, 3);
          Serial.println(F("done!"));
          while (!cc3000.checkDHCP())
          {
            delay(1000);
          }
          Serial.print(F("data.sparkfun.com -> "));
          while (ip == 0)
          {
            if (!cc3000.getHostByName("data.sparkfun.com", &ip)) {
              Serial.println(F("Couldn't Resolve!"));
              while (1) {}
            }
            delay(1000);
          }
        }

        void loop()
        {
          cc3000.printIPdotsRev(ip);
          Serial.println(F(""));
          float moisture = analogRead(SensorPin);
          fieldData[0] = String(moisture);
          Serial.println("Sensor Reading: " + String(moisture));
          int t = millis();
          //wdt_enable(WDTO_8S);
          Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
          if (client.connected()&&
            ((millis() - t) < timeout))
          {
            Serial.println(F("Connection to Sparkfun data server."));
            Serial.print(F("Sending Request..."));
            client.print("GET /input/");
            client.print(publicKey);
            client.print("?private_key=");
            client.print(privateKey);
              client.print("&");
              client.print(fieldNames[0]);
              client.print("=");
              client.print(fieldData[0]);
            client.println(" HTTP/1.1");
            client.print("Host: ");
            client.println(website);
            client.println("Connection: close");
            client.println();
            Serial.println(F("HTTP command posted, getting response."));
          }
          else {
              Serial.println(F("Connection to website failed."));
            }

        //  while (client.connected())
        //  {
        //    while (client.available())
        //    {
        //      char c = client.read();
        //      Serial.print(c);
        //    }
        //  }
          client.close();
          Serial.println(F("Posting Data Complete"));
          //wdt_reset();
          //cc3000.disconnect();

          //reset watchdog and disable
          //wdt_reset();
          wdt_disable();

          delay(15000);
        }

title: Sparkfun Red board and CC3000 shield not allowing multiple HTTP_GET requests.

Answers: 0


body: It appears to me that each Arduino has (should have?) a unique /dev/tty...USB... number assigned. Why this isn't explained anywhere (that I can find) is a mystery. When I plug my problem Nano into a USB port on my iMac no /dev/tty... for it appears. It used to work. Have I fried it? Can this be fixed?

title: Arduino Nano -- cannot download, no /dev/tty*** device

Answers: 1

body:
This is probably a duplicate question and duplicate answer, but ...

Flip the board over, look at the bottom. If it says "FTDI" then this answer doesn't apply. But many cheap clones have moved to the CH340G chip for USB serial communication, it's a tenth of the cost with a tenth of the (unused) features.

You can find CH340/341 drivers from the manufacturer at [WCH.CN][1] or linked at the bottom of [this post][2].

Or, skip the USB altogether and search for "ISP" on [Tindie][3] and grab a USBASP or TinyISP programmer.

  [1]: http://WCH.CN
  [2]: http://www.ardueasy.com/2014/10/different-varieties-of-arduino-nano.html
  [3]: https://Tindie.com