text:
Please help. Error message “sendSMS not declared in this scope” im frustrated. :(
//INCLUDED LIBRARIES
 #include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>

//SERIAL PIN ASSIGNMENT, BAUDRATE, PHONE NUMBER, MESSAGE
#define PIN_TX    2
#define PIN_RX    3
#define BAUDRATE  9600
#define PHONE_NUMBER "+639158848570"       //CELLPHONE NUMBER
#define MESSAGE  "Notice: Please be informed that your area is under Level 1 advisory with 4-inches flood depth. Continuous flood is expected due to the heavy rainfall. Be prepared and secure your important documents and belongings in high places. Avoid wirings from getting wet to prevent further injuries and accidents."  //COMPOSE YOUR MESSAGE HERE
#define MESSAGE_LENGTH <=500
char MESSAGE1;

//SERIAL PIN ASSIGNMENT, BAUDRATE, PHONE NUMBER, MESSAGE
#define PIN_TX    2
#define PIN_RX    3
#define BAUDRATE  9600
#define PHONE_NUMBER "+639379488989"       //CELLPHONE NUMBER
#define MESSAGE  "Notice: Please be informed that your area is under Level 1 advisory with 4-inches flood depth. Continuous flood is expected due to the heavy rainfall. Be prepared and secure your important documents and belongings in high places. Avoid wirings from getting wet to prevent further injuries and accidents."  //COMPOSE YOUR MESSAGE HERE
#define MESSAGE_LENGTH <=500
char MESSAGE2;

//SERIAL PIN ASSIGNMENT, BAUDRATE, PHONE NUMBER, MESSAGE
#define PIN_TX    2
#define PIN_RX    3
#define BAUDRATE  9600
#define PHONE_NUMBER "+639357120147"       //CELLPHONE NUMBER
#define MESSAGE  "Notice: Please be informed that your area is under Level 1 advisory with 4-inches flood depth. Continuous flood is expected due to the heavy rainfall. Be prepared and secure your important documents and belongings in high places. Avoid wirings from getting wet to prevent further injuries and accidents."  //COMPOSE YOUR MESSAGE HERE
#define MESSAGE_LENGTH <=500
char MESSAGE3;

char phone[16];
char datetime[24];

GPRS GSMTEST(PIN_TX,PIN_RX,BAUDRATE);//RX,TX,BAUDRATE

void loop() {
      // read the output on digital pins:
  int Level1 = digitalRead(5);
  int Level2 = digitalRead(6);
  int Level3 = digitalRead(7);

  // print out the value you read:s
  if (Level1 != 0){
    Serial.print("Level 1 =  "); Serial.print(Level1); Serial.print("   ");
    sendSMS();
  }
  else if (Level2 != 0){
    Serial.print("Level 2 =  "); Serial.print(Level2); Serial.print("   ");
    sendSMS();
  }
  else if (Level3 != 0){
    Serial.print("Level 3 =  "); Serial.print(Level3); Serial.println("   ");
    sendSMS();
  }
  delay(1);//delay ms

//void setup() {
//  loop();
//}

void sendSMS() {
  Serial.begin(9600);
  while(!GSMTEST.init()) {
      delay(1000);
      Serial.print("INIT ERROR\r\n");
  }
  Serial.println("GSM INIT SUCCESS");
  Serial.println("START TO SEND MESSAGE ...");
  Serial.print("..");
  delay(1000);
  Serial.println(".....");
  delay(1000);

  GSMTEST.sendSMS(PHONE_NUMBER,MESSAGE); //DEFINE PHONE NUMBER AND TEXT

}

void readSMS(){
     //READ THE INCOMING SMS MESSAGE
   Serial.println("   ");
   Serial.println("   ");
   messageIndex = GSMTEST.isSMSunread();
   if (messageIndex > 0) { //AT LEAST, THERE IS ONE UNREAD SMS
      GSMTEST.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
      //IN ORDER NOT TO FUL SIM Memory, IS BETTER TO DELETE IT
      GSMTEST.deleteSMS(messageIndex);
      Serial.print("FROM NUMBER: ");
      Serial.println(phone);
      Serial.print("DATE/TIME");
      Serial.println(datetime);
      Serial.print("RECEIVED MESSAGE: ");
      Serial.println(message);
   }
}

What is wrong with my code? :(

it is incomplete again and you didn't post the error messages. one of the libraries has a variable called message so don't use this name

That is all the code.
The error message is sendsms is not declared in this scope.

You forgot to close your loop() function - so the sendSMS() function is inside it and never gets declared.

Where is that? :(

As @Majenko said, count the number of curly brackets after the "void loop() {" line.  You will find there is none which match w/the curly bracket in the "void loop () {" line of code. So you confused the compiler.  And now you are getting errors from the compiler which are confusing you.  (Fair's fair :)! )

Consider editing your original question instead of re-posting. You need to make more of an effort to make your questions clear. Add text to the question explaining the problem. And make the title specific to the problem And try to format the code by highlighting the code and picking "code" from the menu. Remember: The point of stack exchange sites is to create clear and concise questions & answers that other people can find and use over and over again.


text:
Debugging my Stepper Motor Driver circuit
I'm using the Pololu DRV8825 Stepper Motor Driver to control a NEMA 17 Steppermotor with an Arduino Uno.  According to the Pololu website, the circuit should be wired as follows:

I did, however, deviate from this exact sketch a little bit:

The Arduino (microcontroller) is powered by a USB cable connected to the computer
I connected the 5V pin on the arduino to the + rail on a breadboard.  I then connected two wires on this rail to the RESET and SLEEP pins on the driver.
I'm using a 9V battery to power the motor.
I've connected the DIR and STEP pins to Arduino Uno pins 12 & 13, respectively.

Consequently, I coded and uploaded the following sketch:
int stp = 13;  //connect pin 13 to step
int dir = 12;  // connect pin 12 to dir
int a = 0;     //  gen counter

void setup()
{
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
}

void loop()
{
  if (a <  200)  //sweep 200 step in dir 1
   {
    a++;
    digitalWrite(stp, HIGH);
    delay(10);
    digitalWrite(stp, LOW);
    delay(10);
   }
  else
   {
    digitalWrite(dir, HIGH);
    a++;
    digitalWrite(stp, HIGH);
    delay(10);
    digitalWrite(stp, LOW);
    delay(10);

    if (a>400)    //sweep 200 in dir 2
     {
      a = 0;
      digitalWrite(dir, LOW);
     }
    }
}

RESULT
The stepper motor does not turn.  Instead, it just hisses at a high pitch.  After a short while, the driver gets very hot.
THINGS I'VE TRIED

I double checked to make sure that connected stepper wires pairs are properly connected to the "A" pins and "B" pins on the driver.
I tried reversing the A1-A2 pair and B1-B2 pair in all possible combinations.  All combinations produce the same result as above.
I tried increasing the motor power supply to 12V (8 alkaline AA batteries).  The same result occurs.
I double checked to make sure the 100microF radial electrolytic capacitor is connected with the long end to the positive motor supply and short end to the negative motor supply (on a different breadboard rail than the logic power supply, of course).
I tried using the 3.3V pin instead of the 5V pin to connect to SLEEP and RESET on the driver.  Again, the same result occurs.

I'm not really sure what to try next to debug my circuit.
My Hunch:
I do, however, have one suspicion based on a little warning box on the pololu website which reads:

Caution: Installing the header pins so that the silkscreen side is up
  and the components are down can limit the range of motion of the
  trimpot used to set the current limit. If you plan on installing the
  header pins in this orientation, please set the current limit before
  soldering in the pins.

The way I soldered the headers onto the driver looks like the bottom left corner of the picture below:

My Question:
Given that my stepper motor requires 1.7A current, is there anything I can do to improve this circuit to make it work?  Did I make any mistakes?  Is there anything else I should try or check?  Did I solder the header in the wrong way?

The direction of the pins shouldn't matter.. it's just saying it may be hard to turn the trimpot with the black plastic part of the headers right up against it so it recommends doing it the way you did it.

@sachleen I presume the trimpot is that tiny circular part that looks like a screw.  Do I need to turn it to adjust the current draw?  If so, how can I tell exactly how much current I'm actually getting?

Yeah it's the circular thing in the top-left of the bottom image (component side up). Not sure if you need to change it. Read the "Current limiting" section of the pololu.com to see how to see what kind of current its drawing.

@sachleen:  Ok. I see.  It says "to measure the current running through a single motor coil without clocking the STEP input".   But I'm not sure what "without clocking the STEP input" means... Do you understand what that means?

I've never used a stepper so I might have no idea what I'm talking about. buuut... See where you do digitalWrite(stp, HIGH); and low? that's clocking it. I think it wants you to leave it high.

I think you should also add digitalWrite(dir, LOW); in your setup(), I don't think it will change anything but it's preferrable to enforce the value you want at the beginning.

Have you tried your circuit without batteries but using a "better" power supply (eg some wall-wart 9V 2A)? That would allow you to ensure this is not a power issue (or the opposite).

This question doesn't really have much of anything to do with arduino, and would be more likely to receive knowledgeable input on EE stackexchange.

@ChrisStratton:  I know.  I was debating posting it there or here.  I wasn't sure if the issue was the arduino sketch, the electrical circuit, or something else.  After the responses, it appears now that the problem is most likely the power supply.  Do you recommend that I delete the question here and repost on the EE SE site?

I don't think it should be deleted, but migration would be a good idea.

Sure, @chrisStratton.  Go ahead and migrate it.

I had this same issue when setting up this circuit with this code and driver on an Arduino Uno. All else was fine, but the current for the motor was set WAY too high on the driver from the factory. The VREF was 1.7 volts, and it needed to be around .5 for the motor I was using. As I set the VREF to the appropriate voltage, the motor started to spin as it should and stopped hissing.
I know this post is old, but I hope that this helps someone else. Pololu has a great video (and documentation in general) for setting the appropriate voltage on most of their drivers on the product page here: DRV8825 Stepper Motor Driver Carrier, High Current.

A couple things I noticed first: This is one of the best formatted questions I've ever seen... :) Anyway, your circuit looks fine to me except for a few things:

Warning: This carrier board uses low-ESR ceramic capacitors, which makes it susceptible to destructive LC voltage spikes, especially when using power leads longer than a few inches. Under the right conditions, these spikes can exceed the 45 V maximum voltage rating for the DRV8825 and permanently damage the board, even when the motor supply voltage is as low as 12 V. One way to protect the driver from such spikes is to put a large (at least 47 µF) electrolytic capacitor across motor power (VMOT) and ground somewhere close to the board.

(Added some italic/bold myself, quote from product page.)
Capacitors are cheap ($1.50 on eBay from US), and although new drivers are too, it's generally a good idea to build it right. There's nothing more annoying than waiting for shipping on something you shouldn't have had to fix.
Additionally, battery power (especially AAs) can be bulky if not done right, and may not provide enough current. Note that in a series configuration that it will provide the voltage of 8 AAs, but only the current of one. You can't run a 1.7 A motor off of a single AA's current. Stab in the dark guess: you'll need ~80-100 AAs to provide enough current and voltage. I'm too lazy to measure the internal resistance and actually calculate it.
Suggested solution: There are a million things that could go wrong. Without being there, I'm betting that your delay function is too short. What this will do is not provide enough time for the motor to move, thus it staying still. This would still use a lot of current (50% of the time it's full current to motor coils), therefore it would make the driver hot. (Note on heat: ...to supply more than approximately 1.5 A per coil, a heat sink or other cooling method is required... -Product page: you'll need a heatsink to cool your chip down.) Also note that some heat is normal; a general rule of thumb is if it's too hot to hold your thumb on it for a few seconds, you need more cooling. Remember that the more it's used, the hotter it'll get, so keep this in mind when deciding if you want to add a heatsink.
tl;dr: You need to increase the delay time and provide more current than you have currently.

I just tried increasing the delay time to 1000ms (1 second), and still no change in behavior.  I guess I'll have to try batteries that can provide higher amperage.  I looked up my AA batteries and found that they provide about 900 milliamp-hours.  Should I look for batteries that provide at least 1700 milliamp-hours (corresponding to the 1.7amp current draw from the stepper motor)?

@Paul No, this is a common misconception. A mAH means that it has the capacity to release that much power, not that it can release that all at once. Since it's hard to tell the maximum current on most one-time batteries, I'd recommend getting a 9.6V rechargeable "RC battery" that can provide 1.8+A (amps, not amp hours). They can get a bit costly, but you need that much power. Advice: don't try adding rechargeable batteries in series. They're highly dangerous if not perfectly "balanced!"

Please stop giving mistaken advice about batteries.  Most cells can supply a current many times their mAh rating, by a factor of 10 or more (the C rating).  "Balance" is largely a charging concern, and primarily with lithium chemistries - something neither a 9.6v RC pack nor individual 1.2 - 1.5v AA cells utilize.

There is already a 100uF cap shown on the circuit, so why mentioneing that adding a cap is needed?

@Chris By balanced I meant that if you combine two slightly different lithium batteries they can be highly dangerous. From what I can tell, the OP is using standard AA alkaline batteries which I am positive that one can't support two amps at a time. Even if it could, it most likely wont last twenty minutes because of voltage loss in the battery. There is no chip to manage voltage loss. The OP hasn't specified the battery composition they are using, either, so it may be able to supply enough current, if charged enough.

@jfpoilpret Oops, didn't notice that. However, it can't hurt to leave it in there. :)

@AnnonomusPenguin: I am using alkaline batteries.  Perhaps switching to lithium would work better?  I've heard that they can provide more amps...

Do not use lithium - there are real concerns though not quite as erroneously described here.  Alkaline AA's can easily supply 2 amps, though only for a bit less than an hour.  You really should use a power supply.

@Chris Please ping the person you are talking to with @Username so they will get pinged. Anyway, can one AA supply 2A? You have to remember in series that the voltage characteristics are added, but the current characteristics are those of only one battery. I'm concerned that one AA won't be able to provide 1.5V 1.8A, which is what the OP needs.

@Paul Like others have pointed out, the best route as far as I know to debug this further is to get a power supply that can for sure supply the right amount of electricity. You could also use an old PSU for this purpose...

@AnnonomusPenguin - a single AA cell can in fact provide several amps.  One of the real problems with specialist sites such as this is that topics get diverted to a backwater where there's a shortage of actual knowledge and a lot of mistaken information. Also, if you are going to make site usage recommendations, you could start by using someone's actual username in your @ notification - otherwise, you depend on the automatic notification to those in the preceding posts.

@Chris I stand corrected, I must be buying cheap batteries :) Anyway, you only need the first three letters for a ping.

I don't think your batteries were too low in current capacity, your delay time is not too short, at 10 +10 ms per clock pulse, you are only talking about 50 steps per second, that's not all that fast. I've written programs where I have had to go to microseconds to get enough rpm out of my stepper.
First, take everything out of your loop except the digitalwrite high, delay digitalwrite low and delay lines. Then the program "should" just spin the motor continuously in one direction. That way you are sure you don't have a logic issue.
Second, did you check to see if you didn't hook up pin 12 and 13 backwards, such that you are telling the driver to change direction every 10 ms instead of stepping? The sound it makes would be more like a buzz or vibration, usually a soft, staticy hiss is when the motor is enabled, but not getting a step pulse.
Finally, this post is about 18 months old, it is considerate and helpful to others to explain how you solved the problem (assuming you figured it out).

The one thing that helped me was NOT to connect GND to stepper board from microcontroller (bottom black line from schematic posted in first post).
If it was connected, driver would draw 12V@3A immediately and gets freaky hot. Also motor didn´t turn at all.

No, you are mistaken.  A common ground is absolutely necessary for this to function, and if you are not getting one there you are probably getting one through the AC wiring.  Whatever cause your overheating was a different issue.  What you have posted here is bad advice.

source: Stack Exchange

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

sort: votes


text:
Any problems taking arduino(esque) devices through airport security?
I'm flying out for vacation, and I want to take some of my half-done arduino projects with me to work on.  I'm concerned that aiprort security might mistake my devices for something sinister or at bare minimum 'suspicious' and be confiscated.
Has anyone ever had any negative experiences taking arduino-esque wiring projects through airport security?

from a technical point of view you should also be careful that the x-ray scanners and metal detectors use EM fields and ionizing rays, which could possibly harm your arduino (espessialy if it's wired to some circuit which could act as an antenna).

@nonchip: As long as it's not hooked up to any power, it should be fine. Right?

unless it or parts of it get powered by the radiation.

Unfortunately, this is a one of those case-by-case things. If that particular inspector got up on the wrong side of the bed this morning, or didn't like the way you parted your hair, or who-knows-what, you could get the PCS (punitive cavity search) for no good reason and never get an explanation. And on the other hand, you can get waived through without a second glance. "We don't care. We don't have to. We're the !"

I personally haven't taken my Arduino through security, but here are a few things I'd look at before flying:

International flights might be more secure, so keep that in mind.
(Like already mentioned) check your bags whenever possible
Go extra early in case you do have to explain to the TSA (or equivalent). You don't want to miss your flight!
Take it out of your bag so it doesn't look like you're hiding anything. The more open you are about it, the less suspicious they'll be.
Bring any original packaging for your Arduino/parts.

A few other things I've read to do:

Take tickets if going to some event like a Maker Faire, especially if they can look it up online. If they seem skeptical, you could always pull it up on your phone.
Don't make it look like a bomb (i.e. don't be stupid!)
Don't take tools unless needed
Be patient and calm if they stop you. You have nothing to hide from them (Right? Right?)

I don't think that is a problem. I have taken my arduino several times with me when I travel by plane and have never had any problems. I have even carried an oscilloscope and I only was warned about the pointy probes. I have taken international flights with it without any problems. However, always verify the airline baggage restrictioins.

It will depend on your particular country of course. Check the rules on cabin baggage.
In Australia, Arduino boards should pose no problem. It is best to not take any batteries or tools with edges (screwdrivers) or heavy tools (wrenches). In case they do want to have a look, place the boards at the top of your bag for easy access.
I have traveled to Europe from Australia with half a suitcase full of large PCBs with no problem. The only time my bag was opened was when I was carrying a tea pot stand, which was in the shape of a tea pot. Apparently it looked like a gun.

Ever had any problems taking a soldering iron with you?

I've never taken one, but if it has a sharp tip they might not let it through. If you are taking the whole workshop you might have to check in the baggage. :)

Indeed... it's probably best to check in that item.

Real world example:
I have just flown from  JFK - New York to GRU - Sao Paulo (Brazil) (October 2016) with this 'RIAspire UNO R3 Master Beginner Starter Kit for Arduino DIY Discovery - 25 Sensors with RFID, Ultrasonic, Temperature, HC 05 Bluetooth, ESP8266 Wifi' on my hand luggage.
There were a lot of wires, detectors and everything.
Nothing happened.

That's actually quite bad.

@user400344, why is that quite bad? I'm not sure I understand.

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


text:
Is that correct that input and output pins are not supposed to have current through them?
Are input and output pins not supposed to have current through them and only either apply voltage or "measure" it?

An output pin (on an AVR 8-bit board like an Arduino Uno) can pass up to 40mA (absolute maximum). It is recommended not to exceed 25mA.  This is called sinking current when the output pin is set to LOW, and sourcing current when it is set to HIGH.
An input pin is what is known as high impedance. I.e., it looks, to the circuit connected to the pin, like an incredibly high value resistor connected between the input and ground. Because of that only very tiny currents will ever flow through it (unless you do something silly like plug it direct into the mains).

First, you can not apply a voltage to or with an I/O pin connected to a circuit, and have no current flow as a result. There is a limit to the current a given pin on a given device can pass without damage and that is specified in the device's datasheet. How much current a given pin and circuit will pass or try to pass depends on the external circuit and the circuit internal to the device. Majenko's answer (except possibly for the specific limits, depending on the device) is correct.
You haven't specified what device. Is this a generic question or is it specific to the AVR micro-controllers used in most Arduino boards? If the latter, the limits in @Majenko's answer are also correct.

What everyone else said.
It's difficult to measure voltage without taking at least a tiny trickle of current, and that's what input pins do.
Anything that is driven needs current to drive it (power = current * voltage). However, an arduino pin - as someone mentioned - should only ever be used to supply about 25mA. Drawing a heavier current than that can fry the chip.
V=IR, so, the resistance on an output pin should be no less than 200 ohms, hence the 330 ohm current-limiting resistor you put on an LED. Power is IV, so the maximum power you can safely get get is 125mW (oh, you can get more - but you may fry your chip). This translates directly into the maximum safe brightness of a LED, the strength*speed of a motor, the loudness of a buzzer powered by an output pin.
Another big thing when trying to drive coils (motors, solenoids, relays) is that when you switch off the power to a coil, it generates a spike of voltage going the other way. This spike also can fry the chip. This is why relay shields are a thing - they contain electronics to deal with this back-emf. If you want to drive a motor and don't want to buy a shield, look into darlington array chips. I used one to run a stepper - worked perfectly.
So.

Inputs in theory need almost no current - but they do need that tiny trickle.
Outputs must have current to do any work. The amount you can get off the board without frying it is limited.


text:
esp8266-01 and arduino UNO communicating over i2c
i am not able to communicate over i2c with my esp-01 as master and UNO as slave. i get special characters sent back to esp, but my esp is sending correctly...
output on my esp-01

output on my UNO is

connections are esp-01 gpio-0 to uno A4 and gpio-2 to uno A5
is it because i am not using a level shifter or any mistake in my code..?
here is my esp master code
#include <Wire.h>
#define I2CAddressESPWifi 6
int x=32;

void setup()
{
  Serial.begin(115200);
  Wire.begin(0,2);//Change to Wire.begin() for non ESP.
}

void loop()
{
  Wire.beginTransmission(I2CAddressESPWifi);
  Wire.write(x);
  Wire.endTransmission();
  x++;
  delay(1);//Required. Not sure why!

  Wire.requestFrom(I2CAddressESPWifi,10);
  Serial.print("Request Return:[");
  while (Wire.available())
  {
    delay(100);
    char c = Wire.read();
    Serial.print(c);
  }
  Serial.println("]");
  delay(500);
}

and here is my Uno slave code
#include <Wire.h>
#define I2CAddressESPWifi 6

void setup()
{
  Serial.begin(115200);
  Wire.begin(I2CAddressESPWifi);
  Wire.onReceive(espWifiReceiveEvent);
  Wire.onRequest(espWifiRequestEvent);
}

void loop()
{
  delay(1);
}

void espWifiReceiveEvent(int count)
{
  Serial.print("Received[");
  while (Wire.available())
  {
    char c = Wire.read();
    Serial.print(c);
  }
  Serial.println("]");
}

void espWifiRequestEvent()
{
  String ts = getTime();
  Serial.print("Sending:[");
  Serial.print(ts.c_str());
  Serial.println("]");
  Wire.write(ts.c_str());
}

String getTime(){
  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;
  String ts = "U:";
  if (hr<10) ts+="0";
  ts += hr;
  ts +=":";
  if ((min%60)<10) ts+="0";
  ts += min % 60;
  ts +=":";
  if ((sec%60)<10) ts+="0";
  ts += sec % 60;
  return(ts);
}

Pullup resistors?

no... why should I ? and between what?

Try choosing an address that isn't reserved for special purposes. One that is between 8 and 119 inclusive.

I tried 15, that didn't make any difference... :(

Pullup resistors on the I2C bus (SDA, SCK) is required if not provided on the board. Check the I2C specification.

Perhaps the Serial.print()s in the slave's request event function are causing too much delay (clock stretching?). You should make the Wire.write() the second statement in that function right after the getTime call. Or you could use Wire.write("Hello") as the only statement in the function, so you can narrow down the problem.


text:
Is replacing USB serial WITH ESP8266+ESP link feasible?
ESP8266 (01-512k,) Arduino Uno (clone), Arduino IDE, Python 2.7.6 on Macbook pro running OSX 10.10.4 64-bit.
Hello!
I'm using a motion sensor with the following setup:
Arduino Uno+motion sensor >>>sensor values>>>USB Serial>>>Laptop running Python code>>>Notification>>>WiFi>>>Web
The sensor generates a value. The value is displayed on the serial monitor. The python program is triggered into action by a specific value appearing on the serial monitor and the program sends an email notification.
I would like to replace that setup with the following:
Arduino Uno+motion sensor>>>sensor values>>>ESP8266 as transparent WiFi to Serial bridge>>>Laptop running Python code>>>Notification>>>WiFi>>>Web
Essentially, I want to get rid of the USB cable and use the ESP8266 as a transparent WiFi to Serial bridge. Of course, a battery would power the Arduino and ESP8266.
I read this post  and the Jeelabs/ ESP Link Readme. It seems that the ESP8266, once flashed with ESP Link, could replace a serial cable. But, can ESP Link replace the USB Serial in my current setup? If so, are there tutorials explaining how this can be done?
I did some further reading and researched the matter but so far I only found one use case similar to what I want to do. In the said use case, a virtual serial connection through WiFi was being executed via a server within the ESP8266. Unfortunately, there were no detailed explanations on how this was achieved and I don't think this would be suitable for my specific use.
Please let me know if further information or clarification is needed.

Why not use an actual protocol, such as HTTP?

The jeelabs link is indeed what you are looking for. You no longer need a USB-to-serial for that one (other than to program the ESP the first time).

@IgnacioVazquez-Abrams Hello, Would you say that the HTTP protocol would be better than the Jeelabs ESP Link transparent WiFi to serial bridge? If so, for which reasons? Thanks!

@Gerben Hello, Thank you for your comment. I'll dig deeper into the Jeelabs documentation and forums to determine the best way to go about it and report back here with progress or a solution. If you have any tips please feel free to post them. Thanks!

What kind of motion sensor are you using? You might be able to use an ESP8266 directly with it.

@Pabluski Hello, For this project it's a standard PIR motion sensor. I thought about having everything on the ESP8266 but first I need to understand the ESP8266 a bit better. Thanks!


text:
Arduino LCD is displaying gibberish, sometimes
Below is my code and a picture of the gibberish.  It's different every time.  If i pull out the temp sensor, i still get gibberish, sometimes.  I'm at a loss as to what to even be looking at now. Any ideas?

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//set capacities
int keg1_volume = 19;
int keg2_volume = 19;
const int temperaturePin = 0;

void setup() {
  //initial delay
  delay(1000);

  //set contrast
  pinMode(9, OUTPUT);
  analogWrite(9, 100);

  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);

  // Print header to the LCD
  lcd.setCursor(6, 0);
  lcd.print("BeerView");
  lcd.setCursor(0,1);
  lcd.print("Keg (C)");
  lcd.setCursor(10,1);
  lcd.print("Keg (F)");

  //initialize serial for debugging
  Serial.begin(9600);

  //get voltage and calculate temp
  float voltage, degreesC, degreesF;
  voltage = getVoltage(temperaturePin);
  degreesC = (voltage - 0.5) * 100.0;
  degreesF = degreesC * (9.0/5.0) + 32.0;

  //display temp
  lcd.setCursor(0,2);
  lcd.print(degreesC);
  Serial.println(degreesC);
  lcd.setCursor(10,2);
  lcd.print(degreesF);
  Serial.println(degreesF);

}

void loop() {
}

float getVoltage(int pin)
{
  return (analogRead(pin) * 0.004882814);
}

Does problem still occur if you substitute a fixed voltage (eg use a voltage divider or pot) for the PWM'd contrast input?  The PWM's sharp-cornered waveform might be introducing a lot of noise into the LCD.  If fixed voltage fixes the problem, and you still want to use PWM, put a good low-pass filter between PWM and LCD pin 3 or whatever

that was it.  i had originally tried to use the pot, but couldn't get it to work (no clue why, hence using the PWM).  just changed back to pot, and it's all beautiful now.  thank you so much for the help!!!!

Used a pot instead of the PWM from pin 9.  Thanks for the help!!


text:
Noise from the I2C - digital potentiometer
I have a digital potentiometer controlled by Arduino, connected via the I2C bus (it controls volume). For some reason it beeps just by itself, even when no audio is playing. I have checked that it is def. I2C, as when I unplug the SDA&SCL then there is no noise (and I have many more connected to Arduino. Is there anything special about "de-noising" the I2C bus?

What do you mean by noise? what is the audio you mentioned? plrease add more details (at least the schematic), because I know that it is perfectly clear in your mind but if you can't communicate us the details we can't figure out what the problem can be

Best thing to do is take the I2C speed outside the audible range (if its not already there), try to put some distance between the I2C lines and speaker input lines and add an RC low-pass filter centred around 20kHz to the speaker's lines.

Hi, thanks for the idea, but what you exactly mean by "take the I2C speed outside the audible range"?

Or where to put it? just in front of the speaker?

My suggestion may have been premature. Best you include your schematic and code so we can get a better idea of your problem.

Are you saying a digital potentiometer is making an audible sound?  Have you got pull up resistors in your circuit for the I2C bus?

I have replaced the I2C with SPI in the end, as nothing helped with removing this noise :(


text:
Does anyone know how to connect 2 digipots to Arduino? (MCP4141)
I'm struggling with getting the code right. I'm trying to connect 2 digipots (MCP 4141) to Arduino to work separately over SPI. Has anyone got any experience with that?

Do you have one working?

What have you tried? What are you trying to achieve? Can you provide links to the supplier of the digipots? Do they have any example code? Did it work for you?

Try to read the datasheet and get a basic understanding of how the device works. in this case, it consists of 16 bits transfer (2 bytes).
Try to write a set of routines that communicates with the chip over the spi.
After that, it is all about using the _CS pin to select a particular chip.
edit: if this helps you, here is my code driving two mcp41010 - slight different from your digit pot but very similar.
//write to the device wiper0
void mcp41xxx_write0(uint8_t dat) {
    spi_write(MCP41XXX_P0 | MCP41XXX_CMD_WRITE);    //send the command byte
    spi_write(dat);                                 //send the data byte
}

//write to the device wiper1
void mcp41xxx_write1(uint8_t dat) {
    spi_write(MCP41XXX_P1 | MCP41XXX_CMD_WRITE);    //send the command byte
    spi_write(dat);                                 //send the data byte
}

the actual writes to the devices will differ -> mine is specific to the mcp41010 devices. It supports two wipers, P0 and P1. No increment or decrement on my digit pots.
the way to drive two digit pots are below:
//first pot
spi_select(MCP41XXX_CS1);           //deselect cs1 -> idles high
mcp41xxx_write0(i + i);             //send the data
spi_deselect(MCP41XXX_CS1);         //select hte device

//second pot
spi_select(MCP41XXX_CS2);           //deselect cs1 -> idles high
mcp41xxx_write0(i++);               //send the data
spi_deselect(MCP41XXX_CS2);         //select the device

as i'm using a single pot device, writing to the 2nd pot means writing to its wiper0.

I looked at your digit pot and the only thing you need to change are the wiper-specific routine(s), as your transmission is slightly different in the msb.
the spi_write() routine can be replaced / mapped to the shiftOut() routine under arduino.
here is the above code, without any change, running on an arduino:

I also took a brief look at your device's datasheet (mcp4141) and I think this is all you need to change:
//send data on wiper0 of mcp4141
void mcp41xx_write0(uint16_t dat) {
    dat = dat & 0x03ff;                             //10-bit data
    spi_write(MCP41XX_CMD_WRITE | MCP41XX_WIPER0 | (dat >>  8));    //write the msb
    spi_write(dat);                                 //write the lsb
}


text:
Serial Connection
I was trying to communicate with my arduino uno over the serial connection from the USB. Connecting to it is usually not a problem, but what buggs me is the first transaction of the data... No matter with what I do it, java code or the serial monitor which comes with the IDE, I always have the problem that usually only one Byte is being transfered or received from the Arduino. What could be the problem? Is it just a bug and I have to live with it or can this somehow be fixed?
My Arduino Code:
#include "RGBdriver.h"
#define CLK 10
#define DIN 11

RGBdriver driver(CLK, DIN);
byte red = 0;
byte green = 0;
byte blue = 0;

byte newRed = 0;
byte newGreen = 0;
byte newBlue = 255;

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

void loop() {
  if (Serial.available() >= 3) {
    newRed = Serial.read();
    newGreen = Serial.read();
    newBlue = Serial.read();
  }

  if ((red != newRed) || (green != newGreen) || (blue != newBlue)) {
    red = newRed;
    green = newGreen;
    blue = newBlue;

    driver.begin();
    driver.SetColor(red, green, blue);
    driver.end();
  }
}

Are you waiting for the Arduino to finish the bootloader timeout after opening the serial port from the PC?

Yes, I do! The Arduino is being used for controlling the lights on my LED strip. I know it booted because they turn on and after 10-15 sec, just to be safe, I try to send the data and on the first try it turns off and on in a short time and on the second try it really changes the color.

Now I have actually looked at your code your problem is immediately obvious to me. I cover it in detail here: https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/

Ok what I could have changed in my code is putting Seria.available() >=3, bcs I need 3 Bytes of data for updating. But it still doesnt update the color on the first try. This also happens in the serial monitor...

I updated my code. Now it works with the serial monitor, but my java program is still not working, meaning the first attempt of sending the data doesnt work... Only after trying the data one time it will work from there on.

Are you waiting the bootloader timeout time in your java program?

Well, just to be sure I always wait for like 5-7 sec until I do anything just to be sure I am not doing something that will interupt the boot time

Even after opening the serial port in your Java program? (Open port - wait 2+ seconds - send data)

Well, I do use in the program the function setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0). I am not actually typing data in it, I send it over right away with starting the program. I also close the port on the end, because else I won't be able to access it next time.

You do know, don't you, that the act of opening the serial port resets the Arduino?

Ok,I didn't know that ... So I will try to make a while code for input of data and see what will happen then. Also, when I open the port for the second time the Arduino doesn't reset... Everything works fine from then on.

Consider giving sufficient delay to initiate the time to receive the data. The loop would otherwise terminate since the data received is less than 3


text:
Safe place to download CH340G drivers from
I am working with an Arduino Uno clone that uses the CH340G USB to TTL converter in lieu of the 16U2 found on the Uno. I see that most tutorials suggest downloading the CH340G drivers from what they call "a chinese website". I don't quite trust that site, is there any more trustworthy website where one might be able to acquire CH340G drivers for a modern Linux distro (preferably CentOS or Debian).
I ask here because devices with that chip seem to be popular in the Arduino community. If the unix stackexchange site would be a better place to ask then the question can be moved. Thank you.
EDIT: Apparently my system is having an issue with recognizing the device. Here are some specs:
$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 04d9:3015 Holtek Semiconductor, Inc.
Bus 003 Device 003: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n
Bus 003 Device 012: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ lsusb | wc -l
9

$ # Now I plug in the Uno clone
$ # Wait about a minute just to be sure...
$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 04d9:3015 Holtek Semiconductor, Inc.
Bus 003 Device 003: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n
Bus 003 Device 012: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ lsusb | wc -l
9

$ uname -a
Linux happiness 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l

My entire dmesg file can be found on pastebin, here is the end of it:
[37253.943739] usb 3-6: device descriptor read/64, error -71
[37254.159669] usb 3-6: new full-speed USB device number 15 using xhci_hcd
[37254.159841] usb 3-6: Device not responding to setup address.
[37254.363858] usb 3-6: Device not responding to setup address.
[37254.567744] usb 3-6: device not accepting address 15, error -71
[37254.679654] usb 3-6: new full-speed USB device number 16 using xhci_hcd
[37254.679756] usb 3-6: Device not responding to setup address.
[37254.883917] usb 3-6: Device not responding to setup address.
[37255.087716] usb 3-6: device not accepting address 16, error -71
[37255.087749] usb usb3-port6: unable to enumerate USB device

That "Chinese website" is the manufacturer's web site. Can't be more authoritative than that...

Drivers...? for Linux...?!?! What are they?!

Indeed, you should not download drivers from random websites for a Linux system, not only as  matter of safe practices but also because it is unlikely that they would be usable.  USB serial converters for Linux are handled by kernel modules and those need to be compiled for the specific kernel in use or its close relative.  Modern Linux distros likely support the CH340G already as the driver is included in the official kernel source, if not you should pursue obtaining a suitable kernel module from the provider of your distro or get the upsteam or distro kernel sources and compile the module.

Your edits suggests this is an electrical fault or signalling issue, with the board, cable, USB port (or possibly two of these being slightly out of spec in opposite directions so they still work with other things but not with each other), and not a driver problem at all.

@ChrisStratton: Thank you. I've actually just reverted the edit and asked a new question on Unix.SE. In the meantime I'll try on different USB ports on the same machine. I don't currently have access to another computer to test on.

Since you do not appear to have a software problem, posting on unix.se is inappropriate, and removing information from the posting here that revealed the nature of your problem was highly inappropriate.

@ChrisStratton: I see, thank you. I see that you've reinstated the information on this post. Thank you, your help and initiative are much appreciated!

It's more likely that the CH340G chip is dead, or that the crystal driving it isn't accurate enough.

I think you really don't get it: That strange chinese "not-trustworthy website" all tutorials recommend, is the homepage of the manufacturer! So, no matter if windows, linux, mac, or android, it will be hard to find alternative drivers.

Yes, I now know this to be correct. Luckily the current Linux kernels already do come with the proper drivers. Thank you!

Linux doesn't need drivers (indeed, the whole concept is pretty alien to Linux users).
The CH340G is fully supported by the default kernel in all distros I have ever used. On my Ubuntu machine the CH340G on my NodeMCU is detected automatically:
[ 8195.450566] usb 4-1: new full-speed USB device number 2 using uhci_hcd
[ 8195.630710] usb 4-1: New USB device found, idVendor=1a86, idProduct=7523
[ 8195.630714] usb 4-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 8195.630716] usb 4-1: Product: USB2.0-Serial
[ 8196.675137] usbcore: registered new interface driver usbserial
[ 8196.675153] usbcore: registered new interface driver usbserial_generic
[ 8196.675166] usbserial: USB Serial support registered for generic
[ 8196.677581] usbcore: registered new interface driver ch341
[ 8196.677600] usbserial: USB Serial support registered for ch341-uart
[ 8196.677620] ch341 4-1:1.0: ch341-uart converter detected
[ 8196.690670] usb 4-1: ch341-uart converter now attached to ttyUSB0

Nothing to download, nothing to install, nothing to risk the security of your system with.

"Linux doesn't need drivers", then proceeds to post log showing how kernel loads dynamically three driver modules. I feel conflicted.

@snaipperi Right, those come as part of the kernel itself. You can just as easily build a kernel with those drivers non-modular, or build an entirely monolithic kernel that doesn't use modules at all. Also, Kernel modules aren't always "drivers", various other internal workings like filesystems and even security management tools are implemented as kernel modules.

I was just nitpicking that the statement "linux doesn't need drivers" is incorrect. The ch341 module, regardless of being shipped with the kernel, is an interface driver and is very much needed by the kernel to be able to talk with the chip.

I think what is attempted here is a statement that downloading drivers from a third-party site is pretty alien. If your distro does not already ship the driver as a kernel module, you would typically download the driver's source code and compile it against your kernel version (for which you then also need the source code); though of course, some distros already do this for some drivers, and package the result as an installable package. But it's not unheard of for a manufacturer to provide a downloadable device driver module for Linux (possibly even as closed source).

"Linux doesn't need drivers (indeed, the whole concept is pretty alien to Linux users)."
I feel alienated, however this information is incorrect. I have at least two Ubuntu machines that did not recognize the CH340g chip. One is Linux Mint 18.2 32bit the other is a Linux Mint 19 64bit. I used the 'driver' that I downloaded from the site in question and guess what? It is the exact same driver that NodeMCU uses. For those that want or need to download the driver, but don't want to visit a 'suspicious site' just go here nodemcu-dev and you will find three flavors: Linux, MAC and Windows. Strange that they have an MIT license for their own software.
For Linux, just extract the archive CH341SER_LINUX.ZIP, then open a terminal in the directory and use make && sudo make then load the module ahem.. driver with (may need to use sudo) insmod /{path-to-your-extracted-folder}/ch34x.ko or reboot.
Now, I am not arguing whether or not Linux comes with the module, because I see two (one for each kernel) on just one of my systems located at /lib/modules/{x.x.x-xx}-generic/kernel/drivers/usb/serial/ch341.ko, however the one that is needed comes from the Chinese site in question that happens to be the same place where NodeMCU got theirs (or possibly some other site) for it to be recognized.
Also, I don't get how someone can buy Chinese products (or from anywhere else) and be afraid to visit their site.

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


text:
Advice on setting up a real-time audio equaliser
First time Arduino user here.
We have a microphone set-up which feeds back loudly on particular frequencies and need an equalizer to (preferably automatically) detect spikes in particular frequency bands and attenuate them before sending them on to the speakers. The dB level that has been cut from that frequency channel would then be displayed on an LED matrix such as this one:

Does the Arduino have the processing capabilities to keep up with the audio without noticeable lag? As the LEDs will only be a visual indication of the affect the attenuation is having on the frequencies, it is not particularly important that these be fast. Unfortunately, as the audio stream will be vocals, even a slight delay will render the thing useless. What delay might I expect with a single mono channel going through the arduino?
I expect that I will eventually have to revert to the less-interesting project of an RTA which takes a split of the audio sends to the speakers and simply displays the frequency band intensities rather than altering them.
I'd appreciate any thoughts.

How were you planning on performing the attenuation?

Have you looked at using an FPGA?

Try Googling "Arduino FFT". I found this one for example which looks remarkably like what you are asking about.

Somewhat possible if you accept that the Arduino won't be doing most of the work:

Yes, the Arduino can sample audio and perform FFT on it, though not fast and not at high frequencies
Yes, the Arduino can decide what to do depending on the power of different buckets
Yes, the Arduino can display the results
No, the Arduino cannot do realtime audio filtering.

If you accept that the filtering will have to be done with a bank of analogue band-cut filters that the Arduino turns on and off as needed then it may be possible.
The Arduino Due might be a more suitable candidate since it will be able to sample and do the FFT much faster so you'll be able to respond to the peaks much quicker, and the displaying won't get in the way so much, but actively filtering inside the chip really requires a DSP.


text:
How to limit the number of message that an Arduino sends to a phone without terminating it
I just stayed on delay() since that is the only thing I know but the thing is delay() cannot be interrupted. What I'm trying to achieve with this code is:

When the soilSensor detects moisture it would send a text message to a number only ONCE without terminating the program even if in the next loop the soilSensor is still detecting moisture.
The soilSensor's delay is delay(60000) and we would still wait for while to finish the delay but what if in the middle of the soilSensor's delay(60000) there is a movement for just about 5 seconds? What to do so that the tiltSensor can overlap the soilSensor's delay and sends a message to a number?

I want this program to run forever. Please help me! I needed this ASAP!
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
int led=22;

void setup()
{
  Serial.begin(9600);
  SIM900.begin(19200);
  pinMode(led, OUTPUT);
  delay(1000);
}

void sendSMS1()
{
  SIM900.println("AT + CMGS = \"+************\"");
  delay(100);
  Serial.println("Water Detected");
  delay(100);
  SIM900.println("Water Detected");
  delay(100);
  SIM900.println((char)26);
  delay(100);
  SIM900.println();
  delay(100);
}

void sendSMS2()
{
  SIM900.println("AT + CMGS = \"+************\"");
  delay(100);
  Serial.println("Movement Detected");
  delay(100);
  SIM900.println("Movement Detected");
  delay(100);
  SIM900.println((char)26);
  delay(100);
  SIM900.println();
  delay(100);
}

void loop()
{
  int soilSensor = analogRead(A0);
  int tiltSensor = analogRead(A1);

  if(soilSensor >= 10)
  {
    digitalWrite(22, HIGH);
    Serial.println(soilSensor);
    sendSMS1();
    delay(60000);
  }
  else
  {
    digitalWrite(22, LOW);
    delay(60000);
  }

  if (tiltSensor >= 100)
  {
    digitalWrite(led, HIGH);
    Serial.println(tiltSensor);
    sendSMS2();
    delay(60000);
  }
  else
  {
    digitalWrite(led, LOW);
    Serial.println(tiltSensor);
    delay(60000);
  }
}

BlinkWithoutDelay is good reference material for solving this issue.

If you were the Arduino, how would you go about solving the problem?

You use millis() to keep track of time and also prevent blocking. Replicating your program logic:
long soil_timer = 0;
long tilt_timer = 0;
char soil_flag = 1;
char tilt_flag = 1;

void loop() {
    int soilSensor = analogRead(A0);
    int tiltSensor = analogRead(A1);

  if (soil_flag == 1) {
    if (soilSensor >= 10) {
      digitalWrite(22, HIGH);
      Serial.println(soilSensor);
      sendSMS1();
    }
   else {
      digitalWrite(22, LOW);
    }
    soil_timer = millis();
    soil_flag = 0;
  }

  if (tilt_flag == 1) {
    if (tiltSensor >= 100) {
       digitalWrite(led, HIGH);
       Serial.println(tiltSensor);
       sendSMS2();
    }
    else {
       digitalWrite(led, LOW);
       Serial.println(tiltSensor);
    }
    tilt_flag = 0;
    tilt_timer = millis();
  }
  if (millis() - soil_timer >= 60000){
     soil_flag = 1;
  }
  if (millis() - tilt_timer >= 60000){
     tilt_flag = 1;
  }
}


text:
SIM800L project not working
I got a SIM800L, same as the one under this link, Quickstart SIM800 (SIM800L) With Arduino, and played around with an Arduino Nano and Uno. I had a few problems, at the start, not getting it work properly. It turned out that my Nano 5V pin wasn't enough for the SIM unit. It works fine with Uno though.
There is the code I tested the GSM (same link) and got it working somehow, I got simple AT commands and managed to send an SMS. But after I dismantled the connections and the next day I tried again... Nothing. I can see the SIM unit connects to network as the LED blinking slows down to once every 3 seconds but when I type commands in nothing happens in the serial monitor. It doesn't give errors or anything, just nothing happens on the serial monitor.
I did wire it incorrectly, once with the Tx/Rx, but that shouldn't damage the unit, should it?
I tried to upload different programs to my Arduino and they work fine so that shouldn't be the problem. Is there a way to reset the SIM800 unit? Or am I missing something here?

If you turn around the Rx and Tx pins, nothing would be damaged. Try connecting a "USB to serial TTL cable" directly, so you can speak from with terminal from PC (USB) to the device directly.

These modules cannot tolerate a 5v supply.  It is theoretically possible for a carrier board to have a 5v to 4.2v regulator, but there is no indication of the existence of one at your link.   the LM317 mentioned there is extremely unsuitable - insufficient current handling, and too high a dropout voltage.

It looks like it has a 5V pin right at the top left doesn't it?  Also kinda curious - what disqualifies the LM317 from candidacy?

The module needs a good 5v supplier as it might have a peak of 1A or 2A, when it registers to the network or connects to 3G.
You need to make sure that you share the ground between the power supplier and you use some 2 pins on your arduino to connect the GSM module.
Dont try to get a fast baudrate as software serial doesnt work, try with 9600 to start then see if it response to the AT command.
SIM800 is a very simple module, try with an FTDI in case you want to make sure you didnt break your Arduino.
For more help, share your schematic how you have connected the arduino.

While you are correct about the high current requirement, the device cannot tolerate a 5v supply unless there is an appropriate regulator somewhere in the system, which would be less than trivial to select (the link's mention of an LM317 is entirely unsuitable)

Isn't he using a breakout board which has an onboard regulator?

I have put in a lot of time with the SIM808, and I always have trouble delivering enough power to it.  Note that the SIM808 will alert you with an "undervoltage warning" sometimes as a response to AT commands.  I bet the SIM800 would do the same.
As Max above is alluding to - try powering the SIM800L via a separate 5V 2A adapter.  When doing this don't forget to still hook up ground between the Uno and your SIM800L board.
If you accidentally hooked 5V to the VDD pin on your module, you may have damaged it.
FTDI is a tool every embedded dev should have.  Get a few!

Keep in mind that the SIM800/808 cannot tolerate a 5v supply - you hint at this, but it's not clear what regulator you imagine would provide an appropriate connection to such a supply.

You're right.  I didn't make it clear - I am using a FONA 808 shield module which is designed to plug in to an Uno 5V directly

The FONA shield accepts a 5v input, yes, but it is to recharge the required lithium cell.  It is actually the cell rather tha the input which provides the peak power required by the module.  That means that a high current 5v supply is not really required, nor even likely to be taken advantage of, since the charge current is set for a relatively small cell.


text:
Motors settings
I'm trying to build my own 3D printer with a guide but I've got a problem with two of my CD/DVD motors: I don't know which settings to set in Marlin (configuration.h) because I can't find any datasheet for them.
So, I tried to set some values by my own, but I'm a little lost. That's why I'm asking for some help!
I'm using an Arduino Mega 2560 (with Marlin firmware), a RAMPS 1.4 and x4 A4988 modules.

The 1st motor has "7810200082AC" engraved on front and "D5X08VF1D" printed on the back.
The 2nd motor has "05Z20P2B" and "092KPL201ACP" printed on the back.

If I wasn't clear or some information is missing, please tell me!

I have played with a few of same looking steppers, burned one up as the one I had was a 3V one, ended up using a 9110 controller for it. So be aware of it getting extremely hot, you might need lower voltage.

Unless you are planning to make a printer with a build area no larger than the length of those screws, those tiny floppy drive motors are probably unsuitable.  Anyway, this is not meaningfully an "Arduino" question.

I don't know your exact setup, but when it comes to steppers, you just need to know a few things:

Meter the coils to get an impression, how much current you can induce.
Limit the current on your driver as low as possible (<= 0.25 A possible?)
Test
Heighten the current, if the motor doesn't turn or stalls

Your motors are quite small, so I would assume, they run with less than 0.25 A at 12 V or 0.125 A at 24 V and so on.
If you limit the current, nothing can go wrong at all. Check the heat from time to time and make sure, your drivers lowers the current, whenever the given axis stands still.
When it comes to to resolution, I would not recommend to use more than 1/4 steps, which would result in 4*48/round steps on a standard stepper and provides very good resolution plus smooth motor action.

Hi, thank you for your answer.
So I, set the Vref at 0.2V (multimeter says 0.199) to get 0.25A with a Rs at 0.1Ohm (0.25A * 8 * 0.1Ohm = 0.2V) and I put a jumper to get 1/4 steps.
Now, I don't know which values to set in Marlin for: DEFAULT_AXIS_STEPS_PER_UNIT, DEFAULT_MAX_FEEDRATE, DEFAULT_MAX_ACCELERATION.
I tried some values and the motor moves smoother than before with driver's settings but I don't know how to find exact values without a datasheet.

Huh .2V seems really less, I thought about .25A@12V which would result in 3 watts. .25@.2V is just 0,05 watts. Not enough to turn your motor, I guess. When it comes to Marlin: You need to know, how much your spindle moves during one turn (lets say: 1cm)  and how much steps your stepper does (substeps included) per round (lets say: 484). So you have 484 Steps per cm. Feedrate is very hard to guess. Try 150 on Z and 4 times more on X and Y. Accelleration is very dependend of your driver. Experiement.

You need to lower/raise the current on the A4988 modules with this tiny screw. Check the manual.

authors: ณัฐฌา แซ่หลี


text:
How to monitor state of 50 Digital Inputs
Good day.
I have a specific project need and I spent the past couple of days searching on forum, blogs, etc and I'm still not clear if that's feasible to do with Arduino or not.
I need to monitor the state of ~50 digital inputs and trigger an action when any of the pin changes either from 0 to 1 or from 1 to 0, pretty much the same as pin state interrupt works, only difference is that I need to "listen" to ~50 pins, instead of just a couple. I must be able to identify what pin triggered the action and what was the change (0->1 or 1->0).
My initial idea is to use a MEGA 2560 and have a group of 50 "if" statements on the main loop comparing the previous state or each pin (stored in individual variables) with the current one and triggering the corresponding action if something changed.
I'd like to hear from the experts here what would be a more elegant or smarter/faster way to accomplishing this.
I'm eager to receive your feedback.
Thank you.

50 ifs? define a constant array of pin number and a for loop over it. and define an array of states to remember the last state.

One alternative is to use daisy-chained parallel-in, serial-out shift registers such as 74HC165. Those parts can be bought for less than 30 cents each from ebay or aliexpress.

I/O expanders, for example the pcf8574 have an interrupt. You would only have to wait for an interrupt, and then request via i2c which pin has changed.

I had a project that used 16 rotary encoders and I used the MUX Shield which uses 74HC4067 analog multiplexers. They port to A0 - A3 on the shield which is fine as you can set these pins to Digital Inputs else you can get teh breakout version and connect to any input pins.
I also used a Due since ALL pins can be interrupt enabled.
Reading was a bit of a pain but worked like this...
The method is.. Continually address each input in turn in the loop or an interrupt is not detected, when an interrupt fires, address each input in turn again to find out which pin changed state.
Hope that helps.

The Mega 2560 appears to have 24 pin change interrupts (I haven't checked if they're all broken out on the Mega Arduino board).
A combination of as many pin change interrupts and 'manual' scanning could be quicker than scanning them all individually.
Another option would be to group as many as possible onto the same ports and use direct hardware access to looks for changes- with this you'd be able to do 8 inputs at a time. With 8 inputs on each port, you just need to have seven main checks that the port value has changed and then jump off to a handler that deals with what specific pin has changed and what action is needed.

See answers in Good solution for more interrupts on an Arduino. E.g.:
Answer lhballoti:
You can use an I/O expander, for example an MCP23008 and MCP23017. They are available in SPI and I2c. Interrupts can be configured (edge-sensitive, level-sensitive) for each input.
Answer embedded.kyle:
You could use a Programmable Interrupt Controller (PIC) such as the 82C59A. It will cascade if you need more than the eight interrupts it provides. It's a bit old school but I think it will handle all of your requirements.

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


text:
Stop and continue loop by using boolean flag for traffic light
By using boolean and flag, I can now control the green light but the program cannot repeat or loop the sequence for traffic light from red to yellow to green. If I don't use flag, the sequence red-yellow-green LED can be looped but I can't control and trigger green light on app.
My current project also serial communicate from NodeMCU to Arduino.
#include <SoftwareSerial.h>

SoftwareSerial nodemcu(2,3);
long int data;

boolean start = true;

void setup() {
  pinMode(7,OUTPUT);//greenbulb
  pinMode(8,OUTPUT);//yellowbulb
  pinMode(9,OUTPUT);//redbulb

Serial.begin(9600);
nodemcu.begin(9600);

}

void changeLights()
{
  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,LOW); // yellowbulb
  digitalWrite(9,HIGH);// redbulb
  delay(7000);

  digitalWrite(7,HIGH);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(5000);

  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);
  digitalWrite(7,HIGH);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);
  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);
  digitalWrite(7,HIGH);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);

  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,HIGH);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(2000);
}

