message:
Getting "avrdude:stk500_recv(): programmer is not responding" while uploading sketch to Arduino Pro Mini

I recently bought an Arduino Pro Mini(3.3V 328p, 8MHz) along with a CP2102 USB to TTL UART convertor. When I try to upload a sketch to the Pro Mini using it, I get a `avrdude:stk500_recv(): programmer is not responding` error. My connection was like

    Arduino pro mini                CP2102
    TXO  ----------------------------> TXD
    RXI  ----------------------------> RXD
    VCC  ----------------------------> 3V3
    GND  ----------------------------> GND
    DTR  ----------------------------> DTR

I tried inter-connecting the TXO and RXI pins and had no luck. Also pressing and releasing the reset button on the Pro Mini doesn't seem to work either.  I also tried programming it with my Arduino Uno, by removing the 328 and connecting correspondingly. Still no use.

Does any one have any ideas?

body:
If this is a cheap clone it may be that there is no bootloader installed. You might try using a programmer or an [Arduino as ISP][1] to reprogram the device if this is the case. Using ISP programming will avoid any problem with serial connections as it is using SPI wiring instead and the Arduino IDE allows you to load the necessary bootloader using this method to enable programming over serial. You will need either an ISP programmer or another Arduino however.

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


sender: user

sender: assistant

body:
You should try another USB port, install the right drivers for the TTL/uart chip and reboot your PC. That worked for me.

----

Also, you should consider getting an arduino nano usb, these have an built in ttl/uart converter, ICSP header and can be placed on a breadboard easily.


body:
In the Arduino IDE for my Pro Mini I have to select the board:
"Arduino Deumilanove or Diecimila"

I'm not sure why this is or if this could cause any potential damage to your Pro Mini but I do know for sure this is the solution I used to program my pro mini and it works every time.


body:
Change baudrate to

    UPLOAD_RATE=57600

in `Makefile` (or via the GUI). I have seen your error many times and this fixes it, albeit on the 5V/16MHz mini USB variant. If 57600 does not work, try other values. I use this rate on my USB serial - may be different on bare Rx/Tx pins.

You have probably not messed up your bootloader, that is rarer than people think. I think your Arduino has some invalid code running, and it keeps resetting until it finds valid code - when I had that problem, I pressed reset just before punching enter for 'make upload'. Even if it does that, you've got perhaps 0.5s to initiate an upload after reset.

Do correct me if I'm wrong.


body:
I had the same problem and I used a magnifying glass to check the processor.  I bought my clones off of eBay and they are using the ATMega168 (3.3V, 8 MHZ) processor.  Once I realized my mistake and switched to the correct processor version, the upload was seamless.

I'm using an "FTDI FT232RL USB to TTL Serial Converter Adapter Module 5V and 3.3V For Arduino" for the programming connection, with

 - DTS-DTS;
 - Rx-Tx;
 - Tx-Rx;
 - VCC-VCC;
 - GND-GND, and;
 - GND-CTS.

I didn't even need to use the "reset" workaround of holding down the reset button before pressing the upload button and releasing when the words "Maximum is ..." appear in the output window.


body:
rx -> tx
tx -> rx

Please check your connections.


body:
The problem is crystal clear in the picture
[![enter image description here][1]][1]

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


body:
1. Check connections, make sure RX-TX lines are crossing over.
2. **Arduino** -> **Preferences** -> **Show verbose output during** - check **upload** will give you better visibility what is happening.
3. When Arduino says "Uploading..." briefly press reset. The upload should start.

But one thing that helped me was... try different USB-UART adapter. For some reason the one which looked like (and was) cheap knockoff worked like a charm.

As a general advice, when sourcing parts from Chinese manufacturers I learned to be redundant - I usually order a bit more than I need and from mixed sources.


message:
Installing Ports for Arduino Nano on Mac OS X Yosemite

Just starting with Arduino and have gotten stuck at the first hurdle: trying to connect an Arduino Nano with my Mac Book Pro which runs 10.10. I can't seem to find the right port as all suggestions have bluetooth in the name and none with USB anything. Also the post list does not change when I plug/unplug the Arduino. Looking at http://arduino.cc/en/guide/macOSX#toc3 it says that I need to install FTDI software to get the USB port to show, however, having done this it still does not work. Any suggestions?

Thanks,
Calum

body:
Had exactly the same problem. Also using 10.10 and just got an Arduino. What worked for me was using a different cable. The one that came with my Arduino Uno only provided power not data. If you have a printer, it might have the right cable, just test it quickly.

Edit: In addition, whilst trying to find solutions, I also installed 64bit mac FTDIUSBSerialDriver_v2_2_18.dmg. I'm not sure if it made a difference. As after installing it and using the original cable the problem persisted.


body: Are you using a USB hub? I had problems with my MBP when the Arduino was on a hub. Attached directly to the mac it was fine.


message:
Arduino Upgrading from 1.0.6 to 1.6, code doesn't work anymore

I'm using Arduino UNO, and today I upgraded my IDE from 1.0.6 to 1.6, just to upgrade, nothing special.

I got my libraries again but I got an error with a code that was working OK.

The error was:

    In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223:0,
                     from C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.h:53,
                     from C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp:32:
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h: In member function 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)':
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ubrrh', can't use default assignment operator
     class HardwareSerial : public Stream
           ^
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ubrrl', can't use default assignment operator
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsra', can't use default assignment operator
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsrb', can't use default assignment operator
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsrc', can't use default assignment operator
    C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_udr', can't use default assignment operator
    C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp: In member function 'void ModbusMaster::begin(uint16_t)':
    C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp:139:16: note: synthesized method 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)' first required here
           MBSerial = Serial;
                    ^

I couldn't find the real error, can someone help me?

body:
You should not have added libraries to the Arduino files in the "C:\Program Files (x86)\Arduino" folder in the first place.
That is only for the Arduino program files and standard libraries that are included with the Arduino IDE.

Could you uninstall the Arduino and serial drivers. Remove also the "C:\Program Files (x86)\Arduino" folder, to be sure that absolutely nothing is left behind, because that will interfere with a new version that will be installed. Remove also the hidden "arduino15" folder(s).
Do you know the location of your sketches, it is in the preferences and is often "Documents\Arduino". Go to that folder and go into the "libraries" folder. Remove unused libraries or libraries that have been included in the Arduino files.
Do you have Java installed ? Some Java versions are not compatible with the Java files of the Arduino. If you don't need Java, then uninstall it.

Install the newest Arduino 1.8.3 from [Arduino.cc Software][1].
Use the Library Manager in the Arduino IDE, and search for modbus. Install the "ModbusMaster by Doc Walker" with the Library Manager. The modbus library that will be installed is this one: [Github 4-20mA ModbusMaster][2].

There has been a few changes, for example with PROGMEM. All PROGMEM data must now be 'const'. You might have to make a few adjustments.

  [1]: https://www.arduino.cc/en/Main/Software
  [2]: https://github.com/4-20ma/ModbusMaster


body:
Judging by the error messages you were using a ModbusMaster library from GitHub such as [this one][1] and the HardwareSerial library from the Arduino IDE.

I think the key is in the statement:

> I got my libraries again

I would suggest that you have downloaded a different library to what you originally used. Even if you did get the same repository, these libraries are also constantly changing and your code sometimes has to evolve with the library.

You have several errors (with the SoftwareSerial library): `non-static const member, can't use default assignment operator`. Essentially the program is trying to assign a value to a const or perhaps assigning a constant pointer to non-const data. Find more information on the error [here][2] and [here][3]. All of these errors stem from line 83 of HardwareSerial.h.

The last line(s) give the clue. You are assigning your instance of your Serial object to you MBSerial object.

  [1]: https://github.com/4-20ma/ModbusMaster
  [2]: https://stackoverflow.com/questions/15030972/type-non-static-const-member-cant-use-default-assignment-operator-what-does
  [3]: https://stackoverflow.com/questions/634662/non-static-const-member-cant-use-default-assignment-operator


message:
What could cause interrupts from MCP23017 suddenly stop working?

I have 4 rotary encoders connected to an MCP23017 which in turn is connected to interrupt port 0 on the arduino (and to I2C of course). Everything works fine: I get interrupts for all 4 rotary encoders, can read the values for them and even store these values in the EEPROM and load them in setup.

![Fritzing schematic of the (initially) working setup][1]

Now, I connect a WS2812 LED to the arduino (with a resistor and a capacitator in front of it). I connect the UNO and the led lights up. I attach the serial console (resetting the UNO) and it stops working (LED does not light up). This could just be simple wiring mistake and is not my real problem.

I remove the LED (and the capacitor) from the board and start everything up again. I can see via the serial console that the UNO works, however it does not receive any interrupts anymore. I exchange the MCP23017 thinking I fried it somehow but that doesn't change anything either...

Is there some sort of state the UNO has I could have affected?

Or could I have fried the interrupt "sub-system" on the UNO (again: all the other stuff still works)?

EDIT: The code is here: https://github.com/qollin/Liting/blob/master/src/Liting.cpp

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

body: I think I figured out whats wrong: you need to reset the interrupt handling of the MCP in setup() (by reading from both INT pins). Otherwise the MCP may start in a state where it does not generate new interrupts, because it waits for the old ones to be handled...


message:
Communication between python script and Arduino sketch

