text:
Is there a way to play sounds from an Arduino without using a sound shield?
I would like to play a wav file (spoken words) from my Arduino.  I do not want to add a sound shield.  Is there a way to play a sound through an output pin?  The quality does not have to be great.

Does anyone know how to do it without an sd card? I really need to know for a school project that we have to finish in like 2 days. help?

I helped someone with a similar question. The results are in my github repo at https://github.com/linhartr22/count. This example uses the PWM library and includes a reference to the article I used to learn how to convert audio files to MP3 with proper settings for the PWM libary. It plays audio through an 8 ohm speaker or a piezo buzzer connected directly to the Arduino.

The PCMAudio example shows how to play audio data via PWM. Note that you will need to access the MCU at a low level in order to do this; the Arduino libraries don't provide enough control over the hardware.

Yes, you can - see http://www.instructables.com/id/Simple-Wav-Player-Using-Arduino/
Space is quite limited, unless you use an SD card.

Yes, I did a project yesterday to play recorded voice.
You don't need a speaker module.
Just connect the speaker via a resistor to one of Arduino PWM output. Then Connect a micro-sd card module. Format your micro-sd card with FAT32 Option.
Use Sample wave converter to convert your sound files and select the options as 16,000Hz Mono 8Bit. You are all done. Use tmrpcm library. It's all easy.

@Hoytman i think this arduino library can help you a lot https://sensorium.github.io/Mozzi/

old post but still a good question...
Here is a tutorial for playing 8 bit 33khz audio using the Adafruit M0 Express. You can play ~60 seconds of audio from the 2MB onboard flash through the 10bit Analog out pin.
https://github.com/hydronics2/SamdAudio
two other audio board solutions that offer near 16bit quality...

Adafruit's circuit python boards itsbyitsyM0, M4, feather M0. Same as above but using the circuit python interface instead of Arduino.
teensy3.2, teensy3.5, teensy3.6 (you can play out using the Analog pin without the audio shield but the audio shield has a nice 1/8" jack

Teensy Tutorial
Adafruit tutorial

Welcome to Arduino Stack Exchange! I am a bit puzzled by your answer because it is specifically about not using external hardware like a shield, but "to play a sound through an output pin". Thus your answer does not address the question at all.

@NickGammon The boards suggested are not shields or add-on boards but instead alternative Arduino (like) hardware. I agree it is 100% to the question but it is still a worthy answer for those visiting this question.

@NickGammon hey Nick! I love your work.. I use your tutorials all the time. Yeah I guess I forgot to say that you can play 20-60 seconds of audio from onboard flash. The Adafruit M0 has 2MB of onboard external SPI flash.


text:
How to network multiple Arduinos so they react to the same signal
I want to build a project that contains multiple Arduino nano's, each connected to one controlling Raspberry Pi.  I would like to send one signal (a string of characters or numbers) which would be the master state, which the other Arduinos would react to based on their programming.  What is the best way to do this?
Can the Arduino support a protocol for this, or will it need additional hardware?
Max distance: 30 meters

Pretty similar to How to interconnect multiple Arduinos with a Rpi to control home-lights/switches

Interesting.  is RS485 bus the way to go?  Looks like it needs extra hardware.

Yes, but the extra hardware is pretty trivial. I read recently (I can try to find the reference) that RS232 (normal serial) was not intended for long runs. In any case a Nano is 5V signal, not even RS232.

Perhaps there is a better solution

Perhaps, but I2C and SPI are designed for even shorter cable runs. Serial is probably the most reliable, but the voltage drop over 30 m, plus noise picked up, is likely to make it unreliable. You could get one of those cheap radio transmitters, but that again is extra hardware.

Another option is wireless - especially if it's one-directional. May be an advantage? Will almost certainly be more expensive and error-prone.

Wireless is an attractive option.  Most of my Arduinos can function on 1 way transmissions, but a few need 2 way.

Have you thought about inexpensive RF?  It would only require about 2 pins and you could effectively write your code so that you're treating the RF as a bus to which the arduinos are connected.

yes, I have a few of those.  I'd like to use a wired option for this

Rule 1 do not connect Arduino pins to long wires.
You can achieve your your goal in many ways, a serial interface looks good from here.  I am doing it with a RS485 interface, note it is an interface not a protocol. You can use CAN, Wi-fi and many others.  It sounds like all the units except 1 will be receiving data, the other is transmitting it to the other devices.  RS485 will work good and it needs only 5V.  It will work over several thousand feet and some reasonable speeds. You can use a UART either hardware or software to accomplish the task with a RS-485 driver at each node.  You need to remember you need to wire from point to point with the terminating resistors only on the end nodes.

source: Stack Exchange

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

sort: votes


text:
Can I connect a PWM pin on one Arduino to an analog input on another?
I was considering several different ways to send simple data from one Arduino to another when I though, why not connect a PWN pin of one Arduino to the analog pin on another?  I could send simple messages for one to the other by setting different values on the PWM pin.  This seems like it would work, except for the fact the the PWM pins mimic voltages with pulses.
Is this a reliable way to link two Arduinos, If I only want to communicate 4 states?  Also, will I need to include some additional components in the connection (resister, capacitor, etc.)
All it needs to do is send a 2v pulse for yes and a 5 v pulse for no. It needs to do this about 6 times an hour.

Yes, you can do this with "a little programming"  or more easily by adding two cheap components.
If you connect a say 47k resistor from PWM_Out to Analog_In and a say 100 uF capacitor from Anaolg_In to ground you will be able to read the equivalent analog value to an accuracy of around 1%. Read it N times (maybe 10 times) with a delay of say 12 ms between reads and average it for a better result. This works because the PWM period is about 1 mS so delaying for a period of multiple cycles but not an exact multiple means you sample semi randomly.
For the sort of resolution that you want (4 levels) a MUCH smaller capacitor could be used (maybe 1 uF.) But even a 100 uF capacitor is cheap.
You could instead use PWM out (analogWrite) and a digitalRead.
Perform say 100 digital reads with say 12 ms between reads (so about 1.2 seconds total) and keep two counts - PinWasHigh and PinWasLow for (obviously) high or low conditions. The contents of PinWasHigh tells you what % of reads was high. Due to random sampling you cannot rely on this for 100 levels but determining say 10 levels should give good accuracy. The sum of PinWasHigh and PinWasLow should total 100 as a sanity check.
While use of a serial port (hardware or software) or SPI allows more data transfer per time and without much effort, this simple analog method is good enough for many applications.

Great answer, I eventually went with the no-component solution that you gave towards the bottom of you answer

@Hoytman I avoided mentioning a similar solution that takes slightly more coding knowledge but is faster to read. The Arduino PWM takes ABOUT 1 mS per cycle. If you dave the value of micros() when it goes high and compare it with the value when it goes low again you get the APPROXIMATE high time in microseconds. You can do the same thing for low time. The two should add to ~= the PWM period. Once you are confident in the ability to read the high pulse duration and have a feel for the variations to expect you can read the PM % high in maybe 2 mS.

It is possible, but not the best idea. The analog inputs require a reasonably stable input - this can be achieved with a RC filter to smooth the PWM output. This would work for reasonably slow data rates.
You would be better to use one of the many communication protocols supported by Arduino (serial, SPI, I²C).

The best choice would be to use SPI, as it is the fastest communication method. Instead, the easiest to use (at least from what I learnt) is I2C

All it needs to do is send a 2v pulse for yes and a 5 v pulse for no.  It needs to do this about 6 times an hour.

@Hoytman, then why don't you send a 1 second pulse for yes, and a 10 second pulse for no? Just pull (at least once per second), and count how long it is before it goes back down?

For greater precision, less code, faster execution and no need for capacitors read the PWM "analog" signal on the other Arduino from a digital input pin with
pulseIn(pin, HIGH, timeout)
The timeout is optional (1 second by default). As soon as the line goes high, a timer engages and automatically stops the instant the line goes low.
The primary reason to use PWM communcation (as opposed to i2c, SPI, etc.) is to broadcast to an unlimited number of devices simultaneously without the need for a clock signal or acknowledgement.
We are currently using this method of communication for neural networks composed of separate tiny processors for each neuron substructure (one processor for each synapse and activation function).

Indeed, this is quite a bit better than the filter methods, if the processor can be available to take the measurement then.  If not, some better use of hardware timers and interrupts should handle it.  But all of these schemes are generally inferrior to place-value-coded communication channels like asynchronous serial, I2S, SPI, etc.

Full solution to receive PWM signal and convert to a like analogRead() one. Its based on @Cortex_systems answer and Id like to share it to help others with a more comprehensive answer.
int var = pulseIn(digitalPin, HIGH, 4200);
if (var == 0 && digitalRead(digitalPin) == 1) {
    var = 2100;
}
var= map(var, 0, 2100, 0, 1023);

Here is the why:

You can not just read PWM signal to analog pin in arduino. We will
receive the PWM in a digital pin with its pinMode set to input and read it with pulsIn(pinNum, high/low, timeout).
pulseIn() records the length of the pulse. Longest pulse in PWM is 2100 microseconds.
Timeout is set to 4200 for 2 cycles of PWM. Without this
it will wait for a new high and freeze the code in cases that PWM is
0 or 255.
At max and min this will read 0, so in that case check with digitalRead() to determine and adjust.
Finally, map the result so it appears like an analogRead().

Note! This adds a delay of up to 4.2 milliseconds to code.

To read PWM without delay use Interrupts http://www.camelsoftware.com/2015/12/25/reading-pwm-signals-from-an-rc-receiver-with-arduino/

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


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

NB: 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 :-).

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 a useful introduction
Extensive international standards summary
Wikipedia on UL
MET Labs strut their stuff comparison with UL.
Intertek test labs bow in
Useful - Understanding electrical certification
Possibly useful templates


