body:
I'm trying to follow [this tutorial][0].
But I'm stuck in this error:

    Can't find OV2640 module! pid: 254

I tried to contact the author of the program, but I have not had an answer yet.
I'm using the ArduCAM Mini module OV2640.

Has anyone ever been in this situation?

[0]:https://github.com/dmainmon/ArduCAM-mini-ESP8266-12E-Camera-Server

title: Can't find OV2640 module! pid: 254

Answers: 3

body:
If you look at line 762 of 'ArduCam_ESP8266_FileCapture.ino' you should see it is looking to read two bytes from the camera to check that the model number is either a '2641' or '2642'.

You are seeing the error because you are not getting those values back.  So between 761 and 762 insert some debug and print what you are getting back:

    Serial.print ("vid = ");
    Serial.println (vid);
    Serial.print ("pid = ");
    Serial.println (pid);

I guess you will either get 00 00 or a different valid (maybe) model number.  If you think its a valid model number add another condition to the if statement and see if it works.

Oh and don't forget to post the results, because I'm going to give it a chance too when I get time :)

body:
Does it still happen if you power the cameras off and then on again. I was getting the same thing as there is a bug in one of the examples where the cameras are placed into deep sleep mode so when you reset the microcontroller or whatever you have the cameras can't be found because they are sleeping. I add the line

    yourcam.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK);

to clear this state when intialising.

body:
Thank you very much for your attention.
But the problem was in the dupont connection wires, [as mentioned here!][0]

[0]:https://github.com/ArduCAM/Arduino/issues/92


