text:
How to use 2 serial port when WifiEsp library uses one of both
I try without success to receive datas from DataPort and transmit them to my computer via WifiPort, using ESP8266 wifi module. Each second, serial datas income on DataPort from another device.
Initialization as follow:
#include <SoftwareSerial.h>
#include "WiFiEsp.h"
SoftwareSerial DataPort(10, 11); // RX, TX
SoftwareSerial WifiPort(8, 9); // RX, TX

In setup:
Serial.begin(9600);
DataPort.begin(9600);
WifiPort.begin(9600);
WiFi.init(&WifiPort);

In loop, i do:
//WIFI PART
WifiPort.listen();
WiFiEspClient client = server.available();
if (client) {
 //.... bla...bla...bla...
}

//INCOMING SERIAL PART
DataPort.listen();
while (DataPort.available() > 0)
{
   char c = DataPort.read();
   str += c;
   if(c == '/')
   {
      Serial.println(str);
      str="";
      break;
   }
}

WIFI PART runs fine if i isolate INCOMING SERIAL PART and INCOMING SERIAL PART runs fine without WIFI PART.
So how can i receive datas on DataPort and transmit them when my computer ask them via the ESP8266 on WifiPort ?

please post the code in one block, not in chunks

Yes Juraj, but how to switch on DataPort from WiFiPort or getting via wifi the serial incoming datas? What is the good code?

DataPort only receives serial datas each second. Tx is not used. And I want to get this data with the ESP8266.

The esp8266 AT firmware doesn't wait until you listen on the SoftwareSerial instance. If there is a connection to the server it sends +IPD and data. If the SoftwareSerial instance doesn't listen the information about client connection is lost.
You must listen to esp8266 all the time, so you can't use two SoftwareSerial instances.
You could use the RX pin of Uno to received data over hardware Serial, if you only receive on DataPort and only print to SerialMonitor.

I saw an example of instance of SoftwareSerial here: https://www.arduino.cc/en/Tutorial/TwoPortReceive. I think I could make it with Esp8266...

it is what you have now. You must listen to esp8266 all the time, so you can't use two SoftwareSerial instances.

Sorry, but I don't understand and see how can I solve my problem.

wire the DataPort device to RX pin of Uno, remove SoftwareSerial for DataPort and read data from the device with Serial.read()


text:
Issues with CO2 sensor SEN0159
I followed the sketch example for the SEN0159 CO2 sensor as precised in the data sheet  https://www.dfrobot.com/wiki/index.php/CO2_Sensor_SKU:SEN0159. It's powered by a 9V/2A DC power supply more than 48h and it still reads 2.81V on the analog ouput pin even if i exhaust on the sensor during long time, nothing happen, giving - 1ppm CO2 value.
Can you explain me why i cannot observe CO2 variations ? Is there troubles with the board ?
Thanks!

why do you power it with 9V?! the tutorial states a operating voltage of 5V and the datasheet (https://media.digikey.com/pdf/Data%20Sheets/DFRobot%20PDFs/SEN0159_Web.pdf) specifies that the maximum input voltage is 6V. Maybe you broke it...

From datasheet link: "External power supply (7~12V) is necessary to supply the microcontroller board when you using this CO2 sensor module."

Yes, i made a mistake... The arduino board should be powered by a 7-12V power supply to support high current from 5V pinout in order to power the sensor card... I'm very lucky, my sensor is not broken. I have powered it with 5V and it works fine!!! Thanks

source: Stack Exchange

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

sort: votes


text:
Reverting Arduino Environment on OS X
I am using Arduino environment 1.6.17 on OS X, 10.12.2. In this version, all of the core avr library stuff is located in ~/Library/Arduino15.
I was told by a vendor that in order for their program to compile properly, I needed to compile it under 1.6.4 of the Arduino environment. I dowloaded that version and compiled the program again. I could tell though, by the compiler messages, that while the IDE may be version 1.6.4, the program was still compiling with version 1.6.17 tools and avr libraries. Is there anyway to change that so I can get it to actually compile with all tools and libs from 1.6.4?

Send the product back for a refund if the vendor isn't going to provide proper support. Arduino IDE 1.6.4 is outdated and it would take very little effort for the vendor to make it compatible with current versions.

I didn't try the total removal of the environment and then a re-installation as JRobert suggested, because I didn't really want to nuke my current environment. But his post did inspire me to try and run the 1.6.4 environment from another user account that had never run any Arduino stuff before. This seemed functionally equivalent to his or her suggestion. That seemed to work. Although, I still have a feeling that there is a more convenient solution out there.

You can be selective about the files you allow an app remover to delete. If you've modified your Preferences.txt, for example, don't delete it, and/or pull a copy of it aside somewhere for safety. But you're on the right track - something isn't being down-graded that needs to be, when you install the older version.

Try removing the Arduino app with AppCleaner or a similar application remover. AppCleaner should find any related files not contained within the app. Let it remove them. Then reinstall Arduino 1.6.4.

When you run a recent-ish version of the Arduino IDE, it installs stuff in ~/Library/Arduino15, unless it already exists. So when you installed 1.6.4, it saw the ~/Library/Arduino15 folder and proceeded without installing its own version of the tools.
The only way to have your 1.6.4 running alongside a newer version is to have copies of the ~/Library/Arduino15 folder, by renaming them when appropriate.

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


text:
Using multiple HC-SR04: sharing trigger pin and interference between HC-SR04
If I have four HC-SR04 detectors, can they share the same trigger pin on the Arduino?  This would reduce the number of pins needed from eight to five.
Even if they can share the same trigger, maybe this doesn't make sense because the emitted signal from one HC-SR04 will give a false reading to the others.  If this will occur, how much time should the sketch pause before triggering/reading the next HC-SR04?
Thanks.

No, you can't really share the same trigger pin, for the reasons you have already worked out. You can, though, share the same echo pin, since you know which HC-SR04 has been activated by the trigger.
To do that you will need a "wired or" circuit. The simplest method is a diode per ECHO signal and a pull-down resistor:

simulate this circuit – Schematic created using CircuitLab

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


text:
How should I initialize a RepRap Discount 12864 on u8glib?
I was taking the advantage of an existing piece of hardware (RepRapDiscount Full Graphic Smart Controller) for my present project.
Here is a link for the RepRap wiki about the controller
#define LCD_PIN_SCLK   A4
#define LCD_PIN_MOSI   6
#define LCD_PIN_CS   8
U8GLIB_ST7920_128X64_1X u8g(A4,6,8, U8G_PIN_NONE);

But all I got is a blank screen with no light at all. What has happened?

I solved the problem myself. It turns out to be a problem of wrong pinouts.
My PCB of the project was originally designed for the LCD2004 counterpart, and I thought it was a drop-in replacement for 12864. But no, it's not.

This is the "Smart Adaptors". Notice that the orientation are 180 degree different.
If you have the same problem not lighting up a 12864 when switching from 2004, or vice versa. Check your orientation as above.
My solution will be crimping a different JTAG wire instead.

I had a similar issue with figuring out how to get the Zyltech.com RepRapDiscount Full Graphic Smart Controller (with their Mega 2560 clone) to work with u8glib. After some fiddling it looks like the correct settings for me were:
// SPI Com: SCK = en = 23, MOSI = rw = 17, CS = di = 16
U8GLIB_ST7920_128X64_1X u8g(23, 17, 16);


text:
Motion sensor large areas
I'm looking to build a motion sensor which detects if an object is in the monitored area. Doing some researched I found out that I can use PIR motion sensor for this but it seems the area it monitors is pretty small.
I need something that can monitor about 3 feet x 1 feet area. Is there something else that I can use for this?
My goal is to light up some LED lights when an object is detected in that area.
Thanks in advance.

What kind of object? What are its dimensions compared to the area it's in?  Is it an enclosed area or an unbounded area within a larger space?

I wanted to mount on my garage's ceiling and monitor when a car is in the monitored area

I would strongly suggest a ultrasonic ping sensor.  It is low cost (under $3 on E-Bay) and will give you an accurate reading.
Here is an example:
http://www.instructables.com/id/Ultrasonic-Garage-Parking-Assistant-with-Arduino/
I would use an Arduino Nano on e-by if you want to keep total cost under $5.

A standard PIR motion sensor will work fine.  It can monitor motion in a very room.  You just need to make sure the PIR sensor is far enough away.
Here is one article that states it should work up to 10 meters away.
https://www.mobotix.com/eng_US/Support/FAQ/Configuration2/What-is-the-range-of-the-PIR-Passive-Infrared-motion-detector
Note that the device that the PIR sensor is mounted on must be stationary.  It will not work on a robot of anything that is moving.

Also, note that the object sensed by the PIR must be hot, and that object must be moving, not stationary.  The PIR works by sensing changes in infra-red light between two overlapping fields of view. That's why you can sit in a room with a PIR and it's normally off. As soon as you stand up or otherwise move it'll activate.

It sounds like what you want is an ultrasonic distance ("ping") sensor over the area where the car is.
When the car isn't there it will measure the height of the garage (say 3m).  With the car there it will measure the distance from the ceiling to the top of the car (say 1.5m).
Ultrasonic sensors have a limit to their range.  The cheap ones are usually around 2m, so may not work for you, or you may get away with it if it will return "infinite" for anything outside its range, in which case anything that is not "infinite" will be something present under the sensor.

What's the coverage of a ping sensor? can it monitor specified area or it's just one straight line ?

It's roughly a straight line, but a car is a pretty large object - bigger than the 3' by 1' area you mention.  If it's there it'll be filling the area, so even with a 1µm wide laser as the sensor it'll still be present.

What if I wanted to monitor a specified area rather than a straight line ? 3' by 1' was something I specified so that it can be placed in the middle of the garage.

Pressure sensor under the floor? Array of ping sensors? Grid of infra-red beams intersecting the area? For these kind of things it can often be easier to sense an entry or exit to an area rather than the area itself.


text:
How to wirelessly communicate with I2C infrared thermometer
I've been getting involved with arduino recently as a means of improving a heating device which is quite small, a box about 15x10x5cm which I would like to rig with an MLX90614 infrared sensor.
The box is already "wired" with many small flexible tubes, so I would like to set up the sensor so that I can read from it wirelessly, to keep it from getting anymore complicated than it needs to be.
What would be the most compact way to set up a transceiver capable of I2C (ideally with arduino uno coding compatibility) and to then communicate with another arduino? (I already have an Uno to act as the base station)
The reason I mention that the device should be codable with Arduino is that the MLX90614 uses a communication protocol that is beyond my skill level and which I can only operate with open source code libraries for arduino.
I've been doing some research and the best thing I've found so far is the PanStamp, but I have never soldered before, and they are not in business at the moment.
Another limitation is size. I would prefer not to use another entire arduino Uno, with shield.
And of course low cost is a plus :)
So if any of you have worked on something like this before and you have a recommendation, it would be greatly appreciated.
-Ryan