void loop() {

if ( nodemcu.available() > 0 )
{
  data = nodemcu.parseInt();
  delay(100);
  Serial.println(data);

      if (( data == 10) && (start == true)){
           changeLights();
            start = false;
      }

      if (( data == 11) && (start == false)){
      digitalWrite(7, HIGH);
      digitalWrite(9, LOW);
      digitalWrite(8, LOW);
            start = true;
      }
}
}

see the BlinkWithoutDelay example

tip: if (start) is same as if (start == true)  .........    if (!start) is same as if (start == false)   .............. less typing and less redundancy

What you really want is a Finite State Machine.

you have a bunch of useless code in your program .... why are you making pin 8 LOW a multiple times in a row? .... you only have to do it once .... same goes for the other pins

This is not an answer (that is looking at the BlinkWithoutDelay as Juraj mentioned), but I want to provide a way how to greatly reduce your program and use this method in future.
You are repeating
digitalWrite(7,LOW);// greenbulb
digitalWrite(8,HIGH);// yellowbulb
digitalWrite(9,LOW);// redbulb
delay(2000);

A lot, with variations of LOW/HIGH and the delay time. Instead, use a function that has parameters:
void changeLight(int green, int yellow, int red, int delayTime)
{
    digitalWrite(7, green);
    digitalWrite(8, yellow);
    digitalWrite(9, red);
    delay(delayTime);
}