body:
I am currently making a GPS tracker with UNO and SIM808 ([this is the model][1].

It says `The range of voltage of Lithium battery input power is 3.5 - 4.2V.` for the module. I am aware that UNO needs 5V to power.

I want to make it compact as possible so it can be placed within the dashboard of a car or motorcycle.

How do I power both of this using just one battery holder?

  [1]: https://www.lelong.com.my/sim808-module-gsm-gprs-gps-development-board-arduino-stelectronics-191687273-2018-04-Sale-P.htm

title: Powering Sim808 + Arduino UNO

Answers: 0


body:
So I got [this][1] water flow sensor that measures the flow of water. I also got an ESP8266 module to help me make HTTP requests.

So as far as I know, one must set the board type to Generic ESP8266 and upload a sketch that the ESP8266 runs.

However, how can I write code in such a way that when the water flow goes over say 30 Litres, it makes a GET request to the Api that alerts the user? I am not able to use both the modules in one sketch. Any possible methods?

  [1]: https://www.amazon.com/DIGITEN-Sensor-Switch-Flowmeter-Counter/dp/B00VKATCRQ/ref=sr_1_3?ie=UTF8&qid=1501241366&sr=8-3&keywords=water flow sensor

title: Can I get the arduino to run ESP8266 code?

Answers: 1

body:
I think you have a fundamental misunderstanding of what you are working with.

There are two ways of working with an ESP8266:

1. Directly program the ESP8266. This involves installing the ESP8266 boards package and uploading the code to the ESP8266. No Arduino is required (unless you want to use one as a USB to UART adaptor for the programming).
2. Use the ESP8266 as a serial peripheral to an Arduino. You program the Arduino, not the ESP8266, and no special software is needed (unless you want to use an ESP8266 library for Arduino). You send the ESP8266 `AT` commands to get it to do internet related operations. *You are still working with an Arduino, so that is the board that should be selected.*

It sounds like you are wanting to do (2) but are mistakenly trying to so (1).

Option 2 does rely on the ESP8266 having the AI Thinker AT firmware installed on the ESP8266, which most come preinstalled with. If you have uploaded code to your ESP8266 using the ESP8266 boards package that firmware will have been replaced with your code and you will need to put the original firmware back on. There's many tutorials on the web showing you how.

If you do want to program the ESP8266 directly then it's the ESP8266 that you need to program, not an Arduino. Everything will be done by the ESP8266 - the GET request, the water flow sampling, the decision making, etc. The Arduino will be relegated to your bits box where it will gather dust.


body:
Is the following connector is valid for Arduino Pro Mini (no `BLK` and `GRN`)?

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

I was told to make a certain Arduino application, and got some Arduino Pro Mini  (ATmeag328 3.3V 8 MHz) with the connector above.

Everytime I tried to upload an example sketch 'Blink', the IDE complains (verbose enabled):

    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x83
    ...
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x83

`resp` may differ (I saw `0x1f` and `0x83`)

But, according to [the official document](https://www.arduino.cc/en/Guide/ArduinoProMini),  I think that I should use some *FTDI* thing, which has 6 pins including BLK and GRN.

I wonder whether I can use the existing 4-pin connector, or whether I must use 6-pin FTDI connector.

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

title: Should BLK and GRN of Pro Mini be connected to upload sketch?

Answers: 1

body:
[![][1]][1]

If you look at the picture in your link, you would see that `BLK` is ground (`GND`) and `GRN` is `DTR`, that is used to reset the board and enter the bootloader for programming.

As Majenko said, without `DTR` you will need to press the reset button at the right time, to enter the bootloader.

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


body:
i want to merge 2 batteries socket of 4 AA 1.5v batteries , how can combine them to have 12v ?
[![enter image description here][1]][1]

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

title: How to merge 2 batteries socketof 6v each

Answers: 1

body:
Put them in serie. One red cable to another black cable. Glue the cases back to back.

Don't get confused by the clamps; I only used them for keeping things in place. Oh, my cases are for 3 batteries, but the procedure is aplicable to 4 batteries cases also.

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

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


body:
I'm using an Arduino Mega.
I know that Ethernet Shield 2's come with a sticker with the MAC Address printed on it. This would imply to me that this address is hardcoded into the shield. Is there any way to recover the MAC without manually entering it in the sketch?
Thanks!

title: Arduino Ethernet Shield 2: How can I automatically determine the MAC Address?

Answers: 2

body:
No, the W5500 chip does not have a mac address. You can give it any mac address that you want. The router might not like some mac addresses though.

There are online mac address generators.

The sticker with the mac address is an extra service. It is unique number. But it is just a number on a sticker, it is not related to that specific shield.

Often the mac address DEADBEEFFEED was used. But when two different Arduino boards use the same mac address, the router thinks it is the same device. When there are two devices with the same mac address at the same time connected, that is for sure a way to mess up the router.

body:
This is an old question, but I wanted to share my code which fixes this.
Basically, the next code generates a "locally managed address" and stores it to EEPROM.
On subsequent starts, it read the address from EEPROM so that you would generally get the same IP address from the DHCP server.

If you do not have EEPROM, you may have another memory that survives programming cycles (SPI Flash, RTC RAM, etc) - you'll need to update the sketch for that.

    #include <EEPROM.h>

    // If defined, report information about MAC ADDRESS INITIALISATION
    #define ENABLE_MAC_INIT_MESSAGES

    // Local mac address, initialiser can be removed (when using initMacAddress)
    uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};

    void initMacAddress() {
      // Rather than having a fixed MAC address for an Arduino sketch,
      // this implements a different, random address which is persistant
      // by storing it to EEPROM (which only works when EEPROM is available).

      // Here the MAC ADDRESS IS LOCATED AT ADDRESS 0 OF THE EEPROM
      for(int i=0;i<6;i++) {
        mac[i]=EEPROM[i];
      }

      // Generating a new MAC address if the address found is not locally
      // Administrated.  This test requires that the 2 lower bits of the first
      // byte are equal to "2" (bits 1 and 0).
      // Normally it is only required that bit 1 is "1", but checking bit 0 for a 0
      // allows to detect an uninitialized EEPROM.
      if((mac[0]&0x03)!=2) { // Is this a locally administered address?
        // No a locally managed address, generate random address and store it.
        #ifdef ENABLE_MAC_INIT_MESSAGES
          Serial.println("GENERATE NEW MAC ADDR");
        #endif
        // make sure random numbers used are not always the same
        randomSeed(analogRead(0));
        for(int i=0;i<6;i++) {
          mac[i]=random(256);
          if(i==0) {mac[0]&=0xFC;mac[0]|=0x2;} // Make locally administered address

          EEPROM.update(i,mac[i]);

          #ifdef ENABLE_MAC_INIT_MESSAGES
            if(mac[i]<10) {Serial.print('0');}  // Print two digets
            Serial.print(mac[i],HEX);Serial.print(":");
          #endif
        }
        #ifdef ENABLE_MAC_INIT_MESSAGES
          Serial.println();
        #endif
      }
    }

    void setup() {
      initMacAddress();
      /*...*/
    }

EDIT: An anonymous use suggested a call to randomSeed(analogRead(0)); to ensure that the generated value is random. This (may) need to be done only once in the program.  It's best done in the 'setup()' as  the analog pin that can actually be used depends on the application - one might also use more complex & random initialisation schemes.


body:
I have an arduino micro that works fine off USB. I need to power it from an external 12V power supply. When I connect the 12V supply to the adjacent VIN and GND pins, the arduino will not power up. When I measure the power at VIN, it's 12V. When I measure power at the 5V pin, it's also 12V. If I disconnect the external power and go back to USB, it powers up.

Blown regulator?

title: Arduino Micro not providing regulated power

Answers: 1

body: In comparing this with another Arduino Micro, it appears that the regulator is malfunctioning.


body:
I have a rather voluminous sketch with a heap of source and header files.

Now I'm facing the problem, that controlling the MCP23S17 on my board fails in different ways within this sketch. This is rather awkward, because when I modify the sample sketch taken from this library to my needs, the port expander can be accessed and controlled without any problem.

what happens within my own sketch?
If I initialise SPI myself before using any of the library methods, everything of my sketch and hardware but the port expander works flawlessly. I.e. all hardware does what it is intended to, only the pins of the port expander do nothing.

If I remove all SPI commands I inserted there to initialise SPI according to my needs, the code will fail during the first call to MCP23S17::pinMode(…).
Fail means: The CPU crashes. It hangs inside this routine and keepalive-LED stops blinking, serial output is severed. As I don't have any means of debugging besides Serial.print(), I narrowed it down to the call of

    _spi->transfer(cmd);

within

    void MCP23S17::writeRegister(uint8_t addr)

So something from my other code must interfer with this call, somehow, so the CPU comes to a halt. What the heck do I have to look for?

Additional information:

 - Portexpander chip select is tied to Pin 7 of Arduino Uno.
 - Portexpander address i 0
 - Other device connected to SPI: display
 - Other notable devices: RTC (on I2C), lot of 1-wire devices.

**Addendum**
following Majenko's suggestions, I reduced my code to reach functionality in this issue. I did not succeed. So I decided to post two antagonistic sketches, one crashing and one working.
**Spoiler: I found my coding flaw myself five minutes ago, I'm going to post it as answer later, but decided to go on writing this addendum as I had intended**

Here comes the .ino-file of the failed sketch:

    #include <SPI.h>
    #include <MCP23S17.h>
    #include "spin.h"

    void setup() {
     Serial.begin(9600);
     Actors::setup();
     Serial.println("setup finished");
    }

    void loop() {
     Actors::service();
    }

part of this are two further files, from which I removed everything possible:
spin.h:

    #ifndef _INC_SPIN
    #define _INC_SPIN

    #include <MCP23S17.h>

    class Actors
    {
     private:
     static const uint8_t PexSSPin;
     protected:
     static MCP23S17 portExp;

     public:
     static void setup();
     static void service();

    };
    #endif

and spin.cpp:

    #include "spin.h"

    const uint8_t Actors::PexSSPin=7;
    MCP23S17 Actors::portExp(&SPI, Actors::PexSSPin, 0);

    void Actors::setup()
    {
     Serial.print(F("Ac:se#"));
     Serial.print(".");
     portExp.pinMode(2, INPUT); // not used. INPUT mode prevents damage due to accidental shorting
     Serial.print(".");
     portExp.pinMode(3, INPUT); // not used. INPUT mode prevents damago due to accidental shorting
     Serial.print(".");

     Serial.print(F("Ac:se!"));
    }

    void Actors::service()
    {
     Serial.print(F("Ac:sv#"));
     Serial.print(F("Ac:sv!"));
    }

As noted in my first part of the question this code comes to a halt during the first call to the pinMode() method of the portexpander. There's no serial output after the first pinMode call and the actors weren't working either (when there was useful code left).

On the contrary here comes a working sketch with the same library controlling the same port expander on the same hardware.

    #include <MCP23S17.h>
    #include <Arduino.h>

    #ifdef __PIC32MX__
    // chipKIT uses the DSPI library instead of the SPI library as it's better
    #include <DSPI.h>
    DSPI0 SPI;
    #else
    // Everytying else uses the SPI library
    #include <SPI.h>

    #endif

    const uint8_t chipSelect = 7;

    MCP23S17 Bank1(&SPI, chipSelect, 0);
    uint16_t data;

    void setup() {
     Serial.begin(9600);
     Bank1.begin();
     Bank1.pinMode(8, OUTPUT);
     Bank1.pinMode(9, OUTPUT);
     Bank1.pinMode(10, OUTPUT);
     Bank1.pinMode(11, OUTPUT);
     Bank1.pinMode(12, OUTPUT);
     Bank1.pinMode(13, OUTPUT);
     Bank1.pinMode(14, OUTPUT);
     Bank1.pinMode(15, OUTPUT);

     // Bank2.pinMode(15, INPUT_PULLUP);
    }

    void loop() {
     if (data==0)
     {
      data = 0xffff;
     }
     else
     {
      data = 0x0000;
     }
      Bank1.writePort(data);
     delay(2000);
     Serial.println(data);
    }

title: MCP23S17 library crashes

Answers: 1

body:
So here is what I found five minutes ago.

**I forgot to call MCP23S17::begin()**

Simple that is.

Before that, I tried to rule out a whole lot of other things. It never came to my mind, that I could have missed such a vital initalisation.

What did I do to get to this point?

 - removed every other library using SPI
 - removed every code using I2C
 - removed every code using 1wire
 - removed every code using Interrupts
 - threw away 9 out of 10 files
 - removed 9 out of 10 calls for functions which seemed irrelevant for this problem.

None of these measures did anything to solve the problem. Only when I had my code reduced to the minimum, so I could dare to post it here, the single line caught my attention. So this Q&A is not really a technical or coding riddle but more a didactic play on how one can fool himself and what to do to locate errors.

But in the end I only found the culprit by strictly following Majenko's advice to remove everything until the code started to work again.


body:
I use visual Micro for Visual Studio. Out of nowhere, I can't compile for any board. I tried a blink sketch for the nano, and I get intelisense red underlines for simple things like pinMode, digitalWrite, and Serial.print. Here's what I get for an output:

    Compiling debug version of 'Nano_Trials' for 'Arduino Nano w/ ATmega328'
    Build folder: file:///C:/Users/jf051e/AppData/Local/V.Micro/Arduino/Builds/Nano_Trials/nano_atmega328
    Additional Defines: VM_DEBUG;VM_DEBUG_ENABLE 1;VM_DEBUG_BANDWIDTH_THROTTLE_MS 50;VM_DEBUGGER_TYPE_HARDWARESERIAL 0;VM_DEBUGGER_TYPE_SOFTWARESERIAL 1;VM_DEBUGGER_TYPE_FASTSERIAL 2;VM_DEBUGGER_TYPE_USB 3;VM_DEBUGGER_TYPE_TEENSY 4;VM_DEBUGGER_TYPE_UART 5;VM_DEBUGGER_TYPE_USART 6;VM_DEBUGGER_TYPE_USBSERIAL 7;VM_DEBUGGER_TYPE_TTYUART 8;VM_DEBUGGER_TYPE_NET_CONSOLE 9;VM_DEBUGGER_TYPE_Uart 10;VM_DEBUGGER_TYPE_COSA 11;VM_DEBUGGER_TYPE_CDCSerialClass 12;VM_DEBUGGER_TYPE VM_DEBUGGER_TYPE_HARDWARESERIAL;VM_DEBUG_BREAKPAUSE;
    Architecture Tools: {runtime.tools.avr-gcc.path}/bin/
    Sketchbook: file:\\\C:\Users\jf051e\Documents\Arduino
    Sketch Include Paths
    Include Path 'C:\Users\jf051e\Documents\Arduino\Nano_Trials'
    Core Include Paths
    Include Path 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino'
    Include Path 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs'
    Library Include Paths (1)
    "{runtime.tools.avr-gcc.path}\bin\avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=106011 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers" "C:\Users\jf051e\AppData\Local\V.Micro\Arduino\Builds\Nano_Trials\nano_atmega328\Nano_Trials.cpp" -o "nul"
    The system cannot find the file specified
     Preprocess: "{runtime.tools.avr-gcc.path}\bin\avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=106011 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers" "C:\Users\jf051e\AppData\Local\V.Micro\Arduino\Builds\Nano_Trials\nano_atmega328\Nano_Trials.cpp" -o "nul"
    Unknown error during deep search source code for includes. Attempting alternative regex exploration
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Visual.Micro.MiroAppAPI.SketchCompilerArduino._TryRunPreProcessIncludesDiscoveryUntilDone(String sourceFilePath, Board brd, List`1 includePaths, Boolean isTopLevel)
       at Visual.Micro.MiroAppAPI.SketchCompilerArduino.TryRunPreProcessIncludesDiscoveryUntilDone(String sourceFilePath, Board brd, List`1 includePaths, SketchLibraryList knownLibs)
       at Visual.Micro.MiroAppAPI.SketchCompilerArduino._compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
    Library Include Paths (1)
    Build Core Paths: C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino
    Using library VM_DBG version 0.0.0 in folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG
    "{runtime.tools.avr-gcc.path}/bin/avr-g++" -c -g -Os -Wall -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=106011 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Users\jf051e\Documents\Arduino\libraries" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG\VM_DBG.cpp" -o "C:\Users\jf051e\AppData\Local\V.Micro\Arduino\Builds\Nano_Trials\nano_atmega328\VM_DBG\VM_DBG.cpp.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUG_BREAKPAUSE
    The system cannot find the file specified
     Process: "{runtime.tools.avr-gcc.path}\bin\avr-g++" -c -g -Os -Wall -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=106011 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Users\jf051e\Documents\Arduino\libraries" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zq2favuv.ley\Micro Platforms\default\debuggers\VM_DBG\VM_DBG.cpp" -o "C:\Users\jf051e\AppData\Local\V.Micro\Arduino\Builds\Nano_Trials\nano_atmega328\VM_DBG\VM_DBG.cpp.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=50 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUG_BREAKPAUSE
    Error compiling libraries

I swear I didn't touch anything. i was working on a different sketch and when I hit compile, Visual Studio froze and said it was busy. i had to kill the process and try again. I did this like 8 times before i realized that I could do longer compile ANY sketch. I even restarted my PC to no avail. What the heck??

title: Suddenly I can't compile any sketch. Not even a blink sketch that I compiled earlier

Answers: 2

body:
There are a few suggestions [here][1], [here][2] and [here][3]:

 1. Ensure you are using the latest Arduino software *that is compatible with Visual Micro* (this is not necessarily the latest Arduino software!)

 2. Go to Visual Micro menu -> Board pulldown -> Find or install a
    board--> Rescan. You should get "Toolchain reload complete". The
    Visual Micro forum administrator suggests that you do this twice.

 3. Reset the User's Appdata Arduino folder

  - Close all IDE's

  - Delete the C:\Users\<USERNAME>\AppData\Local\Arduino15 folder

  - Start the Arduino IDE once. Close after it has fully started

  - Then try Visual Micro again

 4. Delete the preferences.txt file (if it exists)
Goto C:\Users\<USERNAME>\AppData\Roaming\Arduino and delete the preferences.txt file.

  [1]: http://forum.arduino.cc/index.php?topic=313176.0
  [2]: http://www.visualmicro.com/forums/YaBB.pl?num=1490350071
  [3]: http://www.visualmicro.com/forums/YaBB.pl?num=1473023621#top

body: So I seem to have fixed it. One way or another, I think VisualMicro suffered some type of problem with the installed boards. My first clue was that my sketches still compiled int the native Arduino IDE. So I went into the VisualMicro explorer and noticed that there was an update to 1.6.19 in the board manager (I was running 1.6.13). I don't know exactly what the problem was, but installing the update to 1.6.19 seems to have fixed it.


body:
In this project I will be using multiple ESP8266 WiFi modules (4) connected by software serial to an Arduino Leonardo Micro (1 UART). I plan to rotate between all 4 (starting with 2): Open port, write, read response, close port, move on....

This is a very barebones version of my code to address this one issue. Works flawlessly with a single (always open) connection, but it does not work when I close Ser1 (even if I don't start Ser2!!!)
Is the xxxx.end(); command broken or something?
Or am I doing something wrong? :/

Note: This code sends "AT" to the module, it responds with "OK"

When adding Ser2, LED flashes on Arduino periodically indicating it is writing to serial monitor, but nothing appears...

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

    #include <SoftwareSerial.h>

    SoftwareSerial Ser1(10, 8);
    SoftwareSerial Ser2(16, 7);
    SoftwareSerial Ser3(14, 4);
    SoftwareSerial Ser4(15, 2);
    //Set up (RX, TX) pins^

    void setup() {

      pinMode(10, INPUT);
      pinMode(16, INPUT);
      pinMode(14, INPUT);
      pinMode(15, INPUT);
      pinMode(8, OUTPUT);
      pinMode(7, OUTPUT);
      pinMode(4, OUTPUT);
      pinMode(2, OUTPUT);
      Serial.begin(9600);
      //Set up Serial Monitor on host computer

    }

    void loop()
    {

      delay(1000);

      Ser1.begin(9600); // open Ser1

      Ser1.write( 'A' );
      Ser1.write( 'T' );
      Ser1.write( '\r' );
      Ser1.write( '\n' );   // sends the line: "AT" with appropriate format

      Ser1.listen(); // make sure it's listening

      while ((Ser1.available() > 0)) { //Read entire string
        Serial.write(Ser1.read()); //Dump it to serial monitor
      }

      //Should Respond with "OK"

      Ser1.end(); //close Ser1 port
      //This breaks the code for some reason....

      Serial.println(); // Extra line in Serial Monitor for neatness

      Ser2.begin(9600); // open Ser2

      Ser2.write( 'A' );
      Ser2.write( 'T' );
      Ser2.write( '\r' );
      Ser2.write( '\n' );

      Ser2.listen();

      while ((Ser2.available() > 0)) {
        Serial.write(Ser2.read());
      }

      Ser2.end();

    }

title: Simple Multiple RX/TX SoftwareSerial?

Answers: 1

body:
As Ignacio mentions, you should not be stopping and starting the serial ports. Instead just switch between them with `.listen()`:

> Enables the selected software serial port to listen. Only one software serial port can listen at a time; data that arrives for other ports will be discarded. Any data already received is discarded during the call to listen() (unless the given instance is already listening).
>
> [SoftwareSerial::listen() Manual Page](https://www.arduino.cc/en/Reference/SoftwareSerialListen)

So your code would be written as:

    #include <SoftwareSerial.h>

    SoftwareSerial Ser1(10, 8);
    SoftwareSerial Ser2(16, 7);
    SoftwareSerial Ser3(14, 4);
    SoftwareSerial Ser4(15, 2);
    //Set up (RX, TX) pins^

    void setup() {
      Serial.begin(9600);
      Ser1.begin(9600); // open Ser1
      Ser2.begin(9600); // open Ser2
    }

    void loop()
    {

      delay(1000);

      Ser1.listen(); // Select Ser1 for receiving
      Ser1.print(F("AT\r\n"));

      delay(1000); // Give it time to send a response or you'll get nothing!

      while ((Ser1.available() > 0)) { //Read entire string
        Serial.write(Ser1.read()); //Dump it to serial monitor
      }

      //Should Respond with "OK"

      Serial.println(); // Extra line in Serial Monitor for neatness

      Ser2.listen(); // Select Ser2 for receiving
      Ser2.print(F("AT\r\n"));

      delay(1000); // Give it time to send a response or you'll get nothing!

      while ((Ser2.available() > 0)) {
        Serial.write(Ser2.read());
      }
    }


body:
I intend to make the device runs about couple hours a day(let say 2hrs) -> go to deep sleep -> wake up in next 7 days -> repeat the process.

I got the code from one of member here (DotPi) which I can able to make the device wake up every 10 seconds and then back to sleep. When it wakes up, the LED is flashing.

My question is how to make the LED flashes for certain amount of time. For example from 7pm to 8 pm. After that the device should go to sleep again and wait for the next alarm triggered.

I was trying to use the while loop for that but the LED always flash and never go back to sleep :(

title: Wake up Arduino Uno by RTC

Answers: 1

body:
In your while loop, you never check the time again, so when the while loops hits, you will never leave it. You need to request the time again. Something like:

    while ( now.minute()>0 && now.minute() < 30)
    {
       digitalWrite(ledPin, HIGH);
       delay(100);
       digitalWrite(ledPin, LOW);
       delay(1000);
       now = rtc.now(); // check time again
    }


body:
I want to build a program which identifies logic gates connected to Arduino, by testing the output with changing the input voltage...

Here is the code:

    int output1 = 0;   //Change output pins HERE
    int output2 = 1;   //and HERE
    int input = 2;     //Change the input pin HERE, where we will read the data (0 or 1)

    void setup() {
      pinMode(output1, OUTPUT);
      pinMode(output2, OUTPUT);
      pinMode(input, INPUT);
      Serial.begin(9600);  // Start serial communication at 9600 bps
    }

    void loop() {
      int result[12];
      for(int i = 0; i < 2; i++) // For failure test, it runs 3 times
      {
        digitalWrite(output1, LOW);
        digitalWrite(output2, LOW);
        delay(1000);             //Wait for 1sec
        result[i * 4] = digitalRead(input);
        digitalWrite(output1, LOW);
        digitalWrite(output2, HIGH);
        delay(1000);             //Wait for 1sec
        result[i * 4 + 1] = digitalRead(input);
        digitalWrite(output1, HIGH);
        digitalWrite(output2, LOW);
        delay(1000);             //Wait for 1sec
        result[i * 4 + 2] = digitalRead(input);
        digitalWrite(output1, HIGH);
        digitalWrite(output2, HIGH);
        delay(1000);             //Wait for 1sec
        result[i * 4 + 3] = digitalRead(input);
      }
      if(result[0] != result[4] && result[0] != result[8] && result[1] != result[5] && result[1] != result[9] && result[2] != result[6] && result[2] != result[10] && result[3] != result[7] && result[3] != result[11]) // See if the results don't matches...
      {
        Serial.println("Input read error, please try again!");
      }
      if(result[0] == 0 && result[1] == 0 && result[2] == 0 && result[3] == 1) // AND gate
      {
        Serial.println("This is an AND gate");
      }
      else if(result[0] == 0 && result[1] == 1 && result[2] == 1 && result[3] == 1) // OR gate
      {
        Serial.println("This is an OR gate");
      }
      else if(result[0] == 1 && result[1] == 1 && result[2] == 1 && result[3] == 0) // NAND gate
      {
        Serial.println("This is a NAND gate");
      }
       else if(result[0] == 1 && result[1] == 0 && result[2] == 0 && result[3] == 0) // NOR gate
      {
        Serial.println("This is an NOR gate");
      }
      else if(result[0] == 0 && result[1] == 1 && result[2] == 1 && result[3] == 0) // EXOR gate
      {
        Serial.println("This is an EXOR gate");
      }
      else if(result[0] == 1 && result[1] == 0 && result[2] == 0 && result[3] == 1) // EXNOR gate
      {
        Serial.println("This is an EXNOR gate");
      }
      else // If there is no match...
      {
        Serial.println("This is not even a gate");
      }
    }

It always gives back 1s... I have tested with leds, it works perfectly by changing the input, but as soon as serial.begin is declared in setup, it fails to work, the just stays on and I said, the program just gives back 1s.

What I'm missing?

Thanks!

title: Logic Gates Identifier

Answers: 1

body: Arduino uses pins 0 and 1 for Serial. Use other pins in your sketch


body:
I have a sketch where I want to check my nRF24L01's and they work great.

However, due to Serial.print(ln) statements I noticed there is a lot of delay. Is this normal?

I mean, is it better not to user Serial.print at all during speed checks?  (probably not).

What other options would be best? Some I can think off:

 1. Put all debugging info in an array and print it later (downside: more programming needed, probably special logging class)
 2. Print less (bad solution I think, also makes logging more difficult to read)
 3. Use another Arduino (so sending it by other means, via Wire or so? Never tried this, but I think this might be the best solutions.
 4. I couldn't find any print that does not wait until ready sending (which would cause minimal 'downtime' for the running sketch.

I did not try the third option but I think that would be ideal (but cost another Arduino). Since in my project I eventually use multiple AVRs (mostly Arduino's), I was thinking about sending all logging info to one Arduino and let that Arduino print out everything, that means, only one serial monitor, and no delays (or barely) for all others (where it matters).

Do you think this is the best for logging/debugging? Or are there better methods for use with an Arduino?

title: Serial speed for debugging/logging

Answers: 1

body:
I use a couple of techniques to measure code timing or to instrument it with mimimally disturbing time-critical code:

 - Run the code-under-test in a loop of N times, taking the difference in the system clock before and after the loop. If the code-under-test is short enough that the loop housekeeping timing might significantly affect the measurement, I'll unroll part of the loop - cut and paste several repetitions of the code-under-test into the loop - to reduce the relative effect.

 - Toggle an output pin at entry and exit of the code segment-under-test. Measure the pulse width with an oscilloscope, or with a DVM that includes frequency and duty-cycle measurement and calculate the pulse-width from that. I write directly to the I/O port to keep the influence of the software probes (added code) to a minimum.

 - If I'm trying to collect debugging data without disturbing the code timing, then as you suggest, I store the raw data in an array (raw, to keep it small), dump the raw data in hex to the terminal after the test-run, and expand/interpret it on my PC (to address your point 1., more programming needed). You'll still need some extra programming but it will be in a separate domain (your PC), it can be big, dirty, and slow, and requires less disturbance to your embedded source-code.


body:
I'm seeking information about connecting a PS3 controller using Bluetooth to an Arduino.

Bluno cards could be an integrated solution for that, but can it work?

Also, I've seen some tutorials using a USB shield + a Bluetooth dongle: in this case, at some setup steps a USB connection is needed between the PS3 controller and the Arduino. It is still the case with a Bluno card?

title: Bluno + PS3 controller?

Answers: 1

body:
While not strictly impossible, using a PS3 controller with the Bluno (ATmega + CC254x) is essentially impractical.

The PS3 controller is either a USB device, or a *classic* Bluetooth device.

- A USB device can only communicate with a USB host.  Neither the ATmega nor the CC254x on the Bluno is capable of being a USB host.  An add-on USB host shield would cost more than simply buying a platform suitable for fulfilling the *entire* requirement natively.

- The CC254x only speaks Bluetooth Low Energy.  It is not compatible with classic Bluetooth devices. To communicate with the PS3 via Bluetooth you would need to add a Bluetooth classic radio to the system.

If you wish to use a PS3 controller you should pick a non-Arduino platform having native USB Host capability or native classic Bluetooth capability.

Otherwise, if you wish to use an Arduino-like platform, pick an earlier generation controller with either a very old wire-per-function interface or a simple synchronous serial interface, for example a PS2 controller.


body:
I am fairly new to Arduino. As far I know all official Arduinos run on 5 volts. Or there is Arduino versions that run from 3.3V? I need use Arduino with devices which chipsets all use 3.3V logic level. Do I need modify Arduino to make it  3.3V powered, like described in this [Tips][1], or there is another way? I plan get Arduino UNO R3 ATmega328P board (comes with bootloader for Arduino UNO ZT).

  [1]: https://learn.adafruit.com/arduino-tips-tricks-and-techniques/3-3v-conversion

title: Arduino 3.3V Conversion

Answers: 3

body: Arduino Pro Mini comes in 3.3v and 5v versions.

body:
You can use different possibilities:

1. Use Arduinos which are already 3.3V by default (like Pro Mini, Due if I recall right)

2. (removed after valid comment of minto below)

3. Use 5->3.3V adapters, most general devices have adapters which can be bought separately (for under 1$) to convert 5 to 3.3V (including logic level converters)

body: What about just getting the bare chip so you can run it at whatever rail you want? Seems like the simplest and easiest solution.


body:
I'm trying to gain an understanding of the Arduino timer and interrupts, particularly the CTC-modes 4 and 12. I wrote a small example in which I generate interrupts while the mainloop sleeps for 1 second and the display how many interrupts occured. It can toggle between mode 4 and 12 with the #if 1.

This works fine for mode 12 ( 50 interrupts/sec ) but in mode 4 it gives -12k interrupts / seconds... unless when I set OCR1A to 39999 again inside the ISR then it does give the expected 50 interrupts/sec, but I'd like to know why.

I think my confusion might be related to not understanding the table-header explaining the modes where it says "Update of OCR1x at". What is meant with that ( who updates it, and to what value? or do I need to update it in the ISR ) ?
Why would OCR1x be updated in mode 12 ( the table seems to state that it is) ? And it seems to work, even if I don't update it...?

Also, the only difference between mode 4 and 12 seems to be the register used for comparing to the timervalue (OCR1A vs ICR1)... but what is so fundamentally different between those? Why are there 2 options and what is the argument to choose for either mode 4 or 12 ?

Update: The issue seems to be related to initialization-order. If OCR1A is set to 39999 at the current location it gets reset to 0 a few lines further. When moving it after TCCR1A = TCCR1B = 0; then OCR1A keeps the value. So it's not necessary to set it on every interrupt.
This also explains why we get -12k counts on mode 4 (because we are comparing OCR1A in that mode, comparing to 0 and generating loads of interrupts)...

Any insight into why the initialization-order matters in this case would be appreciated.

Thanks in advance!
[![Arduino Datasheet Table 20-6][1]][1]

    volatile int isr1 = 0;

    ISR(TIMER1_COMPA_vect)
    {
      // this is called every time our timer-compare matches to ICR1 or OCR1A
      isr1++;

      // when using the #if part below, we need to do this, or we end up with weird values for isr1 ( around -12.000 )
      // If we set it to the original value then we get 50 interrupts per second...
      OCR1A= 39999;
    }

    void setup() {

      Serial.begin(115200);
      delay(50);

      ICR1 = 39999;                   // 50Hz signal @ 16MHz clock
      OCR1A= 39999;

    //TIMSK1 |= 1 << ICIE;            // bit 5: Input Capture Interrupt Enable (execute interrupt when TIFR1.ICF flag is set)
      TIMSK1 |= 1 << OCIE1A;          // bit 4 : Enable the Timer-Output-CompareA-Match Interrupt

      TCCR1A = TCCR1B = 0;            // reset timer-config flags
       // An interrupt can be generated at each time the counter value reaches the TOP value by either using the OCF1A or ICF1 Flag,
       // depending on the actual CTC mode. If the interrupt is enabled, the interrupt handler routine can be used for updating the TOP value.
    #if 1
      // Arduino Datasheet 20.12.2. : The counter value (TCNT1) increases until a compare match occurs with OCR1A, and then TCNT1 is cleared.
      TCCR1B |= 1<<WGM12;             // code 4 (CTC, compare with OCR1A, Immediate update of OCR1x, overflow on MAX)
    #else
      // Arduino Datasheet 20.12.2. : The counter value (TCNT1) increases until a compare match occurs with ICR1, and then TCNT1 is cleared.
      TCCR1B |= 1<<WGM13 | 1<<WGM12;  // code 12 (CTC, compare with ICR1, Immediate update of OCR1x(?), overflow on MAX)
    #endif

      // using a prescaler of 8, which "slows down" the clockticks by factor 8.
      // 1 clocktick takes 0.5 microseconds, so 39999 clockticks need 19999,5 microseconds
      // 1 second = 1.000.000 microseconds, so we get 50 interrupts per second
      TCCR1B |= 1<<CS11;   // timer CS11 = clki/o/8, 1 tick per 0.5 microseconds
    }

    void loop()
    {
      delay(1000);            // wait 1 second
      Serial.println(isr1);   // print how many interrupts we had in that second
      isr1 = 0;               // and reset for the next second.
    }

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

title: Arduino timer ctc mode 4 vs 14

Answers: 1

body:
As described in the operation part of the datasheet section, `OC1x` is *double-buffered*; the code sets a shadow buffer to a given value and then at some point the hardware copies the shadow buffer to the register that controls operation. "Immediate" means that the buffer is completely transparent since the value is copied immediately.

The difference between modes 4 and 12 is that mode 4 allows the use of ICP1 for input capture and mode 12 allows the use of OC1A for waveform generation.


body:
I've downloaded the Timer1 library but unfortunately it seems that the read() method has been removed from it. I tried also SimpleTimer library from the arduino website but the program didn't compile because of undefined reference to `SimpleTimer::SimpleTimer()' error. Anybody knows how to solve this error or just another timer library which has a read function?

To be more specific I need to start a timer as I press a button and to stop it as it is released.

title: How to read a timer's value once stopped?

Answers: 1

body:
Here, below is a code which is you looking for. When you pressed a button then a timer is started and when you released it then a timer is stopped. And you can also see that time also means how long button is pressed.

    const uint8_t button_pin = 2;

    void setup()
    {
        pinMode(button_pin, INPUT_PULLUP);
        Serial.begin(9600);
    }

    void loop()
    {
        static int last_button_state = HIGH;
        static unsigned int push_count;
        static unsigned long last_press_time;
        int button_state = digitalRead(button_pin);
        unsigned long now = millis();

        // Record when the button is pressed.
        if (last_button_state == HIGH && button_state == LOW) {
            push_count++;
            last_press_time = now;
        }

        // Report when the button is released.
        if (last_button_state == LOW && button_state == HIGH) {
            unsigned long push_duration = now - last_press_time;
            if (push_duration < 10) {  // discard bounce
                push_count--;
            }
            else {
                Serial.print(F("pushes: "));
                Serial.print(push_count);
                Serial.print(F(", duration: "));
                Serial.print(push_duration);
                Serial.println(F(" ms"));
            }
        }

        last_button_state = button_state;
    }


body:
In this video I'm watching then instructor talks about using "jumpers". He's got a motor controller shield and at first he says that "during the making of this video we only had 1 jumper, thus only Pin 4 is working", and that as a result he could only move a motor/wheel in 1 direction.

He proceeds to find another jumper, uses it to make Pin 5 work, and then he can reverse polarity and change the direction the the wheel spins.

At first I thought that he must mean header pins, but when he holds the tiny component up, it looks like it's something else:

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

I read about a "[power jumper][2]" on an Adafruit page, but it only applied to one version of the Arduino and sounded like it was to do with Power joining (using the same power source for the motor and controller), so I really don't know if that's the same thing.

  [1]: https://i.stack.imgur.com/enI4l.jpg
  [2]: https://learn.adafruit.com/adafruit-motor-shield/power-requirements#how-to-set-up-the-arduino-plus-shield-for-powering-motors

title: Which component is described as a "jumper" (NOT jumper wire) when working with a motor shield?

Answers: 1

body:
It's one of these (or similar). It connects two adjacent male header pins.

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

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


body:
My online video Arduino instructor makes use of various devices to amplify signals, currents, and voltages. This seems like magic to me.

For instance, he has 4 AA batteries with 1.2V each. He says "that's not going to be enough for Arduino" so he then passes the power through a voltage up-converter and increases it to 9V.

I'm going to assume there must be some tradeoff here, because otherwise we can just use a giant string of these up-converters to give the world infinite energy from a single AA battery. I found the Wikipedia articles on this topic a little hard to understand, but basically gathered that if Voltage is boosted then it's at the expense of current. My questions are:

 1. Is my understanding correct (higher voltage = lower current)?
 2. If the current decreased then why was this still an adequate power source for Arduino? Does current not matter?
 3. What are the practical limits of this type of conversion?

I would appreciate a plain-language (easy to understand) answer. I'm also kind of curious how the conversion works, but I assume that will be highly technical.

title: How to understand the "power economy" of a voltage up-converter (boost converter)?

Answers: 1

body:
He is describing a [boost converter](https://en.wikipedia.org/wiki/Boost_converter) which steps up voltage at the expense of current. To quote from the Wikipedia page on that subject:

> A boost converter (step-up converter) is a DC-to-DC power converter that steps up voltage (while stepping down current) from its input (supply) to its output (load). It is a class of switched-mode power supply (SMPS) containing at least two semiconductors (a diode and a transistor) and at least one energy storage element: a capacitor, inductor, or the two in combination.

As an example, an Arduino Uno consumes around 50 mA from the power jack (at 9V) running a "do nothing" sketch like this:

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

You could say that this is consuming 450 mW of power.

    9V * 0.050A = 0.450W

To run from a lower voltage the boost converter (say, 3V) you still need to get 450 mW of power, so therefore it will consume a higher current:

    0.450w / 3V = 0.150A

In other words, we now need 150 mA (3 times the current) since we have 1/3 of the voltage.

Also, these converters are not 100% efficient. Say a particular converter is 90% efficient, that means it requires even more current (150mA / 0.9 in this case, being 166 mA).

The efficiency is not linear anyway. It varies somewhat depending on the input voltage and the load. There is a [question and answer on Electronics Stack Exchange](https://electronics.stackexchange.com/questions/131698/boost-converter-efficiency-goes-down-as-duty-cycle-goes-up) (Boost Converter Efficiency goes down as Duty Cycle goes up?) which discusses this.

---

> Is my understanding correct (higher voltage = lower current)?

Yes - in the sense that the device consumes *power*. Thus a higher voltage requires a lower current to deliver the same power. Conversely, if you drop the voltage you need to increase the current to get the same power.

> If the current decreased then why was this still an adequate power source for Arduino? Does current not matter?

Yes it matters. You need a certain voltage, with the *capability* of providing enough current. In this particular case if your batteries can supply 166 mA then the Arduino can still run.

> What are the practical limits of this type of conversion?

You will eventually exceed the capacity of your battery to supply enough current. A more elaborate Arduino circuit may involve LEDs and motors. The higher current drain may exceed what the battery can supply, or possibly it will just be drained quickly.

Another factor is that batteries are less efficient when supplying higher current (the quoted mAh figure for a battery is usually for quite a low current). In other words, if you double the current drawn from a battery, the time the battery lasts is not half the time, it is *less* than half the time. One of the reasons for this is that batteries have an equivalent series resistance (ESR). At higher current drains there is a larger voltage drop over that resistance (some power gets turned into heat, in other words). Thus it isn't practical to try to get 10 amps from an AA battery. The battery will just get very hot.

---

> For instance, he has 4 AA batteries with 1.2V each. He says "that's not going to be enough for Arduino" so he then passes the power through a voltage up-converter and increases it to 9V.

This is actually quite inefficient in the first place. The Arduino nominally can run from 5V (if sent directly to the 5V pin on the board) and 4 * 1.2V is 4.8V which should be close enough for practical purposes.

His idea is to step up the 4.8V using a boost converter to 9V (which in itself has some inefficiency) and then use the voltage regulator on the Arduino to drop the 9V back to 5V which is also inefficient because some power is now being dissipated as heat.


body:
(Newbie Arduino developer).

I am interested to read the signal being sent to a small flat screen display in an industrial appliance, while not disturbing the display. The goal is to capture screenshots and upload them over a network connection.

Is that possible. What do I need to find out about the signal/display?

Any pointers to get started, would be greatly appreciated.

title: Tap into display signal

Answers: 0


body:
I've been looking for a solution for this problem for quite a time I tried different I2C libraries; like,

> I2C master library using hardware TWI interface
> * Author:   Peter Fleury

But the same problem, I think my problem is in the HMC5883L_my library.

Update: I have to mention that I'm including `I2C_TWSR_Check();` function to check the status of the I2C operations success in the HMC5883L library in `int16_t data_read (int16_t *results_ptr);` function, and as a result I get a successful operations all the time. But, the problem is when the serial monitor of the Arduino IDE is open and I'm watching the values and moving the module with different vectors, as soon as x-axis changes from -ve to +ve values, the serial monitor stops and I have to close it and open it again.

    #include <avr/io.h>
    #include <Arduino.h>
    #include "HMC5883L_my.h"
    #include "I2C.h"

    int16_t results[3];

    void HMC5883L_init (void)
    {
      I2C_start(HMC5883L_write);
      I2C_tx(Configuration_Register_A);
      I2C_tx(0x78);
      I2C_tx(0x20);
      I2C_tx(0x00);
      I2C_stop();
    }

    int16_t data_read (int16_t *results_ptr)
    {
      uint16_t lsb,msb;
      int16_t status_of_process = 0;

      I2C_start(HMC5883L_write);
      I2C_TWSR_Check();
      I2C_tx(Data_Output_X_MSB_Register);
      I2C_TWSR_Check();
      I2C_stop();

      I2C_start(HMC5883L_read);
      I2C_TWSR_Check();

      msb = I2C_rx();
      lsb = I2C_rx();
      I2C_TWSR_Check();

      results[0] = msb << 8 | lsb;

      Serial.print("x-axis = ");
      Serial.println(results[0]);

      msb = I2C_rx();
      lsb = I2C_rx();
      I2C_TWSR_Check();

      results[1] = msb << 8 | lsb;

      Serial.print("z-axis = ");
      Serial.println(results[1]);

      msb = I2C_rx();
      lsb = I2C_rx();
      I2C_TWSR_Check();
      results[2] = msb << 8 | lsb;

      Serial.print("y-axis = ");
      Serial.println(results[2]);
      I2C_TWSR_Check();
      I2C_stop();
      Serial.println();
      return status_of_process;
    }

    void HMC5883L_read_reg (uint8_t reg)
    {
      uint8_t reg_dat;
      I2C_start(HMC5883L_write);
      I2C_tx(reg);
      I2C_start(HMC5883L_read);
      reg_dat = I2C_rx();
      I2C_stop();
      Serial.println(reg_dat);
    }

As you can see I put `I2C_TWSR_Check();` after each I2C operation to see if there's any problem during read operation but I can't see any problem when the module stops reading if x-axis value get to positive region.

This is my I2C library but I don't think there's a serious problem with it because it worked with other I2C modules without any problem.

    /*
     * I2C_Library.c
     *
     * Created: 6/6/2017 12:34:39 AM
     * Author : wolfrose
     */

    #include <avr/io.h>
    #include <Arduino.h>
    #include "I2C.h"

    void I2C_init(void)
    {
     //set SCL to 100kHz
     TWSR = 0x00;
     TWBR = 0x48;
     //enable TWI
     TWCR = (1<<TWEN);
    }

    void I2C_start(uint8_t address)
    {
     TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);
     while (!(TWCR & (1<<TWINT)));
     TWDR = address;
     TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA);
     while (!(TWCR & (1<<TWINT)));
    }

    void I2C_stop(void)
    {
     TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN);
    }

    void I2C_tx(uint8_t data)
    {
     TWDR = data;
     TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA);
     while (!(TWCR & (1<<TWINT)));
    }

    uint8_t I2C_rx(void)
    {
     TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA);
     while (!(TWCR & (1<<TWINT)));
     return TWDR;
    }

    void I2C_TWSR_Check(void)
    {
      uint8_t Status;
      Status = TWSR & 0xF8;
      switch(Status)
      {
        /////////////// MASTER TRANSMITTER //////////////
        case 0x08:
        Serial.println("Start is OK");
         break;
        case 0x10:
        Serial.println("Re start");
         break;
        case 0x18:
        Serial.println("SLA+W OK ACK");
         break;
        case 0x20:
        Serial.println("SLA+W no ACK");
         break;
        case 0x28:
        Serial.println("data TX OK ACK");
         break;
        case 0x30:
        Serial.println("data TX OK no ACK");
         break;
        case 0x38:        // arbitration lost in SLA+W or data TX
        Serial.println("arbitration lost in SLA+W or data TX");
         break;

        /////////////// MASTER RECEIVER //////////////
        case 0x40:
        Serial.println("SLA+R OK ACK");
         break;
        case 0x48:
        Serial.println("SLA+R OK NO ACK");
         break;
        case 0x50:
        Serial.println("data RX OK ACK");
         break;
        case 0x58:
        Serial.println("data RX OK NO ACK");
         break;

         default:
         Serial.println("Error");
        break;
      }
    }

title: HMC5883L stops reading when x-axis value get to positive value

Answers: 0


body: Around 4 days ago my Arduino Pro Micro arrived. I've been messing around with it, using it to run keyboard commands on a computer. Just recently, whenever I plug it in to the computer it isn't detected by ports or anything. The green light is still on, and the left red light (looking at it from the side of the micro USB input) still works as well, however the right red light no longer works. Can someone tell me what's happening? Have I broken it all ready?

title: Arduino Pro Micro not recognised by computer or showing up in ports

Answers: 2

body:
The `arduino pro micro` is notoriously difficult to program. I am sure you have figured this out when first installing the drivers but on power up, the micro runs a `bootloader` for `<750ms`  so for me at least, it was extremely difficult to install drivers.

However, if you look at [this guide by sparkfun](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/troubleshooting-and-faq#ts-reset), you will see that resetting the board in quick succession will load a longer `8 sec` bootloader, which gives your more time to program it. Obviously, this is not normally something you need to worry about as the `Arduino IDE` automatically resets the board sending it into the bootloader when you upload a sketch to it.

Back to your problem, if it is not popping up as a device when you plug it in to your computer, go into `control panel > system > hardware > device manager` and look to see if you can find it there. If it still doesn't show up, do what I said above and reset it twice and hopefully you will see the bootloader appear where you can reinstall the drivers for it. You can find the appropriate drivers in the same location where you installed the `IDE` originally.

Hope this helps!

body:
Sorry to tack onto a 4yr old thread, but hoping this helps others, as it would have me.

Unbeknownst to me,some USB micro cables are power-only and don't have the data lines. I had one of these in my rotation of cables, and while the LEDs lit up nicely, the USB does not appear. I was sure it was not a cable prob as I thought I'd tried multiples. I was unaware I had one of these power only USB cables about - marked with the USB Trident just like the others.

So if you have the 'dead USB' problem with your Pro Micro, do make the effort to be absolutely sure of your cable situation.

I read the debugging posts across the web far and wide, but I yada-yada'd the cable check, as I never saw anyone point out the cable might be undamaged, but just a null-data variant.  My bad obvs - but just FYI for others like me.


body:
https://www.m.nu/neopixel/mini-skinny-neopixel-digital-rgb-led-strip-60-led-m-black-pcb-1m

I just purchased this led-strip that I plan to use with my Multiwii SE 2.5.

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

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

I power the Multiwii itself via a power distribution board where I connect a 3s LiPo battery. Now I wonder how I would wire my LED strip in order to use it with my Multiwii. I have a few smaller LiPo batteries if I need to power the LED itself (not via the 3s LiPo that powers the Multiwii) but the best solution would of course be to power them together.

I appreciate all help I can get.

title: How do I connect a LED strip to a Multiwii SE 2.5?

Answers: 1

body:
The led strips I've used with my Naze32 have three connection, +5VDC, GND and DATA. I'm not familiar with your FC but based on the image you provided it looks like you would use one of the two I2C ports. As long as you don't try to run too many LEDs (I've maxed out my FC with 32 LEDs no problem) the +5VDC connection should be able to power the LEDs. Obviously connect LED GND to the FC GND. You'll need to check the docs for you FC to confirm but it would make the most sense to me to connect the FC SDA to the LED DATA. The FC SCL would not be used.

NOTE: If your PDB has a +5VDC output you'd be better off using that one to power the LEDs.

In the picture with the Arduino one of the leads is providing +5VDC. I've read the suggestion for LED strips to place a capacitor across the +5VDC and GND to make it more stable but I don't and I've not had any issues. FYI, the lead to the Arduino is for GND and DATA (being driven by one of the Arduino Digital I/O Pins.


body:
**The plan is to control a NEMA 17 stepper motor with an endless rotary encoder.**

First, I found a code to read the rotary encoders data on [www.HowToMechatronics.com][1] by Dejan Nedelkovski. It basically manipulates an integer and outputs it on the Serial Monitor.

Works almost perfectly except that it actually doubles the count of steps the rotary encoder does.
So a clockwise turn subtracts 1, outputs it in the SM, subtracts 1 and outputs it in the SM again. Same in the other direction with adding 1. Although being not a big deal for intended use of the rotary encoder data, I think this has something to do with the problem.

In the code down below you will find a modified version of the code from Mr. Nedelkovski. I added a few lines to move the motor a few steps in each direction.

Clockwise rotation works as I expected.
One step on the rotary equals subtract, output, movement, subtract, output, movement.

But counterclockwise rotation now adds 1 to the rotary position and subtracts it immediately, leaving the motor in moving back and forward.
But if I move the rotary very very slowly it will work.

Why are the rotary values jumping around once I added the lines?
Is there a way to solve this?

**The code:**

    /*     Arduino Rotary Encoder Tutorial
     *
     *  by Dejan Nedelkovski, www.HowToMechatronics.com
     *
     *  to make it work with a stepper
     *  modified by me
     *
     */

    #include <Stepper.h>

    #define outputA 52
    #define outputB 50

    int counter = 0;
    int dir = 0;
    int aState;
    int aLastState;

    Stepper myStepper(200, 47, 49, 51, 53);

    void setup() {

      pinMode (outputA,INPUT);
      pinMode (outputB,INPUT);

      Serial.begin (9600);
      // Reads the initial state of the outputA
      aLastState = digitalRead(outputA);

      // set the speed at 60 rpm:
      myStepper.setSpeed(60);

    }

    void loop() {

      aState = digitalRead(outputA); // Reads the "current" state of the outputA
      // If the previous and the current state of the outputA are different, that means a Pulse has occured

      if (aState != aLastState){
        // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise

        if (digitalRead(outputB) != aState) {

          counter ++;
          myStepper.step(50);

        } else {

          counter --;
          myStepper.step(-50);

        }

        Serial.print("Position: ");
        Serial.println(counter);
      }

      aLastState = aState; // Updates the previous state of the outputA with the current state
    }

Thanks for taking your time to read this and help me. I hope that a detailed explanation will help solving the problem.

  [1]: http://www.HowToMechatronics.com

title: Weird behaviour of rotary encoder values

Answers: 1

body:
Unfortunately, I couldn't find the issue.
BUT I used another approach which worked fine.

I used the [ClickEncoder library][1].
This time, my rotary encoder triggered 4 events per notch.

After a little research I found out, that it's possible to set the steps per notch with this library.
I used this code to initiate the ClickEncoder:

    encoder = new ClickEncoder(A15, A14, A13, 4);

The first three arguments define the pins the encoder is connected to. **The last argument sets the steps per notch.** Now it works like a charm!

Full code:

    #include <ClickEncoder.h>
    #include <TimerOne.h>

    ClickEncoder *encoder;
    int16_t last, value;

    void timerIsr() {
      encoder->service();
    }

    void setup() {
      Serial.begin(9600);
      encoder = new ClickEncoder(A15, A14, A13, 4);

      Timer1.initialize(1000);
      Timer1.attachInterrupt(timerIsr);

      last = -1;
    }

    void loop() {
      value += encoder->getValue();

      if (value != last) {
        last = value;
        Serial.print("Encoder Value: ");
        Serial.println(value);
      }

      ClickEncoder::Button b = encoder->getButton();
      if (b != ClickEncoder::Open) {
        Serial.print("Button: ");
        #define VERBOSECASE(label) case label: Serial.println(#label); break;
        switch (b) {
          VERBOSECASE(ClickEncoder::Pressed);
          VERBOSECASE(ClickEncoder::Held)
          VERBOSECASE(ClickEncoder::Released)
          VERBOSECASE(ClickEncoder::Clicked)
          case ClickEncoder::DoubleClicked:
              Serial.println("ClickEncoder::DoubleClicked");
              encoder->setAccelerationEnabled(!encoder->getAccelerationEnabled());
              Serial.print("  Acceleration is ");
              Serial.println((encoder->getAccelerationEnabled()) ? "enabled" : "disabled");
            break;
        }
      }
    }

  [1]: https://github.com/0xPIT/encoder


body:
People often use Arduinos to send data over serial to other peripherals (flashing firmware onto modules, etc) by pulling RES to ground,  connecting the TX and RX pins to the device being programmed, and then sending data to the Arduino over serial. As an alternative, one could also remove the ATmega instead of grounding RES.

That being said, there should be no reason why one could not receive data from a connected device in the same way. However, no matter what I try, I never succeed in using an Arduino to relay serial input from another device over USB.

I have even tried setting up a simple echo to no avail (even though the TX and RX LEDs flash):[![enter image description here][1]][1]

Is it even possible?

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

title: Can an Arduino be used to read data from a serial port?

Answers: 1

body:
Yes, it can, and the wiring diagram you have drawn works perfectly for me using `minicom` in Ubuntu.

The majority of serial communication is bi-directional anyway - especially when using it to program a device.

There is absolutely no difference between interfacing the built-in USB->UART adaptor to an external device of your choice and interfacing it with the ATMega328P chip. Just because the ATMega328P chip is on the same board doesn't make it in any way special - it is just a UART interfaced device.

If your setup is not working you can try:

1. Physically remove the ATMega328P chip to see if that is interfering even when held in reset
2. Check for software that may be interfering with your communication, such as the notorious ModemManager.


body:
**Short/summary**

I expected that the round trip delay of a nRF24L01+ would be less than 1 ms. In practice I see around 3 to 5 ms and other sources have similar values. Does anybody know why this round trip delay is so long?
In short: nRF24L01+, adapters for them, tmrh20 RF24 library, 16 byte payload, highest speed.

Below is the full problem and related info.

**Problem description**

I received my nRF24L01+ radios and they work much better so far than my 433 MHz radios.

However, still with my nRF24L01 I get response times which are much lower than I expected.

I used the sketch of [Example][1] using dynamic payloads (which I increased to 16). The library I use is from tmrh20.github.

I also reduced the characters written to serial (and increased it to 250K) and some other small changes.

**Transmitter code**

Below is the code for the transmitter (manually removed receiver code and role switching code since that works/was not used except for first time)

    /*
       Dec 2014 - TMRh20 - Updated
       Derived from examples by J. Coliz <maniacbug@ymail.com>
       http://tmrh20.github.io/RF24/pingpair_ack_8ino-example.html

       Results:
      PA                          MAX
      Retries                    2,8   2,4   2,8
      AutoAck                     True       False True
      EnableAckPayLoad            True
      PayLoadSize                  16          16    8   32
      DynamicPayLoad              True                        False True
      CRC Length                   16                                 8

      Failures / 25 iterations     0-1  3-4  ???         24??

      write min [us]              812    (792)    625         652   644
      write avg [us]              2618           2106              2251
      write max [us]              6224   (804)   5756        5756  7724

      logdata[m][n] = millis()       4                  us
      write:                       812..6224 (avg 2617) us
      available:                    28..  32            us
      read                         100                  us
    */
    #include <SPI.h>
    #include "RF24.h"

    RF24 radio(7, 8);
    uint32_t counter = 0;

    static const int NR_OF_LOG_ITEMS = 10;
    static const int LOG_LENGTH = 25;
    uint32_t logData[LOG_LENGTH][NR_OF_LOG_ITEMS];
    uint8_t currentLogLine = 0;

    void setup()
    {
      for (int m = 0; m < LOG_LENGTH; m++)
      {
        for (int n = 0; n < NR_OF_LOG_ITEMS; n++)
        {
          logData[m][n] = -1;
        }
      }

      Serial.begin(250000);
      Serial.println(F("TRANSMITTER SPEED TEST"));

      radio.begin();
      radio.setPALevel(RF24_PA_MAX);
      radio.setRetries(2, 8);
      radio.setAutoAck(true);
      radio.enableAckPayload();
      radio.setPayloadSize(16);
      radio.enableDynamicPayloads();
      radio.setCRCLength(RF24_CRC_16);

      byte addresses[][6] = {"1Node", "2Node"};
      radio.openWritingPipe(addresses[0]);
      radio.openReadingPipe(1, addresses[1]);
      radio.startListening();

      radio.writeAckPayload(1, &counter, 16);
      //radio.printDetails();
        radio.stopListening(); // Takes 336..348 us

    }

    uint32_t response = 0;

    void loop(void)
    {
      uint32_t response;

      uint32_t time = micros();
      logData[currentLogLine][1] = micros();

      if (radio.write(&counter, 16))
      {
        logData[currentLogLine][2] = micros();
        if (!radio.available())
        {
          logData[currentLogLine][3] = micros();
          Serial.print(F("Got blank response. round-trip delay: "));
          Serial.print(micros() - time);
          Serial.println(F(" microseconds"));
        }
        else
        {
          logData[currentLogLine][4] = micros();
          while (radio.available())
          {
            logData[currentLogLine][5] = micros();
            unsigned long timer = micros();
            radio.read(&response, 16);
            logData[currentLogLine][6] = micros();
            logData[currentLogLine][7] = response;
            logData[currentLogLine][8]++;
            Serial.print(F("Got response "));
            Serial.print(response);
            Serial.print(F(" round-trip delay: "));
            Serial.print(timer - time);
            Serial.println(F(" microseconds"));
            counter++;
          }
        }
      }
      else
      {
        logData[currentLogLine][9] = micros();
        Serial.println(F("Sending failed."));  // If no ack response, sending failed
      }

      if (counter == LOG_LENGTH)
      {
        for (int m = 0; m < LOG_LENGTH; m++)
        {
          Serial.print("Location ");
          Serial.print(m);
          Serial.print(": ");
          for (int n = 0; n < NR_OF_LOG_ITEMS; n++)
          {
            Serial.print(logData[m][n]);
            Serial.print("  ");
          }
          Serial.println("");
        }
      }
      currentLogLine++;

      delay(100);  // Try again later
    }

**Receiver code**

Below is the code for the receiver (manually removed transmitter code and role switching code since that was not used)

    /*
       Dec 2014 - TMRh20 - Updated
       Derived from examples by J. Coliz <maniacbug@ymail.com>
    */
    #include <SPI.h>
    #include "RF24.h"

    RF24 radio(7, 8);
    uint32_t counter = 0;

    void setup() {

      Serial.begin(250000);
      Serial.println(F("RECEIVER SPEED TEST"));

      radio.begin();
      radio.setPALevel(RF24_PA_MAX);
      radio.setRetries(2, 8);
      radio.setAutoAck(true);
      radio.enableAckPayload();
      radio.setPayloadSize(16);
      radio.enableDynamicPayloads();
      radio.setCRCLength(RF24_CRC_16);

      byte addresses[][6] = {"1Node", "2Node"};
      radio.openWritingPipe(addresses[1]);
      radio.openReadingPipe(1, addresses[0]);
      radio.startListening();

      radio.writeAckPayload(1, &counter, 16);
      //radio.printDetails();
    }

    void loop(void)
    {
      byte pipeNo = 0;
      uint32_t response = 0;
      while ( radio.available(&pipeNo))
      {
        radio.read( &response, 16);
        // Since this is a call-response. Respond directly with an ack payload.
        response++;
        radio.writeAckPayload(pipeNo, &response, 16); // This can be commented out to send empty payloads.
        Serial.print(F("Loaded next response "));
        Serial.println(response);
      }
    }

**Resulting log fragment**

Below are the results:

    TRANSMITTER SPEED TEST
    Got response 26 round-trip delay: 1960 microseconds
    Got response 1 round-trip delay: 1964 microseconds
    Got response 2 round-trip delay: 876 microseconds
    Got response 3 round-trip delay: 880 microseconds
    Got response 4 round-trip delay: 1960 microseconds
    Got response 5 round-trip delay: 4128 microseconds
    Got response 6 round-trip delay: 6296 microseconds
    Got response 7 round-trip delay: 880 microseconds
    Got response 8 round-trip delay: 884 microseconds
    Got response 9 round-trip delay: 3044 microseconds
    Got response 10 round-trip delay: 880 microseconds
    Got response 11 round-trip delay: 880 microseconds
    Got response 12 round-trip delay: 884 microseconds
    Got response 13 round-trip delay: 876 microseconds
    Got response 14 round-trip delay: 1964 microseconds
    Got response 15 round-trip delay: 1956 microseconds
    Got response 16 round-trip delay: 4128 microseconds
    Got response 17 round-trip delay: 3044 microseconds
    Got response 18 round-trip delay: 4128 microseconds
    Got response 19 round-trip delay: 1964 microseconds
    Got response 20 round-trip delay: 4124 microseconds
    Got response 21 round-trip delay: 8452 microseconds
    Got response 22 round-trip delay: 880 microseconds
    Got response 23 round-trip delay: 1960 microseconds
    Got response 24 round-trip delay: 884 microseconds
    Location 0: 4294967295  12328  14216  4294967295  14248  14280  14384  26  0  4294967295
    Location 1: 4294967295  115260  117152  4294967295  117184  117216  117316  1  0  4294967295
    Location 2: 4294967295  218152  218956  4294967295  218988  219020  219120  2  0  4294967295
    Location 3: 4294967295  319916  320728  4294967295  320760  320788  320888  3  0  4294967295
    Location 4: 4294967295  421684  423576  4294967295  423608  423636  423736  4  0  4294967295
    Location 5: 4294967295  524572  528628  4294967295  528660  528692  528792  5  0  4294967295
    Location 6: 4294967295  629624  635844  4294967295  635876  635912  636012  6  0  4294967295
    Location 7: 4294967295  736844  737660  4294967295  737688  737720  737820  7  0  4294967295
    Location 8: 4294967295  838616  839428  4294967295  839460  839492  839592  8  0  4294967295
    Location 9: 4294967295  940388  943364  4294967295  943396  943424  943524  9  0  4294967295
    Location 10: 4294967295  1044356  1045168  4294967295  1045200  1045232  1045332  10  0  4294967295
    Location 11: 4294967295  1146168  1146980  4294967295  1147012  1147040  1147140  11  0  4294967295
    Location 12: 4294967295  1247972  1248784  4294967295  1248816  1248848  1248948  12  0  4294967295
    Location 13: 4294967295  1349784  1350588  4294967295  1350620  1350652  1350756  13  0  4294967295
    Location 14: 4294967295  1451592  1453484  4294967295  1453516  1453548  1453648  14  0  4294967295
    Location 15: 4294967295  1554524  1556412  4294967295  1556440  1556472  1556580  15  0  4294967295
    Location 16: 4294967295  1657448  1661508  4294967295  1661536  1661568  1661668  16  0  4294967295
    Location 17: 4294967295  1762544  1765516  4294967295  1765548  1765580  1765680  17  0  4294967295
    Location 18: 4294967295  1866552  1870612  4294967295  1870640  1870672  1870772  18  0  4294967295
    Location 19: 4294967295  1971648  1973540  4294967295  1973572  1973604  1973704  19  0  4294967295
    Location 20: 4294967295  2074580  2078636  4294967295  2078668  2078696  2078804  20  0  4294967295
    Location 21: 4294967295  2179680  2188060  4294967295  2188092  2188124  2188224  21  0  4294967295
    Location 22: 4294967295  2289096  2289912  4294967295  2289940  2289972  2290072  22  0  4294967295
    Location 23: 4294967295  2390904  2392800  4294967295  2392832  2392860  2392960  23  0  4294967295
    Location 24: 4294967295  2493832  2494644  4294967295  2494676  2494708  2494808  24  0  4294967295

And here some processed (with Excel) results:

  write available available read
  us us us us
  1..2 2..4 4..5 5..6

  4060 32 28 100
  816 32 28 100
  6224 32 32 100
  2980 32 28 100
  1896 32 28 100
  816 32 32 100
  1896 32 32 100
  812 32 32 100
  2976 32 32 100
  2976 32 32 100
  816 28 32 100
  4060 32 32 100
  816 32 28 100
  4060 28 32 100
  816 32 32 100
  816 28 32 100
  1896 32 32 100
  5140 32 28 100
  6220 32 36 100
  816 32 32 100
  4060 32 32 100
  2980 28 32 100
  4060 32 28 100
  816 32 28 100

    min  812 28 28 100
    avg  2617.666667 31.33333333 30.83333333 100
    max  6224 32 36 100

The main chunk is the write which takes 812..6224 us (with an average of 2617 us). Probably this big variance is due to retries, but still the lowest 812 us is more than expected:

**Summary of results**

I did some more tests, I will not put all log/intermediate results here, but the following table shows some tests:

      PA                          MAX
      Restries                    2,8   2,4   2,8
      AutoAck                     True       False True
      EnableAckPayLoad            True
      PayLoadSize                  16          16    8   32
      DynamicPayLoad              True                        False True
      CRC Length                   16                                 8

      Failures / 25 iterations     0-1  3-4  ???         24??

      write min [us]              812    (792)    625         652   644
      write avg [us]              2618           2106              2251
      write max [us]              6224   (804)   5756        5756  7724

      millis()  [us]                4
      available [us]              24/32
      read      [us]               100

**Conclusion of results**

- Changing the number of retries lower than 2 (= 500 us), 8 (retries) results in too many errors, and does not lower the minimum, just the maximum, but with errors so useless
- AutoAck always returns in 7u92-804 us, but I need AutoAck in my project
- Changing payload to 8 results in a minimum of 625 us
- Changing payload to 32 resulted in too many errors
- Disabling dynamic payload resulted in a minimum of 652 us
- Changing CRC length to 8 results in 644 us

**Expectations**

When I use the calculation in the datasheet, I come to the following results:

    Datasheet  https://www.nordicsemi.com/eng/nordic/download_resource/8765/2/84238108/2726
    Table 15
                    Item                          Value Unit    Item              Value Unit
    T_OA            Time on-air                 0.0001005 s     Preamble              1 byte
    T_ACK           Time on-air Ack             0.0001005 s     Address               5 bytes
    T_UL            Time upload                 0.000512  s     Payload              16  bytes
    T_ESB           Time Enh Shock-Burst Cycle  0.0008785 s     CRC                   2 bytes
    Back and forth?                             0.001757  s     packet Control field  9 bits
                                                                Air data rate   2000000 bits/s
                                                                SPI data rate    250000  bps  (guess)
                                                                T_stby2a        0.00013 s
                                                                T_IRQ          0.000006  s

According to the formulas, I would get around 0,875 ms (probably one way) and about double back-and-forth. Btw, I don't understand why T_OA is not in the formula.

However, I get as minimum 0,812 which may be some rounding/timing inaccuracy.

**Conclusion**

The retries are causing the longer writes. The minimum is similar to the calculated value from the datasheet.

**Question**

- Home come there are so many retries?
- Should I check for noise on channels?

**Background**

What I hoped for was to send a 32 (but 16 is ok too) byte message, than after 5 ms another message, and have the ack of the second message back within like 6 ms or so (including the 5 ms delay between the first and second message to be sent). This means the sending and receiving of an ack should take about 1 ms (which is well within the 0,256 ms calculated above).

**Setup**

Note my Uno's with nRF24L01 are about 1 meter apart, settings: 2 mbps, set retries(2, 4), enable ackpayload/dynamic payloads.

**RF Radio hardware**

The RF radios I'm using are nRF24L01+ like this:

[![nRF24L01+][3]][3]

Datasheet: [PDF Download][4]

Update: I see people use various capacitors and/or a voltage regulator.
I did not do that, but I have a an adapter from 5V->3.3V specifically for the nRF24L01 (like this). I think there is already a voltage regulator and needed capacitors on this board. As far as I know the IC on the adapter is the voltage regulator and the capacitor (one) is probably just above the GND/VCC connection in the picture above. Or a second capacitor left of the MI/IRQ

[![Adapter][1]][1]

**Results**

  [1]: https://i.stack.imgur.com/7e9RD.jpg
  [2]: https://forum.arduino.cc/index.php?topic=171611.0
  [3]: https://i.stack.imgur.com/OlAul.jpg
  [4]: http://www.nordicsemi.com/eng/nordic/download_resource/8041/1/45228426

title: Slower nRF24L01 round trip delay than expected

Answers: 0


body:
Good day folks. I'm new here and have been starting to be enthusiast in Arduino. I have a problem and I don't know what I should do, or whether I did something wrong regarding an array of arrays. Surfed on the internet to find a bunch of examples but the only difference is that they don't use arrays that have been declared to have a name inside array.

Every array inside array I see that works is like this:

    byte array[2][4] = { {1,2,3,4}, {5,6,7,8} };
    Serial.println(array[0][2]); is equal to '3'.

But mine is like this:

    byte arrayX[4] = {1,2,3,4};
    byte arrayY[4] = {5,6,7,8};

    byte arrayZ[2][4] = { arrayX[4], arrayY[4] };

    Serial.println(arrayX[2]); is equals to '3'.
    Serial.println(arrayZ[0][2]); is equal to '0'.

Why?

Below is what in reality I am experiencing. I hope someone can try this out too.

    softAddr = cycle * 2;

is an expression I used for looping where cycle is the iterated variable

    for (byte cycle = 0; cycle < 7; cycle++) {}

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

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

I did a simple simulation and I guess the way I initialize the parent array, it initializes a new array in the name same from the declared variables but separate.

    byte arrayX[4] = {1,2,3,4};
    byte arrayY[4] = {5,6,7,8};

    void setup() {
      Serial.begin(9600);
      byte glass[2][4] = {arrayX[4], arrayY[4]};
      Serial.print(F("OLD 1: ")); Serial.println(arrayX[0]);
      Serial.print(F("OLD 2: ")); Serial.println(arrayX[1]);
      Serial.print(F("NEW 1: ")); Serial.println(`glass[0][0]`);
      Serial.print(F("NEW 2: ")); Serial.println(`glass[0][1]`);
    }

output:

>OLD 1: 1
>
>OLD 2: 2
>
>NEW 1: 0
>
>NEW 2: 0

//answered realized

I forgot that the array I put inside the array already had its data based on its index and the `[4]` resulted to nothing or 0 since there is no value at index `[4]` (knowing, indexes where 0, 1, 2, 3 on a 4 sized array). I realized this after I made a simple loop declaration not instantly like this:

    byte arrayZ[2][4] = { arrayX[1], arrayY[1] };

But like this:

    byte arrayX[4] = {10,11,12,13};
    byte arrayY[4] = {20,21,22,23};
    byte arrayZ[2][4];
    void setup() {
      Serial.begin(9600);
      for (byte parent = 0; parent < 2; parent++) {
        for (byte child = 0; child < 4; child++) {
          if (parent == 0) {
            arrayZ[parent][child] = arrayX[child];
          } else {
            arrayZ[parent][child] = arrayY[child];
          }
        }
      }
      for (byte parent = 0; parent < 2; parent++) {
        for (byte child = 0; child < 4; child++) {
          Serial.print(F("value: ")); Serial.println(arrayZ[parent][child]);
        }
      }
    }

Output:

>value: 10
>
>value: 11
>
>value: 12
>
>value: 13
>
>value: 20
>
>value: 21
>
>value: 22
>
>value: 23

Resulting in simply like this:

    byte arrayZ[2][4] = {
      {arrayX[0],arrayX[1],arrayX[2],arrayX[3]},
      {arrayY[0],arrayY[1],arrayY[2],arrayY[3]}
    };

title: How to declare and use "Variabled arrays" inside arrays

Answers: 1

body:
Something is wrong with your type description:

    byte arrayX[4] = {1,2,3,4}; byte arrayY[4] = {5,6,7,8};

    byte arrayZ[2][4] = { arrayX[4], arrayY[4] };

Serial.println(arrayX[2]); is equals to '3'.

This is normal ... arrayX[0] = 1, arrayX[1] = 2, arrayX[2] = 3

However, the next one is not good:

    byte arrayZ[2][4] = { arrayX[4], arrayY[4] };

You are declaring a byte array, but you add arrayX[4] and arrayY[4] which, where arrayX[4] is the 5th elements of arrayX but it has only 4 elements, so it points to memory outside the array (probably into the next array.

 byte arrayX[4] = { 1, 2, 3, 4 };
 byte arrayY[4] = { 5, 6, 7, 8 };

    byte* arrayZ[2] = { arrayX, arrayY };

 Serial.print(arrayZ[0][2]);

This should print 3 (not tested).


body:
I have recently purchased a RoboMower. Like most of the automated mowers these use electric-fence wiring to mark the borders of the property and keep a small charge on those wires so that the mower can tell where the borders are. The  RoboMower I purchased is rated for 3/4 of an acre and I have 2.25 acres to mow.

As a result I was thinking of breaking my yard into multiple 3/4 or less acre zones and using an Arduino to shift which zone is active/has current in it so that the mower would follow those boundaries. The base station would be in a place where all zones overlapped slightly. Based on what day of the week it was, the Arduino would activate the proper zone, and the mower would go out and mow in that zone because it was active. I'd clearly have to schedule this so that the switch did not happen when the RoboMower was actively mowing or it would cause all sorts of issues.

In any case, my question is: What is the hardware called that I would need in order to activate one zone or the other? Is that called a digital switch or something else? Is there such a thing of one switch that would be able to switch multiple zones, or would I basically need a bunch of switches to individually control each zone?

Each zone is a loop of wire and therefore there would not be any shared wires between the zones.

title: Arduino: Digitally Muti-Switch - What is the proper term for hardware?

Answers: 1

body: The technical term of what you're looking for is **demultiplexer**. Note that the demux itself will not be enough to activate the zone, it will simply allow you to choose between different zones based on its input. It is still up to you to provide any further electronics required to enable the appropriate zone.


body:
I use Sim808 gprs/gsm/gps module and call these:

    AT+SAPBR=3,1,"Contype","GPRS"
    AT+SAPBR=3,1,"APN","internet"
    AT+SAPBR=1,1
    AT+SAPBR=2,1
    AT+HTTPINIT
    AT+HTTPSSL=1
    AT+HTTPPARA="CID",1
    AT+HTTPPARA="URL","https://www.mywebsite.com/getTime?token=jsdaljdaskl"
    AT+HTTPPARA="REDIR",1
    AT+HTTPACTION=0

I always get `+HTTPACTION: 0,606,0` as the result.

What does 606 mean? I cannot find it everywhere in the documentation.

title: AT+HTTPACTION: What is status 606 means?

Answers: 0


body:
I'm working on a project with SDcard, and I would like to write int and long in a file.

If I try to write 0x1954 I had 0x5419 on my file with file.write() so I did a circular shifting like:

      data=(data<<8)|(data >> (16-8)); //circular shift
      file.write((char*)&data,sizeof(data));

But with a long, I have 0x54195521 on my file instead of 0x19542155.
So I don't know how to fix this. If you have any idea, I would like to read it ! (Or another way to do it)

Thanks !

title: Writing int/long on Sd card

Answers: 1

body:
(Its not circular shifting, its bit shifting, the bits don't go round in a circle they disappear off the end and are lost forever.)

So in the library you are using you are writing bytes to the SD Card.
If you write the data 0x1954 on the card you get 0x5419.
So what is happening is you are writing the least significant byte followed by the most significant.  This is because you have take your int `0x1954` and cast it to a char[2] which contains `c[0] = 0x54` and `c[1] = 0x19`  and then you write that out in the order c[0]c[1] et voila you have reversed you number.

The solution is to reverse the buffer before you write it:

    char tmp = buf[0];
    buf[0] = buf[1];
    buf[1] = tmp;

HOWEVER - If you are only reading and writing from this code, who cares.  As long as you read it in backwards does it matter how it is stored on the SD Card?


body:
I very accidentally caused a short-circuit to two completely different cheap (under 4$ each) Arduino Uno clones, rendering Windows sound alert for unplugged USB several times.

This subsequently led to a problem with uploading code and not blinking green light on reset on both the Arduinos. Now, I am aware what this means but I am unable to see why this happens. I thought it has protection against that.

Is it normal for them to react like that so easily? How can I prevent this happening AGAIN?

title: Burning Arduinos one after another

Answers: 4

body:
> I thought it has protection against that.

Genuine Arduinos do have some protection, yes.

> Is it normal for them to react like that so easily?

Cheap rubbish? Sure. You get what you pay for.

> How can I prevent this happening AGAIN..

Buy a real one. Also *be more careful*.

But at the price you pay for cheap clones, do you really care if they end up broken? You can buy many clones for each genuine one, and while a genuine one may last longer, when you do manage to kill it (they aren't *that* much more rugged, but some components are more reliable, such as the USB interface chip), which you seem adept at, you would be far more upset than if you'd killed a clone.

So I would suggest invest in one Genuine one for *special* projects, and to support Arduino (if no one buys Genuine boards there will *be* no Arduino), and a pile of clones that you can experiment and learn with. Blow them up at will, and when you are happy with your project transfer it over to the genuine board for showing off to people.

body:
Measurements to prevent breaking an Arduino (or AVR in general):

**Precautions**

- Always remove the USB or adapter plug when you make a change in the circuit.
- Check all wires before you switch it on.
- Remove or make sure (temporary) loose wires/jumpers do not touch other components or the Arduino (better take them out or 'park' them somewhere else in the breadboard.

**Preventing wanted changes resulting in shortcuts**

- Check again the wires/jumpers you just changed/added.
- Make sure no other components/wires/jumpers are touching the Arduino or the breadboard (components).
- Clean your desk (if you have space), so if something metal falls/moves, it does not hurt your Arduino.
- When changing a shield, always check all wiring to and from it, to your Arduino and the components on the shield itself if needed.

**Preventing component shortcuts or overpowering**

- If you have a wire from a pin to GND or a pin to VSS, always make sure there is either a resistor, or you know why a resistor is not needed. This can also damage directly your Arduino.
- Make sure that every component does not get more power than it can handle.
- More specific: If you have components using 3.3V, make sure they don't get 5V.
- If you have components using 3.3V, make sure they don't get 5V.

**Preventing too much heat**

- Do not just put an Arduino in some case/enclosure ... heat may destroy it, so check before there is enough cooling, add a fan, heatsink or make holes in the enclosure.
- If you connect any power source other than USB, check again if it does not generate unnecessary much heat. Unused voltage will generate much heat.

**Preventing static electricity**

- Do not touch components when not needed
- If you touch components, make sure you are discharged (touch a radiator, use a wrist band, use an ESD mat, touch grounded wire).

**Preventing trivial mistakes**

- Do not keep drinks next to your Arduino or breadboard (or if you, keep it on the other side).
- Watch out for heavy cables not dragging your Arduino from the table/desk ... a USB cable can easily drag an Arduino down.
- Watch out when you change cables, not to pull your Arduino from the table/desk.
- Keep animals (and people too, to your own judgement) away from your electronics project.

body: Always use a series resistor when connecting anything to your IO pins. In many cases you will need one anyway (like driving a LED or a BJT), and in other cases it will not hurt (like driving MOSFET gates or UART lines). A 100 Ohm resistor will limit the current to 50 mA (keeping it within the safe range), while having little effect on your circuit in most cases.

body:
I have used a current limiter (a cheap LM317 will do) occasionally, though even 100mA will burn your devices. It is good practice to limit current.

Generally don't wire a live circuit. Pull caps from the breadboard as well. Eventually you can disregard this, as you become more adept. I burned 4 arduino clones in the first few months.


body:
My dad told me, if i can mount some servo (to control 4 way ventil of heating) to his arduino-controlled home. But there is a problem... The servo does not have a normal 3 cables but 6 and I have no idea how to control. So i start some research about it and i found web site of manufacturer. There was also a Datasheet, but i dont understand it :D. So here is a link to the Manufacture´s web: http://www.mutmeccanica.com/prodottomutmeccanica.php?p=207
And link to datasheet: http://www.mutmeccanica.com/download_file.php?file=downloads/scheda_V70.pdf

And I have a question: Is any hope to connect this to arduino? Is there some shield for it?

title: Arduino and big servo

Answers: 1

body:
In the Arduino world, a [servo motor is a RC servo motor][1]. It runs at 5V or 6V and most of them can rotate 180°.

In an industrial environment or with the central heating in a house, the valves are often 24V AC. The most common voltages are 12V and 24V, and most of them with work with DC as well.
Sometimes the term "servo" is used for them, that is for example for a controller for valves with multiple positions.
To control them with an Arduino, the easiest way is with a number of relais.

Some intelligent valve controllers have an input signal. That is the one that you have.
The link to that datasheet is for a valve controller for 24V or 230V AC mains voltage. It has inputs to control it. Depending on the type, the input signal can be 0...5V, to 10V or to 20mA. Which one do you have ?

When that valve is in a central heating, it is possible to cause damage. First of all the central heating is tuned to the house. The valves work together with the pump, and not every system has a automatic overpressure-loop-valve.

  [1]: https://www.arduino.cc/en/Tutorial/Sweep