I'm trying to transfer data beetween the two scripts. I'm already using the YunMesseger library (https://github.com/plotly/YunMessenger). But it only make the

Arduino -> Python

communication.
I would like to know how to make the reverse way.

I would like to point that I'm search for a solution that doesn't involve the use of the Bridge, because I don't want to have concurrency problems.

body:
One option is to use [spacebrew](http://docs.spacebrew.cc/). This is a cloud-based service, however you can run your own [server](https://github.com/spacebrew/spacebrew) which is based on node.js, so it should work on the Yun.

Your Arduino can then send or receive data using [yunSpacebrew](https://github.com/julioterra/yunSpacebrew), and you can connect it to python using [pySpacebrew](https://github.com/Spacebrew/pySpacebrew). This is a pure python library, so it ought to run fine on the Yun.


message:
How to access 315mhz signals from household devices, with an arduino 315mhz kit?

Background:

I am looking into automation and I have realized that many of the devices I have around my house transmit 315mhz to their specific controllers.  I know this from reading the labels on the back that say 315mhz

Question:

Is there a way I can use a 315mhz receiver with an arduino to view the signals and log the data based on what happens and mimic certain actions with the transmitter?  In other words can I program the reciever to display every bit passed through 315mhz that is in range?

I know the virtual wire library parses the data before I receive it, but I don't know to what extent?  If I just dedicate the arduino to watch that pin and print results will that tell me what is being sent?

Thanks Very Much,

Joel

body:
**The Short Answer:**

In theory it is possible to do what you are asking.
There are examples of using an Arduino to send and receive messages at 315 MHz. Such as [this example][1].

Although these devices might not even be compatible with the ones you are using. They may be modulating their signal differently or framing their data differently or at different baud rates or encoding bits differently or a number of other fundamental differences that would make them incompatible.

**The Long Not Quite An Answer:**

There is more to the problem than just being able to get bits at 315 MHz.

For one you would need to know how the bits are encoded. See some of the answers on [this][2] post.

Even if it was a simple high low stream of even width bits. You also need to know what baud rate the bits are being transmitted at so you can sync with it. (Consider 4800 vs 9600 baud, slow I know but just an example. You just got a bit stream, was it 1010 at 4800 baud or 11001100 sent at twice the speed of 9600.)

Not to mention that the lowest level of data is probably not just a stream of bits, but is probably framed in some way and grouped into a byte/bytes. Or has a leader to help lock onto the signal.

Even once you are getting reliable data you would need to know the data structure. Is the data arranged in packets? Do they have a packet header? Does the header contain these packet destination address? Where in the header is this data? How is  the data apart from the header structured? What does it mean?.

Knowing the answers to these questions defines, or is defined by, the protocol that is being used by the transmitter (as others are saying in comments.) But these are only a few simple questions that **start** to define a protocol. Often this information is difficult to come by. Often in the case of proprietary protocols it is very very difficult.

  [1]: http://www.buildcircuit.com/how-to-use-rf-module-with-arduino/
  [2]: https://electronics.stackexchange.com/questions/81399/reverse-engeneering-a-home-automation-rf-315mhz-transimtter


message:
Is it possible to read VGA with an arduino

In this forum thread on arduino.cc http://forum.arduino.cc/index.php?topic=107375.0 they talk about it not being possible to get 800 x 600 video in color with the arduino.

My case is a bit different:

 - I don't care about color, it can be black and white / grayscale.
 - I don't need 800 x 600 just 640 x 480.
 - I can do with something like 2-5 frames per second.
 - I don't need it to be processed by the arduino, just transmitted through an ethernet shield.

In other words, it is possible to transmit simple video (just enough to handle eg. bios) remote?

body:
Well, it's very possible, but actually you'll stress the arduino. You can use it perfectly but the problem is, it takes a lot of time of Arduino. The reason is actually simple: Horizontal syncronization takes each 32uS of arduino, so the code is interrupted a lot, and if you use other codes the screen may flick. But i have a solution for you. I found software libraries:
http://forum.arduino.cc/index.php?topic=102181.0
or:
http://labdegaragem.com/profiles/blogs/gerando-sinal-vga-colorido-com-arduino-completo

The last link is in portuguese but you can always ask me anything.

OK, what people do is to use for example 2 arduinos to aliviate de stress, you can buy a arduino bare metal chip and put it in a protoboard to reduce costs. Buuut, ther's another very very easy way to work with vga in arduino. Using a isolated hardware:
http://www.hobbytronics.co.uk/serial-vga

You just need to send serial commands to the vga driver and it will do whatever you want. It comes with a library so you can use in arduino. It's perfect, aliviates the arduino, so you can use your ethernet communication and the price is great (for you, here in Brazil the fees kill a lot of children every day :-( ).


body:
Trying to *capture* analog video such as VGA and transmit it over Ethernet is going to be technically challenging, and of questionable wisdom (at least without compression).  A conventional ATmega-based Arduino is just about the *worst* contemporary platform you could choose for this job - even aside from the VGA issue, it is a poor choice for Ethernet requiring an expensive add-on.  But just for the sake of "can it be done" ....

If you can threshold your signal to a digital level (assuming a high contrast image) this probably can be done, crudely, but will be quite tricky.  The display is likely to be very blurred horizontally - really, it would only be worth doing for bragging points.

The first thing to realize is that the standard VGA 640x480x60 mode has a pixel clock of 25.175 MHz, and most others will be even faster.

One approach would be to try to write a program which samples a digital pin (directly, no Arduino abstractions) to memory as fast as possible.  This would not capture every pixel, but rather something like every 10th.  You would then have to send these over the network before you fill up your available memory.

The tricky part is that you then have to go back, and scan another frame of video with a slight offset, so that by getting every 10th pixel again, you effectively get the pixel adjacent to the first.   And then you do it again, and again, until you have collectively transmitted the entire screen, which hopefully hasn't changed much as you did it.

It's going to be tricky as you will have to work your delays from the sync signals, and you really want a delay which is a fraction of ATmega's clock - which won't happen without external circuitry (programmable delay buffer, etc)

The whole project would be a lot more feasible on an 80+ MHz ARM Cortex part, as you could then use a counter/timer to generate pixel-or-less-adjustable starting delays relative to the sync pulse.  An FPGA would likely be an even better choice.


message:
What happens if I connect an external power supply, plus to GND and minus to VIN?

So far, I have connected plus to VIN and minus to GND, but I am curious what would happen if I do it the other way around. And I am not going to try in case I break someting.

So, what will happen?

body:
Some systems have protection against people connecting things in reverse.
Some don't.

On unprotected systems you MAY destroy the powered system and/or you MAY destroy the power supply - both these depend on happenstance, system design and luck.

Possibly worse - you may damage the target system in an inobvious way so that it subsequently behaves incorrectly or damages other equipment.

Systems which are designed to be protected may not be protected in all cases. eg if you have a "shield" connected that accesses the Vin pin outside the protection diode the reverse polarity voltage may damage the shield AND current may travel via the shield circuitry back into the Arduino via other connections.

______________

Advice on You tube may just sometimes very very occasionally be wrong. Or more often.

If [**this "Reference Schematic"**](http://www.google.co.nz/imgres?imgurl=https://electrosome.com/wp-content/uploads/2014/07/Arduino-Uno-R3-Schematic-Diagram.jpg&imgrefurl=https://electrosome.com/arduino-uno/&h=1739&w=3144&tbnid=_4QHyB6a-usdPM:&zoom=1&docid=DagWDjCRj--l2M&ei=3eHtVITPL4XZ8gWW_IK4DA&tbm=isch&ved=0CCEQMygFMAU)  is correct (as you'd hope it was) then Vin is connected to the "inside" of protection diode D1 - so D1 does not protect against reversed polarity. See lines and boxes in red.
[Larger version of diagram **here**](https://i.stack.imgur.com/3gNVF.jpg)

D1 does protect against reversed polarity on "PWRIN".
How PWRIN relates to shield feeding I know not.

![enter image description here][1]

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


message:
Serial, Numbers sent as Floating Point and Characters are different at 1e-8 level

I have some code that generates random numbers on the Arduino, it then sends these random numbers firstly, using `Serial.print(float data,int lenght)` and as a floating point number using the following function

    void send_float (float arg)
    {
      // get access to the float as a byte-array:
      byte * data = (byte *) &arg;

      // write the data to the serial
      Serial.write (data, sizeof (arg));
      Serial.println();
    }
I then receive this data using python, take the absolute difference of the two values, discard any differences less than the length with which I send the string and output the rest to the screen.

I observe two things, a) Fluctuations of the order with which I send the data (ie. if I send to 6 decimal places then I see fluctuations of ~1e-6), this is reasonable and b) I see fluctuations of absolute value 1e-8 or lower **independent** of what accuracy I send the string.

Even if I send the string to 11 decimal places, when I compare against the float I see fluctuations up to but not above 1e-8.

Why? This doesn't make any sense. My full code is actually the answer to an old [unanswered stack exchange question][1]

  [1]: https://stackoverflow.com/questions/12664826/sending-float-type-data-from-arduino-to-python/28719607#28719607

body:
This is a somewhat dumb question but, in case anyone else searches it as pointed out:

> The precision of a float is around 7.2 decimal digits. en.wikipedia.org/wiki/Single-precision_floating-point_format –  BrettAM

So in python the number goes float -> double -> decmial, whereas on the arduino the number goes float -> decimal. The additional step of the double in the case of python causes the discrepancies. But anything after the 7th decimal place is nonesense anyway.


message:
How to send SMS from an Ethernet shield via SMS Gateway?

How do I send SMS from an Ethernet shield via SMS Gateway?

The site [Clickatell][1] provides free SMS.

Does anyone know how to do this or is there some other way to do it?

  [1]: https://www.clickatell.com/

body:
First contact Clickatel's support and ask them how to use their API, make yourself familiar with it.

Then when you know that you connect your Arduino to your ethernet shield, I'm just gonna assume you got Arduino's original shield, because you want to support the arduino foundation.

http://arduino.cc/en/Main/ArduinoBoardEthernet if you have the standalone board.
http://arduino.cc/en/Main/ArduinoBoardEthernet if you have the shield board.


body: Open an account and try to implement their API using something like Chrome REST client. Then do the same through the ESP8266. I would personally relay it through my own web service/ url. You could also take a look at: http://www.instructables.com/id/Send-SMS-from-Arduino-over-the-Internet-using-ENC2/


body:
Thanks to the moderator for telling me to give an improved answer, Here it goes->

From your question I infer that you want to send a SMS from your Arduino with an Ethernet Shield.

My suggestion to you is to use a service "CAYENNE".
It's a cross platform service for IOT.

You can create a **FREE** account on it by visiting their website :[here][1]

  [1]: https://mydevices.com/

You will be provided with a **KEY** to use with your devices

Then all you have to do is connect your Ethernet Shield and upload Cayenne's BASIC code to your Arduino so that it would link the key assigned to you to the account.

You can now Control your Arduino from any APP or directly through their website as provided above.

As far as SMS is concerned all you'll have to do is to add a trigger (GO TO OPTIONS -> TRIGGERING AND ALERTS  ) and select the notify option(Add SMS here)

Then you just have to enter the country code along with the phone number and when a particular event of your choice occurs you will be notified via SMS.

Hope this helps :)
Feel free if you have any further doubts.


message:
RF network using Arduino

I am working on home automation project. A network consists of one master device and many (maybe 10-20) slave devices, all communicating via these [RF modules](http://cdn.instructables.com/F4L/W6X0/HM8DG3PI/F4LW6X0HM8DG3PI.LARGE.jpg). I am using arduino in slave devices. Master will be based on raspberry Pi (most probably). Slave nodes can be sensors or switches(to control household electronics). To and fro communication will include data such as : a) Turn off bulb 1, b) Turn on TV, c) Set the bulb brightness to 34%, d) Temperature reading is 23 degree Celsius etc.

From security point of view, imagine there are similar other networks in the range and one network must not interfere with another. As such, I need to implement some sort of authentication whenever each data transfer takes place between master <---> slave. **What logic do you suggest for this process?**

There can be cases when data has not been received successfully by the receiving end. In such cases, I am planning to use some sort of checksum and acknowledgement system. If acknowledgement is not received, data will be resend in time intervals of 1s, 5s, 10s, 30s, 30s. If these 5 resends fail, the slave/master will be considered as unavailable/powered down. **Your opinions/suggestions on this?**

Slave arduino will be busy controlling appliances/sensors connected to it (real busy when controlling appliances). As such, it won't have much time for communication. Less time required for communication == Awesome. **How much time do you think the arduino will take to complete one such data transfer?**

Another solution I could think of was using two arduinos connected via i2c in each slave module. One arduino will be busy controlling the lights/sensors. Other one will take care of RF communication. If it receives some valuable info which was meant for this particular module, it will transfer the same to the other one using i2c bus. **Is this a feasible backup plan?**

**Am I doing wrong by selecting RF modules for this purpose? Should I switch to Zigbees?**

Thanks guys for reading. Any constructive suggestions from your side will be very helpful.

body:
The NRF24s are great, but limited to communication only.

Digi's [XBee 2mW][1] module has got great indoor range, but more to the point **it's got 8 I/O lines and 6 10-bit ADCs on board**. It's also built for mesh networks (or you can get star-network equivalents) and has security encryption to boot. This means that, for some of your nodes, you don't need any other hardware to have a fully functioning control point (not including relays and sensors of course), so you can ditch having arduinos at every node.

They're so easy to use, very low power, and have plenty of support and documentation available online.

Do it!

  [1]: https://www.sparkfun.com/products/10414 "XBee 2mW"


message:
ws2812b NeoPixel - how to address it? How Arduino knows the correct order of LEDS on the stripe?

How to get a One-Wire address of a given WS2812B pixel? I bought several of these, and I cannot make them light. On the other hand, when I connect the addressable LED strip made of these diodes, I have no problem controlling it.

Here is my set-up:

![enter image description here][1]

I tried many programs, e.g. AdaFruit_NeoPixel -> simple, setting number of LEDS to 1, but no effect. No blinks, nothing - as if the diodes were dead.

If every One-Wire device is identifiable by 64 bit ID, how does the Arduino know the correct "order" of the LEDS on the ribbon? How to tell the Arduino the new sequence of the LEDS on the strip that would result if I replace one (broken) LED with another?

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

body:
The WS2811/2812/2812B is not a 1-Wire device but is in fact a timing-based shift register with 3 LEDs (external in the case of the WS2811) connected to it.

As long as valid bit pulses are sent to the input of one of these devices it will shift the data through it and subsequently out of its data output. Connecting this output to the input of another device will shift data into that device as well, with the latest data sent being transmitted towards the furthest device in the chain.

Provided 24 bits per device are sent before the latch signal, The first 24 bits will be shifted into the first device, the second 24 bits into the second device, and so on until the last 24 bits into the last device in the chain. Once the latch signal is received, the devices will switch to the color indicated by the 24 bits currently shifted into them.

Since all of the devices use the same signaling (the only differences being supply level and the presence of a built-in RGB LED), they can be replaced freely with devices of the same or different make between the three.


body:
Just one correction. The the first 24 bits of the data are shifted into the first WS2812. That device loads those 24 bits into its PWM registers. If more data is transmitted, the first WS2812 shifts that out to the following WS2812. So the first data sent stays in the first WS2812, the 2nd data stays in the 2nd WS2812, and so on. This is explained in the data sheet.
Data-wise, it's a one-wire device. Power connections don't count.


message:
Arduino WiFIWebSever - why client.println()?

I need to modify the WiFiWebServer [example][1] on the Arduino website but I am having some trouble understanding the code. I am hoping to get some advice from the community on the client-server relationship in this example so I can better modify it to suit my needs.

The problem I am having is the jump between server commands and client commands. Initially I see server commands; server.begin() in setup and server.available() in the loop. The commands quickly shift, however, as nearly all the other commands in the loop become client.println()'s.

I understand the initial client commands that deal with whether the client is available and whether it is still connected. The part I don't understand, however, are the client.read and client.println commands. Even client.read makes some sense to me since I want some communication from the client side but why does the example use client.print? The [Arduino webpage][2] defines the WiFiClientPrintln as data you write from the client to the server that it is connected to. Wouldn't I want to use server.print since the Arduino in this example is the server and the client is the computer I use to view the webpage that I built on the server?

I am using the WiFIWebServer example as a template for my project. The goal is to have the Arduino take sensor readings and post them on a webpage it hosts by acting on the server. This is quite similar to the example but I notice that I have slow update/transmission speeds and errors when a different client connects to the server. For example, if I view the website on my computer, I get the data fairly consistently If somewhat slow. If I try to view the same website off my mobile device, however, I have problems connecting, may need to refresh several times and the webpage crashes on the computer.

I am trying to troubleshoot the issue but going through the code I can't figure out the reason for the client.println()'s instead of server.println(). Even if that isn't the cause of my multi-client issue, I would like a better understanding of the code before going forward so would appreciate any guidance you can provide.

  [1]: http://arduino.cc/en/Tutorial/WiFiWebServer
  [2]: http://arduino.cc/en/Reference/WiFiClientPrintln

body:
client.println() is sending data to a specific client.

server.println() is sending data to every client that is connected to the server.

Also, i believe that the arduino keeps sending data to the client instead of stopping the request. You should have some javascript that updates the value say... every 5 seconds or so... Or you could have a

    <meta http-equiv="refresh" content="5">

inside the <head> part which would tell the browser to refresh the page every 5 seconds instead of using the header

See http://tentencraft.net/demo1.php vs http://tentencraft.net/demo2.php


body:
The confusion you have arises from the context of the command.

The server.* commands manipulate the server instance - that is, the actively listening socket that is waiting for connections.

The client.* commands change their meaning depending on if you are a server waiting for connections or a client that is making a connection.

In the latter case client.print() sends data to the server.

In the former case, on a server, the client.* commands refer to a specific client that has made a connection to the server.  Using client.print() in this instance sends data *to* the currently connected client.

So "client" can be thought of as "the connection between me and the remote end" however that connection was created - either by "me" specifically connecting to the remote end, or the remote end connecting to my "server" instance and a new "client" being spawned from it for this one connection.

Remember - a client can only connect to one server, but a server can have many connections from many different clients, and it is those *client* connections that you talk to.


message:
Decide on baud rate for a project using Arduino Uno R3

I am using an Arduino Uno R3 with the MPU 6050 to get motion data. Different example codes use different baud rates, without any proper explanation as to why.

So how do I know which baud rate is perfect for my project?

body:
I most cases it doesn't matter!

In some cases the highest possible is preferred, as it prevents delays. That is when the buffer is full (when sending large amounts of data through the serial connection). As `Serial.write` will block until there is room in the buffer. In most cases this won't be an issue.

When running your arduino at slower speeds, you have to select a lower baudrate, or the micro-controller can't keep up.

When connection to other devices (e.g. GSM shield) using serial, that device may require a specific baudrate.


message:
Anyone have the Maplin N97DG bluetooth shield working?

I went & impulse-bought a Maplin [Bluetooth shield](http://www.maplin.co.uk/search?text=Bluetooth+Shield+for+Arduino) yesterday.

It comes with a little tiny book containing [examples](http://linksprite.com/wiki/index.php5?title=Bluetooth_Shield_for_Arduino), and uses the softwareserial library in these; I can load them, and get the Arduino <-> PC communication going OK, however there appears not to be a response from the bluetooth part of the device. The LED lights much as the booklet says it should. I did see it return some odd characters one time, just the once..

Given that the system appears to be alive, I don't want to give up & take it back; however the output from Google is not promising, and my trial to date isn't either - so I'm looking for positive news that this product does actually work for someone somewhere?

I'm using the built-in serial in the IDE to talk to it, not X-CTU as they suggest (as they don't do a Linux version).

body:
I've just got mine working, in about 3 hours.

The first example I've never got working. The SAT+RESET worked first time... and I was then able to pair.

An easier module is the HC-05. That by default goes straight to discovery mode, and makes things alot easier.

I have more success with the serial monitor in Arduino studio, rather than X-CTU.

The point of the sheild is to prototype, or the shield you have to use in your production project. If you are doing the former, then there is little point in using the shield as you would have to change the code to fit the hardware.

It seems a thorough product, probably too involved.


message:
Connect multiple RFID-RC522 cards?

I have a project that requires 4 different RFID-RC522 readers.  The RFID-RC522 has the following pins:

 - SDA
 - SCK
 - MOSI
 - MISO
 - IRQ
 - GND
 - RST
 - 3.3V

I have read that the SDA pin is used for selecting the active device, So I'm thinking that these devices can share data pins.  Is it possible to connect multiple RFID-RC522 readers to the same 3.3V, RST, GND, IRQ, MISO, MOSI and SCK pins if you use a different pin for each SDA?  If so, this would save me a lot of pins.  So far, I have only seen direction on how to connect one RFID-RC522 to an Arduino.

I'm using the MFRC522 library.  It appears to only support one reader because it only allows one SS pin to be identified in the constructor, and offers no way to change it later.  An I missing something or do I need another library?

body:
Connect everyone to the MOSI / MISO / SCK and ground, then define every SDA all the way around. and set respectively high low depending on where you want to write.

How ever im not sure if you need to set high or low if you want to read. But since you got multiple you can play around with that your self. Feel free to add to this question with the result for future googlers.

    #include <SPI.h>
    #include <MFRC522.h>

    #define RST_PIN           7          // Configurable, see typical pin layout above
    #define RST_PIN2           8          // Configurable, see typical pin layout above
    #define SS_PIN           9          // Configurable, see typical pin layout above
    #define SS_PIN2          10          // Configurable, see typical pin layout above

    ....

    MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
    MFRC522 mfrc522_2(SS_PIN2, RST_PIN2);   // Create MFRC522 instance.

    ....

    void setup() {
      Serial.begin(9600); // Initialize serial communications with the PC
      SPI.begin();        // Init SPI bus
      mfrc522.PCD_Init(); // Init MFRC522 card
      mfrc522_2.PCD_Init(); // Init MFRC522 card


message:
Why does my servo twitch and turn on its own?

I've been trying to write a very simple program using Arduino to tell a servo to go to a specific angle when a button is pressed, and to another specific angle when it is released. I find that, even though my sketch is but the simplest possible if then else statement without anything added to it, the servo goes to the right angle when the button is pressed, but when it is released, the servo oscillates between the two specified angles at a regular rate (about once every second). What's even stranger is that when i add delay time to the end of the loop in my sketch, the oscillation becomes more like twitching, and the more delay i add the weirder and less predictable the twitching becomes.

**added info**

    #include <Servo.h>
    Servo Servo1;
    int const switchPin = 4;
    int switchState = 0;
    void setup()
    {
        Servo1.attach(11);
    }

    void loop()
    {
        switchState = digitalRead(switchPin);
        if (switchState == HIGH) {
            Servo1.write(40);
        } else {
            Servo1.write(70);
            delay(39);
        }
    }

the power supply is the regular usb connector plugged from the board to my computer. The circuit is virtually similar to the "mood cue" project on the arduino projects book, except there is a button connected to digital pin 4 instead of a potentiometer.

body:
I'm assuming you do not have a potentiometer hanging out of the servo motor its self.

2 things i could see here, without seeing the actual circuit itself.

1- The inputs are left floating therefore the input is thinking it sees a high state when you never push the button due to electrical noise. To fix this add a 10k Resister to ground on pin 4 while the switch is wired to 5v/3.3v on one side and the other side going into pin 4. This will fix noise going into pin 4.

2- Power supply on board is overheating or lack of power since computer usb port has a max power of 500mA. Use an external power supply to the servo and connect power supply ground to the board's ground to have a common ground.


body:
I see two potential issues in your code.

1. There is no button debouncing in your code: this means everytime you push the button down or up, the `digitalRead()` call will return `HIGH` and `LOW` several times until the signal is stabilized; that could make the servo twitch as you observed.

2. For any call to `servo.write()`, you need to give time to the servo to reach the desired position, typically a few dozen milliseconds.

For the first problem, google for arduino button debouncing and you'll find various solutions for it.

For the second issue, you just need to add `delay()` after every call to `servo.write()`; note that in your code you added `delay(39);` but only for one call to `servo.write()` not for both calls.


body:
If it does what you expect when the button is pressed, but behaves unpredictably when released, you almost certainly have a floating input.

See [Switches tutorial](http://www.gammon.com.au/switches).

In particular, this is a no-no:

[![Floating switch][1]][1]

Random fluctuations in voltages will make the switch read HIGH and then LOW, and your servo will chase around trying to change positions.

The simplest fix (without changing anything else) is to add a pull-down resistor between the pin and ground, so now the pin reliably reads LOW when not pressed.

[![Pull-down resistor on switch][2]][2]

Other methods are discussed on that page, including debouncing.

  [1]: https://i.stack.imgur.com/KKfZD.png
  [2]: https://i.stack.imgur.com/t7lxC.png


message:
Fog machine Arduino integration

I want to control my fog machine with an Arduino.  Has a simple button that is used to activate the machine.  I want to press this button using an Arduino digital output pin, but the fog machine is operating on its own electrical circuit.  How do I use the Arduino to activate this machine?

I a few other machines with buttons that I want to wire into an Arduino, so is there a generic solution?

body:
You can interface with the fog machine's button by:

 1. Use a Relay (this will isolate the fog machine's circuit from your Arduino's)
 2. Use a Servo to physically press the button on the fog machine

I believe those would be the simplest and most generic.


body:
Please do not upvote this answer.
This is an expansion of @Krol's answer.
Krol may incorporate this material in his answer if he wishes.

The image below shows a typical relay module which is able to be driven by logic level / GPIO signals from typical microcontrollers.
The relays have 5V coils and there are optocouplers and drive transistors between the input and the relay.
Inputs are active LOW - ground to turn on.

These are available by mail from China for under $2/relay (under $1/relay if you buy 10 modules with several relays in).

They are **NOTIONALLY** opto-isolated as well as having relay isolation between input and contacts. **BUT** the PCB layout and relay design is such that mains to input clearances are poor. They will **PROBABLY NOT** kill you or your controller but they may - as is the case with much other items manufactured afar off at ludicrously low prices.

I have found the seller/manufacturer whose logo appears on that photo to be a reliable supplier of well made products. (Being well made does not overcome "dangerous design" as above.

Note that the above warning applies to most buffered relays you can buy on the hobbyist market and also top consumer products that have not been put through formal testing (UL etc). This relay board would fail UL testing - as would most others.

![enter image description here][1]

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


message:
Tv remote connection to an Arduino

I have a tv remote that I want to connect to an Arduino so that I can send a series of commands to the TV using the remote.  I would like to open the remote and solder transistors or a Transistor Array in place of the buttons.  I have never done this before, so what do I need to be aware of?  I think that I will need to power the remote using the Arduino's power supply, but I am a bit foggy on the details.

body:
If you're just running lines to the buttons, you won't need to power the remote from the arduino.  You could just let it keep the internal batteries.  But it would be possible to wire it up for power as well.

As a learning project, you could just take it apart and see if you can access the button contacts.  See if the contacts are split.  If so, shorting one side to the other should count as a button press.  But the details have nothing to do with an arduino.  They would depend on your specific remote and how it's constructed.

If your purpose is really to control the TV (rather than learning about the remote and fiddling with it), it will be much easier (and probably cheaper) to blast the IR without involving the remote at all.  A single IR transmitter and a library would work in most cases.  As an example: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

P.S.  By coincidence, Adafruit just posted an updated guide to IR library use on Arduino.  https://learn.adafruit.com/using-an-infrared-library/overview


body:
Using an IR library as mentioned in a previous answer is likely to be about the best approach.  However, if you decide to use electronic switches to jumper across the remote's switch contacts, consider using CMOS analog switch chips for the purpose.  If each button on the remote connects one contact to a common net, inexpensive chips like 74HC4051 and CD74HCT4067 would serve for 8 or 16 buttons each, respectively.

I don't have a reference for an affordable many-SPST-contacts CMOS switch.  Inexpensive chips with a few such contacts are available.  The 74HC4053, for example, contains three SPDT CMOS switches.  Handling a dozen buttons would use four 4053 chips.  A CD4007 probably could provide three SPST switches also.

![PS4051/52/53 pinouts][2]
  [2]: https://i.stack.imgur.com/hyBNX.jpg

*Edit:* The figure above shows pinouts of CD4051/52/53 devices.  To use a CD4053 as three separate switches, connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and each of COMA,B,C to one circuit contact to be switched.  With NCA, NCB, NCC connected to the other contacts of circuits A, B, C, raise ADDA, B, or C and drop INH to close circuit A, B, or C.

If your remote has dozens of buttons, it's likely that they are arranged in rows and columns for multiplexed scanning.  In this case, follow the printed circuit tracks to identify which buttons attach to which rows and which columns.  Suppose there are eight or fewer of one or the other; eg, suppose there are 5 columns and 8 rows.  In this case, you would hook up 5 CD4051 chips: connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and the COM of each 4051 to a different column line.  Connect NO0–7 to row lines 0 to 7.

To close circuit *j* in column *k*, put *j* in binary on ADDA,B,C of all 4051s and drop INH on 4051 #*k*.  (Either use one DIO line per INH, or use a DM74LS138 or MM74HC138 (etc.) and put *k* in binary on the A,B,C select lines of the '138.)


message:
Why is Serial.print working when nobody receives the data?

I have a kind of theoretical question. Let's have an Arduino Uno connected through USB that does a lot of Serial.print-ing. Then I disconnect it and I don't see anything on the Serial monitor, but the Arduino is still working. I can judge by the blinking lamps and so on.

Now I see that all printing goes through HardwareSerial::write from the Arduino core. There is this statement:

      // If the output buffer is full, there's nothing for it other than to
      // wait for the interrupt handler to empty it a bit
      // ???: return 0 here instead?
      while (i == _tx_buffer->tail)
        ;

It means that if the output buffer is full, the Serial.print will hang there eternally. However this doesn't happen. I guess somebody is consuming the data and to be more precise in ISR(USART_UDRE_vect). It seems as the only place where within interrupt _tx_buffer->tail can be changed. Otherwise the code would loop endlessly in HardwareSerial::write. This interrupt USART_UDRE_vect should be raised only when the Data Register is empty.

My question is - who is consuming the sent data? Is that done by some USART_to_USB drivers? Or am I missing some part of the picture?

Regards,
Boyan

body: The USB-UART bridge is, if it can. And if it can't, no one cares. A UART is *asynchronous*, hence it doesn't care if anyone consumes it; as long as it has sent the data, that's all it cares about. There can be additional checks to see if the other side is able to *receive* data, but that is not implemented on the Uno.


body:
atmega 328p datasheet, section 20.6.3:

> The Data Register Empty (UDREn) Flag indicates whether the transmit
> buffer is ready to receive new data. This bit is set when the transmit
> buffer is empty, and cleared when the transmit buffer contains data to
> be transmitted that has not yet been moved into the Shift Register
>
> ...
>
> When interrupt-driven data transmission is used, the Data Register
> Empty interrupt routine must either write new data to UDRn in order to
> clear UDREn or disable the Data Register Empty interrupt, otherwise a
> new interrupt will occur once the interrupt routine terminates.

the USART Data Register Empty vector is run when the hardware for USART serial has taken the byte in the register and sent it, not when a receiving device has polled and "taken" it. Once copied into the shift register and sent out of the chip nothing knows if there was another device to "hear" it or not. Some systems may have hardware flow control and wait for a CTS (clear to send) signal on a different wire, but the arduino does not.

You may also notice that if interrupts are not currently enabled (preventing USART_UDRE_vect from ever occuring) the HardwareSerial::write routine will manually poll the correct condition and run the interrupt handler when appropriate to cycle data through and prevent a deadlock.


message:
How can I send data to many IC's without using tons of shift registers?

I'm building an audio circuit that will play `VGM` files (Video Game Music).

I have it working with two different "vintage" IC's such as the `SN76489` and the `AY-3-8912`.

Currently, my design is using an `Arduino Micro` and two shift registers for the data buses and direct pins for the control pins on the audio IC's.

On average, an audio IC has `8 pins` for the data bus and `4 pins` for the control or address bus.  This varies per IC.  Some might be 3, some 4, some 6, etc.

Bottom line, even with the 20 IO pins on the Arduino, I will quickly run out of pins.  I thought about serializing many shift registers and basically pass 64 or 128 bit numbers to spread out to the multiple IC's but this sounds ugly.

I'd like to be able to support maybe 6 IC's which could be 60-80 pins.

I also have an `Arduino DUE` which has many more IO pins.  But then I have to deal with the 3.3v limit and I only have 4 level shifters (16 pins).

Any suggestions on how to handle this?

Thanks.

body:
There are other ways,but for a brute force many pin driver solution:

Back at the beginning of time when steam driven IC's were all the vogue there was the awesome **MM5450.**  40 pin DIP. 34 on/off outputs. 3 pin control. Or the really keen could do it with 1` pin control and some basic RC timing. I was. I did.

Its day has passed. but, fortunately. neither Micrel or Digikey know this.

[**MM5450 datasheet**](http://www.micrel.com/_PDF/mm5450.pdf)
[**In stock Digikey $5.46/1**](http://www.digikey.com/product-detail/en/MM5450YN/576-1341-ND/771810)

It's a very benign beat to drive once you get to know it. There is no reset (inless you buy bare dies) so you have to start off getting it synchronised  - it's not hard, just not quite usual. Works well.

For single GPIO pin control the pin acts as data out and clock with some RC timing.
Fot ICs with clock/data/load you can do all 3 with RC timing on one pin.

**And there is a [44 pin PLCC pkg version](http://www.digikey.com/product-detail/en/MM5450YV TR/576-1342-1-ND/771935) available.**
____________

AND!

SN74LS673 16 bit SR, 24 pins
http://www.ti.com/product/sn74ls673

ICM7243
http://www.ebay.com/itm/ICM7243BIPL-HARRIS-40-Pin-DIP-LED-DISPLAY-DRIVER-ICM7243-7243A-/390402848376

And others
http://www.ebay.tv/sch/i.html?_sop=7&_nkw=led+driver+ic&_frs=1


message:
Arduino, relays and building code

I want to install several Arduino controlled relays which are use to turn on/off some lights, a fog machine and some door locks in a building.  What do I need to do to insure that the power relays don't violate building code?

Do components need to be put in a box or can they be mounted to a 2x4?
Are there requirements regarding the points were the bear wire is screwed into the relay?

I am assuming that if anyone as ever wired an Arduino into a garage door opener, these questions may have come up.

body:
**Disclaimer:**   IANAL nor US regulations expert.

There are a few standard certifications that will essentially guarantee that a part will meet US regulatory requirements. Usually more of the form "your building burned down and you have no insurance because ..." rather than prosecuting you for non compliance.

Relays with UL rating bought via a reputable US supplier will usually quality.
eg if Digikey sell it it is PROBABLY Kosher.
Also if made by reputable manufacturers the same applies, as long as its genuine. eg (1 of many) Omron - they don't make no junk largely and even their junk is certified :-).

**HOWEVER** if you are building something using such parts the whole unit will need to be certified. For small volume applications it may be easier and cheaper to buy comething COTS (commercial off the shelf) which has the relevant certifications. That said,be sure these are legitimate.

## As a guide: ##

[**US standards**](http://www.sensorcentral.com/worldsupport/standards03.php) a useful introduction

[**Extensive international standards summary**](http://www.technick.net/public/code/cp_dpage.php?aiocp_dp=guide_safetymarks)

[**Wikipedia on UL**](http://en.wikipedia.org/wiki/UL_(safety_organization))

[**MET Labs strut their stuff**](http://www.metlabs.com/Services/Product-Safety-Testing.aspx) comparison with UL.

[**Intertek test labs bow in**](http://www.intertek.com/marks/etl/)

[**Useful - Understanding electrical certification**](http://www.watertechonline.com/articles/understanding-electrical-certification)

[**Possibly useful templates**](http://www.med.govt.nz/energysafety/forms/certification/electrical-certification-templates)


message:
Need help with on off switch to power arduino.

I am trying to add an on and off power switch to my arduino project.  My project is running off a 9v battery and I would like to save as much power as I can.  There might be a better why that I don’t know.  I added SLEEP_MODE_PWR_DOWN to my project and from what I can tell, the arduino enters sleep mode.  I am having a hard time getting the arduino to wake from sleep mode.  Am I able to do this from a full power down?  I have been reading this link. http://www.gammon.com.au/forum/?id=11497  and others.

body:
Since you are using an Arduino Uno board, putting the MCU (the ATmega328P-PU) to sleep won't save you much battery juice. Putting the MCU to sleep won't make a difference because the voltage regulator on the Uno will waste a lot more power than anything else on the board. The ON LED will also draw significant amount of current on that board.

To really save power you should look into getting an Arduino board that has a more efficient voltage regulator, or use no regulator at all by changing your 9V battery by, say, 4 NiMH AA cells.

Here's some more information about the issue for you to look at: [What are (or how do I use) the power saving options of the Arduino to extend battery life?](https://arduino.stackexchange.com/q/6/46)


body:
There is a very good write-up on how to save power, use sleep mode etc, at: http://www.gammon.com.au/power

This includes step-by-step examples of what was done to save power, and how much power was saved, including examples on how to go to sleep and wake back up.


message:
Is there a thermal sensor with a distance of 10 meters for Arduino

I am looking for a thermal sensor with a distance of 10 meters . In my plan , I would like to recognize objects based on the heat. for example car.

body:
How about [this one](https://www.sparkfun.com/products/9570) at £20?

The range depends on what lens you put in front of it - this has to be plastic as IR doesn't penetrate glass, but you can set your own range, like a focus adjustment. Commercial IR remote thermometers generally have aiming dots (laser) so you can see the optimum range - there's a fixed lens.

The actual sensor won't have a defined range, because of this.


message:
Powering fans and arduino pro mini from single 12v supply

So, I have a 5V Arduino Pro Mini, which is running the logic behind a multi-DHT22 sensor array, and using that input to control a 12v 24mm fan (12v, 0.16 A).

This is currently a working board on an Arduino Nano with two separate power supplies (1 to USB, 1 to fan). I want to simplify it and make a more permanent installation.

What I'm keen to do is something like the following:

    Wall Wart (12v, 500mA) ------------------------> Relay -> Fan
                    \ (1) -> Arduino Pro Mini @5V -> /

In order to power the Arduino efficiently at 5V, and avoid drawing power all the time (i.e. when the Arduino is asleep), is the best way to apply a Linear (or Switching) Regulator with minimal burn when idle at ```(1)``` in the diagram, and power the Pro via its VCC line, or is it better to just run via the internal regulators and RAW?

Will this actually just generate a high burn whenever the arduino is on to convert the 12v-5v? What is the most power efficient approach here?

body:
If you want to minimize power usage, the best thing would be to start with **devices that use more power!** :D

It's time for math! I'm going to use the [generic L7805CV][1] 5V, 1A linear regulator. Poking in the [datasheet][2], we find that the quiescent (standby) current is max of 6 mA. I'm assuming this power drawn is 12V, not 5V.

Since a linear regulator is basically a variable resistor, we can figure out that the efficiency is:

    Vout / Vin

...thus, our efficiency in this application is...

    5V / 12V = 0.416666667% efficiency

... [Read more here.][3]

So, we can use the inverse of the efficiency function (`Vout / Vin` → `Vin / Vout`) to establish the amount of power it'll use. Final equation:

    Power Used (W) = (12V / 5V) * Current Draw + (0.006A * 12V)

...which simplifies to:

    Power Used (W) = 2.4 * Current Draw + 0.072 W

So, all we need to find is the power consumption of the Arduino. [This forum post][4] states the power consumption of different sleep modes:

 - SLEEP_MODE_IDLE: 15 mA
 - SLEEP_MODE_ADC: 6.5 mA
 - SLEEP_MODE_PWR_SAVE: 1.62 mA
 - SLEEP_MODE_EXT_STANDBY: 1.62 mA
 - SLEEP_MODE_STANDBY : 0.84 mA
 - SLEEP_MODE_PWR_DOWN : 0.36 mA

Let's give the Arduino a generous 15mA to sleep:

    Power Used (W) = 2.4 * 0.025 + 0.072 W = 0.132 W

So, 132 milliwatts, idle. A bit further, we can calculate that, if your wall wart has an efficiency of 10%, it will actually draw 1.32 W from your wall socket. Using a general cost per killawatt hour ($0.125), we can calculate that it will cost you about $1.45 a year for that Arduino to be ran in sleep mode 24/7 (given that we used the maximums for everything).

It's pretty cheap, so I wouldn't worry about that power. A good switching regulator will cost more than to run it for a few years with a linear regulator. I'd use the onboard one.

If you still want to optimize things, the wall wart or the fan should be looked at first. Consider getting a switching wall wart instead; this will give you a higher return on your investment since both the fan and the logic use this.

  [1]: http://www.mouser.com/ProductDetail/STMicroelectronics/L7805CV/?qs=9NrABl3fj/qplZAHiYUxWg==
  [2]: http://www.st.com/web/en/resource/technical/document/datasheet/CD00000444.pdf
  [3]: https://electronics.stackexchange.com/a/21135/18442
  [4]: http://www.gammon.com.au/forum/?id=11497


message:
SainSmart CO2 sensor module use?

I purchased this CO2 sensor a while back: [SainSmart MG811 Gas CO2 Carbon Dioxide Sensor Module Sensor Module for Arduino UNO R3 Raspberry Pi][1]

The module has four pins, Vin, GND, Dout and Aout. I assume Dout and Aout are digital output and analog output, respectively.

Other than that, the sensor came with no datasheet, instructions, or tutorial. I also searched online but fail to find anything useful.

I'm going simple for now, just hooking up the sensor module to Arduino board. I know I can probably connect the output pins to the analog pins, and analogRead them, but what I am looking for is how to convert the raw data readings into CO2 levels in PPM. Like a formula.

Also, I'm curious as to how the digital output works...

  [1]: http://www.sainsmart.com/sensors/eco/sainsmart-mg811-gas-co2-carbon-dioxide-sensor-module-sensor-module.html

body: You can not directly convert the reading to ppm because you do not know what value means what ppm. You'd need at least one calibration point to calculate how many particles per million there are. The sensor is both affected by temperature and humidity so you might wish to compensate that too.


body:
The Dout is a TTL threshold indicator; basically it goes high when a certain threshold of the sensor is reached, which is adjusted by the pot.  The Aout is the VRef of the sensor.

Now the MG-811 is not the best sensor in the world; I did look at the [datasheet][1] which shows this sensor outputs mV in relation to the PPM so a map function could be used such as 100-600mV maps to 400-10000ppm CO2, see [MG-811 CO2 Sensor Module][2], so you could feed this into a `map()` function and get the result but since there is a signal conditioning circuit consisting of a op-amp I'm not sure what it does to the raw sensor voltage.

Now the sandbox electronics module may not be identical to the SainSmart module, so you may need to reverse engineer the module you have to determine what is going on or use the schematic from the sandbox site to build your own and de-solder the MG-811 from the SainSmart module.

  [1]: http://www.dfrobot.com/image/data/SEN0159/CO2b MG811 datasheet.pdf
  [2]: http://sandboxelectronics.com/?p=147


message:
Can ZigBee API and ZigBee AT work together in the same network?

I'm currently trying to make 3 arduinos talking to each other with ZigBee, and it's kinda working.
But I currently use AT mode on the Bees and it's a little bit harsh when I have to switch the destination address in the Coordinator of the network (1 Coordinator and 2 Routers)

Can I put the Coordinator in API mode (to make it easier to switch addresses with xbee-api for Arduino) but still be able to communicate with the AT routers and be able to send/receive data from them?

Thanks for your answer :)

body:
My question has been answered on Stack Overflow, if you ask

https://stackoverflow.com/questions/28765288/can-zigbee-api-and-zigbee-at-modules-work-together-in-the-same-network


message:
Does Nano not get sufficient power via USB?

I have an Uno, and I can play all I want with it, just using a USB cable.

Then I got two Nano clones, and they both show the same behavior:

When I connect it to the USB cable (which leads to my PC) it blinks a few times, then seemingly does nothing. I am also not able to connect to it via the Arduino IDE.

If I then connect an external power source to Vin and Gnd, it wakes up and blinks forever, and I am able to connect to it.

Is this just because I got a cheap clone? Or is this really the accepted / expected behavior?

![enter image description here][1]

  [1]: https://i.stack.imgur.com/7UBfE.gif

body:
I have a few clones but have not seen this behaviour so I guess it could be one of three things (in order of most likely to least):

 1. They have a fault related to taking power from the USB connector.
 2. The USB lead is not able to supply enough power ie. it is cheap and extremely thin and cannot carry much current. Have you already tried other cables?
 3. Your USB port cannot supply enough power. Given that the spec says 500mA from a USB 2 port, this seems unlikely unless the port is faulty. Have you tried other ports / another PC?


body:
To answer your title question, My Nanos run at significantly less than the 500 mA you can draw from a normal USB port, so unless you have a cable problem it should be getting enough, yes.

One thing I have learned about cables is that your mileage may vary.  For the Pi, it is nice enough to show me a lightning bolt on-screen when it isn't getting enough, and swapping the cable fixes it 99.9% of the time.

Arduinos simply display odd behavior like this one.

**I always suspect power supply first.**

So first, try changing cables.  Then if that doesn't help try changing Arduinos and see if the problem follows the Arduino.

Good luck!


message:
Arduino Based Solid State Drive

I've searched high and low for something to get me on the right track, it's making me think it might not be possible.

Basically, I want to create a cheap SSD using Arduino (or another microcontroller if it is too weak). I know I would have to implement the SATA protocol on the device and an OS driver for the disk drive. Assuming I could jump those two hurdles, what else would bar me from implementing a rudimentary SSD? I'm not even talking about full production quality, just a SATA wire coming from a mother board plugged into a socket on a breadboard. Do I need flash storage or would I need another kind of chip to handle the data needs?

body:
The good news is that SATA drivers are fairly generic so you don't have to write the OS side. The bad news is everything else.

*just a SATA wire coming from a mother board plugged into a socket on a breadboard*

Let me stop you there. The minimum data rate for SATA is sufficiently high that you need a PCB. If you try and do this with wires or breadboards it will simply not get through; it will be lost to parasitic capacitance.

(Many years ago as a student I tried to do something vaguely similar with a wire-wrap board. At just 20MHz you could see a clean signal go in one side and a noisy unreadable mess come out the other side. Actually seeing it on a scope drove home the importance of shielding.)

*Do I need flash storage or would I need another kind of chip to handle the data needs*

Where would you put the data otherwise? It might be an entertaining first step to create a read-only drive with constant contents, but it's not very useful.

You need a chip with a SATA interface. This will almost certainly be an ARM and almost certainly *not* in DIP. I can't remember at the moment whether SATA master and slave "PHY" interfaces are different or whether it's all defined in software, someone else can answer that.


message:
Powering Arduino Uno R3 with battery packs

I am using Arduino Uno R3 with MPU 6050 for a personal project. MPU 6050 is being powered by the 3.3V supply pin in the Arduino board.

In order to make the sensor mobile, I ordered this battery, which has one power output of 5V 1Amp that I plan on plugging into the Uno's USB Power/Data Outlet.

I know that when plugged into the computer via the same USB port, around 5V 500 mA is supplied. I was wondering if someone could tell me, **whether the 1A battery that I ordered would burn my board or not**.

**Also, is there a built in fuse inside this board?**

body:
The battery will be fine; the 1A rating is just a maximum, if your device only wants up to 500mA then it's got spare capacity, is all.

The battery appears to have in-built short protection etc, so better than a fuse..


body:
Power sources like batteries and wall warts are **voltage sources**: they will deliver a fixed voltage, more or less. The current that they supply will be determined by the load you attach to them.

The "Amps" listed on a power supply is not how much current it **will** put out, it is the **maximum** current that the manufacturer has decided it **can** put out safely, without acting funny or overheating. So when you read that the USB port on a computer supplies 5V and 500mA, that means that it will supply 5V and **up to** 500mA. If you draw more than a 500mA current from your USB port, you would exceed the max current rating of the USB port. USB ports usually have an emergency shut-off mechanism built in, so they would just turn off if you drew more than 500mA out of them. I wouldn't try it though :). Your battery seems to have pretty similar safety features: "Super protection: overshoot, over-discharge, short circuit, over voltage, leakage, and many other protective functions".

If you had a 5V 20 Amp power supply, it will act the same as the USB port power supply, except it will be able to handle putting out much more current. As long as you don't exceed a voltage source's max current rating, **the amount of current that a voltage source puts out depends on how much current the load draws, not on the voltage source.** For example, a resistor will draw a current in Amps equal to the voltage supplied to it divided by the resistance (I=V/R), via Ohm's Law. For microcontrollers, you can often find their current draw on their datasheet: your MPU 6050 with the Gyro + Accel running has an operating current of [3.8mA](http://www.invensense.com/mems/gyro/mpu6050.html) when you give it ~3.3V. An Arduino Uno draws about [80mA](http://forum.arduino.cc/index.php?topic=135872.0) by itself, though I don't think this includes the 3.3V power regulator on the 3V3 pin. So you're looking at somewhere a little over 84mA (=0.084A) in total. Your battery can supply 2.5A or 1A depending on which of its ports you use, so you are nowhere near exceeding the battery's max current rating, which is a good thing.

There are no fuses built in to the Arduino Uno R3. If you exceed its [maximum current limitations](http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations), you will mess it up. There's a [ruggedino](http://www.ruggedcircuits.com/ruggeduino/) available with more safety features if you're worried about frying your arduino. But as long as you're careful you should be fine with a standard R3.


message:
Send Keyboard Media Keys with Keyboard Library

I have an Arduino Pro Micro (ATMega32u4) that I want to use as an IR receiver for a media PC and need to send codes like Volume Up, Media Home, Play, etc. But when I look up the scan codes for those and send them to Keyboard.press() it just prints out '0' every time.

Any way to send those keyboard commands?

body:
[Keyboard.press()](http://arduino.cc/en/Reference/KeyboardPress) presses a key and “holds it down” until a [Keyboard.release()](http://arduino.cc/en/Reference/KeyboardRelease) or releaseAll() is issued.  That is, Keyboard.press() isn't appropriate for simulation of just tapping and releasing a key, unless you follow it with a delay and a release.

Also see [Keyboard.write()](http://arduino.cc/en/Reference/KeyboardWrite).  But note the following, from Keyboard.write()'s documentation:

>Only ASCII characters that are on the keyboard are supported. For example, ASCII 8 (backspace) would work, but ASCII 25 (Substitution) would not.

On my linux system, `xev` (used via `xev -event keyboard`) shows the following data for media keys labeled as shown.

      Excerpt from info displayed by xev           Picture
    keycode 180 (keysym 0x1008ff18, XF86HomePage)   house
    keycode 179 (keysym 0x1008ff81, XF86Tools)   quarter-notes
    keycode 163 (keysym 0x1008ff19, XF86Mail)      envelope
    keycode 172 (keysym 0x1008ff14, XF86AudioPlay)  >/||
    keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume)  speaker
    keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume)  speaker
    keycode 121 (keysym 0x1008ff12, XF86AudioMute)  x'd-speaker
    keycode 148 (keysym 0x1008ff1d, XF86Calculator)  Calculator


body:
You have to do some tweaks to the usbkeyboard libraries that comes with the IDE.

For a video tutorial, take a look at this:

[Arduino Leonardo as a multimedia keyboard][1]

Which uses the information from this site, if you prefer text only:

[Arduino Leonardo multimedia keys][2]

The Leonardo and ProMicro both use the ATMega32u4 and should both work with theses tweaks. If you need more functionality than the ones that this tweak gives you, you have to dig down into usb descriptors on usb.org for the commands you need.

  [1]: https://www.youtube.com/watch?v=ubORsI4uWuo
  [2]: http://stefanjones.ca/blog/arduino-leonardo-remote-multimedia-keys/


body:
It is indeed possible and also without the requirement to modify the Arduino environment itself. Just ***register an HID descriptor*** for the "report ID" for "Consumer Control" (the code is 4 (constant `kHID_ReportID_ConsumerControl`), where the "report ID" code for keyboard and mouse are 2 and 1, respectively):

```
static HIDSubDescriptor node(HID_ReportDescriptor_ConsumerControl,
                             sizeof(HID_ReportDescriptor_ConsumerControl));

HID().AppendDescriptor(&node);
```

After the registration, `HID().SendReport()` now works for "report ID" equal to 4 (the first parameter), and the audio volume can be changed, etc.

The registration needs to done once and can be put into the init() function, for instance, after the `Keyboard.begin();` and `Mouse.begin();` calls.

### Usage

Example usage, increasing the audio volume by one step:

```
uint8_t data[2];
data[0] = kVolumeUp;
data[1] = 0;
HID().SendReport(kHID_ReportID_ConsumerControl, data, 2);
```

The constants are at the end.

### Notes

"Consumer Control" has the multimedia controls *Volume up*, *Volume down*, *Mute*, *Play*, etc.

The registration is similar to the way the constructors for the built-in [keyboard][1] and [mouse][2] libraries do it. `HID_ReportDescriptor_ConsumerControl` and constants are listed at the end because it is quite long, but they must come first (for instance, in the beginning of the file).

All this could be packaged into a reusable form. Here I have demonstrated it in a paste-and-forget form to keep it short.

`HID().SendReport()` looks strange, but `HID()` is a global function that returns an instance of the class `HID_` (all built into the standard Arduino libraries, presumably to avoid some initialisation order problems with global/static objects - I thought Scott Meyers had solved that a long time ago (47. in the first book)).

`HID().SendReport()` can also be used to circumvent the limitation of a presumption of a US keyboard. E.g. using [code 100][3], page 56 (and kHID_ReportID_Keyboard, like in the standard class `keyboard_`) to emulate the 102th key on European keyboards (e.g. [a Spanish keyboard][4]).

Only volume up and volume down were tested.

### Definition of `HID_ReportDescriptor_ConsumerControl` and constants:

```

// For direct use of USB HID (yes, 3 is left out)
const uint8_t kHID_ReportID_Mouse           =  1;
const uint8_t kHID_ReportID_Keyboard        =  2;
const uint8_t kHID_ReportID_ConsumerControl =  4;
const uint8_t kHID_ReportID_SystemControl   =  5;
const uint8_t kHID_ReportID_Gamepad         =  6;
const uint8_t kHID_ReportID_MouseAbsolute   =  7;
const uint8_t kHID_ReportID_NKRO_keyboard   =  8;
const uint8_t kHID_ReportID_TeensyKeyboard  =  9;
const uint8_t kHID_ReportID_SurfaceDial     = 10;

// For use in "Consumer Control". They are bit coded.
const uint8_t kVolumeUp   = 1 << 0; // Bit 0
const uint8_t kVolumeDown = 1 << 1; // Bit 1
const uint8_t kVolumeMute = 1 << 2; // Bit 2

static const uint8_t HID_ReportDescriptor_ConsumerControl[] PROGMEM =
{
    0x05, 0x0c,                           // Usage Page ("Consumer Devices")
    0x09, 0x01,                           // Usage (Consumer Control)
    0xa1, 0x01,                           // Collection (Application)
    0x85, kHID_ReportID_ConsumerControl,  // "Report ID"
    0x15, 0x00,                           // Logical Minimum (0)
    0x25, 0x01,                           // Logical Maximum (1)
    0x09, 0xe9,                           // Usage (Volume Up)
    0x09, 0xea,                           // Usage (Volume Down)
    0x75, 0x01,                           // Report Size (1)
    0x95, 0x02,                           // Report Count (2)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xe2,                           // Usage (Mute)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb0,                           // Usage (Play)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb1,                           // Usage (Pause)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb7,                           // Usage (Stop)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb5,                           // Usage (Next)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb6,                           // Usage (Previous)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb3,                           // Usage (Fast Forward)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x09, 0xb4,                           // Usage (Rewind)
    0x95, 0x01,                           // Report Count (1)
    0x81, 0x06,                           // Input (Data, Variable, Relative)

    0x95, 0x06,                           // Report Count (6) Number of bits remaining in byte
    0x81, 0x07,                           // Input (Constant, Variable, Relative)
    0xc0                                  // End Collection
}; // Table for USB HID "Consumer Control" (for audio volume control, etc.)
```

### Platform

This was tested with:

 * [Arduino Leonardo][5] (already used as a macro keyboard, using an old [PS/2][6] keyboard. Two new macro keys were assigned for testing audio volume up / down).
 * The Arduino Leonardo connected to an *extra current* port of a [D-Link][7] USB hub (necessary, for unknown reasons - probably a local problem)
 * Arduino IDE v. 1.18.10
 * Linux, [Ubuntu 19.10][8] (Eoan Ermine), but with [the buggy GNOME][9] replaced by [Cinnamon][10].

  [1]: https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
  [2]: https://www.arduino.cc/reference/en/language/functions/usb/mouse/
  [3]: https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf#page=56
  [4]: https://en.wikipedia.org/wiki/IBM_PC_keyboard#Keyboard_layouts
  [5]: https://store.arduino.cc/arduino-leonardo-with-headers
  [6]: https://en.wikipedia.org/wiki/PS/2_port
  [7]: https://en.wikipedia.org/wiki/D-Link
  [8]: https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_19.10_(Eoan_Ermine)
  [9]: https://askubuntu.com/questions/1188960/copy-and-paste-issue-with-ubuntu-19-10/1197042#comment2027077_1197042
  [10]: https://en.wikipedia.org/wiki/Cinnamon_(desktop_environment)


body:
If you are getting zeros, the most probably cause is it's the library for the IR. Reinstall or update the library. Sometimes you have to reinstall more than one time. That should work.

About media keys, the keyboard library doesn't have media keys functionality, so you need to use another one. This one worked for me: https://github.com/NicoHood/HID

After you install this library, you have to change your code. The code for pressing media keys is different. You have to use *Consumer.write*, for example, *Consumer.write(MEDIA_VOLUME_UP)* for volume up. You can find the name of every key here: https://github.com/NicoHood/HID/wiki/Consumer-API

For normal keys, just use Keyboard.write(). If you want, I can send you the code I made to do this.


body:
Peter's answer probably is the way to go from scratch. But if you want to start from somewhere there's also another library by BleKeyboard https://github.com/T-vK/ESP32-BLE-Keyboard/blob/master/BleKeyboard.cpp. It shows you pretty much the whole process how the media report is created.

```
// ------------------------------------------------- Media Keys
  USAGE_PAGE(1),      0x0C,          // USAGE_PAGE (Consumer)
  USAGE(1),           0x01,          // USAGE (Consumer Control)
  COLLECTION(1),      0x01,          // COLLECTION (Application)
  REPORT_ID(1),       MEDIA_KEYS_ID, //   REPORT_ID (3)
  USAGE_PAGE(1),      0x0C,          //   USAGE_PAGE (Consumer)
  LOGICAL_MINIMUM(1), 0x00,          //   LOGICAL_MINIMUM (0)
  LOGICAL_MAXIMUM(1), 0x01,          //   LOGICAL_MAXIMUM (1)
  REPORT_SIZE(1),     0x01,          //   REPORT_SIZE (1)
  REPORT_COUNT(1),    0x10,          //   REPORT_COUNT (16)
  USAGE(1),           0xB5,          //   USAGE (Scan Next Track)     ; bit 0: 1
  USAGE(1),           0xB6,          //   USAGE (Scan Previous Track) ; bit 1: 2
  USAGE(1),           0xB7,          //   USAGE (Stop)                ; bit 2: 4
  USAGE(1),           0xCD,          //   USAGE (Play/Pause)          ; bit 3: 8
  USAGE(1),           0xE2,          //   USAGE (Mute)                ; bit 4: 16
  USAGE(1),           0xE9,          //   USAGE (Volume Increment)    ; bit 5: 32
  USAGE(1),           0xEA,          //   USAGE (Volume Decrement)    ; bit 6: 64
  USAGE(2),           0x23, 0x02,    //   Usage (WWW Home)            ; bit 7: 128
  USAGE(2),           0x94, 0x01,    //   Usage (My Computer) ; bit 0: 1
  USAGE(2),           0x92, 0x01,    //   Usage (Calculator)  ; bit 1: 2
  USAGE(2),           0x2A, 0x02,    //   Usage (WWW fav)     ; bit 2: 4
  USAGE(2),           0x21, 0x02,    //   Usage (WWW search)  ; bit 3: 8
  USAGE(2),           0x26, 0x02,    //   Usage (WWW stop)    ; bit 4: 16
  USAGE(2),           0x24, 0x02,    //   Usage (WWW back)    ; bit 5: 32
  USAGE(2),           0x83, 0x01,    //   Usage (Media sel)   ; bit 6: 64
  USAGE(2),           0x8A, 0x01,    //   Usage (Mail)        ; bit 7: 128
  HIDINPUT(1),        0x02,          //   INPUT (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
  END_COLLECTION(0)                  // END_COLLECTION
```

If you are curious why these media button works, you can checkout the USB doc https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf, Page 75, where it states why each key usage is used.


message:
Do Water sensors Rust?

I'm new to Arduino and still learning the basics.
I tried reading water level by using [this sensor](http://www.emartee.com/Images/websites/emartee.com/Water Sensor.jpg) I left it in the water for about 5 minutes then I noticed it changing color (some parts darker than other)like the water is still over it .
So my question is do Water sensors really rust ? or is it my own imagination?

body: Most metals will tarnish, rust, or corrode when left in water, especially in the presence of an electric current. To be safe, a water sensor should either be gold-plated or made of a conductive, insoluble, non-metallic substance.


body: I have that same sensor, and found a couple things to help with this issue.  The first thing that I did with min was tin the contacts with solder (All 10 'sensor contacts' all the way down) and also, using the GPIO, only power it on about 1 second before I read it, and turn it off immediately after.  By reducing the amount of time current is running through it, you reduce the tarnish, and the solder i tined everything with is less likely to corrode than the raw contacts.


body:
The color change you observed is probably caused a galvanic reaction between metals in the sensor and other metals that are present, such as the tank, piping, or dissolved metals in the water. Do not modify the parallel strips of metal on the sensor. This will render the sensor useless. To reduce the effects of galvanic corrosion, you can:
1) Reduce the current passing through the sensor. To do this, sample the sensor less frequently. For, example, sample it once every second.
2) If possible, remove sources of metal from the water. For example, replace metal pipes with PVC, and replace screws with plastic zip-ties.
3) Move the sensor further away from sources of metal.
4) Place a grounded sacrificial zinc in the water, close any other metal sources. If the water is circulating, place the zinc near the inflow opening.
5) Remove stray or electrical currents from the water. Connect the "-" pin (GND) and the water to the same ground.


message:
Can I mix 22awg and 26awg hookup wire in the same circuit?

I'm still fairly new to Arduino projects, and am only just now getting into building circuits where I want to cut and place my own hookup wire instead of using the precut jumper wires. I inherited some supplies from a friend who abandoned the hobby, and about half of the wire he gave me is 22awg and the other half is 26awg. All of it is solid core copper. Is it ok to mix wire gauges like this in the same circuit/project?

body: Assuming you won't ever put more current through it than the 26AWG wire can handle, you'll be safe.


message:
Which Microcontroller to use

I want to use a wifi shield, as well as a 2.8 inch touch LCD shield; both would fit the arduino uno V3 nicely.  Is that the best microcontroller to use

body:
To answer your first question, regarding stacking a WiFi Arduino Shield on top of a LCD Shield:

> can I stack them simultaneously

The obvious answer is - **it depends on the shields**. Each shield might use a different set of Arduino I/O pins, making them unavailable to the next shield stacked on top of it.

for example, this [formal Arduino WiFi shield][1] makes **I/O pins 10, 11, 12, 13 and 7** (on Arduino Uno) unavailable to the next top shield.

Unfortunately, this [LCD KeyPad shield][2] needs pins 7 and 10 available (among others) in order to function properly. This makes it incompatible for stacking on top of the WiFi shield mentioned above (or vice versa).

It doesn't mean that there is no way that **any** LCD shield could be stacked on top of a WiFi shield, but to be honest, I couldn't easily find any LCD shield that won't collide with a WiFI shield pins. You might want to change approach and send the WiFi data using the built-in Serial to a computer.

> Is that the best microcontroller to use

If there would have been a manifest to this website, I'm sure that "The best product is the one that meet your needs best" would be it's first sentence. In order for someone with experience to answer what is best, (s)he would need to know your exact needs. Since you are still not sure what they are, and just want to play around a bit, I imagine that the classic Arduino Uno R3 could help you find your way, especially if you are doing your first steps with Arduino.

  [1]: http://arduino.cc/en/Main/ArduinoWiFiShield
  [2]: http://www.dfrobot.com/wiki/index.php/LCD_KeyPad_Shield_For_Arduino_SKU:_DFR0009


body:
I'll have to chime in with the others and say "It depends." The Uno, or more precisely its Atmega328p microcontroller, is rather memory limited, especially the RAM memory needed for data buffers, stack-frames, and tables such as the character-generator for the LCD. That last one can usually be kept in program memory, but note that if you're having to plan memory assignment before you even start the project, it's a pretty good sign that you should consider something more capable.

An Arduino Mega 2560 is about twice the price of the Uno (in the US, US$50 vs. US$25) but gives you 4 times the RAM memory, 8 times the flash (program) memory, and a bunch more (sorry to get all technical :) I/O pins. Of these, the RAM is likely to be your most stringent limit with the UNO.

I keep one Arduino Mega around for prototyping or when don't want to build another board for an experiment, and a handful of AtMega328p chips to build into "Arduin-ettes" for my more permanent gadgets. Most of my toys will fit on the '328 chip but it's awfully nice to be able to shove a ton of code, libraries, debugging statements, logging buffers and what have you, into the larger processor without having to think about what will fit. Or, what's worse, if I cause a stack crash by stuffing all of that into too-little memory, I could waste a lot of time debugging a presumed coding error when it was really an out-of-memory problem.


message:
POST request not working

I'm following a guide on storing sensor data to MYSQL:

[Guide][1]

I'm using different sensors but my POST request is getting any results to my server. For now, I'm only storing temperature.

Here is my code for saving data:

    void sendData(double input){

    String data = "sensorid=3000000&temp=" + doubleToString(input, 2) + "&hum=1.2";

    if(client.connect("192.168.1.50",80)){
        client.println("POST /arduino/add.php HTTP/1.1");
        client.println("Host: 192.168.1.50");
        //client.println("User-Agent: Arduino/1.0");
        //client.println("Connection: close");
        client.println("Content-Type: application/x-www-form-urlencoded");
        client.print("Content-Length: ");
        client.print(data.length());
        client.println();
        client.print(data);

        Serial.println("Sent data: " + data);
    }

    if(client.connected()){
       client.stop();
    }
    delay(300000);
    }

I've commented out two headers since it did not give any other results. My Serial.println gives: Sent data: sensorid=3000000&temp=24.00&hum=1.2
Which means that the arduino is connected to the giving IP-adress and that my Request data is as I want. They are also working perferct when I'm testing with [Requestmaker][2]. So I'm pretty sure my error comes from the way I'm doing the request here.

So do you have any idea how I can solve this? Or how I can debug it t

  [1]: http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/#step1
  [2]: http://requestmaker.com/

body:
*Answered by Edgar Bonet*

There needs to be an empty line between the headers and the body of the request. Therefore you have to println() (not print()) the end of the last header.

---

Please accept this answer so the *system* knows it is the correct one.


message:
Arduino weird bluetooth module

Recently I bought a BT module from eBay which was very cheap. I didn't really noticed the image and I just bought it. When it came I couldn't find any holes to solder the headers. Also the specific module is pretty rare and I couldn't find anything.

Here is an image:

[![BlueTooth Module][1]][1]

How do I wire up this chip?

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

body:
From the picture you posted, i was able to google and find something called a BC04-B Bluetooth serial module. It looks almost exactly like yours, and I found a diagram on how to hook it up.
![BC04-B Bluetooth serial module][1]

I also believe that these are the serial commands you can use with it...
![Bluetooth module serial commands][2]

  [1]: https://i.stack.imgur.com/kRMZH.jpg
  [2]: https://i.stack.imgur.com/ureCG.jpg


body:
These Bluetooth modules are typically mounted onto another substrate, either the product board or a small PCB backplane which provides the pinouts and any additional circuitry like the pairing LED, and power- & signal-level management.
They are readily available as HC-05 (master/slave) or HC-06 (slave only) with signals brought to through-holes or pins at the edge of the backplane.


message:
External access to Yun - request not recognised as HTML

I am trying to access my Yun externally.

My router recognises traffic on Port XXXXX and forwards it to my Arduino Yun.

I have the below code working internally and now trying to adapt this to work for external (adapted from http://arduino.cc/en/Tutorial/TemperatureWebPanel).

To access the Arduino Yun over the network I type:

<!-- language: lang-none -->

    http://XXX.XXX.XXX.XXX:XXXXX/arduino/on

When using this script locally, i.e. `myArduinoName.local/arduino/on`, the onboard light turns on (and off if URL changed accordingly).

Adapting this working code, I have changed to "`noListenOnLocalhost`" and put in my port number (XXXXX).

The code is reached (see below for the response).

<!-- language: lang-cpp -->

    #include <Bridge.h>
    #include <YunServer.h>
    #include <YunClient.h>

    // Listen on default port 5555, the webserver on the Yun
    // will forward there all the HTTP requests for us.
    YunServer server(XXXXX);
    String startString;
    long hits = 0;

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

      // Bridge startup
      pinMode(13,OUTPUT);
      digitalWrite(13, LOW);
      digitalWrite(13, HIGH);

      Bridge.begin();
      Console.begin();

      // Listen for incoming connection only from localhost
      // (no one from the external network could connect)
      //server.listenOnLocalhost();
      server.noListenOnLocalhost();
      server.begin();

    }

    void loop() {
      // Get clients coming from server
      YunClient client = server.accept();

      client.println("hello");

      // There is a new client?
      if (client) {
        // read the command
        String command = client.readString();

        command.trim();        //kill whitespace

        client.println(command); // why does this return a full GET request instead of "on"?

        if (command == "on") {
          digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
          delay(1000);
        }

        if (command == "off") {
          digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
          delay(1000);              // wait for a second
        }

        // Close connection and free resources.
        client.stop();
        hits++;
      }

      delay(50); // Poll every 50ms
    }

The response I get is (I have replaced my IP and port with X's):

> hello
>
> GET /arduino/off HTTP/1.1 Host: XXX.XXX.XXX.XXX:XXXXX
> Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
> Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
> User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36
> (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
> Accept-Encoding: gzip, deflate, sdch Accept-Language:
> en-GB,en-US;q=0.8,en;q=0.6

I expected

> hello

> on

So it would seem that because I'm using a different port (other than 80 or 5555) the response is no longer being interpreted as an HTTP request.

I have also tried to edit the uhttpd file via SSH to provide a specific address and port for both my external IP address and my fixed internal IP address.

Then tried to restart the device and also a uhttpd restart i.e.:

<!-- language: lang-none -->

    /etc/init.d/uhttpd restart

I have attempted to access the URL using my mobile phone (i.e. not on the same network).

Any ideas why my request is not being treated as HTTP?

body:
It works!

The changes to the uhttpd must have done the trick to listen for http traffic on a given IP/port (other than 0.0.0.0:80).

Instead of supplying a port number for the server in the code, I would surmise that the change to the config takes care of it so this, so the port number in code is no longer needed:

YunServer server(XXXXX);

should be changed back to

YunServer server;


message:
Having difficulty uploading sketch to an Arduino Pro Mini

Having developed and tested a project using an Arduino Uno, I would now like to upload it to an [Arduino Pro Mini][1] (5V, 328, 16MHz) for semi-permanent, long-term use, but I can't get any sign of life from the Pro Mini.

I'm using the latest Arduino IDE (v1.6.0 with Java 6, on Mac OS X Mavericks), and I've got a [USB 2.0 to TTL UART 6PIN CP2102 Module Serial Converter][2] to connect the Pro Mini to the Mac, and I've selected Tools —> Board —> Arduino Pro or Pro Mini (5V, 16MHz) w/ ATmega328.

The problem is that I don't see a suitable serial port in the list. When I plug in the Arduino Uno, "/dev/tty.usbmodem1421" immediately pops up in the Tools —> Serial Port menu, but I don't see anything similar with the Mini Pro.

The problem is probably in the connection between the USB/TTL converter and the Mini Pro, so my question is: which pins should connect to which?

![USB/TTL converter face to face with Arduino Pro Mini][3]

FWIW the USB/TTL converter was supplied with a 5-core (not 6-core) cable to connect its 6 pins.

So do I connect Tx—>Tx and Rx->Rx, or should they be crossed over? It's fairly clear that "5V" connects to "Vcc" and "GND" goes to "GND", but what about CTS and DTR?

  [1]: http://www.amazon.co.uk/dp/B007YQZUEE
  [2]: http://www.amazon.co.uk/gp/product/B00AFRXKFU
  [3]: https://i.stack.imgur.com/nAxLG.jpg

Also FWIW, I have googled this, and I have read a number of other posts and answers on StackExchange, but the fact that I'm here writing my question means that I'm still stuck. Any and all constructive suggestions will be appreciated. Thanks!

body:
You need to hook it up with the Arduino TX --> FTDI RX, and vise versa, so crossed over.  If you take the FTDI and hook it up to the Ardiono pin to pin as you have it pictured it should work, provided the FTDI works.

No to your note about not having a serial port, you should have that as soon as you plug the FTDI into your computer, the Arduino is not necessary for this.  First things first, check you drivers, and check your USB connection.  You won't get anywhere until that Serial port is recognized on your computer.


body: If you still have any issues, try connecting the vcc and gnd to raw and gnd near the pins. Mine worked this way