And you can call it by
changeLight(LOW, HIGH, LOW, 2000);
You can do this for all of the 4 line repeats.


text:
Not able to receive string from database
A few days ago I posted a thread as I was not being able to send data to my database online. It worked when I changed the GPS module. Now I am trying to retrieve data from the same Server and i'm not being able to do it. The PHP code parses the outputs the data as string and i'm not being able to receive it.
when I visit the URL I am able to see the output on a browser window.
I will Basically get a address which i plan to use substring into 3 lines and display on an 20x4 LCD. is there a better way to go about it?
Thank You!
Arduino Code
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <Wire.h>
#include <DS1307new.h>
#include <LiquidCrystal_I2C.h>
#include "LiquidCrystal.h" // For LCD
#include "LiquidCrystal_I2C.h"

#define DEBUG true

TinyGPS gps;

SoftwareSerial sGPS(10,11);

LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7);  // SET I2C Address

uint16_t startAddr = 0x0000;  //Start address to store in NVRam
uint16_t lastAddr;        //New address to store in NVRam
uint16_t TimeIsSet = 0xaa55;  //Helper that time must not be set again

int currentDay = 0;
int currentMonth = 0;
int currentYear = 0;
int currentHour = 0;
int currentMinute = 0;

float flat, flon;
float previousFLat = 0.0;
float previousFLon = 0.0;