text:
How does the Arduino send more than 6 bytes via I2C
I have been working with the wire library (I2C) to send data from one Arduino to another.  I read that the Arduino can only send 6 bytes per cycle, but I have been able to transfer much larger strings.  This code works without error:
  Wire.beginTransmission(4); // transmit to device #4

  for(int i = 0; i < 20; i ++){
    char rand = random(65, 100);
    Wire.write(rand);
  }

  Wire.endTransmission();    // stop transmitting

How is this possible?  It seams that 32 characters can be sent without trouble.
I read this here: http://arduino.cc/en/Tutorial/MasterReader

Arduino 1, the Master, is programmed to request, and then read, 6 bytes of data sent from the uniquely addressed Slave Arduino.

Now that I look at this again (after reading the responses) I think that the limit was set in the code sample.

Please post the code that doesn't work.

Can you link to where it says the arduino can only handle 6 bytes per cycle? And, by 'per cycle' I assume you meant between the 'beginTransmission and endTransmission'. I couldn't find reference to the 6 byte limitation in the wire reference ( http://arduino.cc/en/Reference/Wire )

Can you give the sample code for it

There is no reason to believe there is a 6 byte limit.
The Arduino Reference makes no mention of a 6 byte limit.
The Wire.cpp defines 'txBuffer[BUFFER_LENGTH];' where BUFFER_LENGTH = 32 (defined in Wire.h). The maximum is 32 bytes, just as you noticed.

in the wire code examples, the master uses beginTransmission() and endTransmission(), but the slave does not.  The slave only uses write().  why is this?  How does the Slave know when to end the transmission?

@Hoytman I'm actually not sure why the library handles i2c that way. I would expect that it has its roots in making a generic i2c/twi interface, but I don't understand i2c/twi well enough to give a correct answer.

In the Wire library, beginTransmission() "primes" (starts) collecting data for a transmission. Then Wire.write() simply adds data to an internal buffer (which is 32 bytes long). Finally the endTransmission() actually does the sending of the buffer. As for the slave, in a "requestFrom" function as soon as you do a Wire.write() it is sent (or at least, it commences to be sent). You cannot (successfully) do more than one. If you attempt to, the second one overwrites the buffer used to return the data to the master.

The Arduino Wire implementation is synchronous (blocking) but still requires an intermediate buffer. As the answer about states the buffer is limited to max 32 bytes. This alternative I2C (Two-Wire) library does not have this limit and supports both software and hardware bus manager implementation. https://github.com/mikaelpatel/Arduino-TWI Device drivers written using this library can be used with the AVR/SAM hardware support or with any GPIO pin.


text:
Can do I make an Arduino program that can decipher telephone touch tones?
I have an old land line phone that I want to connect to my Arduino.  Then I would like to write a program that can decipher the touch-tone button presses (which are a combination of two tones) so that the Arduino can react to specific key presses and numeric sequences.  My final goal is to make the Arduino play specific messages when the user enters in codes.  I am really not sure even where to begin.
Thanks for the hardwares fixes for this problem, but if possible, I am looking for a softwares solution.
This will be used to make a telephone (with an attached Arduino) that will play a series of conversations when specific codes are dialed.

possible duplicate of Connecting an Arduino to a telephone line?

Which connection are you trying to make? Are you trying to connect the arduino to a telephone line. Or simply connect the arduino to the "sound output" of a cellphone?

@GregHewgill - not, not a duplicate.  The question is really very different - this is not about electrical connection but about detecting combinations of two tones.

@ChrisStratton: Yes, that's also asked in the linked question. Perhaps the linked question is too broad.

cough cough ever tried googling? http://forum.arduino.cc/index.php?topic=121540.0

As John Taylor said, DTMF is not a single tone but two tones transmitted simultaneously, which select the digit from a two-dimensional grid. (Dual tone multi-frequency). This allow 16 possible combinations from only 8 distinct tones.
There are chips available specifically for the task of decoding DTMF, but it's always nice to try and find a one-chip solution.
There are two solutions that I can think of:

ArduinoFFT - a Fourier transform is an operation that splits a time-based signal into its frequency components. If you control the ADC directly instead of via the Arduino library, it is easily fast enough to sample a DTMF signal. Once you've done the FFT you just need to find the peaks in the output, which will tell you the tones that are present.
If you put the signal through the analog comparator and count the rate of zero-crossings (use an interrupt with a routine that increments a number, you may miss some if you just poll the pin), the rate of crossings should be unique for each tone combination. Counting for e.g. 10 ms and looking up the closest match from a table you've pre-measured should give reliable decoding, and is a slightly less brute-force approach than an FFT.

That said, you won't be able to beat a dedicated chip (although I personally think this way is much more fun.)
Happy hacking!

It is possible to decode DTMF tones with only a few common external components. The trick is to turn the analog audio into a digital signal, and then check the timing between the leading and trailing edges in order to figure out which tone is present.
First, create a 1.1V bias using a voltage divider. This bias will connect to both a capacitor that is coupling the audio, as well as one of the analog inputs. Note that phone lines have high voltages on them at times, and you must have both isolation and voltage clamping in place before connecting a device to one.
Second, enable the analog comparator in the MCU. See the "Analog Comparator" section of the MCU datasheet for details. Configure the non-inverting input to connect to the internal bandgap reference, the inverting input to connect to the analog input chosen earlier, and the output to connect to the input capture facility.
Third, configure the input capture facility in the MCU. See the "16-bit Timer/Counter1 with PWM" section of the datasheet, with particular emphasis on the "Input Capture Unit" subsection. Note that there is no way to trigger the input capture on "any" edge, therefore you will need to either flip the capture edge select bit each time, or you will need to detect the tone from only one set of edges. Also note that you will need to use the overflow interrupt to increment your explicit "high bytes" counter in case the edges to be detected appear on opposite sides of the overflow.
Now that all that is done, all that remains is to compare the timing detected by the input capture with your internal table of timings and select the appropriate tone from that. But that's the easy part.

http://www.seeedstudio.com/depot/DTMFDual-Tone-Multi-Frequency-Shield-p-1839.html
As an expansion to this answer: There are a lot of arduino shields made for this purpose. You should check on the search query: "Arduino  DTMF shield". Most of them work by inputting a 3.5mm jack. This would be easier as a phone line, as those can vary in voltage etc.

Alas, you are handwaving away what is by far the most difficult part - simply digitizing, and timing zero crossing intervals will not be an easy way to detect the combination of two simultaneous tones which may (at least by the time they get to you) be of different amplitudes.

@ChrisStratton: If it can be done in a PIC, it can be done in an Arduino.

DTMF is actually two non-harmonically related frequencies transmitted at the same time as opposed to a single frequency tone that can be measured with the above process, hence Dual-Tone-Multi-Frequency:

You can use the Rohm BU8872 series devices which decodes the 4 x 4 multi tone combinations directly into a 4 bit digital result per the grid above.  This also works the same way in the Mitel MT8870 series devices (I think they were bought by Microsemi).  These have digital filtering which pick out the two signals and some devices can even do single tone detection.


text:
ESP8266 (ESP-01) Not booting with load on IO pin 2
I'm using an ESP-01 to control a load (SSR), which is connected to IO pin 2. This pin needs to be HIGH at boot time, otherwise the module won't boot. I've tried driving the load with an optocoupler to avoid driving the pin LOW while booting, but it's not working. Do you know of any solution to make it boot correctly without changing the IO pin? (there's only two GPIO pins, both ocuppied, plus serial port pins).

On the 01, you don't have to have GPIO2 pulled high to boot, you just can't have it grounded. I've had to use a diode (instead of a wire) to connect relay modules to pin2. btw: you can use TX as an output and RX as an input; I've driven an RGB LED with one and it works out since the LEDs blinking for  a few ms at boot was ok. All pins on the ESP-01 boot/reset high, so take that into account.

I'm already using the TX to drive the built-in LED as a state indicator, but I'll try with RX instead. But still, I'd like to know how to use GPIO 2 without screwing the booting. :S

just don't let the pin fall under 2.4v and it will boot. it's weakly pulled up internally, so keep it high or disconnected by default. depending on the internals of your SSR, you might be able to simply invert the signal wiring and make gpio2 a ground to activate it; i've done that with a few ssr/relay modules, and i didn't even need the resistor in @Majenko's 2nd sketch for some reason, but results may vary...

@dandavis Yeah, that's what I did to make it work. :D

Simply invert the logic - so that LOW turns the SSR on and HIGH turns it off.
Try something like this:

simulate this circuit – Schematic created using CircuitLab
The P-channel FET will invert the logic. Pull GPIO2 LOW and it will turn on the FET which will enable the SSR. The 10KΩ resistor keeps the GPIO pin (and the gate of the FET) HIGH at other times.
If the GPIO pin can sink enough current to directly drive the SSR you can leave out the FET:

simulate this circuit
Again the logic is inverted. Pull GPIO2 LOW to sink current through the SSR to turn it on. The resistor keeps the GPIO pin held HIGH when booting.

I did something similar to what @Majenko proposed in his answer (as in I inverted the output), but instead of using R1 as a pullup resistor in paralell with the SSR's LED, I'm using it as a normal current limiting resistor. In other words, I just swapped GPIO2 from sourcing the SSR to sinking it. The schematic is like this:


text:
Arduino Leonardo - Using ICSP pins for serial
I'd like to know if it's possible to use the ICSP header pins on the Leonardo as GPIO pins, for example for software serial, and how to address them. I've a project which needs all available I/O pins, and I could use having serial comms on those "extra" pins.

From packages/arduino/hardware/avr/1.6.*/variants/leonardo/pins_arduino.h:

// Map SPI port to 'new' pins D14..D17
#define PIN_SPI_SS    (17)
#define PIN_SPI_MOSI  (16)
#define PIN_SPI_MISO  (14)
#define PIN_SPI_SCK   (15)

static const uint8_t SS   = PIN_SPI_SS;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK  = PIN_SPI_SCK;

Those are the pin names and numbers you can use. Note that SS/17 is connected to the RX LED.

Thanks! I'll test it as soon as I have some time to spare! ;)

It works, though SoftwareSerial don't seem to be able to manage baud rates of 115200 bps, which I need.. :$


text:
What's Leonardo 5V pin current limit?
I'd like to know how much current can supply the 5V pin and the 3.3V pin on an Arduino Leonardo board. I've been lead not to trust the specs on Arduino's website. And, as an added question, can the 5V pin supply enough power for an LM741 opamp?
Thanks!

The 5V pin is either supplied by the USB port, which has a limit of 500mA (imposed by a resettable fuse) if directly connected to the computer or a powered hub (or 100mA in an unpowered hub), or the on-board regulator (NCP1117ST50T3G), which is 1A, when powered externally.
The 3.3V pin is regulated using an LP2985-33DBVR which has a current limit of 150mA (the specifications on the website say 50mA. This is wrong. I think it is a left-over from the old Uno boards with FTDI chips where the 3.3V was fed directly by the internal 3.3V regulator of the FTDI chip and thus limited to 50mA).
Yes, the 5V pin has more than enough current to run an LM741 op-amp.

But 5V is a poor supply voltage for a LM741 due to its rather large headroom requirements.

@IgnacioVazquez-Abrams You meant to say "But the LM741 is a poor op-amp because of its rather large headroom requirements"... ;)