I should also add that distance is not an issue. My datalogger/control unit will be only a few feet away

Why I2C in particular? The NRF24L01 gadgets which you can get for a dollar or so on eBay work well over short range, and there is a good library for it. It uses SPI, so you just need your SPI pins spare (basically pins 9 to 13 as it needs one more pin for chip enable).

I2C is needed to read temperature from the sensor, which would then be transmitted to another microcontroller which controls the heater at the AC mains. I was hoping there was a simple MCU with integrated RF that could handle I2C, but it does not look like this is the case, based on the severe lack of responses in here... I also think the nRF24l01 might be the best solution, but it just seems like a waste to buy an entire arduino uno or similar to act as the intermediary between the sensor and the RF module. Have you implemented these before? If so, did you have any problems with it?

So if any of you have worked on something like this before and you have a recommendation, it would be greatly appreciated.

See Solar powered Arduino - I used a standalone Atmega328P on a prototyping board for that. That used the NRF24L01 to send information (the current voltage in this case) to another Arduino.
For small and simple you could get an Arduino Nano or Arduino Pro Mini. The Pro Mini is around $US10, and is quite small.
They have the same processor (Atmega328P) so you can connect your I2C sensor to it, and the NRF24L01 as well.

I have never soldered before ...

I think you will have to do a little soldering, to connect up the sensor, and the transmitter, but soldering on connecting wires isn't too onerous.

That is a nicely implemented project. I see that the setup for the nRF24l01 is fairly simple. I may take up soldering for this project, but I am reluctant because I fear I am deviating from what I am paid to do, which is biology, and I have no workspace to solder. Perhaps I can find someone willing to help me. I recently found out about the ESP8266 has GPIO capabilities and could potentially handle the IR sensor, but again, this involves investing a lot more time, so i'll probably get a Pro Mini.

You can always take it home to do a bit of soldering. You can get a cheap soldering iron for $25 or so, and a small packet of solder. Spread newspapers over a table and hop to it. :)

haha ok sounds good. thanks for your help. I would give you some points but i can't yet.


text:
Showing chronometer on PC controlling the begining and end of time by Arduino
I'm really new on this Arduino thing, so I don't know whether what I'm gona ask is feasible or not.
I'd like to make a chronometer in the computer but the controlling button (beginning and end of count) not to be some computer key. So I was wandering if I could make a button controlled by the arduino - maybe via a piezoelectric element?
Besides the problem of not knowing what to use as a button, I don't really know if it's possible to make a graphical interface (i know how to programme in C, Python, ...) showing the numbers in the screen of the computer and the beginning and end of counting controlled by that button. Is this possible to do?
Thanks for any help to both questions!

Yes. Is there a particular reason you want to use a piezo rather than, say, a pushbutton?

Besides the problem of not knowing what to use as a button -- How about... a button...?

No, I just thought that with a piezo I could make a larger button (something like Buzz! game button - this is for a demonstration to use with kids)...
What about the interface with software? Where can I read about it?

You should clarify your question by telling us WHAT should trigger the start and stop: human finger (then any push button is suitable), light detection, presence detection... Voting to close the question until clarification is provided.

Yes, the human finger is the right answer. Like I said, it's somehting like Buzz! game button - this is to use for a demonstration with kids where they have to start and end the counting.

It's perfectly possible to do, and the way I would probably do it is to use one of the ATMega32U4 based Arduinos (such as the Arduino Leonardo or the somewhat smaller Arduino Micro) to act like a keyboard. A keyboard with just one key - your chosen button.
Then you program the computer to respond to the keycode the Arduino sends to start and stop the chronometer. You could even use an off the shelf chronometer program that starts and stops with a specific keypress and tell the Arduino to send that keypress. It would probably take about 5 minutes to write the software - if that.

Yes! That's exatcly the kind of think I want to do. My problem is just really how to make the connection between the Arduino software (I'm writing the code to programm Arduino via the official software provided in Arduino website) and the GUI - I will probably make the chronometer in Tkinter... Do you have any suggestion? Where can I read about that?

If you use an ATMega32U4 based Arduino and use Keyboard.print(...) there is no "connection" between the Arduino and your program. The PC just sees the Arduino as a keyboard and you just react to a keypress in your software. You could use the same software with any run of the mill keyboard too if you wanted.

I'm using Arduino Uno... Is it still possible to do so with this Arduino?

There are ways, but none of them very nice. For the Uno you are really limited to just a serial connection. There's millions of examples around showing you how to communicate through serial with a PC.

This simple communication cannot be done by the USB cable? Would it have to be through the serial?

The USB cable is the serial!!!

Oh yes. Okay. Then I'll read about serial communication. I wasn't aware of the existence of it. Like I said, I'm really new on this thing. Thanks.

I am already familiarized with the concept of serial communication. I can turn on/off LED via Serial Monitor.
I can also connect it with Python and I've made a small program that makes the LED blink - and this works perfectly.
However I now added a pushbutton to my circuit, so that when it is pressed, the blinking process is interrupted. But this is not working. My attempt was to send a Serial.print when the pushbutton is pressed with the message "Exiting\n".
Part of my Arduino code is:
if(digitalRead(BUTTON) == HIGH){
Serial.print("Exiting\n");
while(1){}
}

And part of my Python code is:
while True:
    arduino.write("Y")
    print arduino.readline()
    time.sleep(0.5)
    arduino.write("N")
    time.sleep(0.5)

    try:
       if arduino.readline() == 'Exiting\n':
          print arduino.readline()
          break
    except:
          print("nothing\n")

The problem is that when I run the program, it gets stucked in the line
if arduino.readline() == 'Exiting\n':

Any help?