const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 4;
const int buttonPin4 = 5;
const int buttonPin5 = 6;    //call Cluster
const int buttonPin6 = 7;    //call User

const int ledPin1 =  22;
const int ledPin2 =  24;
const int ledPin3 =  26;
const int ledPin4 =  28;

int button1State = 0;
int button2State = 0;
int button3State = 0;
int button4State = 0;
int button5State = 0;
int button6State = 0;

String rcv=""; //Variable in which the server response is recorded.

void setup()
{
  Serial.begin(9600);
  sGPS.begin(9600);
  Serial1.begin(9600);
  lcd.begin(20,4);  // Initialinze LCD.
  lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
  lcd.setBacklight(HIGH);

  /*
  Control the clock.
  Clock will only be set if NV-RAM Address does not contain 0xaa.
  DS1307 should have a battery backup.
  */

  RTC.getRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
  if (TimeIsSet != 0xaa55)
  {
    RTC.stopClock();

    RTC.fillByYMD(2011,4,8);
    RTC.fillByHMS(22,7,0);

    RTC.setTime();
    TimeIsSet = 0xaa55;
    RTC.setRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
    RTC.startClock();
  }
  else
  {
    RTC.getTime();
  }

  /*
   Control Register for SQW pin which can be used as an interrupt.
*/
  RTC.ctrl = 0x00;                      // 0x00=disable SQW pin, 0x10=1Hz,
                                        // 0x11=4096Hz, 0x12=8192Hz, 0x13=32768Hz
  RTC.setCTRL();
  delay(5000);

    pinMode(ledPin1, OUTPUT);
    pinMode(buttonPin1, INPUT);
    pinMode(ledPin2, OUTPUT);
    pinMode(buttonPin2, INPUT);
    pinMode(ledPin3, OUTPUT);
    pinMode(buttonPin3, INPUT);
    pinMode(ledPin4, OUTPUT);
    pinMode(buttonPin4, INPUT);
    pinMode(buttonPin5, INPUT);
    pinMode(buttonPin6, INPUT);

  }

  void loop()
{
    RTC.getTime();

    currentDay = RTC.day;
    currentMonth = RTC.month;
    currentYear = RTC.year;
    currentHour = RTC.hour;
    currentMinute = RTC.minute;
  String rcv="";

  bool newData = false;

  //For one second we parse GPS data and report some key values

  for (unsigned long start = millis(); millis() - start < 1000;)

  while (Serial1.available())
    {
      char c = Serial1.read();
     //Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
      newData = true;
    }

  if (newData)
  {
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);

    if ((flat !=previousFLat)||(flon !=previousFLon))
    {
      previousFLat = flat;
      previousFLon = flon;
      //Serial.print (previousFLat,6)
      //Serial.println(previousFLon,6);
      SendSQL();
      PullSQL();
      startTrip();
    }
  }

}