Yeah, that too

@IgnacioVazquez-Abrams I can't recall ever actually seeing an LM741 in a new design in the past 10 years... They still exist for some reason, but I am not aware of anyone in their right mind that would actually use one.

It's been a while since I used opamps... I guess I messed up, should have used 358s instead :S

Ugh, just as bad ;)

what're the practical applications for op-amps? I know, google.

@user400344 Op-amps have many many practical uses - from comparators (as in the Uno power selector) to audio pre-amps, to instrumentation amplifiers for sensors - the list is long. They are incredibly useful gadgets.

I'm gonna get some :)


text:
Arduino programming through HC06
My goal is not upload sketch to Arduino Pro mini through bluetooth module HC06. I have made a breadboard version of DTR signal simulator which takes LED status pin as a source. The output from the detector goes to RST pin of Arduino. When connection is initiated the status LED stops blinking and output pin goes low and than high which leads to Arduino rebooting. This part works fine. Unfortunately avrdude from Arduino IDE does not see the bootloader and shows the following error in the console:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
I have noticed that HC06 stops blinking with some delay after a connection is initiated. I suspect that this might be a problem. To overcome this issue the boot loader should probably be changed. Unfortunately I am not familiar with the embedded C programming, thus if someone has experience in changing the bootloadder, please help me to solve this puzzle.
The following is a scheme of detector:

Did you set the same USART speed on HC06 as bootloader uses? (You have to use this speed in your program too)

BTW with HC05 it's much easier as there are two LED indicators and LED2 indicate successfull connection. So if you use AT+POLAR=1,0 to set active low mode for LED2, you can connect it as DTR input.

@KIIV, Thanks. I have set the BAUD rate through the TTL for HC60 and now the uploading works as expected. By the way for Arduino Pro Mini 5V 16mGhz the baud rate is 56700. At this speed the bootloader works, you can check it in the boards.txt file. With HC05 is simpler but also requires soldering, thus the difference is not big.

I do not know how to vote it or how to mark it as answered.

I'll make it as answer

http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/

You should read the link above, it shows how easy it can be do to with the HC-06. Also, as noted by KIIV, the HC-05 is also very easy.

Setting serial speed on your computer side doesn't change speed on the HC-06 side. So you have to set the same speed for HC-06 interface (and in your sketches) as a bootloader is using.

authors: Артём Ильдяев


text:
Adafruit Feather 32u4 Bluefruit LE and HC-05 Bluetooth module
Is it possible to connect an Adafruit Feather 32u4 Bluefruit LE with an HC-05 Bluetooth module?
I am making a heart rate monitor using an Adafruit Feather, but it is unable to send the data to LABView for processing as it uses BLE. I do not have the means to buy a Bluetooth dongle to work around the issue.
However, I do have an HC-05 Bluetooth module that can be read by VISA on LABView.
Therefore I would like to ask if it is possible to connect my Adafruit Feather to my HC-05 module and send the data through the HC-05 instead of the built-in BLE.
Thank you!

HC-05 does not support BLE as far as I know but you can use a HM-10 if you can get your hands on one; Its almost about the same cost as a HC-05, maybe a little more;

I understand that HC-05 does not support BLE. To clarify, is it possible for me to hook up the Adafruit to the HC-05 to connect to my laptop via classic Bluetooth? Thanks!

You should be definitely able to do that for one simple reason that hc-05 can be connected to any microcontroller board over simple serial communication; I dont have an adafruit feather handy but I have connected hc-05 to a variety of boards including but not limited to the arduinos, esps and stms;


text:
How does Arduino digital input pin measure its input voltage?
Just starting with my first Arduino project.
In order to measure voltage in a circuit I connected my multimeter to two points in the circuit (for example before and after a resistor).
I am interested to know how an input pin can measure its voltage (for example 5v or 0v).

Assuming you are asking about digital input pins on an Arduino:
Digital logic operates at the saturation and cut off regions of the transistor logic used.  Most modern day processors use CMOS transistors.  The logic levels are Low: 0 V to 1/3 VDD and High:2/3 VDD where VDD is the supply voltage.  This information can be found here.
So, if your processor is designed to operate at 5 volts and is likely made of CMOS logic gates, the low level voltage is from 0 to 1.67 volts and the high level voltage is from 3.33 to 5 volts.
But to address your question specifically:  Digital input pins do not measure the voltage.  Not like an ADC input.  Instead, it is agreed that nothing operating normally that is to interface with a digital pin will produce (linger at) a voltage other than those designed to force the transistors into cut-off or saturation.
So do be careful not to do this.  It could result in unexpected behavior.
Now, if you can not avoid voltage between the designated upper limit of the low logic signal and the lower limit of the high logic signal you man need to buffer your signal with a device called a Schmitt Trigger.  This device adds hysteresis to your signal and converts it into either a low or high logic state.  Examples of hysteresis include the thermostat control for your furnace.
A final word, do not exceed the voltage at a digital input to that which is supplied at the power pin of that digital circuit. This can cause all kinds of problems.  Usually this is not a problem as most devices / projects are powered off of one power source.  But in case multiple power supplies are used, keep this in mind.

There is no point in using an external Schmitt trigger: there is already one inside each digital input.

That is good to know.  But can you say that for every Arduino?  I'm betting there are micros being used on different Arduino platforms which do not have Schmidt trigger like inputs.

Not for all – I don't know them all – but for the AVR-based ones (most Arduinos). I just checked the datasheet of the SAM3X8E (Arduino Due) and it says “With a few exceptions, the I/Os have input Schmitt triggers.” When in doubt, it's always wise to check the datasheet.

The implementation of the digital inputs may depend on what kind of
microcontroller you are using. On AVR microcontrollers (most common
Arduinos are AVR-based), the inputs go through Schmitt triggers.
This means that the voltage seen by the logic downstream is always a
valid logic level. You should then not worry about an invalid input
causing “unexpected behavior”.
It should be noted, though, that the characteristics of the Schmitt
trigger are very loosely specified. If I take the ATmega328P at Vcc =
5 V as an example (the MCU powering the Arduino Uno), the thresholds are
expected to be “typically” around 2.1 V (for the HIGH → LOW transition)
and 2.6 V (LOW → HIGH). But these are only typical values. The only
thing that is really specified is that the input reads LOW when the pin
voltage is below 0.3 Vcc and it reads HIGH above 0.6 Vcc. At 5 V this
means that the thresholds could be anywhere between 1.5 V and 3 V).


text:
Interrupt volatile variable doesn't work as expected
Please examine the following code.
volatile uint8_t myVar;

void setup() {
  attachInterrupt(digitalPinToInterrupt(2), isr, FALLING);
  Serial.begin(115200);
}

void loop() {
  myVar = 0;
  while (myVar != 5) {
  }
  Serial.println("ISR called");
}

void isr() {
  myVar = 5;
}