text:
Reading PushButton status with pyserial
I'm trying to read the status of a PushButton with python via pyserial.
In the loop function of Arduino Uno I have this:
void loop() {

if(digitalRead(BUTTON) == HIGH){
Serial.print("E\n");
while(1){}
}

So, if my pushbutton is pressed, it will send this message "E" via serial and then it will enter in an infinite loop so that nothing else happens.
But I want to detect this message in the python code. So this is my python code:
import serial
import time

try:
   arduino = serial.Serial('/dev/ttyACM0', 9600)
except:
   print "Failed to connect on /dev/ttyACM0"

try:
   print arduino.readline()

   while True:
      if arduino.readline() == 'E':
        print("Detected!\n")

except:
   print ("Failed to read!")

The first print before the infinite While is working: it is printing in the ubuntu terminal "Program Initiated", which is a message that I'm sending in the void Setup function of Arduino.
Then, it gets stucked in the line:
 if arduino.readline() == 'E':

I mean, I press several times my pushbutton, and nothing is happening.
Any help?
Thanks!

Use arduino.read instead of arduino.readline

Isn't more secure to use readline() once I will end up my message with \n?

The string you are sending ("E\n") is not the same one you are checking for: 'E'.
You could, for example, strip newlines from the string:
if arduino.readline().strip() == 'E':

You're right! I thought that as I was using .readline (which stops reading with \n) it wouldn't be necessary to put it on. Thanks, now it's working - without using that strip thing. What does it do exactly?

strip() removes newlines and whitespace from the start and end of strings. I'm slightly surprised that readline() works at all if you're not sending newlines but OK if it does. Please feel free to accept the answer if it was helpful.


text:
How to change the topic_name string to PROGMEM?
I'm trying to save SRAM on my Arduino pro mini by going through some libraries. I've noticed that to use my Arduino as a ROS node the library stores the topic name and message type as constants.
class Publisher
{
public:
  Publisher( const char * topic_name, Msg * msg, int    endpoint=rosserial_msgs::TopicInfo::ID_PUBLISHER) :
    topic_(topic_name),
    msg_(msg),
    endpoint_(endpoint) {};

  int publish( const Msg * msg ) { return nh_->publish(id_, msg); };
  int getEndpointType(){ return endpoint_; }

  const char * topic_;
  Msg *msg_;
  // id_ and no_ are set by NodeHandle when we advertise
  int id_;
  NodeHandleBase_* nh_;

private:
  int endpoint_;
};

How can I store the constants to PROGMEM? Thank you

My take on this is that you cannot save more memory on topic-name nor msg parameters. Their memory usage is already optimized.
The const keyword in the constructor declaration Publisher( const char * topic_name, Msg * msg, ... just tells the compiler that the parameter won't be changed throughout their life cycle. But their values will be defined at run-time during object creation when you issue something like this:
Publisher pb = new Publisher("topic", "message", ...);

So, they cannot be put into flash memory if they are not there already. But if the strings you pass on to the constructor are already in flash, then you're already saving those bits of RAM.

Finally, I just wanted to warn you not to modify 3rd party lib code extensively without comprehensive testing, like you are trying to do. You'll start to get strange behavior in your code. The slightest and simplest of changes may have unforeseen consequences.


text:
Hall Effect Current Sensor Wiring
I need help with wiring this current sensor so that I can read the output voltage as an analogue input. - http://www.tamuracorp.com/clientuploads/pdfs/engineeringdocs/L03SXXXD15.pdf
This is how I have it wired right now -
1 - +15v
2 - 15v ground
3 - output to arduino
4 - arduino ground
This seemed simple but reviewing the wiring diagram again I have a hunch that this is not at all how I should be wiring this up.
Thanks

Are you planning to measure AC current?

Have you looked at the "Electrical connection diagram" in the datasheet?

Looking at the datasheet the output is +/- 4 volts, so this is not suitable to connect directly to the Arduino, because the input pin will not tolerate -4 V.
I am no Hall Effect sensor expert, but a quick search on Google showed another potential problem: If you are planning to measure AC current, and you try to sample the output on the Arduino, the reading will average out to zero (half of the time positive, half of the time negative).
What may help - and this is a bit of a guess - is to put a diode in series with the sensor output, oriented so that you only get the positive pulses. That is, the anode connected to the Hall Effect sensor, and the cathode (with the black line) on the Arduino side.
Then you probably want to smooth the voltage so you can read the average voltage with the ADC converter, rather than what it is at a particular millisecond. A low-pass filter will take an average, which you can then read with analogRead.
Something like this:

I made up that circuit driven by a signal generator (8 V peak to peak, i.e. +/- 4 V) and found a 400 mV drop over the diode using a 1N4148 normal diode, and a 160 mV drop using a BAT85 Schottky diode.
With a 3 V peak-to-peak signal the voltage drop with the Schottky diode reduced to 120 mV, so it wasn't totally linear.

As Majenko pointed out, there is a voltage drop over the diode. You can make a Precision Rectifier out of an op-amp and a few other parts, like this:

This avoids the problem of the voltage drop (put this in place of the diode in the earlier circuit).
If the signal is AC then the smoothing circuit I described above will only give you an average voltage, not a peak one. You may want to sample rapidly in order to find the peak values.

Don't forget you would have to compensate for the diode voltage drop.

Good point. You could get a diode with a smallish voltage drop, like a Schottky.

To read the sensor properly you have to convert the output signal into something the Arduino can work with.
At full current the output will swing between +4V and -4V, and over-current will cause that to be nearer +6V to -6V.  The frequency of that swing will be the frequency of the input voltage - so typically 50 or 60Hz.
The Arduino can only read between 0V and 5V, so you will need to convert the provided voltage to fit.
You need to first reduce the voltage by about a half, so it fits into +/- 2V, and then you need to add a 2.5V offset voltage to it so that it swings between 0.5V and 4.5V.
Once you have done that you then need to sample the incoming signal fast enough that you can get the peak values, from which you can then calculate the incoming current.
Often for this kind of thing you would use a simple voltage divider with an offset voltage applied to it, but the output impedance of the sensor (set by RL) is 10KΩ which is around the upper limit for the input impedance of the Arduino's input.  A voltage divider that wouldn't adversely affect the output accuracy would be using resistors in the order of 1MΩ, which would be way too high for the ADC on the Arduino to be able to sample accurately.
So you need to buffer the signal with a high impedance buffer.  That can be achieved most simply with an inverting op-amp circuit with a gain of 0.5.  You want a rail-to-rail op-amp which is capable of running from a single supply voltage.

In this circuit the output current is converted into a voltage by the 10KΩ resistor RL.  It is then AC coupled to the rest of the circuit through C1 which has to be high enough in value as to not reject the frequency you are working with (it acts like a high-pass filter).  R1 and R2 set the gain of 50/100, or 1/2, so the voltage is halved.  R3 and R4 form a voltage divider to provide a VCC/2 offset voltage into the non-inverting input of the op-amp.  This is known as the virtual ground voltage and is the voltage the output of the op-amp will swing around.
The result is the input voltage inverted, halved and off-set by 2.5V, which can be read directly by the Arduino's ADC.
Note the magic word inverted there, though.  The values you read will be upside down.  Anything read above 512 from the ADC will equate to a negative voltage.  Anything read below 512 will be a positive voltage.  So it is necessary to first "invert" the reading, which can simply be done by subtracting it from 1023.
Then it's just a matter of sampling often enough and recording the peak (and negative peak) values over a short period.  The faster you can sample the better your results will be.
From those peak values you can then do all sorts of calculations and things.  You can use them "as is" to directly give you the "peak-to-peak" current, or calculate the RMS voltage to then give you the RMS current.

Why are you AC coupling?

I withdraw the question. I made up your circuit, and without the AC coupling it didn't work properly (it was biased too high and the positive output was clipped). I like your solution, Majenko, it gives a nice clean output signal without needing diodes.

You need the capacitor for the AC coupling to separate out the two ground levels - the 0V for the sensor and the 2.5V offset for the op-amp.  As you saw, if you don't have it the inverting input is pulled too low by the sensor's ground point and the output has to raise itself much higher to try and compensate (the output, through the feedback, tries to keep the inverting input at the same level as the non-inverting input), which results in the output being offset and clipped.


text:
Burning Arduino Leonardo Bootloader to ATmega32U4 with 8MHz internal clock
Burning question:
So, I'm trying to burn the Arduino Leo bootloader onto a ATmega32U4 that's on 3.3V and the internal 8MHz clock.  Do I have to modify and rebuild the bootloader to set the fuses correctly, and can this be done with AVR Studio?
All of the references on doing this are dated.  The folder structure for the Arduino IDE has changed. I've done it in the past with 5V 16MHz 32U4s using an Arduino as ISP, but never with the AVRISP mkII on the Arduino IDE.
On the good side, I do have it up and running with Atmel Studio.
Thanks!

Are you planning to run the ATmega32U4 at 8 MHz?

Yes I am.  I have both the RC version and the non-RC with an external 8MHz xtal.

Update: So I have tried several different methods, each with their own issues. The latest was to use the AVR ISP mkII on a Mac, as there are driver problems with Windows. It seems to have burnt the Lilypad USB bootloader on, but when I plug in the USB, nothing shows up on my PC. This is quite the rabit hole for something I thought was going to be trivial.

Where did you get this Lilypad USB bootloader? The Lilypad has an Atmega328V and no USB interface.

@NickGammon link The bootloader is in the Arduino folder hardware > arduino > avr > bootloaders > caterina-LilyPadUSB.

Further Update: for anyone reading with a similar issue, I was finally able to burn the bootloader using the AVR ISP mkII on a Mac OS. On windows, the mkII tries to install it's own USB driver that doesn't work with Arduino IDE.

If you have an appropriate crystal attached then you can do this in the Arduino IDE. Select your board and programmer in the IDE menu, connect the programmer to the board, and choose Burn Bootloader from the menu. This will both burn the prebuilt bootloader image and set the fuses in a single operation.
Note that you cannot use USB on the '32U4 if you are running off either a ceramic resonator or the internal oscillator, and so you should not attempt to use the Leonardo bootloader in either case.


text:
Powering multiple Arduino shields
To start, I am a software guy, so I am not too clued up on the electronics side of things. My question is: I have a number of Arduino shields and would like to power them with a portable power source, and therefore would like some advice on what to use without frying any electronics.
This is a list of the current equipment that will require power:

Arduino Mega 2560
SIM900 GPRS/GSM Shield
Sparkfun GPS Logger Shield
Sparkfun Wifi Shield - ESP8266

The shields will be stacked on top of each other.

Further links as I could not post them in the main question:
Arduino Mega,
SIM900

All the shields are 5v compatible. So no need to worry about 3.3v.
But there may be a chance of insufficient current if you use a battery to the power-jack of arduino mega (due to the internal voltage regulator). I'd suggest you cut a USB cable and solder the +5(red color) wire to VIN on the mega and ground(black wire) to GND pin. And use a 'power bank', which is used for mobile phones.

So I can simply attach a USB's red to the VIN and black to the GND, and then using any mobile phone power bank will provide enough current and voltage for all of the shields?
Wow, that seems super straightforward!

What do you mean interface one shield at a time?

@Calco Check your output rating of the mobile power pack you want to use. Some of them are limited to 500mA, you need enough current to supply all your boards in their respective worst case scenarios

DON'T CONNECT A 5V SUPPLY TO VIN - Vin goes through the 5V regulator - you will end up with about 4V instead of 5V. Instead connect the 5V supply direct to the 5V pin of the Arduino.

Ok, 5V pin NOT VIN! To confirm, if I picked up a product such as this, which says a 2.1A output current. My components list a maximum potential current draw of somewhere around 1500mA (SIM900: 500mA, GPS: 50mA, Wifi: 500mA, Arduino Mega: ?mA). So that gives me around 600mA spare, right?

Be careful relying on the color of the wire in a USB cable. Not every cable manufacturer follows this "standard" of colors.

Your stack will need quite a lot of current - most probably more than the Arduino can supply itself.
You will need to provide your own regulated 5V supply - either from a USB port (convenient if you are by a computer) - as long as it can supply more than 500mA of current (you need a Charging Downstream Port CDP for that) or from some external regulated 5V power supply, such as a mobile phone charger.
That 5V supply should be connected direct to the 5V pin of the Arduino's power header.
One thing to note: the headers themselves are only rated for up to 1A. If you need more than 1A throughout the entire stack it could be worth connecting the 5V power supply direct to the 5V pins of ALL the shields in the stack. Also do the same with the GND pins to the negative of the power supply. That way the high current doesn't need to flow through the pins themselves.

Yes.. Mjanco is right. Connect supply to 5V pin


text:
Arduino Nano stuck on uploading
I recently bought an Arduino Nano ( a clone actually), I installed the CH340G drivers for it and got it working perfectly fine... Played around with it for a while and then kept it aside...
Now after sometime I get time to play with it again, I was actually trying to power it with my 11.1V 2200mAh 8C LiPo battery. So I plug the JST connector to the Vin and GND pin and the LED doesn't light up. I noticed that I had plugged it in the wrong way and I immediately unplugged it. Next I make another attempt and this time I plugged the pins entirely somewhere else, again I disconnect quickly. The third time I connect it properly and the power LED lights up (phew...)
Now I move on to my computer to program it but the Arduino IDE is stuck at uploading. It was working fine before, when I hit upload, the RX LED glows VERY dimly and the board just stays like that. Only the power LED glows up, not even the LED on pin 13 glows up.
Uploading to a UNO works perfectly fine.
This is the error I get after a while-

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

Did I burn my board? Or is it just a bootloader issue?

So I plug the JST connector to the Vin and GND pin and the LED doesn't light up. I noticed that I had plugged it in the wrong way and I immediately unplugged it. Next I make another attempt and this time I plugged the pins entirely somewhere else, again I disconnect quickly. The third time I connect it properly and the power LED lights up (phew...)

Unfortunately Vin on an Arduino Nano does not have a reverse polarity protection diode such as the Arduino Uno PWRin

Did I burn my board?

Very probable. For more details please see "10 Ways to Destroy an Arduino".
Cheers!

that's not at all good... Now I'm gonna have to run around with a UNO strapped to my wrist instead of the Nano

It's unfortunate and I guess not the answer you where looking for. Please leave the question open if you need further answers or mark as answered.

I guess you've already answered the main point of the question so.. I'll mark it as answered.


text:
Sketch not running as expected
I wrote this sketch along with an HC - SR 04 Ultrasonic transducer and a DC motor. Whenever the HC-SR 04 reads any distance less than 15 cm, the motor stops, otherwise it keeps running.
The problem is whenever I upload the sketch, the motor runs for a short while and stops. Then when I open my serial monitor, the motor runs until an object crosses the 15 cm threshold and stops right after the limit is crossed. But when I again put the object outside of the 15 cm range, the motor should start running again, but it doesn't.
I am using a this motor driver and a simple DC motor(12V).
Here's the code-
int trigPin1 = A0;
int echoPin1 = A1;
int distance1 = 0;
int E1 = 10;
int brake1 = 7;

void setup() {
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(brake1, OUTPUT);
  pinMode (E1, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  analogWrite(E1, 153);
  distance1 = getDistance(trigPin1, echoPin1);
  printDistance(1, distance1);
  delay(250);
  if(distance1 <=15){
    digitalWrite(brake1, HIGH);
  }
  else{
    analogWrite(E1, 153);
  }

}

int getDistance (int initPin, int echoPin) {
  digitalWrite(initPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(initPin, LOW);
  long pulseTime = pulseIn(echoPin, HIGH);
  int distance = pulseTime / 58.2;
  return distance;
}

void printDistance(int id, int dist) {

  Serial.print(id);
  if (dist >= 120 || dist <= 0 ) {
  Serial.println(" Out of range");
  }
  else{
   Serial.print("\t");
   Serial.print(dist);
   Serial.println(" cm");
}
}

What mistake am I doing? Moreover I am currently running it with one motor, I'll add another later on along with more sensors, so the motors are controlled by the left or right sensor. How do I make my code work with them?
Thanks...

It was too damn simple...
I just had to add a line inside the else block in the loop function.
digitalWrite(brake1, LOW);

This was happening because the first time the threshold limit was crossed the brake1 pin was left HIGH and was never set to LOW again, which caused a permanent brake in the motor.
I'm too damn stupid. But I still don't have any idea how will I use this code with multiple sensors and motors.


text:
Stop time in Tkinter Stopwatch with a PushButton
So, my main goal is to make a stopwatch with Tkinter, in which time is stoppped with an external pushbutton
My void loop function in Arduino Uno is
void loop() {

if(digitalRead(BUTTON) == HIGH){
    Serial.print("E\n");
digitalWrite(LED, HIGH);

while(1){

 if(digitalRead(BUTTON) == HIGH){
  continue;
  }

if(digitalRead(BUTTON) == LOW){
break;}

        }
                               }

}
Basically, whenever the pushbutton is pressed I send via serial the message "E\n" and the arduino enters in an infinte loop that only breaks when the pushbutton stops being pressed (to avoid sending more than one message).
Then I have my Python code that reads the serial through the serial.readline() function.
Part of my Python code is (remember that i'm making a stopwatch and time is appearing in the screen - variable timer[i] is what saves the second and the ms):
def update_timeText():
    if (state):
       global timer
       # Every time this function is called,
       # it increments 1/100 of a second
       timer[1] += 1

      # Every 100 centisecond is equal to 1 second
       if (timer[1] >= 100):
           timer[1] = 0
           timer[0] += 1

       if arduino.readline() == 'E\n':
           print("FLAG\n")

       # TIME STRING
       timeString = pattern.format(timer[0], timer[1])

       # UPTADE THE LABEL WITH TIME STRING
       timeText.configure(text=timeString)

   # Call the update_timeText() function after 1 centisecond
   root.after(10, update_timeText)

The variable state goes True whenever I start the stopwatch (via a Tkinter button, but that's irrelevant for this case).
My problem, is that the program stops in the line
if arduino.readline() == 'E\n':

i.e., it only continues if I press the pushbutton. What I think that is happening, is that the .readline() continues waiting and waiting until it receives the message 'E\n'... I've tried with the .readline.strip() and also only .read() but none of them worked.
It is though very strange, because if the condition in front of If is not verified, it should just continue...
Any suggestion?

It looks like your 'readline()method blocks.  You need a non-blocking version.  It's a Python question, not an Arduino question, but if you edit into your question the Python library you are using (what is yourarduino` object?) I'll try to help.

In the pyserial docs it states this:

Be careful when using readline(). Do specify a timeout when opening the serial port otherwise it could block forever if no newline character is received. Also note that readlines() only works with a timeout. readlines() depends on having a timeout and interprets that as EOF (end of file). It raises an exception if the port is not opened correctly.

You need to specify the timeout and the end of line string. Try using this  modified line:
if arduino.readline(eol='\n') == 'E\n':

Also, add the timeout option where you define arduino as a pyserial object. For example:
arduino = pyserial.serial(port,baud,timeout=t,etc...)


text:
Customize FTDI driver for custom PID and VID
I have changed PID and VID of my FTDI board for  arduino program because i wanted to rename the com port name.
The ic is  FT232R a USB to serial UART interface IC. I have store new vid and pid to EEPROM.
Now It is showing in unknown devices. I am not able to update driver of it.
I have followed this article http://forum.arduino.cc/index.php?topic=6929.0.
Can anyone tell how to make cutmoize driver for it.
Any suggestions will be very helpful.

Most likely you want to edit the .inf file to add new VID/PID options.

Thank you for a  valuable reply. I have change in inf but i am not able to install it.Would you tell me after changing inf file how to install it.

You may need to go through the convoluted "Update Driver" route in the device manager. It's not a nice method. You may need to (somehow) uninstall the old driver so that it will pick up the new one.

@Majenko Windows is saying the new driver is corrupted.

I have installed the customize driver to windows but forcefully because to driver signature issue. How to get it solve.

On Windows
You can refer to FTDI's documentation here for details on how to create your own custom device driver. The FTDI website has a lot of resources for this, however they seem to be a little outdated. Microsoft details how drivers work in it's Hardware Dev Center.
On Linux
On Linux it may be as easy as registering the device with modprobe. For example, for a device with a VID of 0102 and a PID of 1234, execute the following from the shell:
modprobe ftdi_sio
echo "0102 1234" | sudo tee /sys/module/ftdi_sio/drivers/usb-serial\:ftdi_sio/new_id > /dev/null

You can do it, but you cannot change the PID and VID without a new certificate.
Did you changed the name with the FT-Prog Tool (MProg is outdated)?
You can download the last version from here:
https://www.ftdichip.com/Support/Utilities.htm#FT_PROG
You can set everything on your FTDI chip, even change the PID and VID. But at this point, you will not be able to use the standard FTDI driver anymore as you need to sign it with a new certificate (it is about 400$/year).
What you can do is leave the PID and VID and just give another name. So you will be able to use the default driver and you will see your custom name in the device manager.
Of course, in the list you just see "USB Serial Port (COM X)". But in the description of the device (Serial port), you will find this string:
FTDIBUS\VID_0403+PID_6011+YOURCUSTOMNAME&1\0000
If you create an application, you can just check for this, to see if it is your module. If you want more, you have to develop and release your own driver. But you can't do it anymore without a certificate, or without start Windows in unprotected mode.

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


text:
Powering leds from arduino with adapter
Sorry for having (again) a beginners question, but I was wondering something.
If I would want to drive like 20-30 LEDs from an Arduino (Uno), and I want to use an external adapter (12V, 1A), going into the Arduino, in what way I should drive the LEDs?
Problems I see:

I cannot connect too many LEDs per pin (max 20mA per pin)
I cannot connect too many LEDs per 'group' (I have to find out which pins are connected to what groups)
I cannot connect too many LEDS in total because of the max. 200 mA per VCC/GND (there are 2 or 3 GNDs, so that should be ok)
Using a relay/transistor etc, but how do I get the power? (there are also only 2 VCCs for 200 mA max)

So my basic question: how can I use the 1A from my adapter?

How precisely do you want to control the LEDs?

Have you considered using a driver that works with 12V?

I just read about a darlington IC (ULN8023) ... so probably that's the best way to do ... but I haven't found yet how to connect the 12V 1A adapter (I mean it will go into the Arduino), but how to connect / get that power to the LED ' chains' ?

Using relay module if you don't want to controle every single led could be a good aproach like this one - http://arduinobasics.blogspot.com.br/2014/09/relay-module.html

@AndrewPaes Well I don't need to control them one by one, but I want to have quite some possibilities, so a relay is a bit annoying to use in this case. I would need many.

drive each control group with an n-chan mosfet disconnecting the ground; cheaper than relays and silent. be prepared to use resistors to balance R,G, and B LED's "brightness"

@Majenko ... I'm thinking about a ULN8023 ... can I use the VIn to power the LEDs (and having 12V, 1A, or a bit less) ?

@IgnacioVazquez-Abrams I just found out about the  ULN8023 (can I use the VIn to power the LEDs (and having 12V, 1A, or a bit less) ?

I don't mean what hardware you think you want to use - I mean what do you want the LEDs to do?

@Majenko ... I want for Christmas to make some wooden small '2D'  cardboard tree, put LEDs in it, and making the LEDs go around, or flash on/off in groups, maybe add some Christmas tune along

Do you want individual control of each and every LED? Or will having, say, 6 groups of LEDs that all react together be sufficient?

@Majenko ... initially I had the plan to control every LED, but I don't want it to become a too complicated project (I would have to use 74HC595 probably), so I stick with like 6 groups or so.

@Downvoter: Please say what can be improved (this also applies to all my other answers you downvoted).

The simplest thing you can do is group the LEDs together into chains that almost add up to the voltage of the power supply.
If you have LEDs with a 2V forward voltage (typical red LEDs) you could have up to say 5 per chain.
Each chain, since it only has 20mA or so maximum, can be driven with a simple small transistor.

simulate this circuit – Schematic created using CircuitLab
Connect the 12V to either VIN or the barrel jack, and also drive the LED chain through a suitable resistor (R=V/I = (12 - (Num LEDs * Forward Voltage)) / 0.02). You can have as many chains as your supply can provide current for.

That sounds good ... would it be useful to use the ULN8023 (instead of the transistors)?

(and where does the maximum of 20mA per chain comes from? I would say 20 mA (per LED) * 5 LEDs = 100 mA)

Being darlingtons you get a larger voltage drop than just a transistor. You may not get it quite as bright. Other than that, it could be a convenient way of reducing component count (a chip instead of transistors)

Components in series have the same current but sum the voltages. Components in parallel have the same voltage but sum the current. The LEDs are in series, so they share the same current - 20mA, but sum their voltage - 2V each is 10V, leaving 2V for the transistor and the resistor.

Oh off course (now I feel really stupid).


text:
Is this (loose) capacitor critical?
I have a Arduino Mega where a capacitor is 'broken off' ... I originally posted the question in the Electronics forum (Question).
One of the answers was that the capacitor is not critical. Can anyone confirm it (and consequences by not fixing it at all)? I didn't dare to turn on the Mega because of the broken capacitor.
It looks like this:

You should probably leave the question on EESE where you originally asked it.  You'll get far more credible circuit engineering advice there than here.

Ok ... I thought it would be more Arduino related.

@KingDuken - it's not a question about using an Arduino as a "product", rather it's a question about the detailed requirements of a particular regulator circuit.  So it really belongs on EESE, not here.  Additionally, this is effectively a cross-site duplicate, something that isn't allowed.

@Downvoter, can you instead of downvoting all my posts, explain WHY you downvoted, so I may improve the post.

If the voltage regulator is a MC33269 as in the official Arduino Mega 2560, then you need that capacitor, or else the MC33269 might start to oscillate. Search in the datasheet of the MC33269 for the paragraph with: "The MC33269 requires an external output capacitor for stability". The board will probably still work without it, but if it does indeed start to oscillate, then it can cause trouble. This is only when powered via the power barrel jack or the VIN pin.
That capacitor does not do a lot when the Arduino Mega is powered via the USB cable. You can use it without any problem when powered via the USB.
According to the photo, you can solder it back into place. They wrote enough about that in the EESE section. Give it a try, but don't create a shortcut with too much solder.

Thanks ... eventually I want to use a Mega it with a barrel jack, but I will keep this one for only USB purposes (that's fine for me). I will get a replacement anyway and having a 'test' Mega is always convenient.

Good. What about moving over to 3.3V faster processors ? Like the Arduino Due and Arduino Zero or M0 ?

I don't understand your remark ... why would I move to 3.3V faster processors? Actually I would like, but I don't want to put all 'new' things in at once (I already am new to Arduino Uno, electronics in general, RF, microcrontrollers, opto-couplers, (S)RAM etc).

Well, the Uno and Mega are still very useful, but they are slowly fading out in the coming years. It is moving towards 3.3V processors with more memory. Most sensors are 3.3V and a SD memory card is 3.3V and so on. The Raspberry Pi is also 3.3V.

I already found out that ... I ordered 23LC1024 (128 KB SRAMs) which work on +5 V but +3.3 V is easier too find, and for my RFs (nRF24L01s) I bought breakout boards for +5 -> 3.3 V (same as for WIFI which I just bought for trying).
But I don't feel confident (yet) to use directly 3.3V directly. And for SD I bought an entire shield since the cheap 'breakout' board did not work that well (maybe for the same reason)


text:
Why using a ESP01 adapter?
I bought an ESP-01 adapter (initially I thought this was the WIFI module):
ESP-01 adapter
Than I bought the 'real'  ESP-01 (which is not arrived yet):
ESP-01
However, according to this link: connect (sorry it's in Dutch), but the picture shows that the ESP-01 is directly connected to the 3.3V of the Arduino.
My question: why bother using the adapter card? Or does it give additional security/protection (and what)?

Using an ESP8266 with a traditional Arduino requires logic level translation of the UART signal. That is what this adaptor provides. It also provides a dedicated 5V -> 3.3V voltage regulator so you don't stress the Arduino's rather underpowered 3.3V regulator.
The two SOT-23 components are N-channel MOSFETs (probably BSS138P or similar), and the SOT-89 component is the voltage regulator.
Yes, you can provide all that yourself, to varying levels of complexity - this just makes things easier. And since you already have it you may as well make use of it.

Thank you very much ... I assume with logic level translation you mean also a 5V-3.3V translation (but for the data?) ... I will start using both than ... but eventually I will need more (thanks to your good idea to use multiple Arduinos).

Yes, the logic level translation converts the 5V TX from the Arduino into the 3.3V RX of the ESP8266, and the 3.3V TX of the ESP8266 into a 5V RX to the Arduino (the latter is not strictly needed, but helps to improve noise immunity).

Ah thanks .. and that probably explains also why sometimes I read RX needs to be connected to TX and vice versa instead of RX<->RX and TX<->TX

You connect RX->RX and TX->TX if you are using the Arduino as a UART interface (disabling the ATMeag328P by holding reset LOW or physically removing the chip). Otherwise you connect RX to TX and TX to RX (the Arduino pins in this latter case are usually chosen by you and used with SoftwareSerial since the UART pins are used by your USB connection).

Are software pins (meaning non RX and TX on Arduino) fast enough for WIFI speeds (like Mb/s), using software serial?

Mbps? No. But then neither is the ESP8266 - it usually runs no faster than 115200 baud. If you want high speed communication like that then you need a PC.

Ok ... I think 115kbps is enough, just wondering how much I lose if I use software serial ... but I will test it when I have the ESP-01 :-)

What is it you are hoping to do with it?

For two reasons actually: 1) make a PC application to send information to an Arduino ... this is not time critical (max 128 KB to be sent). 2) sending information between multiple Arduinos, close together (like 1 meter approximately), not much data, but time critical (sending information back and forth within preferably 1 ms, size like 5-25 bytes average).

How are you thinking of getting the Arduino to process the 128KB of data? No "normal" Arduino can store that much information for processing.

The 128 KB will be put into a 23LC1024 SRAM ... (I already tested it by copying it from an SD card). To prevent every Arduino to have its own 128KB I want to make one ' controller' Arduino with 128KB SRAM and the other Arduino's send/receive (processed) messages using that 128KB

Ok, that's fine then. As long as you have that covered. You'll have to "chunk up" your transfer, of course, into a number of smaller requests for the Arduino to process.

Yes the requests will be around 5-25 bytes .. for SysEx messages I might need more, but those will not be time critical (and need to be chunked up. My biggest worry is the speed for the small messages, but if that doesn't work I can use RS232 connector/cables (but WIFI is more convenient, although the distance is very small). RF is another option but I need a lot of extra items (receiver/transmitter), IR is impossible (line of sight).

you won't get 1ms times with wifi. i think my best half-legs are about 15ms. this is due to http overhead

@dandavis thanks for this info ... that means wifi is not possible (back for analysing a wired connection probably).

Unless you program the ESP8266 module(s) directly and get them to talk MIDI directly from their UART pins - then use UDP to transfer datagrams at much higher speed and lower latency.

Hmm, the adapter I got only has a single ceramic disc capacitor, none of the other stuff.  It also has eight pins instead of four, so it's barely anything at all. I guess you really have to be careful when ordering from Chinese sellers on eBay.

The anonymous downvoter strikes again.


text:
Can an arduino tell between being powered by USB or by the jack?
I have an arduino mega that will be communicating through serial to a pc. One of the things I want it to tell the pc is whether or not it is connected to a wall power to 12V converter (where there is a switch between the arduino and the wall power). I was just wondering if there was a way to do that in software without having any additional hardware.
Thanks!

No, you can't do it without extra hardware.
You need to pass VIN through a voltage divider so it sits within 0-5V when powered by 12V, then feed that into an ADC input. Protect the on-board voltage regulator with a diode between 5V (anode) and VIN (cathode). Then you can measure the voltage on VIN and make a decision on if it is around 4.5V or 11.5V
A 22K/10K voltage divider will reduce 12V down to 3.75V, which gives plenty of "headroom" for over-voltage situations (where your 12V unregulated power supply actually provides, say, 15V):

I don't think the diode is needed. You say it is needed for protection. Are you sure the diode is needed?

Yes. Without it you will be drawing current backwards through the 5V voltage regulator when powered by USB. The diode bypasses the regulator when VIN is at a lower voltage (i.,e., not connected) than 5V.

Ah, oh well. Thanks for the hardware implementation too, at least its super simple!


text:
Possible reason for broken Uno
Yesterday I wrote in a comment that I didn't break much, except a LED and a LED matrix. However, exactly yesterday I think my Uno gave up, since I cannot upload a sketch anymore (timeouts). For the rest the board seems to work still ok.
I have two possible reasons, and would like to know what I can do to prevent this in future. I connected a 415 MHz RF transmitter and receiver to it, which are working.

To get more power I attached an adapter (12V), TOGETHER with the USB ... I thought always adapter power would be used, but it seems it is not a good idea to have both connected. Is this true?
The Uno was inside a case (with holes near the output pins). I know this causes some extra heat, but I would guess that adding just an RF receiver/transmitter would not cause the Uno to heat up more than allowed.

Which of these reasons is the possible cause ... or are there any other reasons I didn't think off. Everything worked fine until I plugged in the 12V adapter and it still worked for some time (until I tried to upload a new sketch).

It is a mistaken belief that powering an Arduino from an external power source increases the power available. It doesn't. All it does is increase the amount of heat produced.
Unless you are powering your Arduino from an unpowered hub you will have around 500mA available from the USB power. The 5V regulator, which converts the incoming 12V to 5V, can supply at best between 800mA and 1A on a good day. However with 12V the amount of heat generated will cause thermal shutdown at those kind of currents due to lack of proper heatsinking. So you can't get anywhere near 800mA out of it - instead you are limited to around the same as (or even less than) the USB power source can provide.
All that excess heat (and at 12V you are throwing away about 58% of your power as heat) in an enclosed case will have caused nasty things to happen - at the very least your regulator should have gone into thermal shutdown. Worst case scenario your voltage regulator failed (especially if it's a cheap version) which would end with one of two scenarios:

No power getting through to the rest of the board
More than 5V getting through to the rest of the board

If it's (1) it'd be obvious - nothing works. No LEDs light, etc. However if it's (2) then more nasty things will ensue. One common one is that the ATMega16U2 chip (the USB interface chip) if it's a genuine Arduino will be fried. You may find it's getting excessively hot itself now. Of course, if it's a clone then the CH340G will no doubt have given up what little ghost it had.

So if I'm understanding right, 12V  is normally not a good choice unless the power is really 'used' externally (by LEDs or power hungry parts)?
I read that using more power could improve the RF range (which it did, but not that much).
Also if I understand right, it's not a good idea to power an Arduino with an adapter in an enclosed cage? I think that's not very comfortable.
Too bad probably the Mega chip itself is probably ruined, that would be the only useful part being salvaged, since it was an original DIP-socketed chip.

Your bog standard Arduino Uno / Mega is not really good with external power and enclosed spaces, unless you only draw small currents. RF tends to be quite power hungry, especially when transmitting, which will drive up your current use and thus your heat. You are better bypassing the on-board regulator with a 5V buck regulator (e.g., a model vehicle "UBEC") which produces far less heat and can provide about 10x the current.

Thanks for that info .. however, it disappoints me, I don't hope I need multiple power sources for my Arduino/RF when using RF. I was hoping I could handle everything with either a USB cable OR 12V adapter. How should I bypass it? By powering the buck regulator completely out of the Arduino with it's own power supply? I never used a buck or UBEC regulator.

Why not just a 5V USB power supply (phone charger) plugged in to USB?

Hmm maybe that's better, I would expect they sell typical Arduino adapters with 5V  ... going to search for them, that seems like a good way.Btw, I don't have to use buck regulators when I use a 5V adapter?

A buck regulator is a 5V adaptor. Just not necessarily in a fancy case ;)

Ah ok ... but I think I rather go for a dedicated adapter, otherwise I would need two power sources, one for the Arduino and one for the RF, and I like to have them both in the same case (preferably with one power plug)

You should be OK as long as you use a 9 to 12 volt supply since there is an FET that disconnects the 5 volt USB power from the rest of the Arduino circuitry if VIN is greater than approximately 6.6 volts.
But... if your external voltage is less than 6.6 volts you may have a problem since both supplies will be powering the Arduino circuitry and they probably will not be providing exactly the same voltage.  If you get below the dropout voltage of the voltage regulator then you may have a bigger problem since the USB voltage will be backfeeding the voltage regulator.
There is a diode between the PWRIN connector and VIN so if you feed the Arduino from that connector the voltage will have to be greater than approximately 7.3 volts to activate the FET and anything less than 7.3 volts may cause the problems mentioned above.

It was a normal 12V adapter, specifically for Arduino ... so I guess that should be ok. Seems the case was the problem. Which makes me more worried, since I wouldn't expect so much heat.

this link may be useful for you:                                                        http://www.technobyte.org/2016/08/core-subsystems-arduino-uno-power-supply/                                                                will update you if i found any other solution to your case.

Thanks for this link! I will have to go through it slowly

go through the  link :https://www.rugged-circuits.com/10-ways-to-destroy-an-arduino/


text:
HX711 Load Cell application strange behaviour
I have an application where an HX711 ADC is used with 4 load cells. (in wheatstone bridge configuration, rated at 50kg each).
The thing is that I am trying to sense 30~ish gram changes with it accurately, while the cells will be loaded with 10 to 40 kilograms.
I have built up the circuitry and placements properly, calibrated and tested etc. but I have 2 questions that I couldn't come up with a solution.
1st question:
When powering arduino from USB cable the readings are much more stable (they are fluctuating like +-5 grams only) but when I connect a 12V power source (with 5A output) to the arduino, the readings start to fluctuate much more. (+-30 grams or so). The HX711 is powered from arduino 5v out pin but even though i tried to power it from a 5v adapter the fluctuations seemed to happen.
I should also note that the HX711 is connected to the analog pins A0 and A1, and there are 8 other sensors connected to the pwm pins of the arduino.
Now any ideas why does that happen? Any way to prevent this fluctuation?
2nd question:
If I calibrate with a load close to the max. weight (as suggested in many papers) the small changes seems to be very unreliable. If I calibrate it with a small weight (like around 200g) I can sense small weights properly but this time when a 2 kg weight is put it is read like 2.3kg or something. Is this normal?
I know that my load cells are not the proper ones for the application but I would like to push them as much as i can.
Thanks for your time

Try a few different adapters. Some generate very noisy power. Secondly, you could add multiple calibration points. Cause the output, as you noticed, is not linear.

I will try different sources and return an answer asap, thank you.

1) Put your power source on an oscilloscope and check it. I assume what's happening is you don't have a clean sine, and the power fluctuates, whereas power from a PC USB port is usually very well regulated. This may be causing issues in your sensor due to under/over voltage at a minuscule level.
2) Because you're pushing your sensors to the edge of their capabilities, you're going to have to work around them, so the normal scenario's don't really offer much help, as they are usually based on working within the middle ground of capabilities.
You said that factoring based on low load vs high load created unreliable  variances in your measurements, i would personally suggest calibrating not for max load, nor min load, but 2/3 of max, or 1/3 max, and see if that stabilizes you, or at least gets you somewhere to the middle of the road where your differences are nominal, or something you can live with.

Thank you for your comments and suggestions! I did not have an oscilloscope at hand, i had to assume the power source was working clean as it was somewhat commercial design but I guess i'll have to check it, it really seems to be the problem.


text:
Communicating Arduino with Intel Galileo
I'm doing a project where I have few sensors on Arduino Uno. Now I am trying to send some data to the internet where i figured using my GSM shield with the Galileo board I have is the best solution.
The problem I am facing is that software serial is not working on Galileo so I have to use the Serial1 of Galileo board (Pin 0 and Pin 1) and I am out of serial ports. I was thinking of using serial communication between Arduino and Galileo but Galileo seems to have only pin0 and pin1 as serial and they are occupied by the GSM shield.
Is there any part I am getting wrong or any suggestions?
(other than using the sensors on Galileo and getting rid of the Arduino Uno :) )

What is wrong with getting rid of the UNO and using only the Galileo?
It seems anyway the easier solution even from debugging perspective.

Well I am using some sensors that has AVR specific libraries and many complex codes depending to them which would be taking much time trying to migrate to Galileo.

You could use SPI/I2C as interface between Arduino and Galileo.
They are better than plain serial.

I have started using I2C as you suggested. Thank you!


text:
Why is my potentiometer giving strange reading?
I have a 10kOhm linear Potentiometer. I connected it to analog 0, as in https://www.arduino.cc/en/Tutorial/Potentiometer.
The analogRead() gives a value between 0 and 1023, so I was expecting 0 if the potentiometer is at the lowest position, 1023 if it is at the highest position and 500 somewhere in the middle.
In fact I get ~40 at the lowest position, I get 1021 at the highest position (that's okay, I guess), and I also get 1021 at the middle. 500 is at a 1/4 position, I expected to have ~255 there.
I measured the resistance of the potentiometer. It reads ~200 Ohm at the lowest postion, 10kOhm (as expected) at the highest position and ~5kOhm in the middle, so, exactly as I expected.
So, what did I get wrong?

What arduino are you using? It sounds a bit like you are using a 3.3v arduino, but connected the pot to 5v.

I am using an Arduino mega 2560.

I tried the 3.3V instead of the 5V, but I have the same effect. Good results in the lower 1/4 of the poti, no change as soon as I go higher up.

Does a DMM give correct resistance readings at various positions?

Take the multimeter and measure the voltages you see at the Arduino pin.

Note the comment by @Posipiet is a very important one - measure the voltage at the Arduino pin, with the potentiometer in circuit. Just to rule out the possibility of, say, a poor 5V or 0V connection or something similar. Also the 200 ohm value at lowest resistance is a bit suspect...

Please describe how you wired all contacts of the potentiometer, not only the wiper. And please check what happens if you exchange the wiring of the endpoints.

Exchanging the endpoint wires flips the values around, so, zero is the other end of the poti. However, the effect stays.

Measuring the voltages between 5V and A0 on the arduino gives the readings I would expect with a logarithmic potentiometer. However, measuring the resistance of the poti confirms that it is linear.

Unfortunately I cannot comment. I can't really think of a reason why your readings are the way they are. Though you did not present to us an image of what potentiometer you are using and how you are really wring it up.
It is possible that your potentiometer is a center tapped type with 4 pins. You could have possibly connected the positive rail to the center tap pin, ground to the side pin and the wiper pin to the Arduino pin so that you would have the result you are getting.
Or potentially, you wired it correctly except for the fact the positive rail you connected to was 10V, but that is really dangerous.
Have you tried measuring the resistance of the potentiometer from one side pin to the other side pin?

Well, not sure what was going on, but rotating the cables helped. So probably something was connected wrongly.

Do you mean as in swapping the cables?

Yes, but, looking more closely, it did not help.

@Alex measure the voltage of the wiper at different positions. Also make sure you are not using any other components in the circuit (except for Arduino and power supply). An image would help us greatly.

@Alex basically follow the suggestions in the comments under your question. They will lead you to solving your problem.

It sounds like you have a log taper potentiometer rather than a linear taper potentiometer.  These are used in audio applications.
You can tell the difference by looking at the resistance code.  It may be written as:

103 B

or

10K B

both of which are 10KΩ LOG taper.  The letter A or B as a suffix is the taper type. A is linear, and B is logarithmic.  That's the "normal" standard, though, but Japan does it differently. They use A for Audio taper (log taper) and B for linear.

That was my thought too, but the OP claims that he measured it to be 5K in the middle.

500 (50%) at a quarter turn says logarithmic to me.

oh, at quarter-turn. Yes, of course. I should have reread that part before referring to it :)

The interesting thing is: I did measure 5kOhm in the middle, which says linear. But I also read 500 at a quarter position, which says log. So, WTF!


text:
Adruino Yun's Linux environment not working
I was recently given an Arduino Yun board from my university. I am able to upload sketch to the board, and it seems to function properly. However, I am unable to see the Linux booting up. When I want to reset the WLAN, ressing the WLAN RST button does nothing at all, the WLAN LED doesn't even blink or light up. Pressing the YUN RST button also does nothing.
So I did some Googling and found out that I could upload the YunSerialTerminal to the Yun, so I did that. And when I am trying to monitor the Linux boot up from the serial monitor. Nothing is shown. I press the TUN RST button as taught by the Arduino website while monitoring the Serial Monitor, nothing shows. However, the RX button does blink whenever I press enter.
Can anybody help me?

You might need to re-flash the operating system. Unfortunately it's not a trivial task.
I had to do something similar with a Dragino shield (like a Yun on a shield) that uses the same OS and core chip. Instructions were scarce and hard to follow, plus I run Linux, so there's even less instructions. I worked it out, though, and wrote a tutorial here.
While that is for Linux and the Dragino shield I am sure the basic principles are the same for the Yun - just make sure you get the right image file for your Yun (don't get the Dragino one I link to).
The main thing is to gain access to the boot manager (dr-boot, or whatever the Yun has), which means setting up a wired (ethernet) network and messing with UDP sockets (using nc in Linux - no idea what you can use in Windows).
I'm sure you can find a tutorial for fixing the Yun from Windows (or whatever OS you use) to help you get into the boot manager and upload a new OS image.

Warning use version 1.5.3. When you download the latest version 1.6.2 you also need to update the bootloader.


text:
Arduino IDE/Visual Micro - Undefined reference to constructor
I am using Visual Studio Community 2015 with the newest version of the Visual Micro Arduino Plugin, however I also tried compiling my code in the Arduino IDE.
When compiling my code, there is the following error:
Compiling debug version of 'Autonomous_Car' for 'Arduino/Genuino Uno'
Autonomous_Car.cpp.o:In function `setup
Autonomous_Car.ino:undefined reference to `List<UpdateAble>  List()
Autonomous_Car.ino:undefined reference to `List<UpdateAble>  ~List()
collect2.exe*:error: ld returned 1 exit status
Error creating .elf

Some info

Adding #include "List.cpp" fixes the error, however this does not seem like valid C++.
The files do not lay in any sub-directory
In my Project Explorer both List.h and List.cpp are added to the project.
I also removed both files from the project, deleted them and added them again
I deleted the ´%AppData%\Local\Arduino15´ directory
I am fairly new to C++ and Arduino, there might be something obvious, what I just can't find

Autonomous_Car.ino
#include "List.h"
#include "UpdateAble.h"

void setup()
{
    List<UpdateAble>* myList = new List<UpdateAble>();
    myList->GetCount();

    delete myList;
}

List.h
#ifndef _LIST_h
#define _LIST_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif

template <class T>
class List {
public:
    void Add(T &item);
    bool Contains(T &item);
    bool Remove(T &item);
    void Clear();
    int IndexOf(T &item);
    T* GetItem(int index);

    inline int GetCount() { return count; };
    inline int GetCapacity() { return capacity; };

    List();
    ~List();
private:
    void EnsureCapacity(int capacity);

    int count;
    int capacity;
    T** items;
};

#endif

List.cpp
#include "List.h"

// Constructor
template <class T>
List<T>::List() {
    List::capacity = 4;
    List::count = 0;

    List::items = new T*[List::capacity];
}

// Cleanup
template <class T>
List<T>::~List() {
    delete[] List::items;
}

template <class T>
void List<T>::EnsureCapacity(int capacity) {
    if (List::capacity < capacity) {
        // Kapazität verdoppeln
        List::capacity = List::capacity * 2;

        // Speicher für neues array reservieren
        T** newArray = new T*[List::capacity];

        // Array kopieren
        for (unsigned int i = 0; i < List::count; i++) {
            newArray[i] = List::items[i];
        }

        // Speicher von alten array freigeben und neues array zuweisen
        delete[] List::items;
        List::items = newArray;
    }
}

// Adds a new item to the list
template <class T>
void List<T>::Add(T &item) {
    List::EnsureCapacity(count + 1);

    List::items[count] = item;
    List::count++;
}

// Gets whether the list contains an item or not
template <class T>
bool List<T>::Contains(T &item) {
    return List::IndexOf(item) != -1;
}

template <class T>
bool List<T>::Remove(T &item) {
    int index = List::IndexOf(item);

    // If the item does not exist, we cannot remove it
    if (index == -1) return false;

    // Move every item behind our item one further
    for (int i = index + 1; i < List::count; i++) {
        List::items[i - 1] = List::items[i];
    }

    List::count--;
}

// Release the heap
template <class T>
void List<T>::Clear() {
    for (int i = 0; i < List::count; i++) {
        delete List::items[i];
    }

    delete[] List::items;
}

// Gets an index of an item, -1 if not found
template <class T>
int List<T>::IndexOf(T &item) {
    for (int i = 0; i < List::count; i++) {
        if (List::items[i] == item) {
            return i;
        }
    }

    return -1;
}

template <class T>
T* List<T>::GetItem(int index) {
    if (index < List::count && index >= 0) {
        return List::items[index];
    }

    return 0;
}

I'd be very glad, if we can find the solution.

You're using a template class. A template class is a special corner case that breaks the "code in .cpp and definitions in .h files" rule.
Because it's a template it can't be pre-compiled - it needs to be specially compiled each time it is used, so that it can get the right values compiled in to the template place-holders, which are provided by the CU that has the template class included with it.
Because of that it is one of the rare cases where the code has to be in the header file.
For a full example you can take a look at my Average library which is a fully templated class.


text:
PubSubClient: Subscription working, but callback never called
I am using an ESP32 (https://heltec.org/project/wifi-kit-32/) with a AM2302 DHT22 and an LDR, talking to mosquitto on a Linux box.  Publishing data is working fine, other than the "exceeded timeout, disconnecting" lots of people seem to be having.  However, when a message is sent from another client to a topic I am subscribed to, my callback is never called, so I can't consume it.
In my reconnect function, I have
    boolean success = mqttClient.subscribe("sensors/basement/led");
    Serial.print("Subscribe returned ");
    Serial.println(success);

and it does return 1 which I believe is success (usually success is zero but I don't think that's the case here).  I also see the subscription in my mosquitto logs, which are currently cranked up to debug.
1610417274: New client connected from XXX.XXX.XXX.XXX as Basement1 (c1, k15, u'XXXXXXXXX').
1610417274: Sending CONNACK to Basement1 (0, 0)
1610417275: Received SUBSCRIBE from Basement1
1610417275:     sensors/basement/led (QoS 0)
1610417275: Basement1 0 sensors/basement/led
1610417275: Sending SUBACK to Basement1

When I send data to sensors/basement/led from the other client (mqttdash), the server receives it, and sends it to mqttdash, as well as Basement1, which is my ESP32:
It's definitely sending the message to the ESP32:
1610417546: mqttdash-3785c5ce 0 sensors/basement/led
1610417546: Sending SUBACK to mqttdash-3785c5ce
1610417578: Received PUBLISH from mqttdash-3785c5ce (d0, q0, r0, m0, 'sensors/basement/led', ... (1 bytes))
1610417578: Sending PUBLISH to Basement1 (d0, q0, r0, m0, 'sensors/basement/led', ... (1 bytes))
1610417578: Sending PUBLISH to mqttdash-3785c5ce (d0, q0, r0, m0, 'sensors/basement/led', ... (1 bytes))

However, my callback is never called.  Here is the setup of the callback:
WiFiClient espClient;
PubSubClient mqttClient(espClient);
...
void setupMQTT()
{
    mqttClient.setServer(MQTT_HOST, MQTT_PORT);
    mqttClient.setCallback(mqttSubHandler);
    mqttConnect();
}
...
void mqttSubHandler(char *topic, byte *message, unsigned int length)
{
    Serial.print("Message arrived on topic: '");
    Serial.print(topic);
    Serial.print("'. Message: ");
    String messageTemp;

    for (int i = 0; i < length; i++)
    {
        Serial.print((char)message[i]);
        messageTemp += (char)message[i];
    }
    Serial.println();
...

Full code at https://github.com/djsegfault/arduino/blob/master/basement_monitor/basement_monitor.ino
Does anyone know why the callback is not being called?  Thanks in advance.

nknolleary, the owner of the library, correctly identified the problem:
You need to call mqttClient.loop() in you main loop. Without that, you are never giving the client a chance to check for any incoming messages.


text:
Using the Logging library, sometimes doesn't exit setup()
This has been a hard problem to diagnose, so I hope I'm giving enough info here.  I'm trying to write a program for the Arduino (a lighting controller) using a bit of OO.  There are several classes in my library, and some extend others.  I'm a long-time programmer (mostly Java) but this is my first big Arduino project.
I'm using the Logging library at various points in the main program, as well as the objects, and that's where it get complicated.  Depending on where I put calls to the logging library, or even Serial.print(), it either all works, or what gets sent to the serial port is a bit garbled, and the board never enters loop() (I'm not sure if that means that it's crashing in setup() or not).  This library hasn't been touched in 4 years and there are pending merge requests, so I don't think I'll get answers from the developer.
I have a sneaking suspicion that the root of the problem is that Logging.h ends with instantiating the logger ("Logging Log = Logging();") so multiple instances of the logger may be created and the serial port is being reset several times, possibly at different port speeds.  I thought it was bad form to initialize object, or even have any running code, in a .h file.  Is this a possibility, and do I have any options to fix this?
Are there any good alternatives for printing outputs at different debug levels?
I would hate to have to pass the logger instance in as a parameter to my classes, or have to write setLogger() methods for all my classes.
Thanks.

Logging.h ends with instantiating the logger ("Logging Log = Logging();") so multiple instances of the logger may be created and the serial port is being reset several times, possibly at different port speeds.

I think you are mistaken, or have done something wrong with the library files.  Logging.cpp ends with the instantiation, not Logging.h.  Logging.h only has an extern reference to the instantiated object.
So some guesswork:
If you try and do anything with logging or serial access (or indeed anything more than just setting a few variables) within the constructors of your objects, and you instantiate those in the global scope, you won't have full access to the serial port - if any access at all.  You can only use the serial port once Serial.begin(...) has been executed in setup, and global constructors are executed before setup() is run.
It is for this precise reason that 99% of Arduino libraries have a .begin() method which does all the work a constructor would normally do. The constructor is only used (if at all) for storing some default settings (pin numbers, etc) that are used later on. That way you have full control over what gets executed and when.

Yup, I see that extern is used in Logging.h.  My bad, thanks.  I DO have a constructor that calls a setter method on another class, and I have a Log line in the setter method of that second class.  Maybe that's the problem.  Not sure how to get around that, since I do want debugging.  Maybe the answer is to create a .begin() method that does the same thing without the debugging.   Thanks again @Majenko

The constructor (called in a rather weird way) doesn't do anything, so I don't think that is the issue.
Logging.h:
    /*!
     * default Constructor
     */
    Logging(){} ;

Logging.cpp:
 Logging Log = Logging();

You should be calling Log.init(whatever) once in your code (as in the example). Are you doing that?
Please post a Minimal, Complete, and Verifiable example.
Without any posted code, we can only guess at what you are doing.

I thought it was bad form to initialize object, or even have any running code, in a .h file. Is this a possibility, and do I have any options to fix this?

That is not done in the library you linked to.

Any logging libraries that you recommend @nick-gammon? Asking because this one hasn't been updated in ~5 years. (looking for debug/info etc levels of logging to serial output)

Well, I did a bit of work on debugging using a second Arduino using SPI or I2C. That (fairly quickly) lets you output debug messages via another processor, which has minimal impact on the board under test (it depends a bit on whether you have I2C or SPI free). You could modify the function calls to take a log level conceivably. You might want to post this as a new question to get comments and suggestions from others.


text:
Saving library example sketch getting error "you cannot save a sketch into a folder inside itself.."
I'm writing a library, and that library .cpp/.h code is in devel/arduino/libraries/LightBrightLib/.  I have test code that calls that library, and an example program using the library.  Right now they're in /devel/arduino/lightbright/LightBrightMain/ and /devel/arduino/lightbright/LightBrightLibTest/.
I see most libraries have an examples directory inside the library, so I tried moving mine to /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/ and /devel/arduino/libraries/LightBrightLib/examples/LightBrightLibTest/
When I do that, and try to save my LightBrightMain.ino file into /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/, it says "You cannot save a sketch into a folder inside itself. This would go on forever.".  And of course it won't let me select the examples directory or any other directory above it.
How do other library makers do this?  Maybe they don't use the IDE, or they copy it in outside the IDE, or use symlinks?
What does the IDE think it's doing and why is it fighting putting the file where it already is?
NOTE: This is not a file permission problem as I own all files

What I normally do is make the examples in their own folders (ie. inside the sketchbook folder). Then when they are tested I just use the file system to move the folders into the "examples" folder under the library.

When I do that, and try to save my LightBrightMain.ino file into /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/,

The IDE makes the folder, so you would (if this works at all) save LightBrightMain into the examples folder. Don't make a folder of the same name as the sketch. The IDE does that.

I removed the directories under examples and tried that, and it worked. However...  when I modify it and try to save it, it says 'Some files are "read-only", so you'll need to re-save the sketch to another location'. Of course the files are NOT read only.

It always does that when you open an example file from the IDE. The idea is to stop you corrupting the example. Open them with an external editor if you want to tweak them, or move them somewhere else as required.

But this is MY example. OK I guess I need to give up. It's not possible using the IDE. Thanks


text:
Can an ATtiny print results to a console?
I'm trying to port some Arduino code that I wrote for the Arduino Mega to an ATtiny and I'm having trouble figuring out how to do output. Here is what I have:
char foo;
#include <SoftwareSerial.h>
const int rx=3;
const int tx=4;

SoftwareSerial mySerial(rx,tx);

void setup()
{
mySerial.begin(9600);
}

void loop() {
 if (mySerial.available()) {
   char data = mySerial.read();
   mySerial.write(data);
 }

 mySerial.println("hello");
}

To my understanding this should print "hello" to the console over and over again but for some reason it uploads successfully but then it doesn't do anything.
Here is the programmer that I am using to connect my ATtiny to my computer: https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/programming-in-arduino

One of the available tags for this forum is Arduino and the other it ATtiny. I don't see how it's not, but I'll copy it to the Arduino exchange if no one here knows the answer.

You need to open the serial monitor, the Arduino IDE's console only display message concerning the build and the upload status

@FortunaIwasaki check my other comment.

@MathieuL I won't be able to post another question for at least 40 minutes. Also I know about the little magnifying glass at the top right. I opened it and there was nothing there.

Which pins are you connecting the serial adapter to?

I'm using the ATtiny programmer to connect the ATtiny to my computer and to program it. I provided a link to the programmer I'm talking about at the bottom of my question.

You don't have any output because you don't have a serial adapter connected to the device. The programmer you have is only for programming and does not support a UART serial connection.

Right on point, that programmer don't have the usual ucontroller which manage the Virtual UART connection.

So in other words there is no way to deliver the output to my computer. Do you by any chance know what kind of serial adapter I can get to connect the ATtiny to my computer?

Any FTDI/PL2303/CH340G-based serial adapter should work. You should consider disconnecting the chip from the programmer before connecting it though.

@FortunaIwasaki You can transfer information to your PC with a UART to USB adapter.

Most ATtiny's do not have UART at all. So, probably, even with UART to USB adapter you would need to use some software UART.

This is writing serial data to digital pin 4. If you have a serial to USB converter attached to pins 3,4 and you have a terminal attached to said serial to USB converter, it will print to that terminal.
Also, on an ATtiny, you have to check which pins are pins 3,4. They are probably not the physical pins 3,4, and it is dependent on which pin mappings you are using (dependent on ATtiny libraries).

I'm using the ATtiny Programmer to connect my ATtiny to my computer and according to the diagram pins 3 & 4 are both analog input pins. However, I'm confused as to why the pins matter at all when all I want is for the word "hello" to be displayed in the console.

Please add a link to the ATtiny Programmer, and I will add to my answer.


text:
Data exchange through USB Host Shield
I have a Razor IMU, which communicates through a USB to Serial Converter with a USB Host Shield mounted on an Arduino Mega 2560.
Even though serial communication can be achieved directly through the Arduino pins, I'm using a Host shield to keep the pins free for other devices. I found the Host Shield Library, which had specific examples for XBOX and PS3 controllers, Bluetooth devices, keyboards and mice etc., but I can't figure out a way to send/receive data to the IMU connected to the shield.
I'm kind of a noob, so be kind. :)
Thanks!

That really sounds like massive overkill.  You do realise that you have multiple hardware UARTs on the Mega2560?  Also that you can use any pin combination you like using SoftwareSerial to communicate?


text:
Capacitive sensor MPR121 on Arduino Uno—how many will work?
I need to attach several capacitive sensors MPR121 with each of them using all of its 12 electrodes to an Arduino Uno.
Could you please tell me, how many will work with the voltage and current Arduino Uno supplies?

The answer is 4 regardless of the current consumption.
You can have 4 MPR121 devices on an I2C bus (by connecting the ADDR pin to the right place to select 1 of 4 addresses), and the Uno has one I2C bus - so that means 4 devices.
You could use software I2C to add more devices on other pins, but that's slow and clunky.
But that aside, if you used something to increase the number of I2C buses available, according to the datasheet the peak current consumption is 1mA during sampling, and assuming 300mA maximum for the Arduino's 3.3V regulator, that would mean a maximum of 300 MPR121 connected to the Arduino.  Note that, if you could actually get to the Arduino amongst that tangle of wires, you'd find it getting rather hot...

Thanks very much. So I can use four sensors and in fact 48 electrodes with my Arduino Uno?

Yep. As long as the software you use supports selecting the right bus address.

Uh, I hope so. I wanted to use Sparkfun’s Music Instrument Shield and four of their capacitive sensors.


text:
How to put arduino in sleep mode?
I need to put arduino in sleep mode. I did not find the library avr/sleep.h . From where to download it.

Just use #include <avr/sleep.h>.

Why didn't you find it? Please post your code that proves this point.

avr/sleep.h is part of the compiler. You don't need to download it.
There are other libraries that act as a wrapper to it to make life easier:

https://github.com/lowpowerlab/lowpower
https://github.com/rocketscream/Low-Power


text:
Can BUS Shield on Arduino Leonardo - Can't init CAN
I'm hoping to get some help with this as I am unable to get the CAN to Initialize.
I have the sparkfun Can-Bus shield: https://www.sparkfun.com/products/13262
and an Arduino Leonardo board.
I'm using the following code to try to connect my 2008 Audi S6 to the Arduino board:
#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
#include <Canbus.h>
char UserInput;
int data;
char buffer[456];  //Data will be temporarily stored to this buffer before being written to the file

//********************************Setup Loop*********************************//

void setup(){
Serial.begin(9600);
while(!Serial);
Serial.println("CAN-Bus Demo");

if(Canbus.init(CANSPEED_500))  /* Initialise MCP2515 CAN controller at the  specified speed */
  {
Serial.println("CAN Init ok");
  } else
  {
    Serial.println("Can't init CAN");
  }

  delay(1000);

Serial.println("Please choose a menu option.");
Serial.println("1.Speed");
Serial.println("2.RPM");
Serial.println("3.Throttle");
Serial.println("4.Coolant Temperature");
Serial.println("5.O2 Voltage");
Serial.println("6.MAF Sensor");

}

//********************************Main Loop*********************************//

void loop(){

while(Serial.available()){
   UserInput = Serial.read();

if (UserInput=='1'){
 data=Canbus.ecu_req(VEHICLE_SPEED, buffer);
 Serial.print("Vehicle Speed: ");
 Serial.print(data);
 Serial.println(" km/hr ");
 delay(1000);
}
else if (UserInput=='2'){
 data= Canbus.ecu_req(ENGINE_RPM, buffer);
 Serial.print("Engine RPM: ");
 Serial.print(data);
 Serial.println(" rpm ");
 delay(1000);

}
else if (UserInput=='3'){
 data= Canbus.ecu_req(THROTTLE, buffer);
 Serial.print("Throttle: ");
  Serial.print(data);
 Serial.println(" %% ");
 delay(1000);

}
else if (UserInput=='4'){
 data =Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer);
 Serial.print("Engine Coolant Temp: ");
 Serial.print(data);
 Serial.println(" degC");
 delay(1000);

}
else if (UserInput=='5'){
 data=Canbus.ecu_req(O2_VOLTAGE, buffer);
 Serial.print("O2 Voltage: ");
 Serial.print(data);
 Serial.println(" V");
 delay(1000);

}
else if (UserInput=='6'){
 data=Canbus.ecu_req(MAF_SENSOR, buffer);
 Serial.print("MAF Sensor: ");
 Serial.print(data);
 Serial.println(" g/s");
 delay(1000);

}
else
{
  Serial.println(UserInput);
  Serial.println("Not a valid input.");
  Serial.println("Please enter a valid option.");
}

}
}

Overall, I just can't get the CAN to initialize. I've looked online and just can't seem to find a solid solution. I've tried other libraries as well to no avail.
Please assist!

Leonardo has SPI pins on the ICSP header. Your shield expects SPI pins on pins 11,12 and 13. Maybe this will help: http://www.seeedstudio.com/wiki/CAN-BUS_Shield#How_to_Compatible_With_Arduino_Mega_and_Leonardo

I got that far; The strange part is that even if I bring the SPI pins to pins 11,12, and 13 it still doesn't work.. are there more pins I need bring over?

Had this problem myself. Found this fixed it
Change the following line...
_delay_us(10);

To...
_delay_us(50);

In the MCP2515.c file in the library

Increasing that delay in the MCP2515.c file also fixed this issue for me.
I am running the sparkfun Can-Bus shield on an Arduino pro-mini, and here is my serial monitor output before the change, and after:
12:56:38.580 -> CAN Read - Testing receival of CAN Bus message
12:56:39.556 -> Can't init CAN
13:01:40.992 -> CAN Read - Testing receival of CAN Bus message
13:01:42.016 -> CAN Init ok


text:
Sending data from Arduino to the server where arduino (sketch) acts as a client
I want to make simple client-server program where arduino behave as a client. For example I have a LED connected in arduino board that is controlled by a switch. With the switch I can turn off and on the LED. Now I want to send the status of that LED to another computer wirelessly (let's say within the Local network). That computer will act as a server and update the change as soon as the LED changes its status. I am not expecting any complete code, I just want to know how could it be done in general? May be some links can help me? Because this is my first time working with client-server in arduino sketch, I need some kind of guidelines. Thank you.

There are example client-server sketches included in the IDE. Did you look at those?

When you say "Local Network" - do you mean over Wifi ?

A simple HC-05 module will give you a wireless bluetooth connection.  They're fairly simple to setup, and you can write data to them the same as one would the Arduino serial console.  Obviously they can read data too.
SoftwareSerial bt_serial(2, 3); // RX | TX
bt_serial.begin(9600);

[...]

if (led_state != last_led_state)
{
    if (led_state == HIGH)
        bt_serial.print("1");
    else
        bt_serial.print("0");
    last_led_state = led_state;
}

On the "server" side, a simple program reading the mapped bluetooth serial port would do the job.  For example, some python code:
import serial
import sys

serial_port = serial.Serial(port='COM8:', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE)

try:
    serial_port.open()
except:
    print("Failed to open port")
    sys.exit(2)

while (True):
    try:
        led_state = serial_port.read()
        if (led_state != 0):
            print("LED is on")
        else:
            print("LED is off")
    except:
        pass

serial_port.close()   # yes, it never gets here

Even though I like Kingsley's answer I thought I'd add to this using Wi-Fi becuase you had mentioned LAN.
These two links should be enough to help you:
WifiChatServer
and C# Telnet Library
Those links can sort of be dissected to fit your needs, but if you need some actual code just tell me.
Now I am aware that the Arduino is acting as a server and the computer acts as a client, but I believe this setup is better because it's easier to manipulate connecting to servers on the computer rather than on the arduino side.