void waitUntilReponse(int delayMs)
{
// Delay in ms
while (sGPS.available() < 0) { delay(delayMs); } while (sGPS.available() > 0)
{
Serial.write(sGPS.read());
}
}

  void SendSQL()
  {

    Serial.println("Start Send");
    waitUntilReponse(500);

    sGPS.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+SAPBR=1,1\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+SAPBR=2,1\r\n");
    delay(3000);
    waitUntilReponse(500);
    sGPS.println("AT+HTTPINIT\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+HTTPINIT=?\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+HTTPPARA=\"CID\",1\r\n");
    delay(500);
   waitUntilReponse(500);

    sGPS.print("AT+HTTPPARA=\"URL\",\"http://quickshawdic.000webhostapp.com/geta.php?");
    sGPS.print("desig=R001");

     sGPS.print("&addDay=");

     sGPS.print(currentYear);
     sGPS.print("-");

     if (currentMonth < 10) { sGPS.print("0"); sGPS.print(currentMonth); }
      else { sGPS.print(currentMonth); }
      sGPS.print("-");

      if (currentDay <10) { sGPS.print("0"); sGPS.print(currentDay); }
      else { sGPS.print(currentDay); }

      sGPS.print("&addHour=");
      if (currentHour <10) { sGPS.print("0"); sGPS.print(currentHour); }
      else { sGPS.print(currentHour); }
      sGPS.print(":");

        if (currentMinute <10) { sGPS.print("0"); sGPS.print(currentMinute); }
        else { sGPS.print (currentMinute); }

          sGPS.write("&addLati=");
          sGPS.print(previousFLat,6);
          sGPS.write("&addLongti=");
          sGPS.print(previousFLon,6);
          sGPS.println("\"");
          delay(3000);
          waitUntilReponse(500);
          sGPS.write("AT+HTTPACTION=0\r\n");
          delay(15000);
          sGPS.write("AT+HTTPTERM\r\n");
          delay(500);
          sGPS.write("AT+SAPBR=0,1\r\n");
          delay(500);
          waitUntilReponse(500);
          Serial.println("Finish");
        }