From this code, I expect that every time the pin 2 is falling, I get one single print statement ISR called.
However, when dropping the voltage on pin 2 ONCE, the serial monitor shows ISR called TWICE.
Why is this? This is a simplified, stripped-down example of the problem I am facing with my current project.
Edit:
After reading the comments, here is a bit more info. I am using a 64-button shield that is triggering the interrupt. The process is time critical since I am measuring the time it takes for the button to be pressed (I am testing people's reflexes). I will add a print statement in the interrupt to see how many times it gets called. However, I believe the interrupt is only getting called once per buttonPressed.
Thank you for your help!

does pin 2 bounce?

It looks like its bouncing.  How are you 'dropping the voltage' ?  I don' t know if it could be this but could it be that the ISR is being called twice because as it drops from 5V to say 3V it fires once, and then it drops from 3V to 0V and fires again.  Could you try a different trigger?

@CodeGorilla the Schmitt trigger should stop that kind of thing. It would trigger once at 1.6v and have to rise back to 3.3v before it triggered again.

As a quick check, I would have suggested adding a delay to account for the switch debouncing.  But since you've decided upon using an interrupt instead of polling (why? do you really need to respond that fast?!) you are now facing the difficulties associating with interrupting your programming at any point.  (Possibly) Even in the middle of a delay.  Many programmers (even people who make a living at this) have a difficult time wrapping their heads around this paradigm.

"I will add a print statement in the interrupt" = very bad idea.  You can count in interrupts, but don't print.

During the function Serial.println, the interrupt could be called a number of times. To count also those, you could increment the byte in the isr and decrement the byte in the loop. I think you have to disable the interrupts while decrementing the variable.

Turns out, the 64 button shield calls the interrupt TWICE. Once when the button is pressed and once when it is released.
Thank you for everyone's help!

@LookAlterno I would if I could. Stack exchange forces me to wait a day.

This is probably not the whole story.  You may have inadvertently misconfigured interrupts for both edges.

It would be nice if you included what change you made to solve the problem.

@RubberDuck I don't have the Arduino with me right now but when I do I will.

@ChrisStratton yes this is not the whole story.  This is a simplified piece of code so I can't really explain without rewriting the question however the root cause was that the interrupt was getting called twice.


text:
Undefined reference in Eclipse of .h and .cpp files
I'm trying to create a linked list for use on the Arduino, in the Eclipse IDE with the Arduino/Sloeber plugin. The linked list is written in a .h and .cpp file, and included locally in the project.

However, when building, I get the error undefined reference to Structures::LinkedList<int>::LinkedList().
And despite the fact that I've added the local folder to the list of includes (and it can find the top level file containing setup() and loop()), the problem persists;

My relevant file listings are below. Any ideas of what settings I can add to Eclipse in order to solve this? Potentially, could it be something to do with the use of template<typename T> in the header file?
Thanks very much,
David
FYI: This problem does not occur with the core libraries i.e. I can run examples like Serial and Blink.
My top level .cpp is pretty simple:
#include "LinkedList.h"
#include "RAStarSearch.h"
#include "Arduino.h"

using namespace Structures;
void setup() { }

void loop() {
  LinkedList<int> list = LinkedList<int>();
  return;
}

And the referenced .h is:
#ifndef LINKEDLIST_H_
#define LINKEDLIST_H_
#include "Arduino.h"

namespace Structures {
template<typename T>
class LinkedList {
  public:
    /// Struct inside the class LinkedList
    struct Link {
      T value;
      Link *next;
    };

    LinkedList<T>(); ///< Default constructor
    void addValue(T val); ///< prepends new value at beginning of list
    T popValue(); ///< returns first element and deletes Link.
    Link* peekLink(); ///< Looks at first value
  private:
    Link *head; // this is the private member variable. It is just a pointer to the first Node
};
const int ERRNUM = 0x8000000; ///<Error number used, as exceptions not supported
}
#endif /* LINKEDLIST_H_ */

EDIT
On request I have included my code for LinkedList.cpp
#include "LinkedList.h"
#include "Arduino.h"

namespace Structures {
  template<typename T>
  LinkedList<T>::LinkedList() {
    head = NULL; // set head to NULL
  }
  template<typename T>
  void LinkedList<T>::addValue(T val) {
    Link *n = new Link();   // create new Node
    n->value = val;             // set value]

    if (head == NULL) { //i.e. if list is empty
      n->next = head;         // make the node point to the next node or NULL
      head = n;    // last but not least, make the head point at the new node.
    } else {
      Link *it = head;
      Link *oldIt = NULL;
      //TODO check edge cases i.e. insertion at beginning and end of list
      while (n->value > it->value){ //until place in list is found, needs T to have > operator
        oldIt = it;
        it = it->next;
      }
      oldIt->next = n; //Set pointer to n
      n->next = it; //Set n pointer to next
    }
  }
  template<typename T>
  T LinkedList<T>::popValue() {
    T retval = ERRNUM;
    if (head != NULL) {
      Link *n = head;
      retval = head->value;
      head = head->next;
      delete n;
    }
    return retval;
  }
  template<typename T>
  typename LinkedList<T>::Link* LinkedList<T>::peekLink() {
    return head;
  }
}

Have you tried placing the H file in the same folder as you main cpp file.  This should prove beyond all doubt that there is nothing wrong with the code (I can't see anything wrong).
I suspect its a path issue.  You need to check that Eclipse is setup up properly to source the libraries from you custom location.  Also it needs to be passing this location on to the compiler.  I don't know how to do that in Eclipse but Google should point you in the right direction. Try this http://forum.arduino.cc/index.php?topic=39972.0 ?
Also you might find it easier to specify the include files in the order system, 3rd party libraries, local libraries and then local include files.  This means that duplicate definition faults are reported against the files nearest to the ones you have written.  If you define time_t using your ordering the fault will be reported against  rather than your header file.
Also a using namespace foo statement removes the benefits that namespaces provide, so its best not to do it.
EDIT
Doh - I should have spotted this sooner.  Template classes have to have the functions inline not in a CPP file.  This is because the CPP file can't change what T is at compile time, but because the H file is included in the file it is used in when it is preprocessed the object represented by T can change.
Basically inline your functions and it will work.

Unfortunately they are already both in the same path, and thank you for the tip on namespaces!

Sorry - The mistake is really obvious, but I had to compile it to realise what it was :)  You need the functions implementing.  You can't have a cpp file with a template so you need to inline the functions in the header file.  (I recreated the error on a PC with Visual Studio, so its not paths)

I have been reading up on this. As Matt states this seems to be a FAQ template issue. Have you read this? https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl

I've added the LinkedList.cpp file. Do I take it from this that to solve it I just need to inline all the functions into a single file?

@Matt This seems to be correct - inlining, or #include LinkedList.cpp seems to have worked! If you update your answer to reflect the problem?

The error you get is telling you that you have not implemented the method.
LinkedList<T>()

which you use in loop()
In other words: the header file is found and the correct references are made but when the linker tries to pack everything together he finds that he doesn't have an implementation.
The implementation is in LinkedList.cpp in your project but with templates this is not enough.You need to somehow explain the "toolchain" that your project needs a "instantiation of the template" of type int.
The fact you need to specify this is a "limitation" of the toolchain processong of templates and is well documented here https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl.
The same link contains solutions.
The article states "This solution may (or may not!) cause significant code bloat" which is probably one of the reasons why template classes are not so popular in embedded development.
In your case I would simply include LinkedList.cpp in my .ino file and rename the .ino to .cpp.
As I do not have the source code I can not tell you whether this will work.
note that including the LinkedList.cpp in the .ino doesn work because the LinkedList.cpp is included 2 times and there are no include gards in the LinkedList.cpp file

LinkedList is there (see the image), I just didn't include the listing as I though it was somewhat trivial?

As to the compiler the constructor LinkedList(); ///< Default constructor is not implemented

I updated the answer with the new insights I have on behalf of template classes

I updated the answer now the source has been provided.

authors: Алексей Щербаков


text:
Nano V3 values "overwritten" randomly
When I assign a global var to a certain value inside an if-block it has been changed to another value in the next statement. Somehow the address of the var is overwritten by some other process. It also does not stop at 1 value, this happens to the next vars that are assigned another value too. The vars are not defined in a row but should be close.
I already installed a newer version of Arduino IDE, no change.
Example:
menuActive=1;
Serial.print(menuActive);

gives results in the range 40 to 57 as far as I have seen till now. Further actions assign always the SAME value to next vars I assign after this.
Anyone some idea what could cause this? Am I low on memory for local vars?
This is compile message:
Sketch uses 21790 bytes (70%) of program storage space. Maximum is 30720 bytes.
Global variables use 1454 bytes (70%) of dynamic memory, leaving 594 bytes for local variables. Maximum is 2048 bytes.

edit:
As I already said, it is 21k of code. But I show you the part of the code that mishaves:
while ((digitalRead(rotSwPin) == 0) && lpress <= 200) {
    delay(10);
    lpress++;
    if (lpress > 200) {
        menuActive++;
        menuLvl=0;
        menuPos=0;
        subPos=0;
    }
}

Normally I use menuActive=1. Within the braces, it is still 1, out of that it changes. Maybe change from byte to bool.

Sounds like a buffer overflow to me.

Agreed! But where can I find the memory assignment in a file/list to grab an idea which variable does the overwriting?

You can't unless you generate a "map" file, for which you need to modify the compiler options in the IDE configuration files.  Examine your code for any arrays that you use and make sure you don't try and use more than you should. One common misuse is to declare int foo[10] and then try and use foo[10] as a slice.

Given the range of numbers it gives you, chances are it's a char array into which you are printing numbers, maybe with punctuation like brackets.

or show your code and someone spots the problem

Thanks for your suggestions, but I checked those things already carefully. I think of stepping to Eclipse for this Arduino project and find out more by debugging?

As I already said, it is 21k of code. But I show you the part of the code that mishaves:

while ((digitalRead(rotSwPin) == 0) && lpress <= 200) { delay(10);lpress++; if (lpress > 200) {menuActive++;menuLvl=0;menuPos=0;subPos=0;} }

Normally I use menuActive=1.
Within the braces, it is still 1, out of that it changes. Maybe change from byte to bool.

If your program corrupts memory (which seems to be the case here), the part of the code that misbehaves can be quite far from the part that does the memory corruption. There is nothing wrong with the code you are showing here. Your problem lies in some part of the code you are not showing. Nobody will be able to help you without seeing the bug.

I found the problem.
I could see that the false value is the character code of the minute I am displaying. I display hours and minutes and there was a declaration that was 3 characters short for the string I got as a result for hours added to minutes. Yes it was memory corruption.
So be careful to dimension enough places for your strings including 1 extra for 0.

@hoekbrwr You might want to post that as an answer, rather than a comment.

Comments are not recommended for any of the following: Answering a question or providing an alternate solution to an existing answer; instead, post an actual answer (or edit to expand an existing one);. Feel free to post an answer instead. Thanks.

I found the problem. I could see that the false value is the character code of the minute I am displaying. I display hours and minutes and there was a declaration that was 3 characters short for the string I got as a result for hours added to minutes. Yes, it was memory corruption. So be very careful to dimension enough places for your C-strings including 1 extra for 0. If you are not so short on RAM then a few more characters will do no harm, the end of the string will be the character before the 0 in memory.
When strange things happen start looking at this matter!

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


text:
Strange UDP problems
I am making a simulator box that pretends to be an industrial pump. We make equipment that interfaces with the pump and don't always have a pump available to test the connection. I used and arduino uno with an ethernet shield 2 to do this. The manufacturer of the pump has a very simple communication scheme. A 10 byte packet is sent to the pump via UDP once a second. The IP address and port on the pump are fixed.
I wrote a simple sketch that looks for the 10 byte UDP packet and then does some bitwise examination, then illuminates some LEDs.
Everything seemed to work great at first. I did my initial testing, I would get the packet, the bits would match, LEDs would illuminate. When I went back and tested it again it would not receive anything. parsePacket() always returns zero. The ethernet link is established, the amber LED on the ethernet shield flashes once a second but nothing shows up.
I have two machines that are in known good working order and neither would work with the arduino. They both worked during the initial testing. We do currently have a pump and both machines will operate the pump with no problems.
On a whim I rebooted one of the machines and packets started to show up again on the arduino when connected to that machine. The other machine still shows nothing on the arduino and both machines will operate the pump.
I tried connecting to them with wire shark. I can see both machines sending a 10 byte UDP packet. The source and destination IPs are correct, the port is correct as well. I bet that if I reboot the other machine that it will start working with arduino again.
I'm using the 2.0.2 Ethernet library.
What to trouble shoot next?
It is almost like something drifts slightly out of tolerance over time and the wiznet chip can't handle it or something.
#include <Ethernet.h>
#include <EthernetUdp.h>

#define PUMP_ON 9
#define LOW_PRESSURE 8
#define CUTTING_HEAD_OPEN 7
#define LINK_ESTABLISHED 6
#define HEAERT_BEAT 5

// MAC address and IP.
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAF, 0x01, 0x92 };
IPAddress ip(172, 16, 0, 106);

