body:
Can anybody tell me how the [Particle (Photon/Core)](https://docs.particle.io/guide/getting-started/start/core/) WiFi *setup* works?

I am looking to mimic this WiFi configuration format for my own device.

The basic steps are as follows:

 1. Power device on; put in "listening mode" if not already active;
 2. Connect smartphone to the wireless network that you want to connect your device to;
 3. Open the Tinker/Spark/whatever-it's-called App on your smartphone; choose "Add New Device";
 4. Enter wireless password;
 5. Wait for device to be discovered by the App; device is now connected to WiFi.

How is the information (SSID, password) transferred from the smartphone to the device?

Thanks in advance.

title: Particle-like wifi configuration

Answers: 1

body:
The Particle Photon is a replacement for the Spark Core module. This module was exploiting the Texas Instrument CC3000 chip. It was this chip that handle the very simple and convenient Wi-Fi configuration of the Spark Core. Texas Instrument named this method : [SimpleLink][1].

The Particle Photon is now using a different module than the Core : a Broadcom BCM43362 instead of the CC3000. It's seems to work in a similar manner even if I was not able to find any information on it.

I've found on the George Howkins [Depletion Region blog][2]  multiple articles that explain how the CC3000 SimpleLink works.

 - [CC3000 Smart Config - transmitting SSID and keyphrase][3]
 - [CC3000 advertises presence on network via DNS-SD][4]

All the posts : http://depletionregion.blogspot.fr/search?q=smart+config

  [1]: http://www.ti.com/ww/en/simplelink_embedded_wi-fi/tools_software.html
  [2]: http://depletionregion.blogspot.fr/
  [3]: http://depletionregion.blogspot.fr/2013/10/cc3000-smart-config-transmitting-ssid.html
  [4]: http://depletionregion.blogspot.fr/2013/10/cc3000-advertises-presence-on-network.html


body: I have a generic 16x2 LCD display connected to my Arduino.  I can use the standard LCD library to display characters, but are there way to turn on and of individual pixels?

title: Can I access individual pixels on my 16x2 LCD display

Answers: 1

body:
It's possible to define custom characters for “generic 16x2 LCD displays” [ie, displays based on HD44780 or equivalent controllers], but only up to eight such characters at the same time.  See [LiquidCrystal.CreateChar](https://www.arduino.cc/en/Reference/LiquidCrystalCreateChar) for details.  See page 2 and part of page 1 of the [Print degree symbol ° on LCD](http://forum.arduino.cc/index.php?topic=19002.0) arduino.cc thread for create-character examples that don't use the library.  Page 1 of that thread also shows a table of all the characters built into typical HD44780 controllers, some of which may perhaps meet your needs.

For pixel-by-pixel LCD control, look at graphics LCDs, eg the [KS0108](http://playground.arduino.cc/Code/GLCDks0108) or [LCD12864](http://playground.arduino.cc/Code/LCD12864) and similar.


body:
I'm trying to use the [MS5803 pressure sensor][1] with a Teensy 3.2. Compiling the [Sparkfun][2], or other, libraries, however, results in no output.

Can you provide guidance on how to modify the libraries to work with the Teensy (t3_i2c)?

  [1]: http://www.meas-spec.com/product/t_product.aspx?id=8684
  [2]: https://www.sparkfun.com/products/12909

title: Teensy and MS5803 sensor

Answers: 0


body:
I have two arduinos (An UNO R3 and a Mega 2560), and I need to communicate them via two ESP8266 modules to exchange some values.

In one arduino I'll use a SW-420 vibrarion module, and I need to send a value wirelessly to the other board, which it'll have an LCD screen that will display a message when a value is recieved.

How can I do that with that specific WiFi modules? Thanks in advance

title: Connecting two arduinos using WiFi

Answers: 1

body:
Step 1: I would load NodeMCU on you ESP8266: https://github.com/nodemcu/nodemcu-firmware

Step 2: Connect to your home router or make an ap on one of your ESP and connect them... use the api: https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en over serial connection

Step 3: write a TCP server:

    srv=net.createServer(net.TCP)
    srv:listen(80,function(conn)
      conn:on("receive",function(conn,payload)
        print(payload) //This payload will be send to your arduino over soft serial
        conn:send("<h1> Hello, NodeMCU!!! </h1>")
      end)
      conn:on("sent",function(conn) conn:close() end)
    end)

Step 4: write a TCP client:

    suc = false;
    function sendData( host, pathData )
     suc = false;
     print("GoSending!");
     -- A simple http client
        conn=net.createConnection(net.TCP, 0)
        conn:on("receive", function(conn, payload)
         if(string.find(payload, "200 OK")~=nil) then
          suc = true;
          print("AllDone")
         else
          suc = false;
         end
        end)
        conn:on("connection", function(c)
         print("connected");
            conn:send("GET /".. pathData .." HTTP/1.1\r\nHost: ".. host .."\r\n"
                .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
            end)
        conn:on("disconnection", function()
         if(suc==false) then
          print("ErrorSending")
         end
        end)
        conn:on("reconnection", function() print("reconnection") end )
        conn:connect(80,host)
    end

Step 5: Connect your esp boards with software serial to the arduino

Step 6: write (from board 1) to softserial to esp1: sendData( hostIP, yourData)

Step: 7 Parse the Data on sofserial read on the second arduino

Step 8: DONE!

**EDIT:**

Ok more infos on step 6.
If you got your script running on your esp, you can call functions by sending the function name with parameters over your serial connection.
So, this is some example code for your ardoino if you got the script from above:

    SoftwareSerial wifi(3, 2); // RX, TX

    //at some time in your programm
    //Build up your string that will be send over serial
    String i1 = "sendData(\"ipFromTheServer\", \"send.php?d=";
    String i2 = i1+dataToSend;
    String i3 = i2 +"\");";
    wifi.println(i3);

This will call the sendData function on you esp. this will call the send.php on a Server... you can put a server up on an other esp and call it (dont have to be a php page)

More infos on step 7.
the script on top will always print all incoming data. So you just have to read serial data on wifi:

    if (wifi.available())
        Serial.write(wifi.read()); //this will print all inc data to your arduino console (serial) parse this data!

Info: I've build this on my own... dont know if this is best practice :)


body:
I'm using an Arduino Mega with Ubuntu 15.10.

Sadly I've got an error during compilation, that the Time.h library cannot be found. The verbose compile output shows:
<pre>
/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall
-fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560
-DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105
-D__PROG_TYPES_COMPAT__
-I/usr/share/arduino/hardware/arduino/cores/arduino
-I/usr/share/arduino/hardware/arduino/variants/mega
-I/usr/share/arduino/libraries/LiquidCrystal
-I/usr/share/arduino/libraries/SPI
/tmp/build6998056390288565759.tmp/Home_Guard.cpp -o /tmp/build6998056390288565759.tmp/Home_Guard.cpp.o
**Home_Guard.ino:2:20: fatal error: Time.h: No such file or directory**
compilation terminated.
</pre>
I've already tried to use "time.h" instead of "Time.h" but it doesn't help.

title: Arduino Mega, Ubuntu, Time.h: No such file or directory

Answers: 1

body: ok. It seems that the Ubuntu arduino package does not contain this library. The file Time.zip has to be downloaded from the authors website: http://www.pjrc.com/teensy/td_libs_Time.html and added in the Arduino GUI menue bar: Sketch -> Import Library -> Add Library


body:
In my university we need to buy arduino boards and kits to build a moving robotic arm, that moves up and down and clockwise in a specific degree (almost like humans's).

So, what's the most **suitable** arduino board to build this arm?
I suggested to use the basic UNO board, but we may need to use relays (for example) if the power source is 12volts. So there is should be a better one.

My regards.

title: What is the best arduino board for a robotic arm?

Answers: 2

body:
If you are hoping to drive the arm straight from the Arduino, that's not going to work.

What you should do is:

 - Define the maximum weight and size of the load your arm will carry.
 - Define expected precision and speed of the movements.
 - Count the Degrees of Freedom (DoF) your arm will need (1 DoF = 1 simple joint)
 - Figure out size and materials of each part of the arm
 - Calculate the torque required at each joint (yes, you need some basic physics calculation)
 - Identify the motors you want to drive (DC are inexpensive but not very well suited for this, without lots of additional control logic & HW - stepper motors are better, but they still do require some additional effort - servos are the easier way but they are a bit more expensive)
 - Define the requirements for both the micro controller and the power supply, based on the previous choice.

If you can refine your question, based on the few points I sketched, you will get ahead much faster and with less risk later on to have to backtrack and re-design something.

You might have already answered some of those steps, then I suggest you list here your choices.

Similarly, if you are referring to some link you found (instructables, etc.) please post it.

As reference, hobbyking has an extensive catalog of motors and power supplies. You can find the same items also on ebay, but hobbyking can be used at least as reference for various specs (power, torque, weight, etc.).

body:
Best answer is Arduino Uno because it is enough for your application.

But all Arduino are works on 5 volt or 3.3 volt.

For operating 12 volt devices use transistors or MOSFETs.


body:
Is there a method to play a Melody with Tone() without using the delay() function?

    tone(8, melody[thisNote], noteDuration);
    int pauseBetweenNotes = noteDuration;
    **delay(pauseBetweenNotes);**

title: Playing Melody with Tone() without using delay()

Answers: 3

body:
As others have noted, this can be done using the same method as used in the standard 'BlinkWithoutDelay' example sketch, and combining that with a state-machine type approach. In a simple state machine you'd assume you can be in one of two states: outputting a tone, and not outputting a tone.

Applying these ideas to your code snippet above:

    // BEFORE SETUP
    const int tonePin = 8;
    unsigned long previousMillis = 0;
    const long interval = pauseBetweenNotes;
    const long interval = noteDuration;
    boolean outputTone = false;                // Records current state

    // IN LOOP
    unsigned long currentMillis = millis();

    if (outputTone) {
    // We are currently outputting a tone
    // Check if it's been long enough and turn off if so
        if (currentMillis - previousMillis >= noteDuration) {
            previousMillis = currentMillis;
            noTone(tonePin);
            outputTone = false;
        }
    } else {
    // We are currently in a pause
    // Check if it's been long enough and turn on if so
        if (currentMillis - previousMillis >= pauseBetweenNotes) {
            previousMillis = currentMillis;
            tone(tonePin, melody[thisNote]);
            outputTone = true;
        }
    }

body:
Adding a bit to kabdulla's great example, to be able to use a MelodyArray

    // declaring variables
    const int tonePin = 10;
    unsigned long previousMillis = 0;
    const long pauseBetweenNotes = 250;   // interval between notes (ms)
    const long noteDuration = 400;        // (ms)
    boolean outputTone = false;                // Records current state
    const int MelodyLength = 2;
    const int Melody[MelodyLength] = {880, 698};
    int MelodyIndex = 0;
    unsigned long currentMillis;

    void setup() {
    }

    void loop() {
      currentMillis = millis();
      PlayMelody();
    }

    void PlayMelody() {
      if (outputTone) {
        // We are currently outputting a tone
        // Check if it's been long enough and turn off if so
        if (currentMillis - previousMillis >= noteDuration) {
          previousMillis = currentMillis;
          noTone(tonePin);
          outputTone = false;
        }
      } else {
        // We are currently in a pause
        // Check if it's been long enough and turn on if so
        if (currentMillis - previousMillis >= pauseBetweenNotes) {
          previousMillis = currentMillis;
          tone(tonePin, Melody[MelodyIndex]);
          outputTone = true;
          //Update to play the next tone, next time
          MelodyIndex = MelodyIndex + 1;
          if (MelodyIndex >= MelodyLength) {
            MelodyIndex = 0;
          }
        }
      }
    }

body:
this is a minimal modification of the basic Arduino toneMelody example to a non-blocking version

```
#include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

unsigned long previousMillis = 0;
unsigned long pauseBetweenNotes;
int thisNote;

void setup() {
}

void loop() {

  // iterate over the notes of the melody:
  unsigned long currentMillis = millis();
  if (thisNote < 8 && currentMillis - previousMillis >= pauseBetweenNotes) {
    previousMillis = currentMillis;

    // to calculate the note duration, take one second divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(8, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    pauseBetweenNotes = noteDuration * 1.30;

    thisNote++;
  }
}
```


body:
my vb.net app produce this result as 2d array :

01110000000111000

01110000000111000

01110000000000000

01110111000111000

01111111100111000

01110011100111000

01110011100111000

01110011100111000

01110011100111000

01110011100111000

00000000000000000

i want to send every single column to my arduino over serial port and use the column to turn on this leds :
* leds connected from pin 2 to pin 13
 [![arduino uno r3 ][1]][1]

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

anyone can help me ? :(

title: arduino serial comminucation

Answers: 0


body:
I have an Arduino webserver that displays many buttons over a webpage (73 at the moment) that toggle different switches. I shortened up the button-drawing code with this function:

    void displayButton(String toggleName, byte toggle, byte link1, EthernetClient & client, boolean last) {
      if (toggle == 0) client.print("<a href=\"/?");
      else client.print("");
      client.print(toggleName);
      client.print("");
      if (last) client.print("

");
    }

And this is a shortened version of my loop function:

    void loop() {
      EthernetClient client = server.available();
      if (client) {
        boolean done = false;
        while (client.connected() && !done)
        {
          while (client.available () > 0 && !done)
            done = processIncomingByte (client.read ());
        }  // end of while client connected
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.print("");
          displayButton("F8", f8Toggle, 57, client, 0);
          displayButton("F9", f9Toggle, 58, client, 0);
          displayButton("F10", f10Toggle, 59, client, 1);
          client.println("");
          delay(5); client.stop();
      } // end of "if client"
    } // end of loop

I'm wondering if there's any way to have the displayButton function use the EthernetClient instance without it having to be passed every time. I'm interested in this in order to clean up my code a little (since I would be able to remove 73 instances of the word "client"), and also as a learning experience.

title: Any way to pass EthernetClient to function outside of loop automatically?

Answers: 1

body: As Majenko has noted in the comments, the solution was to declare "EthernetClient client;" as a global variable, outside of the loop. Normally I would've tried something like this on my own, but was hesitant to do so because I had never seen anything like that in other code.


body:
Here is what I want to do or get it done (since I am not a embedded guy)...

 - create a prototype with Arduino to detect open window/door of my room using camera(image processing/object state detection)?
 - that prototype will take pictures of room door/window at certain interval and than using some algorithm to decide whether they are open or not and will sound an alarm if it is open.
 - prototype should work in dark as well
 - No false alarms
 - Form factor should be small (the final product should not be bigger than smoke detectors that we have it in our room)

My questions are..

 - Is it possible? :)
 - What all things I need to create a prototype?
 - Which camera should I use? Camera should be really small.
 - Are algorithms available to detect it?

title: Create a device to detect object state

Answers: 4

body:
Your answers :-)

 - yes, it's possible and should not be too complex
 - for a simple prototype, you do not need an embedded device, just a PC with a webcam
 - a webcam with few megapixels should be enough
 - try [OpenCV][1]

After your prototype is ready, you can use a small PC-like platform.
Examples: [Minnowboard][2], [Edison][3], [BeagleBone][4], [RaspBerry PI 2][5], [Arduino Yun][6], [Galileo 2][7]

A word of warning: depending on the expectations you have, you will have to pick more powerful models. Computer Vision is computationally intensive.
The examples I gave are roughly sorted by performance and, unsurprisingly, cost. OpenCV is available for many architectures, but afaik, it is particularly optimized for x86, since it's mostly sponsored by Intel.

Disclosure: I work for Intel, so I am more informed on Intel products, but by no means I'm trying to do advertisement, this answer is simply given to the best of my knowledge.

  [1]: http://docs.opencv.org/2.4/doc/tutorials/tutorials.html
  [2]: https://www.google.com/aclk?sa=l&ai=CsNmY_dM0VuiRFuKBzAOcxJDgDdGgyKIH8efl4LMC_cvtnrYCCAAQAWD3AaAB3equ_gPIAQGqBCdP0M5kw2YT3Obbzfo8B3d9qayKUzbCXrPpIufHz_uQFQPIWMXZfWaAB4uV0QGIBwGQBwKoB6a-G9gHAQ&sig=AOD64_3sTdZzbZkDAbC22hPrSwlSylgCpQ&clui=0&q=&ved=0CBsQ0QxqFQoTCL3Vz7357MgCFYGocgodxggEyw&adurl=http://netgate.com/turbot/
  [3]: http://www.intel.com/content/www/us/en/do-it-yourself/edison.html
  [4]: http://beagleboard.org/bone
  [5]: https://www.raspberrypi.org/products/raspberry-pi-2-model-b/
  [6]: https://www.arduino.cc/en/Main/ArduinoBoardYun
  [7]: http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-overview.html

body:
I wonder if you haven't overspecified the device? Is there a reason that it must be photo-interpretive? Because if you only need to know whether a door or window is open, a couple of switches and some simple wired logic, or the very most basic of micro-controllers, if you choose to go that way, will be more than adequate, less expensive, more reliable in the long term (Ok, I know you won't be in a dorm room for long), less prone to false or missed alarms, totally unaffected by the ambient lighting or the lack of it, unobtrusive (no cameras - plural - in the middle of the room).

But I get that it might not be as much fun to make, if that is one of your top criteria!

body:
I doubt you could make such a thing, especially with no embedded experience.

* You want to use a camera, but it should "work in the dark" - problem there. You would need to somehow "light" the room with (say) infra-red, but then technically it wouldn't be dark any more.

* It should be really small, but has to have the power of image capture and image processing. Maybe a dedicated board designed by people with a lot of experience, and using surface-mounted devices, could do that. I strongly doubt you could do it on an Arduino of any type.

* No false alarms? Without knowing your windows that might be hard to say, but considering windows are usually made of glass, detecting the difference between a closed window, and a wide-open one, might be marginal as you would still see the scene outside through the glass.

* As the sun rises and falls the image captured would change considerably, quite probably leading to false alarms. Imagine a sudden thunderstorm, where the next image is much darker than the previous one. The image comparison would register a "difference".

* Imagine a picture taken during a storm with lightning flashes corrupting the image.

* What is someone enters the room and walks in front of the window? That would register as a difference, but doesn't mean the window is open.

---

What seems much more practical to me would be variants of existing technologies, eg.

* Magnets and reed switches

* Shine a laser on the window and detect if it moves (the angle would probably change).

* Use distance-detection, such as pinging devices. An open window would change the distance (a bit).

* Use passive infra-red to detect the movement when the window opens.

* Vibration detection mounted on the window glass, or possibly the window frame.

* Temperature measurement to detect a difference in temperature as the window opens.

---

The camera sounds to me the least practical.

body:
> Here is what I want to do or get it done (since I am not a embedded
> guy)...

Welcome to the world of embedded... things. I highly appreciate your interest in the embedded world, after all it's more interesting as just PC things :)

> - create a prototype with Arduino to detect open window/door of my room

You've come to the right place, Arduino (embedded stuff) is very good at input/output. And that seems like a fun project!

> using camera(image processing/object state detection)?

Wait, where did this come from? Humans are good at observing, their main sense would be vision (I guess?) to do so. Microcontrollers are somewhat better at logic signals. They are good at taking sensor signals and turning them into whatever you like.
*There is a possibility you'd just like to do something with image processing/detection. If so, please mention that :)*

> - that prototype will take pictures of room door/window at certain interval and than using some algorithm to decide whether they are open
> or not and will sound an alarm if it is open.

Arduino can read out a simple ["Door sensor"][1] and check if the door is, or is not closed. This will both shrink your project and make it easier.
Arduino can sound an alarm. You can even add a keypad (for a disable code).

>  - prototype should work in dark as well

The drawback of human vision. Is that it does not work so well in the dark. Sensor's based on the touch of the door or a magnetic contact on the door are not affected by darkness.

>  - No false alarms

If your sensor won't fail, the alarm won't go off by accident :)

>  - Form factor should be small (the final product should not be bigger than smoke detectors that we have it in our room)

Use an arduino nano or micro.

> My questions are..
> - Is it possible? :)

Yup! You can check for [existing projects][2] on the web. You can put in your own implementation though.

> - What all things I need to create a prototype?

Whatever you need is what you will need.
An sensor as input, an arduino to process it and an "alarm".
There are a trillion configurations for this, you can choose to just go by one or check what fits your needs best.

>  - Which camera should I use? Camera should be really small.

Unless you really want to get going with camera detection/object tracking, you shouldn't use one. (Especially with arduino it can be quite frustrating.) You should use a PC or raspberry Pi or Android phone.

Or use arduino with said sensor.

 - Are algorithms available to detect it?

Yes. For this, it's again application specific. You should check out some resources, check what others use and determine what would work best for you. Try it out and if it won't work you can ask it :) (probably on normal stack-overflow since it's not really arduino related, maybe robotics stackexchange).

  [1]: https://www.adafruit.com/products/375
  [2]: http://www.instructables.com/id/Getting-the-required-components/


body:
I have this application where I want to send commands from the PC to an Arduino, remotely, and receive an answer back.

The hardware configuration I'm using to achieve that is the following:

    PC <--> Arduino with an Xbee <--> Another Arduino with another Xbee

It's just half-duplex communication. Everything seems easy, but there is a problem.

Each Arduino has an Xbee Shield with an Xbee module connected to it.
Reading the documentation of the ArduinoXbeeShield, an excerpt caught my eye:

*"With the jumpers in the Xbee position (i.e. on the two pins towards theinterior of the board), the DOUT pin of the Xbee module is connected to the RX pin of the microcontroller; and DIN is connected to TX. Note that the RX and TX pins of the microcontroller are still connected to the TX and RX pins (respectively) of the FTDI chip - data sent from the microcontroller will be transmitted to the computer via USB as well as being sent wirelessly by the Xbee module. **The microcontroller, however, will only be able to receive data from the Xbee module, not over USB from the computer**.*

*With the jumpers in the USB position (i.e. on the two pins nearest the edge of the board), the DOUT pin the Xbee module is connected to the RX pin of the FTDI chip, and DIN on the Xbee module is connected to the TX pin of the FTDI chip. This means that the Xbee module can communicate directly with the computer - **however, this only works if the microcontroller has been removed from the Arduino board. If the microcontroller is left in the Arduino board, it will be able to talk to the computer normally via USB, but neither the computer nor the microcontroller will be able to talk to the Xbee module**."*

That means I will not be able to build what I want with this configuration?
I already tried, but didn't work.

title: PC <-> Xbee <-> Another Xbee Communication

Answers: 1

body:
Basically with your shield you have two options:

1. Communicate between the MCU and the XBee at the cost of not being able to communicate between the PC and the MCU.
2. Communicate between the PC and the XBee at the cost of having to remove the MCU from the board completely.

Neither of which are particularly ideal.  The first option is completely out since that rules out all PC communication.  The second option turns the Arduino into just a USB->TTL Serial adapter - and a rather expensive one at that (you can get them on eBay for like $2).

What you want is to re-wire the system using jumper wires (messy, I know) so that the TX and RX pins of the XBee connect to other pins on your Uno then use SoftwareSerial to communicate with the XBee.  That will leave the Arduino's TX and RX pins free for communicating with the PC.

Alternatively invest in a different Arduino that has more hardware UART interfaces, like a Mega2560.


body:
I'm working with esp8266.i am able to send text from webserver to arduino which is displayed on my 16*2 lcd display.but the problem is that when i send text including space i.e:john smith, the text show on my serial monitor and also in lcd  like that (john+smith)..the spaces i gave is converted into "+" sign..Can anyone suggest me how to overcome from that problem??
my code is given below:

      #include <SoftwareSerial.h>
      #include <LiquidCrystal.h>

     SoftwareSerial espSerial(2,3);

      LiquidCrystal lcd(12,11, 7, 6, 5, 4);

    const bool printReply = true;
    const char line[] = "-----\n\r";
    int loopCount=0;

    char html[50];
    char command[20];
    char reply[500];

    char ipAddress [20];
    char name[30];
    int lenHtml = 0;
    char temp[5];

    void setup()
    {
          Serial.begin(9600);
            lcd.begin(16,2);

          Serial.println("Start\r\n\r\n");

          lcd.print("WELCOME ");

          espSerial.begin(9600);

          Serial.println("reset the module");
          espSerial.print("AT+RST\r\n");

          getReply( 2000 );

          Serial.println("Change to station mode");
          lcd.clear();
          lcd.print("station mode");
          espSerial.print("AT+CWMODE=1\r\n");
          getReply( 1500 );

          Serial.println("Connect to a network ");
          lcd.clear();
         lcd.print("connecting...");

          espSerial.print("AT+CWJAP=\"ESP_E61A83\"\r\n");
          getReply( 6000 );

          Serial.println("Get the ip address assigned by the router");
          espSerial.print("AT+CIFSR\r\n");
          getReply( 1000 );

          int len = strlen( reply );
          bool done=false;
          bool error = false;
          int pos = 0;
          while (!done)
          {
               if ( reply[pos] == 10) { done = true;}
               pos++;
               if (pos > len) { done = true;  error = true;}
          }

          if (!error)
          {
                int buffpos = 0;
                done = false;
                while (!done)
                {
                   if ( reply[pos] == 13 ) { done = true; }
                   else { ipAddress[buffpos] = reply[pos];    buffpos++; pos++;   }
                }
                ipAddress[buffpos] = 0;
          }
          else { strcpy(ipAddress,"ERROR"); }

          Serial.println("Set for multiple connections");
          espSerial.print("AT+CIPMUX=1\r\n");
          getReply( 1500 );

          Serial.println("Start the server");
            lcd.clear();
          lcd.print("Server starts");
          espSerial.print("AT+CIPSERVER=1,80\r\n");
          getReply( 1500 );

          Serial.println("");

       lcd.clear();
          Serial.println("Waiting for page request");
          Serial.print("Connect to "); Serial.println(ipAddress);
          Serial.println("");
    lcd.print("feed me more");
    delay(1500);
            lcd.clear();

    }

    void loop()
    {
          if(espSerial.available())

              bool foundIPD = false;
              for (int i=0; i<strlen(reply); i++)
              {
                   if (  (reply[i]=='I') && (reply[i+1]=='P') && (reply[i+2]=='D')   ) { foundIPD = true;    }
              }

              if ( foundIPD  )
              {

                  loopCount++;

                  int nameStartPos = 0;
                  for (int i=0; i<strlen(reply); i++)
                  {
                       if (!haveName)
                       {
                             if (  (reply[i]=='n') && (reply[i+1]=='a') && (reply[i+2]=='m') && (reply[i+3]=='e')  && (reply[i+4]=='=') )
                             {
                                 haveName = true;
                                 nameStartPos = i+5;
                             }
                       }
                  }

                  if (haveName)
                  {
                        int tempPos = 0;
                        bool finishedCopying = false;
                        for (int i=nameStartPos; i<strlen(reply); i++)
                        {
                             if ( (reply[i]==' ') && !finishedCopying )  { finishedCopying = true;   }
                             if ( !finishedCopying )                     { name[tempPos] = reply[i];   tempPos++; }
                        }
                        name[tempPos] = 0;
                  }

                  if (haveName) { lcd.clear(); lcd.print("TEACHERS INFO..");Serial.print( "name = ");lcd.setCursor(0,1);Serial.println(name);lcd.print(name);Serial.println("");lcd.print(""); }

                  else          { Serial.println( "no name entered");   Serial.println("");lcd.print(""); }

                  strcpy(html,"");
                  strcpy(command,"AT+CIPSEND=0,25\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  strcpy(html,"
TEACHERS INFORMATION WEBSERVER
");
                  strcpy(command,"AT+CIPSEND=0,40\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  strcpy(html,"
CREATED by jack
");
                  strcpy(command,"AT+CIPSEND=0,31\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  strcpy(html,"
 Teachers Request number ");
                  itoa( loopCount, temp, 10);
                  strcat(html,temp);
                  strcat(html,"
");

                  // need the length of html
                  int lenHtml = strlen( html );

                  strcpy(command,"AT+CIPSEND=0,");
                  itoa( lenHtml, temp, 10);
                  strcat(command, temp);
                  strcat(command, "\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                 if (haveName)
                 {

                      strcpy(html,"
TEACHER name is "); strcat(html, name ); strcat(html,"
");

                      lenHtml = strlen( html );
                      strcpy(command,"AT+CIPSEND=0,"); itoa( lenHtml, temp, 10); strcat(command, temp); strcat(command, "\r\n");
                      espSerial.print(command);
                      getReply( 2000 );
                      espSerial.print(html);
                      getReply( 2000 );
                 }

                  strcpy(html,"<form action=\""); strcat(html, ipAddress); strcat(html, "\" method=\"GET\">"); strcat(command, "\r\n");

                  lenHtml = strlen( html );
                  itoa( lenHtml, temp, 10);
                  strcpy(command,"AT+CIPSEND=0,");
                  itoa( lenHtml, temp, 10);
                  strcat(command, temp);
                  strcat(command, "\r\n");

                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  strcpy(html,"Name:
<input type=\"text\" name=\"name\">");
                  strcpy(command,"AT+CIPSEND=0,40\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  strcpy(html,"<input type=\"submit\" value=\"Submit\"></form>");
                  strcpy(command,"AT+CIPSEND=0,43\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  strcpy(html,"");
                  strcpy(command,"AT+CIPSEND=0,14\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );

                  espSerial.print( "AT+CIPCLOSE=0\r\n" );
                  getReply( 1500 );

                  Serial.println("last getReply 1 ");
                  getReply( 2500 );

                  Serial.println("last getReply 2 ");
                  getReply( 2500 );

              }
          }

          delay (100);

    }

    void getReply(int wait)
    {
        int tempPos = 0;
        long int time = millis();
        while( (time + wait) > millis())
        {
            while(espSerial.available())
            {
                char c = espSerial.read();
                if (tempPos < 500) { reply[tempPos] = c; tempPos++;   }
            }
            reply[tempPos] = 0;
        }

        if (printReply) { Serial.println( reply );  Serial.println(line);     }
    }

title: How can i change "+" sign into spaces?

Answers: 3

body:
If you have your text in a character array, which it seems you have, then it is simple enough to iterate through that array changing whatever characters you want.

For instance, if the text is in `reply` then:

    for (char *p = reply; *p; p++) {
        if (*p == '+') *p = ' ';
    }

That is, starting at the beginning of reply, by creating a pointer `p` and pointing it at the start of reply, check to see if there is anything except the `NULL` character, run the code inside the brackets, and move to the next character (p++).

The code inside the brackets looks to see if the current character is a + and if so then set the current character to be a space.

Another way is to use an integer counter:

    for (int i = 0; reply[i] != 0; i++) {
        if (reply[i] == '+') reply[i] = ' ';
    }

body:
Two things:
+If you are using strings, try using the String built in object, it is very handy and useful
+when using String, you can use replace function

body:
It is hard to understand what your code does. You said that arduino recives text from the server, but I see in the code is that the arduino **is** the http server, serving an html page with a form in it.

That is also the reason you recieve spaces replaced with "+", the http request is [**url encoded**][1].

The problem with a search and replace solution of a "+" sign is that url encoding is more than a "+" sign. A space can also be encoded into   and there are several other characters that are being encoded as well.

What you will have to do is to implement a **decoding** function. It is not that hard but if you are lazy, there are plenty of C implementations available on the net. Here is a quick google search hit: https://gist.github.com/jmsaavedra/7964251

  [1]: https://en.wikipedia.org/wiki/POST_(HTTP)#Use_for_submitting_web_forms


body:
Previously I had my Due connected via Programming Port for weeks, and it never changed serial ports after pressing the reset button. Recently I switched to having it connected via the Native Port instead, and was surprised to see that it changes port numbers every time I press the reset button.

For example if it was on ttyATM1 beforehand, after pressing reset it'll be on ttyATM2 instead. It changes numbers like this after every reset. Is this normal behavior?

I have a python script sending serial data to the Due, and I have to change the port number in the python code every time the Due changes ports.

title: Why does Arduino Due Native Port change serial ports after every reset? (Linux)

Answers: 1

body:
It happens because of Linux, not because of the Arduino.
Since you unplug/reset the DUE while the port is still open, when it's back online, the old file name is still in use, so a new one is created.
Just close the port before resetting the DUE and you will see that after the reset it will have the same one.

You can easily reproduce the same issue with a serial to usb adapter (/dev/ttyUSBS0,1,2,etc) and screen or minicom.

To make your program more robust, you should listen for kernel events and open the port accordingly.


body:
I am working on a project with Arduino Uno Clone. After having a look on my arrangement, please tell me whether I will have to face any difficulty or consider any thing.

I have a relay on pin 2 (drive An Induction cooktop from AC Mains),

6 mini 9g servo from pin 3-8 (want to drive non-pwm pins with any Software library),

a 8 ohm speaker on pin 9,

a microSd card module from pin 10-13 (play .wav files through speaker),

5 pushbuttons from pin A0-A4,

a toy dc motor on A5 (Drive through a transistor). So my questions are:

 1. Will I have to face any pin arrangement problem in my project? If yes, please give me a solution
 2. I have six servos and a dc motor in which only one will be moving at a time, is there really a need of external power source for motors
 3. I have to drive this arrangement through AC Mains, but i dont want to buy An adapter. I have a mobile charger which have written "INPUT 100-250V AC, OUTPUT 4-12V, 800mA" , can I drive my arduino with this?
 4. Can I boost the volume of my speaker by using a transistor or capacitor (I have no idea about amplifier IC) ?
 5. I have to include these librairies, SD library, tmrpcm, SPI, servo, and any one extra to drive servos on non-pwm pins. What would be the total size because my arduino has only 30kb approx?  Thanks To Give Me Time. Please help me.

title: Will there be any pin interference in this Project?

Answers: 1

body:
 1. possibly you will face problems with current drain and timing. There is no ready made solution. You have to get a bit farther by yourself and come back with detailed descriptions of your problems.
 2. check on other threads (google) the issues with driving directly a coil. There are plenty of explanations why you need to be careful about it.
 3. you should at least try to do the math yourself, then ask for verification. Try to calculate the power requirements of each component (average, maximum, peak) and add them up for every scenario. The you can report your finding and ask for confirmation/advice.
 4. Sure you can, there are plenty of solutions available, but you have to define your requirements and constraints. Then it's easy to pick one solution (or at least google for it).
 5. Just try to include them in the project and compile them. It's fast and you will get the answer immediately. There are ways to optimize things, but first you should assess if it's needed.

All in all, to get more help, you should show more in detail what you have already done, what are your concerns and why.


body:
Let's say someone has four CAT5 cables that are running along the ceiling for the length of a room (30 feet), of which most of the twisted pairs are connected to Arduino input/output pins on one end. Would it be okay to keep these wires bundled together when running along the ceiling? Or is it safer to keep them separated by a few inches? Is interference usually a problem only in very specific situations, or should it be considered for all long wire runs?

How about if there is a telephone cable (hooked up to a landline telephone) running along the same length? Is there any chance of interference if this is too close to the Arduino cables?

How about if there are 120v mains lines running the same length? Should these be kept at a distance from the Arduino cables?

On the other end of the cables that are hooked up to the Arduino, some of the following are connected: temperature sensors, light sensors, servo motors, LCDs, relays, and push-buttons.

title: Should long wires be kept separated from each other, to reduce interference?

Answers: 3

body:
It depends on the frequency/frequencies you care about transmitting on your cables. One simple approach is to put on both ends a filter that lets pass only those frequencies you care about.
You can also consider using some error detection/correction encoding or check if there is some existing library that suits your needs. This last approach will work if you do not get too many interferences and your application can tolerate that data is re-transmitted every now and then, making the communication timing not 100% deterministic.

body: A benefit of using CAT-5 is that the pairs are twisted.  You would want to look at how you are using the pairs so that you're not introducing cross talk inadvertently, but the twisted pairs tend to resist RFI which is why its used.  Telephone wire, however, can be a completely different story.  You may find some that is twisted pair, but most if it is simply flat cable.  Worse, much of it is very cheap flat cable with what amounts to a piece of thread with a very thin foil wrapped around it.  This is very high loss and very vulnerable to RFI.

body:
CAT5 should work well with what you are trying to do, however stay away from power lines unless they are in a grounded conduit.  The phone lines would most likely generate interference when the phone is ringing as there is a lot of voltage transients on the line at that time.

To get the full benefit of the twisted pairs send and receive your signals with differential transceivers, one transceiver per pair.

Personally I will not connect a microprocessor pin to the outside world without some type of buffering isolation etc.  Those pins were not designed to drive long lines, although it may work eventually it will fail, that may be momentary to many years in the making but it will fail.

Lines connected directly to the microprocessor pins will all act as bidirectional antennas. They are not only are sustainable to interference they also generate it.  Remember the wires are small inductors which can generate some huge voltages when the transition time is short.

I typically use Schmidt devices such as a 74C14, 74HC etc. as my input receivers for switches etc.  I normally use an active low input signal, this help to keep noise out of the power supply. The input to the gate is pulled up to the 12VDC with a 10K resistor, this keeps a minimum of about 1 mA through the contact. The other end of the resistor is connected to a 100K resistor that in turn connects to the microprocessor input pin. You can add a cap to de-bounce at the gate if you want. The software is easier as it is looking for an active high which is a logic "1".  This circuit has been replicated hundreds of thousands of times and is very stable and reliable.

What you are doing will work for dorm room, testing etc...


body:
I have modified the code for Flappy Duino to give me a score at the end of the game. Here is the code:

    #include <SPI.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_PCD8544.h>

    Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

    #include "Sprite.h"
    #include "Chym.h"
    #include "Bar.h"

    Chym player;
    Bar bar; Bar bar2;
    int gameScore = 0;
    int highScore = 0;
    int KNOCK_PIN = 2;
    int LED_PIN = 8;

    boolean clicked = false;

    void loop(){}

    void resetGame() {
      player.respawn();
      bar.setPos(0, 20);
      bar2.setPos(50, 30);
      gameScore = 0;
    }

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

      display.begin();
      display.setContrast(50);
      display.clearDisplay();
      display.display();

      digitalWrite(LED_PIN, HIGH);

      pinMode(KNOCK_PIN, INPUT_PULLUP);
      pinMode(LED_PIN, OUTPUT);

      resetGame();

      while(1) {
        getInput();
        player.update();
        bar.update(); bar2.update();
        drawLCD();
      }
    }

    void getInput() {
      int knock = digitalRead(KNOCK_PIN);
      if (knock == 0) { // push down
        clicked = true;
        gameScore = gameScore + 1;
        Serial.println(gameScore);
      }
      else {
        clicked = false;
      }
    }

    void drawLCD() {
      display.clearDisplay();

      if (!player.isDead()) {
        int ht1 = bar.hitTest(player.getX(), player.getY());
        int ht2 = bar2.hitTest(player.getX(), player.getY());
        int die = ht1 + ht2;
        if (die == 1) {
            // game over
            player.die();
        }

        if (clicked) {
          player.flyUp();
        }
        else {
          player.cancelJump();
        }
        player.render();

        bar.render(); bar2.render();
      }
      else {
        if (gameScore >> highScore) {
          highScore = gameScore;
        }
        display.setCursor(0, 0);
        display.setTextSize(1);
        display.print("ur Score- ");
        display.println(gameScore);
        display.print("HI Score- ");
        display.println(highScore);
        if (clicked) {
          resetGame();
        }
      }

      display.display();
    }

The first time the game runs thru the gameScore is greater than highScore so gameScore and highScore print as the same. However every other time the function is called up the highScore doesn't change even when the following statement is true:

    if (gameScore >> highScore) {
              highScore = gameScore;
            }
What am I doing wrong?

title: Broken Score on Game Sketch

Answers: 1

body:
    if (gameScore >> highScore)

You have the wrong operator there.  `>>` is *right shift*, so you are right shifting the `gameScore` by `highScore` bits, which if it's more than 16 will end up as 0.

Instead you just want `>` for *greater than*:

    if (gameScore > highScore)


body:
I was using a 20x4 LCD connected to Arduino Uno via [a common I2C adapter board.][1] Everything was working perfectly, including the LCD. I had it running like this for a couple of days without any problems.

My next step was to connect the LCD to a Nano instead in order to make the package smaller. The exact same code from the Uno was uploaded to the Nano, and I connected the wires in the exact same way. The major difference here was that I soldered the wires onto the Nano, because I didn't want to use headers. I did a continuity test for shorts and the connections seemed to be fine. There are only 4 wires between the Arduino and LCD adapter board: 5v, ground, SDA and SCL.

The Nano powers up fine, and the LCD powers up fine, but immediately the LCD shows the following:
[![Corrupt LCD][2]][2]

That had never happened when I had the LCD connected to the UNO.

After that, the LCD stops working completely, even when I move it back to the UNO. It just constantly displays those 2 lines. (Adjusting the contrast makes the boxes appear or disappear).

After the first LCD seemed permanently broken like that, I tested it on a 2nd brand-new LCD. First I connected it to the same Uno with the same code, and everything was working perfectly. I re-uploaded that same code again to the Nano, just to make sure everything was in sync. Then upon connecting the 2nd LCD to the Nano, immediately it displayed those 2 lines. I disconnected it right away (within 5 seconds), and tried to put it back on the Uno, but still the display is corrupted. I've tried other sketches, but both of these displays seem to be broken and never display anything except for those 2 lines.

Even if I just connect 5v and ground to the LCD, no matter from what source, it just constantly displays those 2 lines.

Any ideas as to what could "break" an LCD so quickly like that, and if it's possible fix it?

**Edit:**
As per Gerben's suggestion, I removed the I2C backpack and hooked the LCD up directly. This was the 2nd one I had broken, the one where I'm more certain of its entire (short) history. I ended up with the exact same result. Adjusting the pot only makes the boxes appear or disappear. I tried skipping the Arduino completely and giving it 5v power from an adapter, and it still has the same result.
[![Corrupt LCD without backpack][3]][3]

  [1]: http://www.ebay.com/itm/IiC-I2C-TWI-SP-I-Serial-Interface-Board-Adapter-Module-Port-For-Arduino-1602LCD-/181576314435
  [2]: https://i.stack.imgur.com/E6Qzl.jpg
  [3]: https://i.stack.imgur.com/O5DY3.jpg

title: What could make an LCD stop working permanently after being connected for 5 seconds to Arduino?

Answers: 1

body:
It's unlikely that you have killed the unit as this is pretty hard to do from the data interface and your picture is typical for an LCD that has not gone through the initialization sequence.  A dead LCD driver will usually display nothing and what your picture shows is that the LCD controller itself is operating.  If anything is dead, I would suspect the I2C interface board as this would yield the same result you are seeing.  It may also be that the timing of the I2C interface is right on the edge which may explain why a long cable'd setup is working.

Note that if the initialization is not done, no other commands will work.  Note also that the initialization timing and sequence of events is ABSOLUTELY CRITICAL and missing any single step or time requirement will give the result you are showing.

Starting at page 10 of this [instructional PDF][1] is my favorite and the basis of my driver that I have been using since the 80's.

  [1]: http://www.tayloredge.com/reference/Electronics/Displays/lcdtech.pdf

----------------------------------------

The driver I use works on every display I have ever hooked to it, regardless of changes in the particular project's processor clock speed because I paid strict attention to the worst case timing requirements.  If the timing of the I2C interface violates one LCD it may not violate another, i.e. one display can tolerate bad timing while another can't.  There are also issues if the LCD driver uses the busy flag or not:  Blind data transmission without reading the LCD's busy state will work if the LCD is fast enough and the driver is slow enough, otherwise 'No bueno!' plus the interface is not going to operate at its maximum speed.  When using the busy flag (Bit 7 of the interface) there is solid handshaking which confirms (Instead of "Trusts") that the LCD is ready for the next cycle and allows operation right up to the limit of performance.

What I would suggest is that you put the interface on a logic analyzer and verify that the timing is not being violated.

Timing tolerances and variation between parts is like lug nuts on a car... If you car has 5 lug nuts per wheel, it will probably work with 3 or even 2 but NOT UNDER ALL CONDITIONS.  SOME LCDs will be happy with bad timing but ALL LCDs NEVER will be.


body: I am planning for a project but i am stuck with a task and hope you could help me. My work is to note down a number which is actually a set of readings displayed on a meter and store it on a arduino. My problem is that i need a detection technique so that i could record the number or extract the number from a image or video if u suggest to use a camera or recorder or purely can be a sensor. Thank you guys, waiting for you.

title: Arduino number detection

Answers: 1

body: "Number detection" sounds like you're trying to interpret a 7-segment digital display - is that correct? One way would be to place 7 photo-detectors (times the number of digits), one per segment, on or at the face of the display. Sample the photo-detectors and create a 7-bit code representing the lit segments, into a byte. You could start with a simple lookup table that translates from code to the digit it represents. You might need to get clever about interpreting codes that shouldn't appear, but do, due, perhaps to light leakage, ambient lighting, or noise. The "lit" segments may only be lit for a fraction of second at a time, and only one at a time, if the display is multiplexed, so your sampling algorithm will have to take that into account. Must the display remain visible? You might need optics or optical fibers to view the segments without obstructing them.


body:
my Problem is, that I get random values from my ultra sonic sensor if my arduino is connected to any external power supply (vin port 30) on my arduino nano.

If I power up from the laptop usb port, I get consistent values.

I have tested 3 different power supplies between 7-17V and up to 2000mA.
I have tested this on 2 different nano boards.
Also tested with an extra 2000uF capacitor between vin and gnd

pls help if you got an idea :)

title: Ultrasonic sensor returns random values on external power supply

Answers: 1

body:
So i tried to used a stable 5V input on the 5V input pin and got the same more or less random values (jumping all around... especially on targets more than 1m away)

So I changed form newPing lib (http://forum.arduino.cc/index.php?topic=37712.0) to Ultrasonic lib (http://forum.arduino.cc/index.php?topic=37712.0).

Now the values are correct on each power supply and even more accurate on high distance than with newPing on USB power supply.

Don't know whats broken with the newPing v1.7 lib -.- but this works!


body:
I'm very new with this devices so I'm a bit confused. I've got two Xbee modules series 1 and an Arduino UNO. I want to make like a chat between the two Xbee modules, one of them connected to the PC through a Xbee Explorer USB and the other one assembled in the Arduino Board through a shield.

I've configured the two Xbee modules with the same PAN ID and Channel, and the Xbee module 1 has MY = 0 and DL = 1 and the Xbee module 2 has MY = 1 and DL =0.

I've connected the Xbee module 1 to the PC through the Explorer and the Xbee module 2 connected to the PC through Ardunino+Shield.
I've uploaded the following code to Arduino:
<!-- language-all: lang-cpp -->

    #include <SoftwareSerial.h>

    SoftwareSerial mySerial(4, 5); // RX, TX

    void setup() {
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }

      Serial.println("Goodnight moon!");

      // set the data rate for the SoftwareSerial port
      mySerial.begin(9600);
      mySerial.println("Hello, world?");
    }

    void loop() { // run over and over
      if (mySerial.available()) {
        Serial.write(mySerial.read());
      }
      if (Serial.available()) {
        mySerial.write(Serial.read());
      }
    }

In my shield the jumper of the RX digital is the 4th pin and the TX jumper in the 5th pin.

When I open the serial monitor window I get the message "Goodnight moon!" but when I send a message from the XCTU console or from the serial window I don't get that message in the other interface (XCTU console or serial monitor window).

In the shield (this one http://www.seeedstudio.com/wiki/XBee_Shield_V2.0) I've 4 leds: first one (power) is on, the second one (signal strength) is off, the third one (association) blinks all the time, and the fourth one (on/sleep) is on.

Why I don't get the messages like a chat? What am I missing?

Thank you!!

title: Chat between Xbee and Arduino

Answers: 0


body:
I am interested in learning how the Arduino IDE handles parameters in order to correctly upload hex files with *avrdude*.

I found this in *boards.txt*:

    uno.name=Arduino/Genuino Uno

    uno.vid.0=0x2341
    uno.pid.0=0x0043
    uno.vid.1=0x2341
    uno.pid.1=0x0001
    uno.vid.2=0x2A03
    uno.pid.2=0x0043
    uno.vid.3=0x2341
    uno.pid.3=0x0243

    uno.upload.tool=avrdude
    uno.upload.protocol=arduino
    uno.upload.maximum_size=32256
    uno.upload.maximum_data_size=2048
    uno.upload.speed=115200

    uno.bootloader.tool=avrdude
    uno.bootloader.low_fuses=0xFF
    uno.bootloader.high_fuses=0xDE
    uno.bootloader.extended_fuses=0x05
    uno.bootloader.unlock_bits=0x3F
    uno.bootloader.lock_bits=0x0F
    uno.bootloader.file=optiboot/optiboot_atmega328.hex

    uno.build.mcu=atmega328p
    uno.build.f_cpu=16000000L
    uno.build.board=AVR_UNO
    uno.build.core=arduino
    uno.build.variant=standard

There is this in *platform.txt*:

    # AVR Uploader/Programmers tools
    # ------------------------------

    tools.avrdude.path={runtime.tools.avrdude.path}
    tools.avrdude.cmd.path={path}/bin/avrdude
    tools.avrdude.config.path={path}/etc/avrdude.conf

    tools.avrdude.upload.params.verbose=-v
    tools.avrdude.upload.params.quiet=-q -q
    tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

    tools.avrdude.program.params.verbose=-v
    tools.avrdude.program.params.quiet=-q -q
    tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

    tools.avrdude.erase.params.verbose=-v
    tools.avrdude.erase.params.quiet=-q -q
    tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m

    tools.avrdude.bootloader.params.verbose=-v
    tools.avrdude.bootloader.params.quiet=-q -q
    tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m

This line is particularly interesting:

    tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

It seems like these variables are corresponding:

    {cmd.path} --> tools.avrdude.cmd.path
    {config.path} --> tools.avrdude.config.path
    {upload.verbose} --> tools.avrdude.upload.params.verbose
    {build.mcu} --> uno.build.mcu
    {upload.protocol} --> uno.upload.protocol
    {serial.port} --> ?
    {upload.speed} --> uno.upload.speed
    {build.path} --> ?
    {build.project_name} --> ?

It seems these are likely used in the Java code for the IDE. There are obviously a few I am unsure of. I would guess these are considered user inputs in the IDE. Though I am by no means a Java or JavaScript programmer.

Where are these variables explicitly defined in the Arduino library? (e.g. `{runtime.tools.avrdude.path}`, `{path}`, `{cmd.path}` ....) Or how do they get defined by IDE?

title: Where do avrdude parameters get defined in the Arduino IDE?

Answers: 2

body:
The Arduino library is about what runs on the target, while the "IDE" (not sure if it can still be called IDE, as now they try to do also command line) is about everything else.

But my impression is that if you are ready to ask these sort of question, you could consider dropping the IDE and moving to a more standard Makefile approach. Or Maybe Eclipse, where you still have the IDE, but you can define everything in a more standard way.

The Arduino approach is good to get people with little experienced started, but after a while one started to feel its limitations.

body:
There are 3(or 4) places that you need to look at to know how to upload.
There is the boards.txt file and the platform.txt file.
You can consider a platform.txt file line

    tools.avrdude.path={runtime.tools.avrdude.path}

as (in linux in windows replace ${xx} by %xx%)

    set tools.avrdude.path ${runtime.tools.avrdude.path}
and the board.txt for the selected board like

    uno.bootloader.tool=avrdude
as

    set bootloader.tool avrdude

The arduino ide uses the following string to know the upload command environment variable

    tools.${bootloader.tool}.upload.pattern

 This way it knows the command to upload is

    "{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

{cmd.path} is hardcoded as tools.${bootloader.tool}.cmd.path which equals {path}/bin/avrdude
where {path} is to be understood as tools.${bootloader.tool}.path wich equals {runtime.tools.avrdude.path}.
{runtime.tools.avrdude.path} is defined by the boardsmanager based n the json file and the location where the boardsmanager extracted the download.

So that makes 3 files: boards.txt, platform.txt and json file and some hard coding.

A 4th file comes into play when you use the "other upload commands". These are located in the programmers.txt file.

IMHO Arduino IDE core team did not opt for the simplest solution to define these things. They also change the way they work from time to time.
If you use a makefile know that a lot of people have done this already so it may be a good idea to "reuse other peoples work" instead of "reinventing the wheel". It is not so easy or straightforward.

**Note** I know all these things because I implemented the Arduino eclipse IDE. As far as I know none of this is documented.


body:
I'm trying to understand the values that I'm getting from my MPU6050. I believe that there is a problem with my code. I'm not entirely sure how the code is supposed to look like. There doesn't seem to be very many examples on the MPU6050.

What is wrong?

*After taking a look at the system print I found that the numbers that are written out is the time and not the values of the MPU6050. Why am I getting the zeros and nan for?*

*I also had a library problem thats fixed now.*

I got the code from a site and I've modified it because it didn't run for me.

This is my code:

    // collect readings
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

    // apply gyro scale from datasheet
    gsx = gx/gyroScale;   gsy = gy/gyroScale;   gsz = gz/gyroScale;

    // calculate accelerometer angles
    ary = -(180/3.141592) * atan(ax / sqrt(square(ay) + square(az)));
    arx =  (180/3.141592) * atan(ay / sqrt(square(ax) + square(az)));
    arz = (180/3.141592) * atan(sqrt(square(ay) + square(ax)) / az);

    // set initial values equal to accel values
    if (i == 1) {
    grx = arx;
    gry = ary;
    grz = arz;
    }
    // integrate to find the gyro angle
    else{
    grx = grx + (timeStep * gsx);
    gry = gry + (timeStep * gsy);
    grz = grz + (timeStep * gsz);
    }

    // apply filter
    rx = (0.1 * arx) + (0.9 * grx);
    ry = (0.1 * ary) + (0.9 * gry);
    rz = (0.1 * arz) + (0.9 * grz);

     Serial.print(ax);   Serial.print("\t");
     Serial.print(ay);   Serial.print("\t");
     Serial.print(az);   Serial.print("\t\t");
     Serial.print(gx);   Serial.print("\t");
     Serial.print(gy);   Serial.print("\t");
     Serial.print(gz);   Serial.print("\t\t");
     Serial.print(arx);   Serial.print("\t");
     Serial.print(ary);   Serial.print("\t");
     Serial.print(arz);   Serial.print("\t\t");
     Serial.print(grx);   Serial.print("\t");
     Serial.print(gry);   Serial.print("\t");
     Serial.print(grz);   Serial.print("\t\t");
     Serial.print(rx);   Serial.print("\t");
     Serial.print(ry);   Serial.print("\t");
     Serial.println(rz);

This is the output im getting

    2 1.00 61.00 0.06000  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    3 61.00 139.00 0.07800  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    4 139.00 219.00 0.08000  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    5 219.00 300.00 0.08100  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    6 300.00 380.00 0.08000  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    7 380.00 462.00 0.08200  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    8 462.00 543.00 0.08100  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    9 543.00 624.00 0.08100  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    10 624.00 705.00 0.08100  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    11 705.00 788.00 0.08300  0 0 0  0 0 0  nan nan nan

...

    41 3223.00 3307.00 0.08400  0 0 0  0 0 0  nan nan nan nan nan nan  nan nan nan
    42 3307.00 3392.00 0.08500  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    43 3392.00 3476.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    44 3476.00 3560.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    45 3560.00 3645.00 0.08500  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    46 3645.00 3729.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    47 3729.00 3813.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    48 3813.00 3897.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    49 3897.00 3982.00 0.08500  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    50 3982.00 4066.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    51 4066.00 4150.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    52 4150.00 4234.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    53 4234.00 4319.00 0.08500  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    54 4319.00 4403.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    55 4403.00 4487.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    56 4487.00 4571.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    57 4571.00 4656.00 0.08500  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    58 4656.00 4740.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan
    59 4740.00 4824.00 0.08400  0 0 0  0 0 0  nan nan nan  nan nan nan  nan nan nan

title: Understanding values from an MPU6050

Answers: 2

body:
The output MPU 6050 does need filtering/processing before you can get any sense from it.  I have used the library "MPU6050_6Axis_MotionApps20.h" with success, it is located here: [MPU6050_6Axis_MotionApps20.h][1]

I have written an example here: [MPU 6050 for MicroView][2].

  [1]: https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050_6Axis_MotionApps20.h
  [2]: https://codebender.cc/sketch:118202

body:
I think the best choice for you is to read raw data from the sensor using Wire library.

1. First of all, you have to include the "Wire.h" library:

    ```c++
    #include "Wire.h"
    ```
2. Next step is to start the I2C communication by calling the following function in `setup()`

    ```c++
    Wire.begin();
    ```

3. Now that the master joined the I2C bus, all you have to do is to set the power mode of the module by setting the register `0x6B` to `0x0`. You can use the following function:

  ```c++
  int sendCommand(int8_t register_address, int8_t register_value) {
  Wire.beginTransmission(mpu_address);
  Wire.write(register_address);
  Wire.write(register_value);
  int statusCommand = Wire.endTransmission(true);
  Serial.print("I2C Address: "); Serial.print(mpu_address, HEX);
  Serial.print(" Register address: "); Serial.print(register_address, HEX);
  Serial.print(" Register value: "); Serial.print(register_value, HEX);
  Serial.print(" Status command: "); Serial.println(statusCommand);

  return statusCommand;
}
```

Please note that the default I2C address for the MPU6050 is `0x68`. You can use the [I2C Scanner][1] to find its address.

To actually set the register `0x6B` to `0x0` you have to call the `sendCommand` like below:
```c++
sendCommand(0x6B,0x0);
```

4. Request the raw data from the MPU6050. You can check the [MPU6050 Register Map][2] for additional information.  Accelerometer can be found from `0x3B` to `0x40`, temperature from `0x41` and `0x42`, and finally, the gyro from `0x43` to `0x48`. **IMPORTANT!!!** Every register's value occupy 1 byte (int8_t), so you have to get the values of two registers (2 bytes) and store them in an int16_t.

Here is the full code to get the angles from the sensor:

```c++
#include "Wire.h"

int8_t mpu_address = 0x68;
int sendCommand(int8_t register_address, int8_t register_value) {
  Wire.beginTransmission(mpu_address);
  Wire.write(register_address);
  Wire.write(register_value);
  int statusCommand = Wire.endTransmission(true);
  Serial.print("I2C Address: "); Serial.print(mpu_address, HEX);
  Serial.print(" Register address: "); Serial.print(register_address, HEX);
  Serial.print(" Register value: "); Serial.print(register_value, HEX);
  Serial.print(" Status command: "); Serial.println(statusCommand);

  return statusCommand;
}

void setup() {
  //join the I2C bus
  Wire.begin();
  //start serial communication
  Serial.begin(115200);
  delay(1000);

  /* sendCommand can return 5 possile values:
   * -> 0:success
   * -> 1:data too long to fit in transmit buffer
   * -> 2:received NACK on transmit of address
   * -> 3:received NACK on transmit of data
   * -> 4:other error
   */
  while(sendCommand(0x6B,0x0) != 0){
    delay(1000);
  }

  Serial.println("MPU6050 started");
}

void convertRawDataToAngle(int16_t AcX, int16_t AcY, int16_t AcZ) {
  int minVal = 265; int maxVal = 402;
  int xAng = map(AcX, minVal, maxVal, -90, 90);
  int yAng = map(AcY, minVal, maxVal, -90, 90);
  int zAng = map(AcZ, minVal, maxVal, -90, 90);

  int x = RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);
  int y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);
  int z = RAD_TO_DEG * (atan2(-yAng, -xAng)+PI);

  Serial.print("X angle: "); Serial.print(x);
  Serial.print(" Y angle: "); Serial.print(y);
  Serial.print(" Z angle: "); Serial.print(z);
}

void readData(int8_t register_address) {

  int bytesReceived = -1;
  int statusCommand = -1;
  do {
    Wire.beginTransmission(mpu_address);
    Wire.write(register_address);
    statusCommand = Wire.endTransmission(false);
    bytesReceived = Wire.requestFrom(mpu_address, 6, true);
    Serial.print("I2C Address: "); Serial.print(mpu_address, HEX);
    Serial.print(" Register address: "); Serial.print(register_address, HEX);
    Serial.print(" Status command: "); Serial.print(statusCommand);
    Serial.print(" Bytes received: "); Serial.println(bytesReceived);
  } while (statusCommand != 0 && bytesReceived != 6);
  //check if MPU6050 sent all the requested data
  //in total 6 bytes, 2 bytes for each axis
  if (Wire.available() == 6) {
    int16_t AcX = Wire.read() << 8 ;
    AcX |= Wire.read();
    int16_t AcY = Wire.read() << 8 ;
    AcY |= Wire.read();
    int16_t AcZ = Wire.read() << 8 ;
    AcZ |= Wire.read();
    convertRawDataToAngle(AcX, AcY, AcZ);
  }
}
void loop() {
  //put your main code here, to run repeatedly:
  readData(0x3B);
  delay(100);
}
```

  [1]: https://playground.arduino.cc/Main/I2cScanner/
  [2]: https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf


body: I have **two 6 volts DC motors** connected to **L298N motor Driver**. Do I need to use 12 Volts battery?

title: I have two 6 volts DC motors connected to L298N motor Driver. Do I need to use 12 Volts battery?

Answers: 1

body:
No, you need to use a (roughly) 6V battery. They are 6V motors, so they need a 6V battery.

However, you *do* need to sum the *currents* not the voltages. The battery must be able to provide *at least* the current required by *both* motors together.


body:
I want to program a temperature sensor with a LED using Arduino.
the goal is to make a sensor, when the temperature is over than Temperature max, the LED turns off and when the temperature is small than temperature max we turn on the LED.

my problem is when I programed the void setup() as followed, the LED doesn't work, and when I comment Serial.begin (9600) the LED work but I cannot diplay the value of the temperature.

    void setup() {
       Serial.begin(9600);
       pinMode(tempPin, INPUT);
       pinMode(led, OUTPUT);
    }
here you find my complet code:

        int tempPin = A0;   // the output pin of LM35
    float Max_temp = 24.0;
    int led = 1;

    float  temp, cel;
    void setup() {
       Serial.begin(9600);
       pinMode(tempPin, INPUT);
       pinMode(led, OUTPUT);
    }
    void loop() {
          cel = readTemp();
      if(cel< Max_temp) {        // if temp is higher than tempMax
          digitalWrite(led, HIGH);  // turn on led
          delay(300);
         }
         else {                    // else turn of led
           digitalWrite(led, LOW);  // turn on led
          delay(100);
      }
       Serial.print("TEMP: ");
       Serial.print(cel);      // display the temperature
       Serial.print("C ");
       Serial.println();
       delay(300);
    }

    float readTemp() {  // get the temperature and convert it to celsius
      temp = analogRead(tempPin);
      return temp * 0.48828125;
    }
thank you very much in advance

title: Arduino Temperature sensor with a LED

Answers: 2

body:
    int led = 1;

You do know that pins 0 and 1 are the serial port don't you?

Take your pick.... Either use pin 1 for the LED *OR* use pin 1 for the serial connection.  You can't do both!

As it says *[in the manual](https://www.arduino.cc/en/Main/ArduinoBoardUno)*:

> In addition, some pins have specialized functions:
>
> - Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

body:
Your logic is backwards. Your program says if the temp is LESS THAN max then turn on the LED.

But worse than that, you should not use pin 1.  Pick any other pin.


body:
I made this circuit:

[![enter image description here][1]][1]

The part with the DC motor is from this tutorial: https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v32/experiment-12-driving-a-motor ( I only use another resistor, with 220 OHM)

As you can see, I also have a TMP36 sensor attached. What I would like to do is this:
When the temperature is 25 degrees or more, the motor should turn on.

I have this code:

    //TMP36 Pin Variables
    int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                            //the resolution is 10 mV / degree centigrade with a
                            //500 mV offset to allow for negative temperatures

    /*
     * setup() - this function runs once when you turn your Arduino on
     * We initialize the serial connection with the computer
     */
    void setup()
    {
      Serial.begin(9600);  //Start the serial connection with the computer
                           //to view the result open the serial monitor
    }

    void loop()                     // run over and over again
    {
     //getting the voltage reading from the temperature sensor
     int reading = analogRead(sensorPin);

     // converting that reading to voltage, for 3.3v arduino use 3.3
     float voltage = reading * 5.0;
     voltage /= 1024.0;

     // print out the voltage
     Serial.print(voltage); Serial.println(" volts");

     // now print out the temperature
     float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                                   //to degrees ((voltage - 500mV) times 100)
     Serial.print(temperatureC); Serial.println(" degrees C");

     if(temperatureC >= 25){
      analogWrite(9, 250);
     }

     delay(1000);                                     //waiting a second
    }

But I get this result:

    0.74 volts
    24.22 degrees C
    0.74 volts
    24.22 degrees C
    0.74 volts
    24.22 degrees C
    0.74 volts
    24.22 degrees C
    0.74 volts
    24.22 degrees C
    0.74 volts
    24.22 degrees C
    0.75 volts
    25.20 degrees C <------
    0.87 volts
    36.91 degrees C
    0.66 volts
    16.41 degrees C
    0.78 volts
    27.64 degrees C
    0.77 volts
    26.66 degrees C
    0.84 volts
    34.47 degrees C

The point where the sensor measures > 25 degrees, the motor turns on but the circuit gets "poluted" and the temp sensor starts to send all kinds of strange values.

How do I solve this?
Thanks in advance!

<hr />

I got it to work in with the following: http:// i.stack.imgur.com/4GFPH.png

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

title: Arduino + TMP36 + DC Motor

Answers: 1

body: Motors tend to use more current than the arduino can supply, try hooking up the motor to a different power supply than the arduino 5V. What most likely is happening, is that when the motor turns on, it alters the value of the voltage, which the temperature sensor is using to tell the arduino what the temperature is. You need to have the temperature sensor hooked up to the arduino to have the reference at the right voltage, so the motor should be on a different power supply. That should fix things.


body: So at my school we are preapering for a competition. They asked me to do the technical side of it. And I accepted... I was thinking of using an arduino as a usb device for the buttons. I am going to use the serial port for this. But I can't think of a way to do it in the way I want. I want to recieve the button presses fair and well. But I also want to control the lights for the buttons, from my computer. I am using `Serial.printLn()` to send the serial data to the computer. But how can I send serial data to the arduino without delaying other things (What happens when someone presses a button while I am sending a command?)? Thanks in advance!

title: Efficiently using a serial inteface

Answers: 1

body:
The nastiest part in what you describe is likely to be the debouncing on the button, rather than the serial communication.

One easy way out is to use some form of bounceless implementation, like an optical coupler. Another is to use HW debouncing, like the MAX 6816 family.

Then you can use a loop where you alternate between serial communications and checks for the status of the buttons.

Or you can rely on interrupts for the buttons, but it's more complex and might be overkill.


body:
I configured two XBees using [XCTU](http://www.digi.com/products/xbee-rf-solutions/xctu-software/xctu), connected them to the computer and sent Bytes back and forth. ***Works.***

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

This is the current, non-working setup:

- 1 XBee, connected to the Computer using a [SparkFun XBee Explorer USB](https://www.sparkfun.com/products/11812).

- 1 XBee, connected to an Arduino Mega using [SparkFun XBee Explorer Regulated](https://www.sparkfun.com/products/11373)

 - GND to GND

 - 5V to 5V on the Arduino

 - DOUT to TX1 on the Arduino

 - DIN to RX1 on the Arduino

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

    void setup() {
      Serial1.begin(9600);
      pinMode(13, OUTPUT);
      //After 3 seconds the XBee should send out a couple of "A"s coming from the serial port
      delay(3000);
      int i = 0;
      while (i < 10) {
        Serial1.print("A");
        delay(100);
        i++;
      }
    }
    void loop() {
      //If anything is sent to the XBee it should appear in the Arduino's serial buffer
      //making the LED on pin 13 turn on
      if (Serial1.available() > 0) {
        digitalWrite(13, HIGH);
      }
    }

The DOUT LED on the Explorer Regulated flashes as supposed to but nothing is received on the computer where my Terminal application is listening.

Same when I send something from the Terminal, the LED on pin 13 of the Arduino does not indicate any bytes in the buffer, meaning that the XBee probably never received anything.

I already tried swapping TX & RX, resulting in the DIN LED blinking instead of DOUT. Transmission still not working.

title: Serial communication between Computer & Arduino via XBee

Answers: 0