void PullSQL()

{
  lcd.clear();
  lcd.home();
  Serial.println("Start Recieve");
    waitUntilReponse(500);

    sGPS.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+SAPBR=1,1\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+SAPBR=2,1\r\n");
    delay(3000);
    waitUntilReponse(500);
    sGPS.println("AT+HTTPINIT\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+HTTPINIT=?\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.println("AT+HTTPPARA=\"CID\",1\r\n");
    delay(500);
    waitUntilReponse(500);
    sGPS.print("AT+HTTPPARA=\"URL\",\"http://quickshawdic.000webhostapp.com/getr.php?");
    sGPS.print("desig=R001");
    waitUntilReponse(5000);

    String line = sGPS.readString(); //Read the server response line by line..
    rcv+=line; //And store it in rcv.
    Serial.println("Received string: ");
    Serial.print(line);
     delay(3000);
  waitUntilReponse(500);

  sGPS.write("AT+HTTPACTION=0\r\n");
          delay(15000);
          sGPS.write("AT+HTTPTERM\r\n");
          delay(500);
          sGPS.write("AT+SAPBR=0,1\r\n");
          delay(500);
          waitUntilReponse(500);
          Serial.println("Pull Finish");
}

    void startTrip()

    {

      button1State = digitalRead(buttonPin1);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (button1State == HIGH) {
    // turn LED on:
    digitalWrite(ledPin1, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin1, LOW);
  }

    }