// The local port to listen for connections on.
unsigned int localPort = 8682;

// The maximum number of characters to receive from an incoming packet
#define MAX_PACKET_LENGTH 100
// Buffer for holding received packets.
char packetReceived[MAX_PACKET_LENGTH];

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

union uint_double_char {
  unsigned int Integer;
  unsigned char Character[2];
};

union BFT_COMMAND_DATA {
  struct {
    bool start : 1;
    bool stop : 1;
    bool reset : 1;
    bool pressure_relief : 1;
    bool adjusting_jet : 1;
    bool enable : 1;
    bool high_low : 1;
    bool valve : 1;
  };
  unsigned char data;
};

union BFT_COMMAND_DATA bft_command_data;

union uint_double_char conversion;

void setup() {
  pinMode(HEAERT_BEAT, OUTPUT);
  pinMode(LINK_ESTABLISHED, OUTPUT);
  digitalWrite(LINK_ESTABLISHED, HIGH);
  pinMode(PUMP_ON, OUTPUT);
  digitalWrite(PUMP_ON, HIGH);
  pinMode(LOW_PRESSURE, OUTPUT);
  digitalWrite(LOW_PRESSURE, HIGH);
  pinMode(CUTTING_HEAD_OPEN, OUTPUT);
  digitalWrite(CUTTING_HEAD_OPEN, HIGH);

  Serial.begin(9600);
  Ethernet.begin(mac, ip);
}

void loop() {
  static unsigned long time_second = 0;
  if (millis() - time_second > 1000) {
    time_second = millis();
    static bool light = false;
    light ^= 1;
    digitalWrite(HEAERT_BEAT, light);
  }

  static bool Link_Established = false;
  if ((Ethernet.linkStatus() == LinkON) && (Link_Established == false)) {
    // Begin listening on the local port for UDP datagrams
    if (Udp.begin(localPort) == 1) {
      Link_Established = true;
      Serial.println("socket established");
    }
    Serial.println("link established");
  }
  if ((Ethernet.linkStatus() == LinkOFF) && (Link_Established == true)) {
    Udp.stop();
    Link_Established = false;
  }

  Ethernet.maintain();

  if (Link_Established == true) {
    digitalWrite(LINK_ESTABLISHED, LOW);
    // Look for a received packet.
    int packetSize = Udp.parsePacket();
    //Serial.println(packetSize);

    if (packetSize > 0) {
      Serial.print("Received packet of size ");
      Serial.print(packetSize);
      Serial.println(" bytes.");

      Serial.print("Remote IP: ");

      IPAddress remote = Udp.remoteIP();
      for (int i = 0; i < 4; i++) {
        if (i < 3) {
          Serial.print(remote[i], DEC);
          Serial.print(".");
        } else {
          Serial.println(remote[i], DEC);
        }
      }
      Serial.print("Remote port: ");
      Serial.println(Udp.remotePort());

      // Read the packet.
      int bytesRead = Udp.read(packetReceived, MAX_PACKET_LENGTH);
      Serial.print("Packet contents: ");
      Serial.write(packetReceived, bytesRead);
      Serial.println();
      conversion.Character[0] = packetReceived[4];
      conversion.Character[1] = packetReceived[5];
      Serial.println(conversion.Integer, BIN);

      bft_command_data.data = packetReceived[4];
      Serial.print(bft_command_data.valve);
      Serial.print(" ");
      Serial.print(bft_command_data.high_low);
      Serial.print(" ");
      Serial.print(bft_command_data.enable);
      Serial.print(" ");
      Serial.print(bft_command_data.adjusting_jet);
      Serial.print(" ");
      Serial.print(bft_command_data.pressure_relief);
      Serial.print(" ");
      Serial.print(bft_command_data.reset);
      Serial.print(" ");
      Serial.print(bft_command_data.stop);
      Serial.print(" ");
      Serial.println(bft_command_data.start);

      if (bft_command_data.start == 1) {
        digitalWrite(PUMP_ON, LOW);
      } else {
        digitalWrite(PUMP_ON, HIGH);
      }

      if (bft_command_data.high_low == 1) {
        digitalWrite(LOW_PRESSURE, LOW);
      } else {
        digitalWrite(LOW_PRESSURE, HIGH);
      }

      if (bft_command_data.valve == 1) {
        digitalWrite(CUTTING_HEAD_OPEN, LOW);
      } else {
        digitalWrite(CUTTING_HEAD_OPEN, HIGH);
      }
    }
  } else {
    digitalWrite(LINK_ESTABLISHED, HIGH);
  }
}

you could use Processing on your computer to emulate the pump, or at least log the packets as an UDP client ... see if the failure also occurs there ... https://processing.org .... https://stackoverflow.com/questions/2880885/processing-open-udp-socket-for-reading

Are you sure you need to stop() UDP listener if the link is off temporally? try just UDP.begin in setup and no link status based handling

increase the serial baud rate and test again ... reduce the program to simply echo every UDP byte to serial, see if it still crashes

@jsotola It's not really a crash. The Arduino/ethernet shield simply can't seem to receive anything sometimes. The device sending the packets is an omron motion controller. During the "condition" a computer or the pump can still receive those same packets.

@Juraj the stop() doesn't seem to affect anything. I can go back and forth between two ethernet cords (from two different systems) and one is good and the other "appears" dead, but the pump can get data from both.

There is an updated https://github.com/SapientHetero/Ethernet library that claims to work better with the W5500 (which is on your Ethernet Shield 2). Some forum posts on Wiznet forums also talk about instability / not working after some time, but no real conclusion except "did you follow the read UDP payload mechanism outlined in the datasheet?".

@MaximilianGerhardt I tried the suggested library with no change. Two machines that both talk to the pump. One will talk to the Arduino and the other one won't. I can go back and fourth and very consistently one talks and the other doesn't. The amber led flashes once a second for both like it is receiving something, but nothing shows up on one of them.

Network delays or timing jitter might cause the Arduino to miss packets if it’s not handling them correctly.

@liaifat85 Do you have any suggestions on how to handle them. The Wiznet 5500 chip with the ethernet library is the one doing all the lifting. I've both looked at the library and the chips data sheet and I didn't see any way of dealing with jitter or other things for that matter.

The W5500  chip and library don't have built-in mechanisms for handling packet timing jitter or missed packets. Open the Ethernet.h file, and look for the receive buffer size setting: #define ETHERNET_RX_BUFFER_SIZE 512 . You can increase this size to see if it solves the issue.

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


text:
CAN-Bus shield, SD-card module & LED_BUILTIN use D13; possible collision?
To my knowledge the SeeedStudio CAN-Bus shield utilizes D13, and so does the SD-card module I use. And also Arduino Uno's LED_BUILTIN is 13. Am I in danger of some sort of collision here?
I have read this question, but that one describes situation where both modules are on a single shield.
Why I am alerted: I can perform following sequence: turn the LED on, open file, write, close file, turn the LED off, no apparent problem here. But when I connect my CAN-Bus shield to merely read messages (i.e. no sending data to the shield, not on purpose) my car behaves funny as if I still somehow managed to send some rogue bytes to the shield. (Right side windows and mirror are dead, infotainment display shows dead splash screen, dashboard complains about "engine malfunction" and airbags...)
I wonder if by writing to the SD-card and possibly turning the LED on I didn't send some bytes to the shield. Do I need to somehow Select Slave?

The actual cause of the car going crazy was that I did not have GND connected

Yes you are in danger of a collision, how much danger I can't say, but the potential is there.

You could stop using the LED on D13?
Could you move the pins of your SD card reader, or get a different one that allows I2C or SPI interfacing?

I guess there is nothing that can be done to the CAN bus device, but if there is it might be a good idea to move its pins.


text:
Why would uninitialized SD-card module without card disable CAN-Bus shield?
(I am able to successfully initialize CAN-Bus shield and SD-card module w/ card in it.)
Now I have removed all code related to the SD-card module, yet I left the module (without the card in it) physically connected. This results in the CAN-Bus shield initialization failing.
When I insert the card into the SD-card module the CAN-Bus shield initializes successfully. (I am still not doing SD-card module initialization.)
Of course, I can just disconnect the SD-card module or leave the card in it... But I am trying to understand this black magic.
I have connected the SD-card module CS to pin 8, the CAN-Bus shield clone CS is connected to pin 10. I tried to set the SD-card module CS pin to OUTPUT and to HIGH. That had no effect.
the CAN-Bus shield + schematics: http://www.elecfreaks.com/estore/can-bus-shield.html [Resource -> Schematics]
the SD-card module: https://ebay.com/itm/161366316226?_trksid=p2057872.m2749.l2649

Maybe it have similarity to this: http://arduino.stackexchange.com/questions/31924/how-to-setup-an-i2c-bus-which-stays-valid-if-a-slave-is-powered-down-or-fails - the uninitialized device can brind the bus to some bad state, as it does not care about the bus at all

Would need a reference/link to the shield and schematics to answer that.

I think the SD-Card and the CAN Bus shield use the same pin and that is the problem.  I read that on a post on here last week.

@MikaelPatel http://www.elecfreaks.com/estore/can-bus-shield.html This is the product; there is Resource tab with Schematics link

@Matt Could be it. Maybe it would explain why I am not able to log any messages when actually connecting the whole ball of wires to the OBD2 access port. When testing on my PC both devices report "init OK" but then in the car I get no messages. Despite the wildly blinking LED on the shield. (That's why I stripped all the SD-card code in the first place.)

Here is the post, I knew I read it :)
http://arduino.stackexchange.com/questions/35198/can-bus-shield-sd-card-module-led-builtin-use-d13-possible-collision/35223#35223

@Matt :)) That was me asking. My understanding is the only pin on the SD-card module I can (and have to) "move around" is the CS. So I moved it to 8.

@Matt From what I understand the rest of the pins are supposed to be shared, i.e. it should not be an issue.

J. Z., please edit the info from your first two comments here and from your comments to Majenko's answer into the question ... more likely to get upvoted if question is more complete

fixed the shield url

Without seeing schematics this is purely supposition:
My guess is that the SD shield contains bi-directional level shifting. The MISO pin, which connects the DO pin of the SD card to the MCU, will have a 3.3V -> 5V level translator on it.  This, with no SD card inserted, will be floating (flapping around in the breeze) causing the output of the level translator to randomly produce digital signals on the MISO pin. These signals interfere with the MISO signals from your CAN shield.
How best to cure the problem very much depends on what level shifting is in the circuit and how it is controlled and wired. For that we will need to see schematics of both the CAN and SD card shields.

CAN-Shield: http://www.elecfreaks.com/estore/can-bus-shield.html [Resources -> Schematics]

SD-card: http://www.ebay.com/itm/161366316226?_trksid=p2057872.m2749.l2649 I can't seem to find more info on this little bugger.

Need a schematic of the SD card to know how the 74LVC125A is wired up - is it buffering the DO pin of the SD card or not?

Unfortunately I can't find any vendor name on that thing, or a product page... The link above is all I could find.

Then you would have to reverse engineer it. Shouldn't be hard with a DMM.

At this point that is something beyond my skill/knowledge, will have to wait, soon or later the pieces will fall into place :) Thanks anyways!


text:
Remove Function at Preprocessor Time
I have a single function for debugging messages, used through all the project. When KEYDEBUG is defined as 1 or 0, the function is enabled or disabled as required.

#define KEYDEBUG 0

void debugging(int var){
   #if KEYDEBUG
   //Assert
   #endif
}

When checking the compiler, the variable var raises a warning -Wunused-parameter.
How should remove this warning just at this part of the project?
Or which other alternative for using debugging code and removing it from memory for production release?

In your case you do not use the entire body, so you can use a macro.
This way the code when KEYDEBUG is 0, will be like the complete function would not exist (except for the void cast, see below).
#include "assert.h"

#define KEYDEBUG 0

#ifndef KEYDEBUG
#define debugging(x) void(x);
#endif

void debugging(int var){
   assert(var);
}

void setup() {
  // put your setup code here, to run once:
  debugging(1);
}

The information below is for not using the function parameter, but keep the function (in case you have code in your function that also does something when KEYDEBUG is 0.
Unused attribute
The cleanest way I could find is using the unused attribute:
#if KEYDEBUG
   void debugging(__attribute__((unused)) int var){
      //Assert
#else
   void debugging(int var){
      //Assert
#endif
   }

or if you prefer better readability:
#if KEYDEBUG
   void debugging(__attribute__((unused)) int var){
      //Assert
   }
#else
   void debugging(int var){
      //Assert
   }
#endif

Cast to void
Less clean but does the job:
void debugging(int var){
   #if KEYDEBUG
      //Assert
   #else
      (void) var; // prevent unused parameter warning
   #endif
}

Macros/Parameter
It's not easy to remove the variable since it's used in a function and will be called from many places probably. You could maybe you use a macro but that gets messy soon.
This solution works, and afaik the compiler will optimize the code out (if not , it will cost very less anyway).

It is possible to remove absolutely the debugging function and its calls without touching the debugging calls?

Not fully, well in the macro I defined, the function call is replaced by a void cast, so this is not a function, and you don't have to touch the debugging calls.


text:
Is there any limitation with Arduino Nano serial communication distance?
I am trying to build Project which communicate multiple Arduino Nanos. I wanted to understand if Arudino Nano is capable of doing that, while doing research I came across post where it says communication with nano can be done up to 2-3 meter, where as my goal is up to 30 meter.
Project - I am trying intercom system, I have 4 Ring button at main gate, when user press any one of those 4 the Arduino will understand it and send to one of the 4 Arduino sitting at other place. Each Arduino will read that message if its for them they will perform activity if not they will skip it.
My problem is I am in selection mode and want know if Arduino Nano can handle that, communication is not that complex. It will be just sending 2/3 value max during communication. As I saw post of distance limitation, I just want get inputs from community. If you have any similar examples of serial communication between multiple Arduino Nano please let me know, I found several but it might save my time if I find something more similar.

why do you need MCUs for a door bell?

@Juraj Its intercom i am trying to build which will connect 5 apartment with 3 different doors. Using MCU i am trying to control 3 camera situated at each door and then allowing user to open that door from selected room.

I agree with Bob Croft, Nick Gammon has a very good description of how to do what you need. Here is a link to his RS485 site. http://www.gammon.com.au/forum/?id=11428

For that sort of difference you are better using RS-485 instead of UART.  UART is really only designed for short-distance communication.
Converting UART to RS-232 will give an improvement, but switching to RS-485 instead will give you the ability to create a multi-drop bus for connecting more than two Arduinos together over a long distance.

UART uses 5V logic level signalling (on the normal Arduinos - 3.3V on most 32-bit boards). It has a "weak drive" and is highly susceptible to induced noise over longer distances.
RS-232 uses ±10V "Non Return to Zero" signalling. This gives far greater immunity to noise and a stronger drive for greater distances.
RS-485 (and the associated peer-to-peer RS-422) use differential signalling. This gives the greatest immunity to noise over the longest distances.

In summary:

RS-232 can be used if you only want to connect two devices together in a low noise environment.
RS-422 can be used to connect two devices together in a high noise (industrial) environment.
RS-485 can be used to connect lots of devices together in a high noise environment.

For more information on how they work there are some good Wikipedia pages:

RS-232
RS-422
RS-485

For interfacing any of these to an Arduino you will need extra hardware ("Driver Chips"). For example:

RS-232: MAX232
RS-422: MAX1184
RS-485: MAX485

There is also "CAN", which is a more modern replacement for RS-485 and is used in many industrial and automotive environments. As this is a newer technology than RS-485 there are fewer resources available and "initial cost to entry" can be higher.

Do you have any example which i can refer for this. I did found youtube video but it doesn't have much details.

There are millions online. Just Google Arduino rs485 or Arduino max485.

Roughly speaking, for a given protocol and medium (cable) the data rate and the distance are inversely related, that is, a connection with half the data rate can work across twice the distance. You will eventually hit the hard limit when the total capacitance of the cable will become too much for the driver.
RS-232 standard provides this table of maximum cable lengths for standard shielded cables:
Data rate (bps) Distance (m)
2400            60
4800            30
9600            15
19200           7.6
38400           3.7
56000           2.6

So, 30 meters can be easily achieved even with RS-232, if you don't mind the 4800 bps baudrate. Even longer distances (or higher baudrates) can be achieved by running RS-232 over a twisted pair, e.g. a UTP 5 cable: these cables have lower capacitance and can run at 9600 bps over 100 m or more.
There are other protocols suitable for long-distance communication. There are Arduino shields for CAN, RS-485 and even Ethernet.

It's worth noting that RS-232 is not the same as the TX/RX pins. The protocol is the same, but electrically it's not. UART is 5V logic levels and weak drive, whereas RS-232 is ±10V NRZ signalling and stronger drive. Whether you go for RS-232, CAN, or RS-485 you will be needing extra hardware "driver chips" to make it work.

@Majenko Obviously. I believe the 2-3 meters limit mentioned in the question refers to the built-in UART driver. The same remarks apply to it: using lower baudrate and lower-capacitance cable can make it work over a longer distance (though 30 meters is most likely unachievable).

Hi please have a look at Nick Gammon's website as he does an Arduino libary for RS485 using cheap driver modules. In particular the non blocking example may well fit your needs.  The library also works for ESP8266 and ESP32 modules under the Arduino IDE.


text:
NRF24L01+ (TMRH20 library): Receiver gets blank data
I am working on sample Arduino project for communication over NRF24L01+ (TMRH20 library), everything is working fine with my example except one issue my Receiver gets message but that message is blank. Now i am not sure how do i debug as per serial monitor data is getting transmitted, as per receiver serial monitor it receives data but its blank.
Transmitter code -

// SimpleTx - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[12] = "Msg AKSHAY";
//int dataToSend = 1;
char txNum = '0';

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[10] = txNum;
}

Receiver code -
// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
  if ( radio.available() ) {

       radio.read( &dataReceived, sizeof(dataReceived) );
      Serial.println(dataReceived);
       newData = true;
   } else {
       Serial.println("No radio available");
   }
   delay(100);
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        newData = false;
    }
}