PHP Code
<?php

 $dbusername = "username";
    $dbpassword = "password";
    $server = "localhost";

 $dbconnect = mysqli_connect($server, $dbusername, $dbpassword);
    //$dbselect = mysqli_select_db($dbconnect, "request");

 $sql="SELECT user_name FROM id8371368_quickshaw.rides
 WHERE rickshaw_id = '".$_GET["desig"]."'";

 $records=mysqli_query($dbconnect,$sql);
 $string="";

    $row=mysqli_fetch_assoc($records);
 $string=$row["user_name"];
 echo $string;
?>

Try adding newline after sending the URL: sGPS.println("desig=R001");

That's what I did at first, same no output.


text:
How to operate a brushless motor & ESC with an Arduino
I have recently bought two brushless motors (Brushless-300w-6-5-Wheel-Tyre-Motor-Hoverboard-Swegway-Board-Replacement-Part) along with two ESC (https://hobbyking.com/en_us/hobbyking-40a-esc-4a-ubec.html).
I have connected the hardware accordingly (photo attached, the potentiometer throttle included is not included in the photo).
And I try run the following code:
#include <Servo.h> //Using servo library to control ESC

Servo esc; //Creating a servo class with name as esc

void setup()

{

esc.attach(10); //Specify the esc signal pin,Here as D10

esc.writeMicroseconds(2000); //initialize the signal to 1000

delay(1000);

esc.writeMicroseconds(1000); //initialize the signal to 1000

delay(1000);

//Serial.begin(9600);

}

void loop()

{

int val; //Creating a variable val

val= analogRead(A0); //Read input from analog pin a0 and store in val

val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed)
esc.writeMicroseconds(val); //using val as the signal to esc
}

The motors seem to vibrate and turn only when the potentiometer is at a specific point, and are then inert for all the subsequent positions.
Does anyone have any advice on how to overcome this issue?
Thanks!]1

I don't know how to control an ESC via the arduino, but I did just find this link which seems to have a fair amount of information, such as calibrating the ESC.
https://dronesandrovs.wordpress.com/2012/11/24/how-to-control-a-brushless-motor-esc-with-arduino/

It may or may not help if you read the troubleshooting part of the ESC manual:
https://cdn-global-hk.hobbyking.com/media/file/378561453X16958X28.pdf

If the photo and code attached are correct, you connected the ESC to physical pin 53 (I believe, photo is blurry), but when calling esc.attach() you are using pin 10. If this is the case and a mistake has been made, please either connect the esc to pin 10 or change the code to say esc.attach(53).

Your code immediately sets the ESC to high upon startup. Most ESCs have protection, and if the initial signal is high, they lockout until you go all the way back to low. You may not have low calibrated though, so it might not ever let you control it. Calibrate by (remove initial high-low code first) setting the pot to high (with the ESC disconnected from power), then powerup the ESC.  You should hear a bunch of beeps, and when it stops, slowly turn the knob all the way to low, and you should be met with some more beeps. Disconnect power, reconnect, and try control (starting with a LOW signal)


text:
The most practical plug socket
I am starting some Arduino's projects with different sizes (very small based on Arduino Nano and bigger using Arduino Mega). These projects will be manipulated by students and they will connect and disconnect many times the wires. I will try to not use breadboard if I can. In order to develop very versatile projects, the idea will be to use very useful plug sockets. Currently I have no idea of which kinds of plug sockets I can use.
Do you have any idea about the existing plug sockets (from 2 to 6/8 wires) and which one it is preferable to use?
Complements:

Some shields and components I already have and want to use have sometimes some plugs sockets (similar to this) but sometimes only some classical pins
I want also to build my own shields by integrating plug sockets to the arduino or to another shield
Some parts will be also composed by small electrical circuit on which I want to integrate plug sockets aswell
I will also use LiPo batteries (for example this one which have a connector I can't buy currently because I don't know the reference)
Communications will be also achieved using SPI and I2C

Without knowing exactly what you are doing with these plugs and sockets, and what signals will be going down the wires, no one can say for sure. In some situations IDC connectors (like you used to have on older hard drives - or the smaller versions of them) could be ideal, but ribbon cable is ghastly for I2C or SPI. 9 Pin D connectors might be good, or they might be too bulky. There's just too many variables to be able to say "This is best".

Actually, I have also had similar considerations over a few educational projects. After many hours of strolling against the wind, I had to realize that probably there is nothing wrong with the plug-in breadboards and the readily available jumper wires. Actually, those are pretty easy to replace, inexpensive, and give the feeling of a full control of the connections, instead of using some yet another connection scheme and pinouts to learn.

@GeeBee It also has the advantage that they are actively learning the circuit, not just plugging together LEGO® bricks.

@Majenko, agreed! This is what I wanted to say, thanks for making this point very clear. I agree with you that lego bricks (e.g. lego wedo, lego NXT, littlebits) totally hide the electric connection aspect by using a much higher level of abstraction of "just put together". While this is great for preschool students since it hides a lots of complexity they are not interested in, it may not be a sufficient approach for an EE students course. It is much easier and inexpensive to let them blow up a few 1$ components for real than explaining all the underlying magic of connections for weeks.

@Majenko I have extended my initial post with more comments.

The problem with most of the connections you have linked to is they require specific crimped connections on the wires. The tool to do that crimping is specific to the connector, and can cost hundreds of pounds each.

@GeeBee I agree with you but in my case my students are not studying Electronical/Electrical fields but mechanical field. The purpose will not be to have electrical approach but use the electrical/electronical component to do some mechanical measurements using dedicated sensors. Moreover I want to minimize at the maximum the damages students can do by pluging and unpluging components.

@Majenko Even considering connectors presents on this shield: http://boutique.semageek.com/fr/280-grove-base-shield-v2.html?adw=1&gclid=Cj0KEQjwrte4BRD-oYi3y5_AhZ4BEiQAzIFxn5xRoul9Pb_uKKQ_Tahm-_D9FlSqx8guNvUjOANcEHgaAlzR8P8HAQ ?

Yes. Those are most likely JST. The last time I looked at a JST crimping tool the cost was in 3 figures.

@Majenko I see (real Tool http://goo.gl/4QqAIB , chinese version: http://fr.aliexpress.com/item/SN-28B-Pin-Crimping-Tool-2-0mm-2-54mm-3-96mm-18-28-AWG-Crimper-Dupont/32436828755.html?spm=2114.30011508.3.1.MUDVRu&ws_ab_test=searchweb201556_0,searchweb201602_1_10017_10005_10006_10034_10021_507_10022_10020_10018_10019,searchweb201603_7&btsid=603793c6-ff44-4d51-93d1-a3e6d5d2bce0 ). Maybe I have to find another solution or buy wires with plug sockets already fixed on it (and weld connectors on shields)

Ok, so more info from the OP:

non-electrical engineering students needs a prototyping platform
minimize possible damages, support hot plug-and-play
not too expensive

Dedicated connector
I suggest using standard subD9 connectors. Sensors shall have male pins, while the control board female socket (this makes very hard to do accidental short circuits on the control board). We were using these connectors in a daily basis in a lasershow system, and I was very statisfied. Inexpensive, easy to solder, works with a wide range of cables or separate wires.
In many cases, you can integrate the sensor into the housing of the connector. For example, an IR receiver, an accelerometer, etc. fits well.
You can use off-the-shelf serial cable extenders which makes it very versatile.
Since it is a D shaped connector, there is only one possible way to connect a sensor to the mainboard, and we're golden.
Dedicated connector light
NSL25 and NSG25 are my favorites:
http://www.soselectronic.hu/?str=371&artnum=4927&name=nsl-25-2-g
http://www.soselectronic.hu/?str=371&artnum=4934&name=-nsg-25-2
Although these are inexpensive wire to board connectors, it is very hard to misconnect them. Criping is a PITA, but you can purchase pre-crimped connectors with wires such as http://www.soselectronic.hu/?str=371&artnum=6175&name=-p-35003
One 3 wire female connector with wires costs about 50 USD cent.
Note though that in this case, the control board has the male connectors. By accidentally dropping a coin to the connector, or using a screwdriver, it is easy to run into short circuits. This leads us to the next plan...
Any inexpensive connector with proper electric protection
Probably the most inexpensive solution is to use standard headers and pins. Here you may also wish to buy ready made cables, than start crimping yourself:
http://www.soselectronic.hu/?str=371&artnum=6171&name=-p-2543
This however opens up a can of worms of misconnection:

connection by one or multiple pin off
connection in reverse direction
shorting the pins on the board

Against sorting, you shall have a multifuse on the power pins, say, 250mA. On each IO pin, you shall have a series resistor of 470 ohm, this ensures that no miswiring can destroy the Arduino.
On the sensor-side, things are a little more tricky. You need a shottky (or an equivalent P fet diode) to ensure that reverse polarity connection will not destroy your sensor. If the sensor has output pins, also use a series 470 ohm resistor.
Considering all the hassle, using a standard subD9 connector is a way easier:

it has enough dedicated pins for I2C, SPI, and a generic IO for dumb sensors
the pins can handle more current, and there are more pins you can connect in parallel to have enough power for small motors
it is impossible to misconnect (once all sensor sockets use identical wiring)

Don't forget ESD protection
In any case, it is a good idea to have some sort of ESD protection whenever you have connectors, and wires, and rough external world.
Have at least a TVS diode on the power pins (say, an 5.8V or 6V unidir TVS will do). On IO pins you can use a simple series resistor, or you can opt for a TVS.
During hot plug and play, it may happen that sensitive sensors get powered in a strange way. E.g. first 5V then the sensor output is getting connected, but no GND for a short moment. Some sensor may get damaged in this case. Use diodes to fix this.
For sensors requiring sudden current peaks (e.g. WIFI, or a motor), add at least 470uF/16V electrolyte capacitor right to the sensor end of the connector. This way once the sensor is connected to a long extension wire, you still have acceptable power to use in sudden current peaks.
Some sensors (e.g. IR receivers) are sensitive to power glitches. Consult their datasheet, use the suggested RC filtering network on the power pins.


text:
Nano can't get reply from ENC28J60 Ethernet Shield
My Arduino Nano can't get a reply from my new ENC28J60 Ethernet Shield - I can't get any library examples to work. Using the UIPEthernet lib, and running the EchoServer example with logging turned up, I get:
ENC28J60::init DEBUG:csPin = 10
ENC28J60::init DEBUG:miso = 12
ENC28J60::init DEBUG:mosi = 11
ENC28J60::init DEBUG:sck = 13
ENC28J60::init DEBUG:Use Native hardware SPI
Enc28J60Network::writeOp(uint8_t op, uint8_t address, uint8_t data) DEBUG_V3:Function started
ENC28J60::init DEBUG_V3:Before readOp(ENC28J60_READ_CTRL_REG, ESTAT)
Enc28J60Network::readOp(uint8_t op, uint8_t address) DEBUG_V3:Function started
...

so it gets nicely into the Enc28J60Network::init function. But shortly after, it does a phyWrite, tries to read a response, and then times out.
ENC28J60::init DEBUG_V3:Before phyWrite(PHCON2, PHCON2_HDLDIS)
Enc28J60Network::phyWrite(uint8_t address, uint16_t data) DEBUG_V3:Function started
... lots of attempts to read
Enc28J60Network::phyWrite ERROR:TIMEOUT !!

And then it all starts to fail, and it never gets better. I tried the EtherCard lib, too, and it fails in a similar way.
I put the scope on the SPI pins, and I see reasonable stuff: activity on SCK and MOSI, nothing on MISO, and the SS (pin 10) switching ok - and the shield claims to use pin 10 (I briefly tried pin 8 as I flailed in confusion, but no luck there either).
So at this point, either I'm misunderstanding something, or the shield is DOA.
Update: Earlier, I strongly suspected the SCK line because it showed a very poor signal on my scope. But it turned out to be poor grounding on the scope probe, and the signal  was actually fine, a red herring. Thanks to @Majenko for drawing my attention to it.
Update 2: After getting no SPI response from the shield under any circumstances, my working hypothesis is that it was DOA. I've gone back to my UNO with W5100: all working fine. I have ordered more Nano ethernet shields, to arrive in a week or two, so I'll try with those, and provide updates/answers then.

How much bandwidth does your scope have? That looks awfully low resolution, and the kind of output I'd expect on a scope with not enough bandwidth to display the waveform correctly.

is ethernet cable connected?

@Majenko good point - and thanks for the pointer. I'd not earthed the scope probe  properly, so fixed, and the SCK line looks perfectly fine now. D'oh, beginner's mistake. I'll edit it out of the question.

@Juraj yes, all connected - and I get a little green light on the shield and on the hub, so I think it's all good there.

How much current can your 3.3V supply to the ENC28J60 Ethernet Shield? The data sheet says it uses 120mA when it's "Active, not transmitting Ethernet packets". Up to 180mA is required when it's "Transmitting Ethernet packets".

@VE7JRO oh I never thought of that... I've spent a whole day trying to .... :-) ok, checking now ...

@VE7JRO Your suggestion seems to be backed up by this discussion: https://forum.arduino.cc/index.php?topic=452822.0 ... I couldn't find anything much to test: my nano's 3.3V pin is stable, but that might be because the shield isn't drawing power when it sees the supply so weak. I'm now building an independent 3.3V supply...

@VE7JRO I've just hooked a 3.3V 2A supply up to the Nano's 3.3V line to give it more juice - no change. I think it's ok to just wire the power straight up to it, even though the 3.3V line is nominally an output (am I right?); I believe I'll definitely need to augment it anyway, but I'm starting to feel the shield is DOA. I wonder if running it with weak power killed it....? seems a bit feeble if it did.

Comments are not for extended discussion; this conversation has been moved to chat.

Perhaps this could bring some solution. https://www.mikrocontroller.net/topic/477142

@Riad what happened to your nice answer?

@Riad My shield matches the one on that forum and has the miscreant connection. I haven't tried fixing it because it's hard and I have other shields now. But I have high confidence that this is the answer. If you want to take credit, please write an answer; otherwise I shall do so myself.

Thanks to @Riad, who posted this as a comment. The problem appears to be a design fault in the "DK ectronics" V1.0 Ethernet Shield.

Perhaps this could bring some solution. https://www.mikrocontroller.net/topic/477142

The site is in German, so here's a brief translation of the key parts:

I bought an ENC28J60 for the Arduino Nano, but it does not respond from the programmed IP.
The shield has "NANO Ethernet Shield V1.0 DK ectronics" inscribed on the underside (spelling error in the original). There
  there is a via on the bottom between pins D11 and D12,
  missing from a (different) working shield. This via connects D12 line to GND from the AMS1117 on the top (easy to check D12 to GND with a multimeter). If that's the case with your shield, then this is the problem: we just have to cut out the via connection. I have
  Do this with a 1mm drill by placing the top copper layer in the
  via very gently (really gently!) Mill it away. If you drill too deep, you break the D12 connection completely and must possibly
  solder on a new wire. Keep checking D12 and GND for continuity to see whether you've milled away enough. Work really carefully!
After I did that, and tried the TCP Server example in the UIPEthernet
  library on the Arduino, the shield was reachable.
-- Christoph K

I haven't yet tried to make the changes described above, because they are fiddly and I have a new batch of working shields. But my device is exactly as described by Christoph and his photos, and the fault description matches mine.

The ENC28j60 shield for Nano has reset of the ENC28j60 chip on the pin 7 of the shield/Nano. Try to set the pin 7 HIGH.

If this solves it, it would be hilarious... ok, will try it at the weekend - alas I'm away atm. So, I just have to add: pinMode(7, OUTPUT); digitalWrite(7, HIGH); on setup? Hmm, I wonder why the UIP/EtherCard library examples don't have this. Perhaps the reset is non-standard, or there's a (too) weak pull-up?

@SusanW, did it help?

no it didn't, I'm afraid - I added pinMode(7, OUTPUT); digitalWrite(7, LOW); delay(1000); pinMode(7, OUTPUT); digitalWrite(7, HIGH); just to give it the best chance possible, but it still times-out on read and the MISO line is silent. Which is annoying, because what you suggested would be the perfect answer - and on reading around, it appears the pin-7 reset is an under-publicised feature. Anyway, I've ordered some more shields which should arrive any day, so I'll be able to eliminate board failure as a factor. I'll keep you posted... Thanks!

@SusanW, do not reset it. only set the pin HIGH. do it as first in setup().

Yep, I tried that first ....

Ok, new shields turned up - and worked first time. We have pings and TCP. And ironically, it works even without me setting pin-7 high. The other board must be dead. Hmm ... would you like to add that as an "alternative explanation" to your answer, or something, then I can mark this as the accepted answer. (I could add/accept an answer myself saying "Board was dead", but that would hide your more useful answer!)

@SusanW, at least you know you can not use the pin 7 or you must bend it on shield to use it on Nano. Or you can use it as reset of the shield, but I didn't find it useful with module I have.

It works if pin 7 is input on Nano, because the reset pin of the ENC28j60 has a pull-up.

I've written up an answer based on Riad's link about faulty ethernet shields, which matches the problem I had. But I feel bad because your answer is informed and helpful. If there's a better way to get the "Susan bought a rubbish board off eBay" explanation out there, do let me know! Thanks.


text:
Same output on displays with different I2C-addresses (AdaFruit library, ESP32)
I've got two displays hooked up to a ESP32 via I2C and I'm using the AdaFruit library. All handling display output is packed in a own library. As I was testing I only had one display set up and everything looked fine. Now, in my actual setup with two displays, I only get the output of the first display on both screens. The displays are running on the same I2C-bus, different addresses are set. I also ran a address/portscanner that confirmed the different addresses (0x3C and 0x3D).
I have used separate displays with the AdaFruit library in such a setup before, but only on an Arduino uno and without having code moved to own libraries. So I can't tell if the ESP32 or having multiple files is messing things up or I'm missing something.
Here are parts of code in the cpp-file I used to initialize the displays and some functions I call:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <gfxfont.h>
#include <SPI.h>
#include "DisplayOut.h"
#include "Game.h"

    /* -------------esp32 Pin setup --------------------- */
    const byte displayData = 21;    // I2C SDA
    const byte displayClock = 23;   // I2C SCL
    /* --------------------------------------------------- */

// Define OLED
#define OLED_RESET displayData
Adafruit_SSD1306 display1(OLED_RESET);
Adafruit_SSD1306 display2(OLED_RESET);

/* some variables */

void DisplayOutClass::init()
{
    // Initialize each display with i2c-address

    display1.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display2.begin(SSD1306_SWITCHCAPVCC, 0x3D);
    display1.setTextWrap(false);
    display2.setTextWrap(false);
}

void DisplayOutClass::scorePlayer1(int score1)
{
    display1.clearDisplay();

    if (gameMode == 2)
    {
        display1.clearDisplay();
        display1.setCursor(0, 0);
        display1.setTextSize(2);
        display1.setTextColor(WHITE);
        display1.print(playerName[player1]);
    }

    display1.setTextSize(4);
    display1.setTextColor(WHITE);
    display1.setCursor(getCenteredPosX(3, String(score1)), 24);
    display1.print(score1);
}

void DisplayOutClass::scorePlayer2(int score2)
{
    display2.clearDisplay();

    if (gameMode == 2)
    {
        display2.clearDisplay();
        display2.setCursor(0, 0);
        display2.setTextSize(2);
        display2.setTextColor(WHITE);
        display2.print(playerName[player2]);
    }

    display2.setTextSize(4);
    display2.setTextColor(WHITE);
    display2.setCursor(getCenteredPosX(3, String(score2)), 24);
    display2.print(score2);
}

/* some more Functions */

DisplayOutClass DisplayOut;

I didn't post the complete code or the header file, because it exceeds a few hundred lines. But this should show how the I2C-addresses are used. If necessary, I of course can post the rest of the code.
My next approach would be either trying the U8g2 library or trying start a second I2C bus. Since I already have a finished circuit board, so this would be my least preferred option.

Your reset pins are set to the number of the i2c address and you use the same reset pin for both displays? Did your read that you can make the reset pin -1 to not use it or share it with the arduino reset.

I agree with @Jot, reset pins must be separated: you are using the same pin (same define OLED_RESET), resulting reset the first display after initialized...

The displays each only have four pins: VCC, GND, SCL, SDA. So there is no reset pin. Setting OLED_RESET to -1 didn't work, neither did setting OLED_RESET to unused pins.

Adding false to the begin-methods display1.begin(SSD1306_SWITCHCAPVCC, 0x3C, false) and display2.begin(SSD1306_SWITCHCAPVCC, 0x3D, false) to disable reset didn't bring any progress either.

fwiw, i had to use a 2nd i2c line to get the esp32 to play nice. worked well and ended my frustration, but if there's a better way, I too am curious.

Try the new constructors (old ones are deprecated):
Wire.begin(21, 23); // SDA, SCL

Adafruit_SSD1306 display1(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT);
Adafruit_SSD1306 display2(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT);

display1.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display2.begin(SSD1306_SWITCHCAPVCC, 0x3D);

Using this with "#define SSD1306_LCDWIDTH 128" and "#define SSD1306_LCDHEIGHT 64" just gives me errors and doesn't compile, although I overwritten the library with the one from the link to be sure to have the correct version.

Found the problem, was still using the constructor wrong. What dfid the trick was:
#define OLED_RESET -1
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);