Below is the output TX1 (Transmitter ) and RX1 is Receiver. You can see that Transmitter even gets acknowledgment also..

Both of my devices are arduino nano and below is wiring diagram between arduino and nrf24l01.

I also saw few post where people suggested using 100uf capacitor in NRF24L01 (GND & VCC), this helped me with accuracy in connection but data is still missing.

Had you tried the for loop while printing your data on the serial as you are receiving data in the form of char array.

I tried that but it doesn't help.

Can you please upload the unmodified PingPair example and see if that works? It's really hard to see the real cause if it might be just your code.

I have tested your code. There appears to be defective clones of the nRF24L01 around that exhibit an issue I show in post nRF24L01 continuously reading closed pipe
You can work around this issue by changing your code as follows (although your process still has to read all those nulls):
void getData() {
  uint8_t pipeNum;
  if ( radio.available(&pipeNum) ) {

       radio.read( &dataReceived, sizeof(dataReceived) );
      //Serial.println(dataReceived);
      if (pipeNum < 2) {
       newData = true;
      }
   } else {
       Serial.println("No radio available");
   }
   // delay(100);
}

A couple of clarifications first

At the time instant 22:38, the receiver isn't detecting any available radio devices but at the transmitter side, an acknowledge is received. How is that possible? How is your tx getting an ack without the rx getting connected.
I have not seen slave adresses being set as - const byte slaveAddress[5] = {'R','x','A','A','A'}; For the record, NRF24L01 adresses are 5 bytes long by default and not 1 byte long as you have defined. While defining the pipe addresses, the first 4 bytes of the adresses should be same among all the pipe addresses. Only the last byte should be unique. Pipe addresses can be 0xF0F0F0F0A1, 0XF0F0F0F0B1, 0XF0F0F0F0C1, 0XF0F0F0F0D1, 0XF0F0F0F0E1 Try setting the pipe addresses as uint_64t address[5] = {0xF0F0F0F0A1LL, 0XF0F0F0F0B1LL, 0XF0F0F0F0C1LL, 0XF0F0F0F0D1LL, 0XF0F0F0F0E1LL};Do the same declaration at the receiver end too. And btw, you can specify any byte you want in the last byte of the address. Here I have defined the last bytes as A1, B1, C1, D1, E1.
To make sure that communication is successful, set some custom ack byte and compare it with the received ack. If both match, you can be sure that the rx did get the data. Sometimes, the NRF24L01 can pickup garbage values from stray signals present around and it can consider it as data sent by the receiver. So to avoid false triggering, its better to make a fool-proof ACK mechanism.

Your second point makes no sense at all. You are trying to stuff five-byte-wide values into one byte, which is pointless. In fact, the original intent of the OP with his const byte slaveAddress[5] = {'R','x','A','A','A'}; apparently is an attempt to create a 5-byte address. Exactly as you said it should be. It is a single slave address, not five of them.

Sorry! It should be uint_64t. Thanks for pointing it out AnT

(Firstly, it's uint64_t, not uint_64t.) But that will declare 5 separate addresses. How is that relevant to the OP's question? Why 5? He does not need five separate addresses, he just needs one.

Also, this is an example from RF24 header file itself: uint8_t address[] = { 0xCC,0xCE,0xCC,0xCE,0xCC }; radio.openWritingPipe(address);.  (https://github.com/nRF24/RF24/blob/master/RF24.h#L246) As you can see, this is the same thing as in the OP's code. There's nothing wrong with it.


text:
Basic Arduino Airplane Control
I have a task where I need to control the airplanes thrust and altitude direction(Up-Down). For the thrust I thought of using a DC Motor and a Servo for the other. Control of servo will be from the buttons and the thrust value will be given from the serial port. (This is not a project of a real vehicle, only thing I need to do is the code, rest is imaginary.)

I have wrote the following code. I would like to ask is there any flaws and how can I further improve it? Thanks in advance.
With my regards...
#include <Servo.h>
  Servo servo1;
  int pos = 0;
  const int buttonSUP = 2;
  const int buttonSDOWN = 3;

  int buttonStateUP = 0;
  int buttonStateDOWN = 0;

  int motorPin = 4;

  void setup() {

  servo1.attach(9);
  pinMode( buttonSUP, INPUT);
  pinMode( buttonSDOWN, INPUT);

  pinMode(motorPin, OUTPUT);
    Serial.begin(9600);
    while (! Serial);
    Serial.println("Speed 0 to 255");

  }

  void loop() {
   buttonStateUP =digitalRead(buttonSUP);
   if(buttonStateUP=HIGH){
      servo1.write(90);
      Serial.println("UP");
    }
    if(buttonStateDOWN=HIGH){
      servo1.write(0);
     Serial.println("DOWN");
      }
    else{
        servo1.write(45);
        Serial.println("STABLE");
        }

    if (Serial.available())
    {
      int speed = Serial.parseInt();
      if (speed >= 0 && speed <= 255)
      {
        analogWrite(motorPin, speed);
        Serial.println(speed);
      }
    }

    }

Your formatting is off, but also, it's always either DOWN or STABLE?

I thought as the servo being 45 degrees shifted just as  this "<". There fore with a 90 degree move, I can shift from up to down or vice versa .

while (! Serial);  Is not needed if you have a board with USB-> Serial bridge Chip (arduino uno for example)
if(buttonStateDOWN=HIGH){
}

In every condition you used = instead of ==. Your "condition" actually assigns HIGH to buttonStateDOWN. If you want to compare integers, use ==.
And according to the question, I think you have misunderstood the speed buttons (or maybe I have). I think, they want you to code it so while the button is pressed or every time the button is pressed, the speed changes by +1 or -1.
Assuming the rest works fine, there could be a problem with your serial output, since you just spam messages.
Read about the millis();, it can help you so you only send something every x amount of seconds, without using delay(); Here


text:
How to write data in RAM memory using Arduino Uno or Arduino Due?
I know that it is possible to write data in ROM(Read Only Memory).
But what about if I want to write data in RAM(Random Access Memory)?
Can I do it using "Arduino Uno R3"?
RAM is normally associated with volatile types of memory.
There are several examples about writing data in EEPROM as in a (Read Only Memory) which may have 8 pins.
In order to store values read from analog input 0 into the EEPROM we need to use the "EEPROM.write()" function.
These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch.
ROM is a Non-volatile type memory.
SD card is also Non-volatile type of memory.
We know that there are few SD card shields for "Arduino Uno" and it is possible create your own shields.
But what about volatile types of memory?
what about if I want to write data in RAM like a "DDR SDRAM" or in a DDR3 memory which may have 240 pins instead of 8 pins?
So my question is is it possible to write data in "DDR SDRAM" using "Arduiono Uno R3"?
How? Where should I connect those 240 pins?

What is your eventual goal? What do you want to do with DDR3 that you couldn't accomplish with SRAM? Or with an SD card if you need a large storage?

I think the OP wants to write to external memory (not the onboard RAM). @IremadzeArchil19910311 - please specify what sort of RAM you have in mind (part number). 240 pins? I hope you are joking. There are not 240 I/O ports on the Arduino. These are designed to plug into a PC or Mac. You can however get SPI or I2C RAM modules.

"So can any kind of SDRAM Shield help me to solve this problem?" You've only asked about a solution - DRAM - and haven't yet explained the problem you're trying to solve. If you could have DRAM, what would you do with it? Must it be DRAM or can you accept alternate ways to accomplish your goal?

Even in the rare situations where external RAM could be remotely sensible, you are probably better off using SRAM than any flavor of DRAM like DDR, SDRAM, etc, as you are unlikely to use enough of it for the greater complexity of dynamic RAM over static RAM to be justified by the lower cost-per-bit.  But really, for anything requiring this scale of memory, you should move beyond the Arduino to a more appropriate platform first.

i too have similar question, its useful in case you have uno refreshing page running of arduino uno, so if you tick the check box on auto refreshing page it we be unchecked on page reload, so best is to store the state on RAM , which would also ensure vale is reset in case we reboot uno .

just hit my mind, can't pointers be handy to access a memory location and store and retrieve data there ?

Your program is already using the on board RAM:
int a = 5; // This is RAM. Where did you think it goes? (This might go to a CPU Reg)
int a[5000]; // This is RAM

DDR3 RAMs require (typically) 1633 MHz clocks, and store gigabytes of data, not something you use with Arduino, which has a 16 MHz CPU.
If you need EXTRA (emphasis on extra) RAM, my first advice would be to refactor your project, and reduce processing on Arduino.
However, if must have more RAM, get SRAM. In most cases, DDR3 trade high maintenance for cost. Have a look here.

int a = 5; is in RAM only if declared at global scope. If it's a local variable, it is almost certainly assigned to CPU registers. There are exceptions though: if you take the address of the variable, or if there are not enough available registers, it will end in RAM, but this is uncommon.

How about recursion. This will almost certainly use stack, in memory.

Even with recursion, the variable is likely to be assigned to a register while “live”, and saved on the stack only for the duration of the recursive call. This may depend on how much use the variable has though, so you should disassemble if you want to know for sure for some particular recursive function.

DRAM of any kind requires a memory controller which is not present in any AVR device. Larger AVR devices such as the ATmega64A and ATmega128A do have an external memory bus that can be used for SRAM and MMIO.

So can any kind of SDRAM Shield help me to solve this problem? Do SDRAM Shields have this memory controller?

The Uno R3 does not have an external memory bus regardless. And performing MMIO to access paged DRAM will be painful at best.

In short, the Uno (or rather, the ATmega328) simply isn't designed for that kind of application. The new Zero might, with it's Cortex M0+ processor. Don't quote me on that, though...

The memory controller wouldn't be integrated into the core, so it would depend on which specific chip or family it uses. The SAM-D21 (Zero) doesn't have an external memory bus. The SAM3X8E (Due) has an external memory bus but no memory controller and doesn't seem to expose the entire bus via headers. The Sitara 335X (Tre) does have a memory controller, but it is only connected to the on-board DRAM.

OK! But what about "Arduino Mega"? Or what about "Arduino Due" which is an ARM device?

The easiest way to read and write DDR SRAM would be to install it in a PC and write a serial server that allowed the Arduino to access the data by requesting it over the serial port.
Now although that is possible to do, the performance probably won't be great.  So it might be worth looking into memory that interfaces over SPI or IIC, there are several ICs that you could use.  Most of them would have libraries already available and you would be looking at about £1 per 256kbits.
But like it has been said above if you are looking at storing multi-GBs of data then you probably want SD cards.  If the write speed is going to be a problem then look at multiplexing the data over many SD cards.


text:
How can I program RFduinos and how can I connect them with Bluetooth?
My RFduino dev kit just arrived, and for my project I have to connect a few RFduinos via Bluetooth and light up certain LEDs attached to the RFduinos. If anyone could point me in the right direction as to where I can program them/how I can connect them, it would be GREATLY appreciated.

I am starting on a similar project (without the Dev Kit).  Hooking the Bluetooth module to the RFduino is pretty straight forward, PWR to PWR, GND to GND, remember to cross the transmission wires: TX to RX & RX to TX.
In your void setup(), you need to start the connection:
Serial.begin(9600); // check your documentation to see the baud rate

In your void loop(), read or write to/from the bluetooth connection with serial write/read. Serial.read() or Serial.write()
Remember that Bluetooth is a communication protocol, not a controller.  You don't mention WHAT you are connecting your RFduinos to using Bluetooth. You still need a controller capable of sending a signal to light up the LEDs using Bluetooth.

Thank you that is very helpful. I plan to use my iPhone as a controller, but I also want to make my own App. I don't want to use the pre-existing RFduino LED controller app. (the one on the app store)

Sweet!  I'm doing the same thing with Android!  However, life has put this project on hold for a while.  Please keep me posted on your progress.


text:
Communication between two Bluetooth modules of two Arduinos
I am designing a home automation project. I want to control different home appliances through GSM. I am designing it in such a way that each apparatus is connected to an Arduino and bluetooth module. There is a master unit with Arduino, Bluetooth and GSM modules. When the user sends a message, the GSM receives it and communicates via Bluetooth to the corresponding Bluetooth module and Arduino.
Is it possible to communicate between two Bluetooth modules of two Arduinos? Is there a better solution?

Your GSM-connected arduino may need to connect and disconnect its master bluetooth module with the corresponding slave bluetooth devices as needed, but it should definitely be possible.

How about little smart WiFi boards (such as Red Bear WiFi Micro or something similar), which are connected at your local home network? You can configure your own dyndns service or use a existing and built a web home appliances or web service for your own mobile application. In general please take care of security aspects, so that your home can not be manipulated...

I'm not sure how many bluetooth devices can be connected to your smartphone. But if you use smartphone, the you can eliminate the master Arduino. But as I said, it still depends on the number of devices you'd like to control. This is supposed to go in the comment section.

You connect your different sensors or devices to many slave arduinos and each slave arduino has its own bluwtooth module that send the data to Master Arduino that contains the Bluetooth and GSM Module.
And yes you can connect max 7 bluetooth devices to 1 Bluetooth module at a time so in that manner you can connect 7 slave devices to Master Arduino

FYI this system is called Bluetooth Piconet and is not supported in many devices. Most likely needs more expensive bluetooth modules.


text:
The 3.3 volts of the USB To TTL
I'm using ESP with USB to serial converter (D-SUN) is it possible to use the 3.3 volts of the USB instead of the Arduino Uno?

I don't know what that adapter is (a link would be nice, or at least the chip number it uses) but in general the 3.3v on a USB TTL adapter can only provide a small current. For instance the FT232RL can only provide up to 50mA at 3.3v. That may not be enough current to drive the RF circuitry of the ESP. The early Arduinos used the FT232RL chip for the USB interface and it was the 3.3v from that which was used for the 3.3v header on the Arduino. This was somewhat of a failing with those Arduinos since the 50mA limit was a real problem when people started using more 3.3v devices. That was one of the driving forces (as well as cost) in the decision to switch to an MCU for the USB interface.
So to be on the safe side I wouldn't use the 3.3v from the USB adapter to power the ESP. You are better using a 5v to 3.3v regulator circuit driven from the 5v of the USB. And yes, that could be a whole Arduino, or build your own on some stripboard.

From my experience using the USB to TTL adapter will not work very well. I got some code on my ESP somehow, but could not get it working reliable. So I ended up powering it from an additional source.


text:
How to send a group message to multiple receivers using GSM900 and Arduino Mega2560?
I'm working on a project and it can send to one receiver only. What I need is to send a message to multiple receivers. I need a code sample that would satisfy my needs. Please help! I need to finish this ASAP.

Simply change the number in the AT command and send the message again.


text:
Arduino Serial and myserial clarification. How to print out rx output?
I currently have a camera I am trying to run off an Arduino. I am new to Arduino and I have had trouble figuring out what serial and myserial really do. I also don't understand why, when I have something like serial.write(0x56) I will get the output in the serial monitor to be V in hex, but If I have the Arduino also connected to an oscilloscope, I won't be able to see the signal.
Yet if I have myserial.write(0x56), I won't see anything in the serial monitor, but will see the bits on my oscilloscope.
Also, if I send a command to my camera, my camera should send back some hex values if the write command is sent. I understand I can send commands via myserial.write(0x56), but how would I read the hex values the camera would send back?

It seems like you are using both the hardware UART pins and two other pins for SoftwareSerial i.e. UART emulated by the arduino.
When you write Serial.read() or Serial.write(), Arduino knows to use the UART hardware on the chip which is has RX/TX pins 0 and 1 for most Arduinos. So by using these functions you will be able to communicate with any device which is connected on these pins.
Generally, when you have the Arduino connected to your computer, these RX/TX pins internally go to a serial port on your computer via the USB, hence you can send/receive data to the computer and view it on the Serial Monitor. Great for debugging purposes!
Sometimes, like in your case for controlling the camera, you need to have another serial port for communication because UART is point to point i.e. only 2 devices can communicate via it. SoftwareSerial helps you do that by using  two other pins on the Arduino into RX/TX pins. If you look at the top of your code file you will see a line like this
SoftwareSerial mySerial = SoftwareSerial(...);

Inside the brackets you will also see the two pin numbers which are being used as RX/TX. In the software serial example pins 10,11 are being used. So whatever is connected to these pins (i think your camera module is) will be able to send/receive data using mySerial.write() and mySerial.read().
Hence, to be able to receive data from the camera you will use mySerial.read().