text:
Trying to power 100 Arduino's from single power line
I'm trying to power up to 100 Arduinos that will be spread across a 25m wall using a single power line.
The idea is each Arduino will have a few a few buttons, leds & an oled screen and will all communicate to a master server using rs485.
====[A0]====[A1]====[A2]====[A3]====[A4]== ... ==[A99]

I've already followed this brilliant post http://www.gammon.com.au/forum/?id=11428 to implement the data connection using an rs485 bus.
However I'm struggling to understand how I could power multiple Arduino's from the one line and not introduce surges/ground loops from the difference in group potential caused by the long power line.
Would I have to isolate each Arduino and rs485 driver? Or is there a simpler solution?

Try electronics.stackexchange. It might be better to have a higher voltage power rail, and have a buck-converter on each Arduino, but I don’t have any experience with this.

Sam's question on Electronics Stack Exchange: https://electronics.stackexchange.com/q/392642

please define single power line .... it means more than one thing

You are already using a differential signalling system that doesn't care about ground levels, so you don't need to worry about that side of things.
As for power distribution - a strategy known as point of load regulation is what you want. That is where you supply a higher voltage (but lower current) power feed to one, or in this scenario more likely a group of, boards and regulate that power down using a switching regulator to a lower voltage (5V) and higher current.
This has the advantage that:

You are only worrying about small groups of Arduinos, not the whole lot
You can use thinner wires to feed in the power to a group
You get less losses from wire resistance at high currents

For 100 Ardunos you may want to have maybe 10 to a group with a 3A switching regulator for each group, giving an average of 300mA per board (depending on your current needs, of course - you may want less per group and more groups to give more average current per board).
In that example you'd have a total output current limit of 30A in 10 sections at 5V. That equates to (P=V×I) 150W. So a 200W 24V power supply would be adequate.
At 24V, 150W would demand 6.25A (plus some more to account for the efficiency of the regulators, so call it 8A - hence the desire for a 200W supply).
For 3A you need at least 24AWG wire - but preferably considerably thicker - maybe 18AWG.  The 8A for the 24V would need minimum 15AWG, preferably bigger - although you don't need that size all the way to the end of your chain of regulators. If you had each regulator wired directly back to the power supply individually that would only need thin wires (absolute minimum 30AWG, which is tiny - though to keep losses to a minimum you'd want more like 20AWG).
So for simplicity and to reduce your wire costs, just stick to one size all the way through so you're buying only one gauge of wire (so you get a bigger discount for buying more).  You could quite easily use:

18AWG direct from the PSU to each POL regulator (24V, 0.8A)
18AWG from each POL regulator to all Arduinos in a group (5V, 3A)

Of course, this is all using numbers plucked out of thin air, and you'd need to adjust it to fit your specific project, but you get the idea - higher voltage to a group, regulate to 5V, then 5V to each Arduino in the group. You don't need to care about grounding etc because you're using RS-485.

Despite being differential, RS485 does care about ground levels, to the point of not saturating the receiver(s).  Given enough amplitude, ground bounce will introduce bit errors.

@AaronD You'd need pretty massive ground bounce...  One of the advantages of RS-485 is that you don't need to care about ground voltage differences at the different nodes. Hell, you don't even need a separate ground connection if you have a common ground somewhere around the system. The spec of RS-485 is -7V to +12V, and since this is working at +5V, it would be very hard for any ground bounce to get anywhere near that kind of level...

I second @AaronD on this. This is not necessarily a ground bounce, as you call it, but a DC offset between the grounds that may or may not be there depending on the power distribution strategy. Such an offset could possibly saturate the RS485 transceivers, so the point remains. RS485 does care about ground levels.

With this much power I’d also add some fuses to the system. Shorting a 200W supply isn’t fun. It will also prevent the whole system from going down if only a single Arduino fails.

Indeed. Although one per Arduino may be overkill. One per POL regulator may be a more realistic proposition...


text:
Looking to blink entire led strip
I am fairly new to FASTLED programming and am looking to make my entire LED strip blink at the same time. Similar to the Example Sketch "Blink" however all 30 of my LEDS. I might just be having a temporary mind derp right now but I cant figure it out.

please post the sketch that you are using .... include a clear description of observed behavior

look at the Cylon example code .... it shows you how to address the LEDs .... extrapolate to multiple LEDs  ......... the Blink example blinks the first LED .... think about what you would have to change in the code to blink the second LED ..... how would you blink the first and second LED at the same time?

FastLED has a function called fill_solid() which will change the color of an indicated range of LEDs in a strip.
From https://github.com/FastLED/FastLED/wiki/Controlling-leds#set-rgb-color

use new 'fill_solid', telling it to fill just one led. (v2) Note that
  this is a pretty silly way to set one pixel, but it lets us illustrate
  the existence of fill_solid, a new convenience function the library
  provides.
fill_solid( &(leds[i]), 1 /*number of leds*/, CRGB( 255, 68, 221) )

For your case, you want to change the color of all LEDS, so you would call:
fill_solid(leds, NUM_OF_LEDS, CRGB::Red);

To turn them back off, you would change the color to CRGB::Black

source: Stack Exchange

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

sort: votes


text:
NodeMCU 12E V2 Power Saving
I'm powering a NodeMCU with 4 x AA batteries (6v, ~9,600mAh).  I am running  ESP.deepSleep([milliseconds]) to minimize power consumption.  Even with deepSleep I am seeing a precipitous drop off in battery voltage.  I've gone from 6.00v to 5.62 in 28 hours.  Does this make sense?  I was expecting the board to consume SIGNIFICANTLY less power and I'm at a loss.
I have the reset/wakeup pins (D0, D3, and D4) set connected to 3.3v with resistors and I've jumped the reset pin to D0 to make the wakeup call.  Nothing else is connected!  Does this power draw make any sense??
As far as the operation goes, it's waking up and posting data just fine.
I've researched various power saving techniques and the best description I've found is here.  I really don't want to start hacking up ESPs though.  That is time consuming and presents a real opportunity (ahem...guarantee) for me to destroy a lot of boards!
My questions:
1.) Are there other SW-based methods for improving power use on the NodeMCU 12E?
2.) Where do I probe a 12E to read current draw with a multimeter
3.) Are there "dumber" ESP8266 modules that have a reset pin, a few? GIPOs and a VIN capable of handling a 6v input with either a 5v and/or 3.3v output?  Product recommendation...I know...I'm hard up though and need some guidance.
I'll make these separate questions if necessary.
I am going to by an in-line current reader.  I need to stick with a multimeter for now.

have you seen this? ... https://www.losant.com/blog/making-the-esp8266-low-powered-with-deep-sleep

I've not but a cursory read of the demo seems to be exactly what I've done...except that the entire thing seems to run in setup().  I'll re-read the summary tomorrow after some sleep and with some coffee.  Thank you!!

perhaps it's the voltage regulator and the USB interface and all the other circuitry on the nodemcu board that still consumes power, despite the ESP module being in deep sleep - searching nodemcu power consumption deep sleep in your search engine of choice will show many documented examples of this behaviour

That's what I'm thinking based on all of the other stuff I've read.

If you can't do anything about the hardware you're using (lower powered USB interface, etc) then the top thing you can do is run the wifi radio as little as possible. The radio uses a lot of power, so the less time it's on for and the less network traffic you send, the less power you'll use.
When the board comes out of deep sleep and reconnects on wifi again, it performs a DHCP exchange to find out its IP address. Configuring a static IP address, network mask and router address will avoid this and let the radio stay on for less time.
The ESP8266 SDK also automatically saves wifi credentials to flash every time you call WiFi.begin(). This is probably not what you want. Disabling this will also help save power.
The new wifi connect code would look something like this:
IPAddress ip( 192, 168, 0, 1 );
IPAddress gateway( 192, 168, 0, 254 );
IPAddress subnet( 255, 255, 255, 0 );

WiFi.forceSleepWake();
delay( 1 );
WiFi.persistent( false );
WiFi.mode( WIFI_STA );
WiFi.config( ip, gateway, subnet );
WiFi.begin( WLAN_SSID, WLAN_PASSWD );

You'd need to replace the specific IP address, gateway (router) address and subnet mask with ones that work for your network. And you'll need to allocate a static IP address either from a range that your router sets aside, or you'll need to configure your router to permanently allocate the address - how you do this totally depends on the router you're using.
The other way to save wifi-related power is to use as lightweight a protocol as possible and do as little work while wifi is on as possible.
For instance, suppose you need to compute a complicated piece of data that you're transmitting over wifi. Maybe it's a chunk of XML or a JSON string. Or you need to read a slow sensor. Do all that work before you enable wifi, and have the data ready to transmit.
Or if you're receiving data, if at all possible, finish receiving the data and turn off wifi before you do any work with the data.
If you have any choice in the matter, use as simple a protocol to transmit the data as possible. UDP is ideal - you can transmit a single packet (but you won't know if it's been received). TCP requires several packets of handshake at connection startup and shutdown. If you use a secure (SSL) connection over TCP that's even more data and computation.
If your very top priority is battery life, UDP is ideal though it's not reliable and not secure.
There's a great series of articles on power saving at
https://www.bakke.online/index.php/2017/05/21/reducing-wifi-power-consumption-on-esp8266-part-1/
https://www.bakke.online/index.php/2017/05/21/reducing-wifi-power-consumption-on-esp8266-part-2/
https://www.bakke.online/index.php/2017/05/22/reducing-wifi-power-consumption-on-esp8266-part-3/
Part 1 is about measuring power use; part 2 is about switching the wifi radio on and off and part 3 gets partly into the stuff I talked about above.

HW is the issue (as Jaromanda X pointed out as well).  This is good advice and I'll have to find ways to optimize.  Bummer, but doable.  Do you know of other ESP HW that has integrated WiFi or is the 12E pretty much it?

@acpilot All ESP8266s have integrated Wifi. It's part of the CPU - it's not an ESP8266 without it. There are quite a few ESP8266 boards without USB ports, or just using USB for power, not data (like the Sparkfun Thing). ESP8266 boards that can be programmed with just a regular USB cable have an integrated USB adapter; boards that need an FTDI cable to program them don't and may avoid the USB/serial adapter power drain. (FTDI is a USB to serial converter that's commonly used with ESP8266s and Arduinos)

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


text:
GPS Module Outputting Question Marks in Serial Window
I've got a uBlox Neo 7N GPS Module and configured it so if theres is no incoming data print no location but if there is print the latitude and longitude. However it's printing ?,?.
So I'm assuming it's wired correctly as I'm getting an output however maybe my code is preventing it from printing the two long numbers hence converting it to a ? instead.
  char buf[128];
  if (gps.location.isValid()) {
    snprintf(buf, sizeof(buf), "%lf,%lf", gps.location.lat(), gps.location.lng());
    Serial.println(buf);
  }

EDIT I know that Im getting a read as I set two variables of type double lat and long to equal gps.location.lat() and gps.location.lng() respectively and I'm getting a number. How do I fix up this snprintf line so it prints properly?

When arduino boards used the atmega8, there was so little memory they decided to take out the floating point support for s(n)printf. Instead of letting the users decide to use sprintf or not, they just took it out. That caused a lot of troubles. In 2018 it is still not there, which is outrageous. Sorry that you bumped into this problem. You have to make a workaround. It can be cast to a unsigned long or the dstrtof function can be used and the Serial.println itself supports float variables. The uno does not support 64 bit double, only 32 bit float variables.

Oh wow, well that makes sense. Thank you for replying, will try your recommendation!

Oops, it is "dtostrf".

I would try adjusting the baud rate your arduino or MCU is reading the GPS data stream at.  My guess is that the stream is being misinterpreted.

No floating point for sprintf, it prints a '?'.
The functions sprintf, sscanf and the alike functions (snprintf and others) do not have floating point support for avr microcontrollers.
History
One of the first Arduino boards used the Atmega8 microcontroller with only 8k flash and 1k sram. It was important to be very memory efficient.
The gcc compiler did not automatically include the floating point support libraries for the sprintf functions, however it was easy to include them. Arduino decided not to include those extra libraries because they use extra memory.
Arduino has a preprocessor, compiler and linker that tries to only use code that is actually used. The sprintf does not know at compile time if floating point will be used, so it would have to include those extra floating point support libraries whether they were used or not.
Now it is 2018 and it is sadly still not included.
Workaround

The Serial.println functions can print floating point variables. They can however not print the output in scientific notation. It rounds the value that is printed to the nearest number.
The dtostrf() and dtostre() convert a float variable to text. The dtostre() is for scientific notation.
A variable of the float type can be cast to a integer.
The Arduino String object can handle a float.

Only float for avr microcontrollers, no double.
The avr microcontrollers are 8-bit microcontrollers. There is no floating point library for 64-bit double variables, only a library for 32-bit float variables.
That library is according to the IEEE standard and is extremely fast and optimized.


text:
Why the MPU6050 gyroscope read write register value is 0x08 for a full scale of 500 degrees per second?
I am trying to connect a gyroscope MPU6050 to arduino ATmega2560 and read its raw values from its 6DOF (gyro and acc).
I found the following code:
//Activate the MPU-6050
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x6B);                                                    //Send the requested starting register
  Wire.write(0x00);                                                    //Set the requested starting register
  Wire.endTransmission();                                              //End the transmission
  //Configure the accelerometer (+/-8g)
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x1C);                                                    //Send the requested starting register
  Wire.write(0x10);                                                    //Set the requested starting register
  Wire.endTransmission();                                              //End the transmission
  //Configure the gyro (500dps full scale)
  Wire.beginTransmission(0x68);                                        //Start communicating with the MPU-6050
  Wire.write(0x1B);                                                    //Send the requested starting register
  Wire.write(0x08);                                                    //Set the requested starting register
  Wire.endTransmission();                                              //End the transmission

I am trying to break it line by line, to understand what is going on during the setup of the gyroscope.
According to MPU6050 datasheet, the I2C is at the register 0x68. The I2C helps us to access all registers and communicate with the master connected to. Which gives the following 3 lines:
Wire.beginTransmission(0x68);
Wire.write(0x6B);
Wire.write(0x00);

According the the sheet, the 0x6B is the register designed to enable and disable the gyroscope:

This register allows the user to configure the power mode and clock
  source. It also provides a bit for resetting the entire device, and a
  bit for disabling the temperature sensor. By setting SLEEP to 1, the
  MPU-60X0 can be put into low power sleep mode. When CYCLE is set to 1
  while SLEEP is disabled, the MPU-60X0 will be put into Cycle Mode. In
  Cycle Mode, the device cycles between sleep mode and waking up to take
  a single sample of data from accelerometer at a rate determined by
  LP_WAKE_CTRL (register 108). To configure the wake frequency, use
  LP_WAKE_CTRL within the Power Management 2 register (Register 108). An
  internal 8MHz oscillator, gyroscope based clock, or external sources
  can be selected as the MPU-60X0 clock source. When the internal 8 MHz
  oscillator or an external source is chosen as the clock source, the
  MPU-60X0 can operate in low power modes with the gyroscopes disabled.
  Upon power up, the MPU-60X0 clock source defaults to the internal
  oscillator. However, it is highly recommended that the device be
  configured to use one of the gyroscopes (or an external clock source)
  as the clock reference for improved stability. The clock source can be
  selected according to the following table.

So why we set its value to 0x00 ?
And the same for setting up the gyroscope at register 0x1B where datasheets specify the full scale ranges as:

The code is setting the range of 500 dps, so why the coder set the register to 0x08 and not 0x01 where the FS_SEL[1:0] should contain decimals from 0 to 3 right ?

The i2c address is 0x68 or 0x69. Some modules with the MPU6050 have indeed 0x69, but most have 0x68.
When searching the datasheet for the word "sleep", this sentence is easy to find: "Note: The device will come up in sleep mode upon power-up".
When the MPU6050 powers up, the SLEEP bit is 1 and the sensor is in sleep mode. Therefor writing a 0 is to get it out of sleep mode. After that you can set the sensor as you want.
The FS_SEL[1:0] is a notation that is used a lot in datasheets. It is an indication that only two bits are used. It is not the bit-position in the register. Those bits are located at Bit3 and Bit4. To turn on the lower bit of FS_SEL, Bit3 has to be set to 1, thus a value of 0x08 is needed for the register.


text:
How to convert a string to long int?
I'm new to Arduino and my first project is an RFID reader. since I need a lot of known tags list , i have a problem with not enough memory. for that reason I want to convert strings like :  "426d9244", "1265dd39"... to a long int. I know it's been asked but as a new programer I find it hard to understand. an example would be very appreciated also.

You could use the atol() function. However, I think that is not your problem. Perhaps you have blocks of code that is repeated a few times. Do you use the Serial.println in combination with the F() macro?

It's a bit unclear what you want to do with the 'd'or 'dd'in between.
You can check some functions:

strtok: which can split a string based on delimiters (in your case probably 'd'). Than you get an array of strings (e.g. for the first: { "426", "9244"}.
For each string ("426" and "9244") you use function atol to convert it into a long integer.

If all those are known tags, you can put them in the source code as
32 bit integers. No
need to convert. Or rather, let the compiler do the conversion:
const uint32_t ID_num[ARRAYSIZE] PROGMEM = {
    Oxbcc0f1c3, Ox821a7d39, Ox4924887c, ...
};

When you read a tag number in hex, in order to compare it with the known
tags, you convert it to the same type using strtoul() from
avr-libc:
uint32_t tag_id = strtoul(tag_string, NULL, 10);

Actualy , it did the compare without even converting the tag_id... , it works perfect now,  HOGE thanks!!!

Please "accept" the answer to show that it helped you. Thanks!


text:
Making an H-bridge with transistors
I am trying to make an H-bridge with two NPN and two PNP transistors to drive a motor which works fine on the 5 V Arduino. I have a schematic in the picture. When I use a simple code to have pin 9 HIGH and pin 8 LOW, the motor doesn't do anything. The transistor which I circled green is getting very hot. Is there something wrong with the schematic or code? Or is it my wiring?
I know people use diodes as well, but in my case the motor doesn't work, so the diodes aren't the problem.

This is my code:
     void setup()
    {

    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);

    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    }

Could you give the transistors a number please? Do you use the Arduino 5v pin to power a motor? I hope not! You could use 4 pins and carefully write the code to avoid a shortcut. You could add two extra transistors to invert the signal. To turn on the motor you need to turn on the upper-left and the lower-right transistor. Or the upper-right and the lower-left.

I used the 5V to power the circuit. I tried to turn on the motor by connecting the upper-right and lower-left transistor to the same pin on the arduino, it didn't work. I used 4 different pins now and it also didn't work.

Unlike an NPN, a PNP turn on when you pull it's base LOW.

Thanks Edgar, I just found that out 10 minutes ago. So the bottum left en upper-left have to be connected to the same pins. Same for the right transistors.

I was wrong, the 4 pins are not needed and inverting the signal is not needed because you use 5v to power it. @smajli gave the right answer. Connect both on the left to a pin and connect both on the right to a pin, as his first picture shows. The arduino 5v pin can not supply a lot of current, you might run into troubles with that.

I exactly have this problem now. I am making an H bridge to control the steering wheel motor of an RC car which I want to make an obstacle avoiding car using the arduino. When I connect the motor directly to the 5V and GND of the arduino, the motor has enough power to turn the wheels. But with the H bridge it hasn't. What can I do now? I already tried to decrease the resistors at the base, but no succes. I also tried to replace the arduino power pins with a 9V battery and this didn't work as well.

There is a few possible scenarios to create a H-bridge:

with NPN transistors only or PNP
mix of PNP and NPN

You have to be careful to not mix the types and inputs. See pictures below:

Note that, while the Arduino boots, all its I/O pins but TX are configured as inputs, i.e. high impedance. In this situation, with the first schematic, all transistor will be on.


text:
For loop broken?
This is a pseudo code from my LED cube project
void loop(){
  //switch( map(constrain(analogRead(pt),10,1020),10,1020,1,4));  - for select pattern
  //show(1);
 for(lp=128;lp>=1;lp = lp/2){
  runfor(1000,lp,1,0,0,0,0);
  //Serial.println("HI");
 }
}

void runfor(short mills,byte a,byte b,byte c,byte d,byte e,byte f){
  timer = millis();
  Serial.println(a);
  while((millis()-timer)<=mills){
    light_L1(a,b);
    //light_L2(c,d);
    //light_L3(e,f);
  }
}

the variable 'lp' here never changes its value and remains 128
Why is this?

What makes you believe lp does not change?

Tested using serial.println, second line in the runfor()

I run it. no surprise. the value changes as expected.

@Juraj Is this a problem with my chip or IDE then?

no. it is a problem of your snippet. it makes something else like the sketch from which you extracted it and didn't test

So maybe another function is affecting it?

Let us continue this discussion in chat.

Don't ever use a global variable for for loop.
You use the same variable in functions for loops which count down to zero. If lp is zero for loop in loop() ends and new loop() starts.

When I ran your code as you presented it in the chat, lp stayed at 128. When I commented-out the "light_L1()" call in "runfor()", lp decremented by 1/2 its value per step as you would expect. The issue is that lp is global and therefore, accessible by any other function. One of your lower functions is resetting it.

so I induced the asker to post the code and the problem showed itself. but you didn't explain why the value jumps to 128

The value changes because one of the lower functions changes it. Why didn't I continue to debug it down to the last detail? 1) To not steal a potential learning experience from the OP; and 2) because it really doesn't matter to the question: "the variable 'lp' here never changes its value and remains 128  Why is this?". I pointed the overall problem - modification of a global from multiple places in the code. The rest is up the OP, who can ask for further help if s/he wants it.


text:
FSR wiring using internal pullup resistors?
What are the disadvantages to using Arduino's internal pullups with a force force sensitive resistor (FSR) sensor?
All the wiring examples I see for FSRs place the sensor on the high side and use a 10k pulldown resistor. Searching Google, I can find virtually no one who places the FSR on the low side and uses the internal pullup. Since this would reduce complexity by using one less wire and resistor, I have to assume there's some big downside I'm not seeing. Why shouldn't you use the internal pullup?
I've worked with conventional potentiometers in the 100k ohm range, and I've found that with values that high, the Arduino's ADC finds a lot of noise, resulting in a sensor value that jitters and drifts. I found that the only reliable way to get a stable ADC value is to use a potentiometer with a maximum value of 10k or less. Since the FSR's range is up to 1M ohms, I'm worried I won't be able to get a stable reading. Does wiring it via the high side or low side effect this? What can I do to minimize noise from the FSR, other than shielding the sensor cable or adding a capacitor between the signal a and ground wire?

There is probably no practical difference concerning high side vs low side (except the Arduino Uno only has a pullup, and no pulldown).
The issue would be the accuracy of the pullup (graphs in the datasheet show variations of 10% with temperature) vs the accuracy of the resistor (1% is now commonplace).
The pullup is usually a current source, not a specific resistor value. Even if the supply voltage is not known, the maths involved with solving a known resistor is series with an unknown resistor is quite straightforward.
Short answer, using the pullups would probably work, but you would have to confirm accuracy, calibration and even repeatability, while this is already well known for a resistor.
Datasheet, see graphs on p412:
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdf


text:
Stepper Motor - Limit Switch for Position
I'm following this guide
https://howtomechatronics.com/tutorials/arduino/diy-motorized-camera-slider-pan-tilt-head-project/
My question is with the following piece of code used to calibrate the position values.
  // Move the slider to the initial position - homing
  while (digitalRead(limitSwitch) != 0) {
    stepper1.setSpeed(3000);
    stepper1.runSpeed();
    stepper1.setCurrentPosition(0); // When limit switch pressed set position to 0 steps
  }
  delay(20);
  // Move 200 steps back from the limit switch
  while (stepper1.currentPosition() != -200) {
    stepper1.setSpeed(-3000);
    stepper1.run();
  }
}

I understand the first while loop is to to get a zeroth position for calibration. But why move it 200 steps back and then set speed to -3000?[Q1] I don't understand that part.
And then later on in loop(), there is
// Limiting the movement - Do nothing if limit switch pressed or distance traveled in other direction greater then 80cm
  while (digitalRead(limitSwitch) == 0 || stepper1.currentPosition() < -64800) {}

I understand the first condition but why is second one there? Is it because 80cm is the max length of the slider/track and you don't want the stepper to move more than that? [Q2] Also how does 64800 = 80cm? [Q3]
Full Code: [Not mine - from link above]
/*
  DIY Camera Slider with Pan and Tilt Head
  by Dejan Nedelkovski
  www.HowToMechatronics.com

  Library - AccelStepper by Mike McCauley:
  http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

*/

#include <AccelStepper.h>
#include <MultiStepper.h>

#define JoyX A0       // Joystick X pin
#define JoyY A1       // Joystick Y pin
#define slider A2     // Slider potentiometer
#define inOutPot A3   // In and Out speed potentiometer
#define JoySwitch 10  // Joystick switch connected
#define InOutSet 12   // Set Button
#define limitSwitch 11
#define inLED 8
#define outLED 9

// Define the stepper motors and the pins the will use
AccelStepper stepper1(1, 7, 6); // (Type:driver, STEP, DIR)
AccelStepper stepper2(1, 5, 4);
AccelStepper stepper3(1, 3, 2);

MultiStepper StepperControl;  // Create instance of MultiStepper

long gotoposition[3]; // An array to store the In or Out position for each stepper motor

int JoyXPos = 0;
int JoyYPos = 0;
int sliderPos = 0;
int currentSpeed = 100;
int inOutSpeed = 100;

int XInPoint = 0;
int YInPoint = 0;
int ZInPoint = 0;
int XOutPoint = 0;
int YOutPoint = 0;
int ZOutPoint = 0;
int InandOut = 0;

void setup() {
  // Set initial seed values for the steppers
  stepper1.setMaxSpeed(3000);
  stepper1.setSpeed(200);
  stepper2.setMaxSpeed(3000);
  stepper2.setSpeed(200);
  stepper3.setMaxSpeed(3000);
  stepper3.setSpeed(200);
  pinMode(JoySwitch, INPUT_PULLUP);
  pinMode(InOutSet, INPUT_PULLUP);
  pinMode(limitSwitch, INPUT_PULLUP);
  pinMode(inLED, OUTPUT);
  pinMode(outLED, OUTPUT);

  // Create instances for MultiStepper - Adding the 3 steppers to the StepperControl instance for multi control
  StepperControl.addStepper(stepper1);
  StepperControl.addStepper(stepper2);
  StepperControl.addStepper(stepper3);

  // Move the slider to the initial position - homing
  while (digitalRead(limitSwitch) != 0) {
    stepper1.setSpeed(3000);
    stepper1.runSpeed();
    stepper1.setCurrentPosition(0); // When limit switch pressed set position to 0 steps
  }
  delay(20);
  // Move 200 steps back from the limit switch
  while (stepper1.currentPosition() != -200) {
    stepper1.setSpeed(-3000);
    stepper1.run();
  }

}

void loop() {
  // Limiting the movement - Do nothing if limit switch pressed or distance traveled in other direction greater then 80cm
  while (digitalRead(limitSwitch) == 0 || stepper1.currentPosition() < -64800) {}

  // If Joystick pressed increase the Pan and Tilt speeds
  if (digitalRead(JoySwitch) == 0) {
    currentSpeed = currentSpeed + 50;
    delay(200);
  }
  // If Set button is pressed - toggle between the switch cases
  if (digitalRead(InOutSet) == 0) {
    delay(500);
    // If we hold set button pressed longer then half a second, reset the in and out positions
    if (digitalRead(InOutSet) == 0) {
      InandOut = 4;
    }
    switch (InandOut) {
      case 0:   // Set IN position
        InandOut = 1;
        XInPoint = stepper1.currentPosition(); // Set the IN position for steppers 1
        YInPoint = stepper2.currentPosition(); // Set the IN position for steppers 2
        ZInPoint = stepper3.currentPosition(); // Set the IN position for steppers 3
        digitalWrite(inLED, HIGH); // Light up inLed
        break;

      case 1: // Set OUT position
        InandOut = 2;
        XOutPoint = stepper1.currentPosition(); //  Set the OUT Points for both steppers
        YOutPoint = stepper2.currentPosition();
        ZOutPoint = stepper3.currentPosition();
        digitalWrite(outLED, HIGH);
        break;

      case 2: // Move to IN position / go to case 3
        InandOut = 3;
        inOutSpeed = analogRead(inOutPot); // Auto speed potentiometer
        // Place the IN position into the Array
        gotoposition[0] = XInPoint;
        gotoposition[1] = YInPoint;
        gotoposition[2] = ZInPoint;
        stepper1.setMaxSpeed(inOutSpeed);
        stepper2.setMaxSpeed(inOutSpeed);
        stepper3.setMaxSpeed(inOutSpeed);
        StepperControl.moveTo(gotoposition); // Calculates the required speed for all motors
        StepperControl.runSpeedToPosition(); // Blocks until all steppers are in position
        delay(200);
        break;

      case 3: // Move to OUT position / go back to case 2
        InandOut = 2;
        inOutSpeed = analogRead(inOutPot);
        // Place the OUT position into the Array
        gotoposition[0] = XOutPoint;
        gotoposition[1] = YOutPoint;
        gotoposition[2] = ZOutPoint;
        stepper1.setMaxSpeed(inOutSpeed);
        stepper2.setMaxSpeed(inOutSpeed);
        stepper3.setMaxSpeed(inOutSpeed);
        StepperControl.moveTo(gotoposition); // Calculates the required speed for all motors
        StepperControl.runSpeedToPosition(); // Blocks until all are in position
        delay(200);
        break;

      case 4: // If Set button is held longer then half a second go back to case 0
        InandOut = 0;
        digitalWrite(inLED, LOW);
        digitalWrite(outLED, LOW);
        delay(1000);
        break;
    }
  }

  // Joystick X - Pan movement
  JoyXPos = analogRead(JoyX);
  // if Joystick is moved left, move stepper 2 or pan to left
  if (JoyXPos > 600) {
    stepper2.setSpeed(currentSpeed);
  }
  // if Joystick is moved right, move stepper 2 or pan to right
  else if (JoyXPos < 400) {
    stepper2.setSpeed(-currentSpeed);
  }
  // if Joystick stays in middle, no movement
  else {
    stepper2.setSpeed(0);
  }

  //Joystick Y - Tilt movement
  JoyYPos = analogRead(JoyY);
  if (JoyYPos > 600) {
    stepper3.setSpeed(currentSpeed);
  }
  else if (JoyYPos < 400) {
    stepper3.setSpeed(-currentSpeed);
  }
  else {
    stepper3.setSpeed(0);
  }

  // Slider potentiometer
  sliderPos = analogRead(slider);
  // If potentiometer is turned left, move slider left
  if (sliderPos > 600) {
    sliderPos = map(sliderPos, 600, 1024, 0, 3000);
    stepper1.setSpeed(sliderPos); // Increase speed as turning
  }
  // If potentiometer is turned right, move slider right
  else if (sliderPos < 400 ) {
    sliderPos = map(sliderPos, 400, 0, 0, 3000);
    stepper1.setSpeed(-sliderPos); // Increase speed as turning
  }
  // If potentiometer in middle, no movement
  else {
    stepper1.setSpeed(0);
  }
  // Execute the above commands - run the stepper motors
  stepper1.runSpeed();
  stepper2.runSpeed();
  stepper3.runSpeed();
}

Q1: my guess is that it's just to move the slider a bit away from the limit switch, so it no longer reads LOW. Q2 I think you are correct. The original project you linked to only has a rail of around 80cm. And no limit switch on the other end. So he uses software to limit the travel. An alternative would be to add another limit switch, or simply change the value to reflect the size of rails you are using.

Q1: It is a common practice to move the stepper a bit away from the limit switch after a calibration, so that it can again be activated, if the stepper is moved into that direction. In most cases the limit switch marks a point very near or at a physical limitation, where the stepper cannot proceed and will hit some kind of wall. The limit switch can turn the motor off, before that happens. And your causal chain is incorrect. The code doesn't move to -200 and THEN set speed to -3000. Instead it checks in a while loop, if the position -200 is reached, and when not will set the speed and run the motor. When the position is finally reached due to the motor being run, the while loops exits.
Q2: The 80cm are used as a soft limit, meaning that the slider at this point will not hit a physical limit or a limit switch, only the software stops the slider to go further and finally hit a wall. This is often used to save limit switches in a physically confined situation and also not hit any physical walls, since a collusion is mostly undesirable (due to possible harm to people and the machine). The 80cm are known here (because the rail for the slider is no longer, than that).
Q3: The Stepper does not count in length (cm), but in the number of steps, that he has taken. Depending on the used stepper motor, 1 steps corresponds to a specific angle, that the motor will spin. And the mechanics determine, what angle of rotation corresponds to what distance on the rail. Most likely the author of the guide had calculated this for his specific build. You can calculated this yourself, so that you can use the correct conversion from steps to distance:
distance for 1 step = circumfence of the driving wheel / number of steps per revolution of the driving wheel

Or shorter:
d1 = C / N

Then you can calculate the steps for a specific distance d by
Nd = d / d1


text:
ESP8266 - does it really have terrible wifi range by default?
ESP8266  - does it really have terrible WiFi range by default??
First time to try this module out and we're disappointed with the range.. as per our testing we can only get max 5m WiFi range line of sight (LOS) to our regular WiFi router (TPlink and other routers we tried)
LOS Distance (Test results based on RSSI):

at 6 meters NO CONNECTION
at 5 meters  -77
at 4 meters -70
at 1 meter -56
at 3 meters -59

We also tried using different WiFi Channel from 1-11
We also tried removing wifi password (no password) and WEP password
We tried also using different modes B G N
NO change ..
Are we doing something wrong here?  Or is this module just that bad?
Any solution not requiring hardware change? (because we already bought a lot)
here's our little module

Interestingly, I saw these guys test the module and it seemed to work well .. Could we have a fake chip?
https://www.youtube.com/watch?v=7BYdZ_24yg0
We have really hit a stumbling block. hope you guys can help

try to erase the flash with esptool to get rid of old WiFi setting, not compatible with SDK you currently use

Do you have a ground plane passing under the antenna? Ideally the antenna should hang over the edge of the board.

My ESPs can talk to my inside router from halfway down the block; something is wrong...

The very first thing I notice is that your WiFi antenna is shielded by the PCB. That is the antenna is placed right over the top of the ground plane of the PCB and your range is going to be severely limited.
You will notice on the NodeMCU design below that they have placed a PCB cutout where the antenna is located. In other pictures you can also see that the ground plane does not go past where the antenna starts.

On other boards the antenna sits proud of the main PCB such as this one from Tronixlabs:

If money is tight and new hardware is out, you could try cutting a cutout where the antenna sits using your Dremel (or other rotary tool). If there are any traces underneath the antenna you will need to fix them up with wire worms. Of course it is best to remove the ESP module first.
Alternatively, you could redesign the PCB and send it out for another manufacturing run. I use PCBShopper.com to find the best price for the bare PCBs.
Edit:
Something else you could do is to unsolder the ESP and mount it 90 degrees to the PCB. You would need to solder wires from the base PCB to the terminals of the ESP. This should work and you won't need to cut the base PCB.

tnx, ur reply is so insightful. didnt realize the both sides of the antenna needed to be exposed. What if I just solder some wires to the antenna to kind of "extend" it out of the pcb? so i wont need to make pcb adjustments anymore , do you think that's ok?

@BrownChiLD the length of an antenna is tuned so as to transmit/receive at certain frequencies. Adjusting the length will move the frequency away from the WiFi band and result in signal loss. I don't advise doing this at all.

crap... ok. but what if, we cut the built in antenna, and solder our little piece of wire antenna to it to preserve length.. at least this way the antenna is more exposed.

That may work but it probably won't be as good as the design of the onboard antenna.

right.. well we'll keep it as last option.. thanks much for your insights.
btw, how long a range should we be expecting from this ESP module in the first place? definitely at least 20m LoS right?

20m sounds reasonable.

It's not just that both sides of the antenna need to be "exposed", but proximity to other conductors, metal objects, or a ground plane matters. The further you can get the PCB antenna away from any other conductors the better, and your PCB design ideally would have your components on one side of the module and the module's antenna on the other side, much like most of the ESP* dev boards you see.

The size and shape of the antenna has been optimised by testing for a certain frequency; soldering more wires to it will change its characteristics and possibly make it worse. It's best to stick with what the engineers have given if possible, and consider an alternative module with an external antenna connector if it's not possible to redesign the PCB or device so the module's antenna sits further away.

Datasheet specifies 15mm free on each side of the antenna.


text:
Is two modules using Serial Interface on one Arduino Uno possible?
I was wondering if I have both a Bluetooth HC-05 module and a GPS module (uBlox 7N) is it possible both for both to be using the serial interface?
I'm aware they cant be operating simultaneously with one another but if I using the RX TX pins for the GPS module, can I receive a location, store it in a variable then terminate the GPS serial usage and using software serial with 2 pins of my choice transmit data via the Bluetooth module which also requires the serial pins?

No, you can not do it on one serial interface. However you can use Software Serial library and "create" second serial interface.

Yes, you can use multiple SoftwareSerial ports, but you can listen only at one at a time. The easiest solution is a arduino mega 2560 board with 3 extra hardware serial ports.

You are right, that you need one Serial interface for each module. The Uno has only 1 hardware serial interface (hardware means, that the Arduinos hardware will do the communication work in the background and you can let it do other things in the meantime). But you can add more serial interfaces, on other pins, that work purely through software. For this the SoftwareSerial library is meant.
SoftwareSerial comes with some limitation, since the load of communication has to be done in software instead of hardware. For example it becomes unstable at high baudrates. Especially for the HC-05 you should not use baudrates of 115200 baud and higher. Also - since it uses pin change interrupts to work - you can only listen at one SoftwareSerial at any given time.
Since you only have 2 modules, it should be easily possible, to utilize SoftwareSerial and access both of them with the Uno. If you at some time want to use more serial modules, you can still change to a bigger board like the Mega.
Note: Be sure to disconnect the module from the hardware serial, before programming the Uno over the Serial interface (USB), or the programming will fail.


text:
Stabilitiy Problem for Interrupts Code related to Flow sensor
There is a problem with code related in link Interrupts Problem with Flow sensor. Code is working but when I stop the pumps, flow value on lcd is frozen until I reset the arduino. And when I start the pumps, flowmeter shows firstly 0.54 value, then begin to show real values. But always 0.54 down or up ( if flow is 5 lt/min, lcd show sometimes 5 lt/min, 5+0.54 lt/min or 5-0.54 lt/min ). When there are no oil flow into flow sensor, value of flow have fixed value that last readings. Could you help me ?
 #include <Wire.h> //I2C lib
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
 // LCD lib
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const int pot_pin = A0;
const int pump_pwm = 3;

const int resetButton = 11;
byte press_pin = A1;

//flowmeter parameters
int flowPin = 2;  // input pin on arduino D2

volatile double flowRate;   // value intented to calculate
volatile double flowR; // flow value in lt
volatile double totalFlow; // total output of flow from system

byte sensorInterrupt = 0; // interrupt 0 on D2 pin Arduino Nano

volatile int count; ////integer needs to be set as volatile to ensure it updates correctly during the interrupt process.

int pot_init= 0;
int pump_init= 0;
int percentValue =0;

unsigned long previous_read;
void setup() {

  pinMode(resetButton, INPUT);
  digitalWrite(resetButton, HIGH);

  lcd.begin(20,4);  // A4 - A5 connection SDA - SCL
  lcd.backlight();
  Serial.begin(9600);

  pinMode( flowPin,INPUT); // Set D2 pin as an input

  attachInterrupt(sensorInterrupt,Flow,RISING); // Configures interrupt 0 ( pin D2 on Arduino Nano ) to run function "Flow"
}
void flow_control(void) {

  // Print the flow rate for this second in litres / minute
    Serial.print("Flow rate: ");
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print("L/min");
    Serial.print("\t");       // Print tab space

    // Print the cumulative total of litres flowed since starting
    Serial.print("Output Liquid Quantity: ");
    Serial.print(totalFlow/1000);
    Serial.println("L");

 if(digitalRead(resetButton) == LOW)
  {
    totalFlow = 0;
    lcd.setCursor(0, 3);
    lcd.print("Resetting....        ");

}

else {
 lcd.setCursor(0,3);
  lcd.print("Total: ");
  lcd.setCursor(7,3);
  lcd.print(totalFlow/1000);
  lcd.print(" lt");

}
  lcd.setCursor(0,2);
  lcd.print("Flow: ");
    lcd.setCursor(6,2);
  lcd.print(flowRate);
  lcd.print(" lt/min");

}

void Flow(void)
{
  count++; // every time this function is called, increment  "count" by 1

  if(millis() -  previous_read > 1000){
    noInterrupts(); // disable interrupts on arduino nano
    int local_count = count;
    count=0;
    interrupts(); // enables interrupts on arduino nano
    previous_read += 1000;

  flowR = (local_count*8.93);   // 112 pulse/lt 423.84 pulse /gallon
  flowRate= flowR*60;     // convert seconds to minutes, new unit is ml/minutes
  flowRate= flowRate/1000; // convert ml to liters, new unit is lt/minutes

  totalFlow += flowR;
 //process flowrate based on local_count

  //calculation for flowmeter

  }
}

void loop() {

  pressure_cal();
  pump_control();
  flow_control();

}

void pressure_cal(void) {

  float sensorVoltage = analogRead(press_pin);   // sensor voltage A0
  float psi = ((sensorVoltage-102)/204)*25;  // Offset    0 PSI= 0.5V=102 unit, 50 PSI= 2.5, 100 PSI= 4.5V, 1 PSI= 0.04V

  // calibration
  float bar = psi*(0.0689475729);           // Conversion PSI to BAR

  lcd.setCursor (0,1);
  lcd.print (psi);
  lcd.print (" PSI");

  lcd.setCursor ( 10,1);
  lcd.print(bar);
  lcd.print( " BAR");

  //lcd.setCursor(17,1);
  //lcd.print(sensorVoltage);

  Serial.print("\t Sensor Value = ");
  Serial.print(sensorVoltage);
  Serial.print("\t Bar = ");
  Serial.print(bar);
  Serial.print("\t PSI = ");
  Serial.println(psi);

  delay (100);
}

void pump_control(void)

{

  // read the analog in value:
  pot_init = analogRead(pot_pin);
  // map it to the range of the analog out:
  pump_init = map(pot_init, 0, 1023, 50, 230);  //  duty cycle between %20 - %90: speed control , duty cycle between %0 - %20: turned off  , duty cycle between %90 - %100: full speed
  // map pump speed percent of full scale
  percentValue = map (pump_init, 50, 230,0,100);
  // change the analog out value:
  analogWrite(pump_pwm, pump_init);

  // print the results to the Serial Monitor:
  Serial.print("\t Speed Input = ");
  Serial.print(pot_init);
  Serial.print("\t Speed Output = ");
  Serial.print(pump_init);
  Serial.print("\t Pump Speed Percentage = ");
  Serial.println(percentValue);

  lcd.setCursor(2,0);
  lcd.print("Speed: ");
  lcd.setCursor(8,0);
  lcd.print("%");
  lcd.setCursor(9,0);
  lcd.print(percentValue);
  lcd.print("     ");

 //  delay after the last reading:
  delay(10);

}

It is about the variable flowRate? Where is that variable calculated? Spoiler: in the interrupt. When there are no interrupts, that value is not calculated. I don't see a simple solution. The interrupt counts and the flowR should use that count (even if it is zero). That means you have to calculate flowR in the Arduino loop, you can use millis to calculate the actual elapsed time to allow that it is sometimes longer than 1 second.

But I add the interrupt code in void loop and function called by main loop. Code dont work. The code I added works , but there is stability problem. When ı begin arduino, Flow sensor shows 0.54 lt/min on LCD. And when flow begin, flowrate changes with +- 0.54 error ( like 4.00 lt/min then 4.54lt/min then 3.46 lt/min and ) How can I solve this problem in void loop ?

if (millis() -  previous_read > 1000) { [...] previous_read += 1000; [...] }

The code inside this block is obviously meant to be executed every
second. However, since this belongs to the interrupt handler, it only
has a chance to execute when the flow-meter sends interrupts. If the
flow is zero or very weak, this will not execute often enough.

flowmeter shows firstly 0.54 value

It is no coincidence that 0.54 is what you get when count == 1.
The piece of code above should be moved to the main loop(), or to a
function called from loop(). This way it will execute consistently
irrespective of whether there is some flow or not, which is the only way
to reliably read a zero flow. Note that for better timing consistency
you should avoid doing something like...

delay(100);

Don't do this. Instead, use the same trick as above:
if (millis() -  previous_pressure_print > 100) {
    previous_pressure_print += 100;
    pressure_cal();
}

But I add the interrupt code in void loop and function called by main loop. Code dont work. The code I added works , but there is stability problem. When ı begin arduino, Flow sensor shows 0.54 lt/min on LCD. And when flow begin, flowrate changes with +- 0.54 error ( like 4.00 lt/min then 4.54lt/min then 3.46 lt/min and ) How can I solve this problem in void loop ?

@sapphire: Do not describe the code, show it! Edit your question and add the version of the code you are talking about.


text:
output not declaired.anyone please help me to fix this problem
output not declaired.anyone please help me to fix this problem
int const trigpin=10;
int const echopin=9;
int const buzzpin=2;
void setup()
{
  {
  Serial.begin(9600);
 }
  pinmode(trigpin,output);
  pinmode(echopin,input);
  pinmode(buzzpin,output);
}
void loop()
{
  long int duration,distance;
  digitalwrite(trigpin,high);
  delaymicroseconds(1000);
  digitalwrite(trigpin,low);
  duration=pulsein(echopin,high);
  distance=(duration/2)/29.1;
  Serial.print(distance);
  Serial.println("CH");
  if(distance<=50)
   {
    digitalwrite(buzzpin,high);
   }
   else if(distance>50)
   {
    digitalwrite(buzzpin,low);
   }
   delay(60);
}

To be used in the pinMode function (note capital M), it needs to be all capitals, ie OUTPUT.
From a quick scan, you might also need the following changes:
output ==> OUTPUT
input ==> INPUT
pinmode  ==> pinMode
digitalwrite ==> digitalWrite
delaymicroseconds ==> delayMicroseconds
Make sure your code matches the case (uppercase/lowercase) of the examples/tutorials etc.


text:
How to convert 0-5v inverted serial to 0-3.3v non-inverted serial
This weather stations has a 0-5v serial output.  I'm trying to read the serial output with the Adafruit 32u4 feather board and I get nonsense data out of it.  When I hook the Ultimeter up to my serial->usb cable I get the normal data output.  When I hook up the Ultimeter to a 5v arduino via SoftwareSerial in inverted mode I get proper data.  But I need to connect this weather station to a 3.3v Feather board's hardware uart which doesn't seem to be able to operate in inverted mode.  Is there a 5v -> 3.3 level converter that also will invert the serial signal ?

Please add more information to your question about the used weather station and feather board. Specifications, brand, type, links. Does that weather have a rs232 output? and the arduino is a 3.3v atmega32u4 running at 8mhz and costs 45 dollars? You need to convert the rs232 to ttl-level. The feather board might be damaged by the rs232.

I have determined that the serial output of the weather station is inverted 5v ttl.  I can get the proper data using software serial inversion.
The 5v output may be too much for the 3.3v TTL but the hardware uart doesn't seem to be damaged at this point although I can't seem to get software serial to work on the Feather board.

The rs232 can be a signal from -12v to +12v, but some devices use -5v to +5v and there are also some devices that are not very compatible that use 0v to +5v. You should use a rs232 to ttl-level converter. For a test use at least a protection resistor to the arduino. For example 4k7 or 10k. The arduino serial is idle high and the rs232 is idle -12v. It is indeed inverted as you already noticed. You can try a transistor to invert the signal. There is no need to use SoftwareSerial. The SoftwareSerial has limitations for the atmega32u4/Leonardo https://www.arduino.cc/en/Reference/SoftwareSerial

I think you're looking for an inverting amplifier. This can be done with either a BJT or a MOSFET (assuming your input is enough to turn the MOSFET on). Here's an example with a BJT:

simulate this circuit – Schematic created using CircuitLab
The output range is independent of the input and is defined by the supply voltage.

Base > Collector is not good ,for NPN transistor.
Because "Base -> collecter" is PN.
So use LM393 for level convert.
LM393 is open collecter.

I ended up using a simple voltage divider to reduce the 5v to 3v and used SoftwareSerial to read the inverted serial. Thanks everyone.


text:
Cannot get Serial working
I've bought a module which should communicate via serial RX/TX. The module and code are described here: https://www.dfrobot.com/wiki/index.php/Weather_Station_with_Anemometer/Wind_vane/Rain_bucket_SKU:SEN0186.
I've hooked up everything as described (using an Arduino Nano instead of an Uno, but the rest is the same) and now trying to get things to work. I could not get any decent output. So I decided to switch to a bare-minimum program to read stuff from the serial port in order to see whats going on. I found the following sample: https://gist.github.com/Protoneer/96db95bfb87c3befe46e and implemented this code (only this).
Now what I see is the following:
- With RX/TX connected the wrong way, when I reset the nano, the serial monitor shows me one instance of the string I'm looking for (as described in the module documentation). When connected the right way, the text is not there but that's to be expected as the nano should receive it (and not the serial monitor). This does however prove that the module is actually sending data.
- Serial.available seems to evaluate to 0 all the time, indicating there is no data to be read from the serial line.
So why would Serial.available return 0 even though there seems to be data being sent to serial, as the monitor does show the string I'm looking for with the pins crossed. I have also tried disconnecting the RX line on the module to prevent statements being sent over serial to interfere with the module. The documentation does not state the need to send anything to the module in order to trigger the response. In fact, if you look at the sample code the first interaction with serial (after Serial.begin(9600)) is Serial.available().
Is there anything else I can do from a debug perspective? As you might notice I'm no expert in this stuff.

1st thought, Nano boards come in 3 and 5 volt versions.  The weather station clearly says it is a 5 volt device. Maybe you have the wrong Nano?

No voltage is correct, it's hooked to 5V on the nano.

If the serial terminal is showing you the data then it means you have the TX and RX pins connected the wrong way around.

@Majenko you're right, I was mixing up test results. With the cables connected the right way (RX-TX, TX-RX) I'm actually not getting the contents on the serial monitor. But the end result stays the same: Serial.available returns false and there's no data incoming, even though having the wires the other way around seems to indicate data is being sent.

available() returns count of available data.

Yeah the actual check is Serial.available() > 0 (which returns false).

so you copy data from Serial to Serial echoing them to the device in ascii form? what could be the reaction of the device?

See the gist, the sample code takes whats coming in and prints it, nothing more. But as there is no code coming in at all, there's no prints as well.
If I do Serial.println, is that being sent to the device as well? I have no clue how it would respond to that.

is the RX of the device connected to TX of Nano? then Serial output of Nano is send to the device

Its connected yes, I tried disconnecting the TX from nano (so only TX module => RX nano connected)  but that gives the same result, available return 0.

@Jasper, there is a saying that the RS232 protocol (never mind the physical bit) is the standard that is not a standard. I would recommend you discover this your self by abandoning the embedded world and connect your weather "thing" to a computer with a configurable application such as RealTerm.  Once you figured out the proper configuration you can work your self back to the embedded world.

sorry about that 2400 baud. it is in the other weater station question

So, you have the module connected to the Nano pins 1 and 2, and are also trying to communicate with the PC via the Serial object and serial monitor? There is a USB/serial converter chip on the Nano that is likely conflicting with your module. You can try SoftwareSerial to get a bit-banged serial port for communicating with the module on some other pins.

@josecanuc if you post that as an answer, I can give you the points you deserve :)

how did SoftwareSerial help if you need only RX to connect to the device and you are not sending anything over USB to Uno

@Juraj, pin 0 and 1 are connected to the usb-serial chip with a resistor. The signals can be overridden by something else, but we don't know how strong the tx signal from the module is.

@Jot, if it works in manufactures example, it should be strong enough

I'm also not sure what the issue is. Maybe it's my cheap Chinese nano that's causing the problems. Any way, I know for sure that now it's connected to other pins and using SoftwareSerial, it all works the way it should. I have a "real" uno lying around as well, will give it a go on that one too.

It seems you have the module connected to the Nano pins 0 and 1, and are also trying to communicate with the PC via the Serial object and serial monitor?
There is a USB/serial converter chip on the Nano that is likely conflicting with your module. You can try SoftwareSerial to get a bit-banged serial port for communicating with the module on some other pins.

you mean pins 0 and 1 - RX and TX?

Corrected answer to refer to RX/TX pins 0/1.

How is it conflicting? The device only sends data to RX of Nano. TX is not connected to the device so the Nano doesn't send data to the device, only to USB. Nothing is sent from computer to Nano and it would not stop the device.

@Juraj , well even if nothing is sent from the computer, the tx of the usb-serial chip is connected (with a resistor) to the rx of the atmega chip. josecanuc, for 9600 baud, I prefer the AltSoftSerial.

This indeed fixed it, SoftwareSerial on pins 10 and 11 works as expected.


text:
Data is not sending to Thingspeak using SIM900 with an interrupt in the code
I'm currently working in a weather station with online recording on Thingspeak. When I send a set of parameters (T, Pressure, Humidity, light), I don't have any problem with sending data. But when I add to the code the rain parameter, the code doesn't send the data. The rain parameter is calculated based on an interrupt, so could this affect my data sending? It is any trick that I can use to solve it?
The code:
#include <Wire.h>
#include <SoftwareSerial.h>
#include <String.h>

SoftwareSerial Sim900Serial(9,11);//Configarión de los pines serial por software: RX, TX

Weather myHumidity;//Create an instance of the humidity sensor

const byte RAIN = 2;

volatile int pulse_counter_ISR;
float mm;
volatile unsigned long raintime, rainlast, raininterval, rain;

float humidity = 0; // [%]

void setup() {
  Serial.begin(19200);
  Sim900Serial.begin(19200);//Arduino se comunica con el SIM900 a una velocidad de 19200bps
  Sim900Serial.println("AT+IPR=19200");    // Tell the SIM900 not to autobaud

  Wire.begin();

  pinMode(RAIN, INPUT_PULLUP); // input from wind meters rain gauge sensor
  digitalWrite(RAIN, HIGH);

  myHumidity.begin();

  // attach external interrupt pins to IRQ functions
  attachInterrupt(0, interrupt_handler, FALLING);

  // turn on interrupts
  interrupts();

}

void loop() {
 calcWeather();
 comandosAT();
 delay(600000);
}

void calcWeather()
{
//Calc humidity
humidity = myHumidity.getRH();

//Calculate amount of rainfall for the last 10 minutes
mm = pulse_counter_ISR*0.2794;
pulse_counter_ISR = 0;

}

void comandosAT(){
Sim900Serial.println("AT+CIPSTATUS");//Consultar el estado actual de la conexión
delay(2000);
Sim900Serial.println("AT+CIPMUX=0");//comando configura el dispositivo para    una conexión IP única o múltiple 0=única
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CSTT=\"internet.simple\"");
delay(1000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIICR");//REALIZAR UNA CONEXIÓN INALÁMBRICA CON GPRS O CSD
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIFSR");// Obtenemos nuestra IP local
delay(2000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSPRT=0");//Establece un indicador '>' al enviar datos
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//Indicamos el tipo de conexión, url o dirección IP y puerto al que realizamos la conexión
delay(6000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSEND");//ENVÍA DATOS A TRAVÉS DE una CONEXIÓN TCP O UDP
delay(4000);
mostrarDatosSeriales();
String datos="GET https://api.thingspeak.com/update?api_key=MYAPIKEY&field1=0" + String(humidity) + "&field2=0" + String(mm);
Sim900Serial.println(datos);//Envía datos al servidor remoto
delay(4000);
mostrarDatosSeriales();
Sim900Serial.println((char)26);
delay(5000);//Ahora esperaremos una respuesta pero esto va a depender de las condiones de la red y este valor quizá debamos modificarlo dependiendo de las condiciones de la red
Sim900Serial.println();
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSHUT");//Cierra la conexión(Desactiva el contexto GPRS PDP)
delay(5000);
mostrarDatosSeriales();
}

void mostrarDatosSeriales()//Muestra los datos que va entregando el sim900
{
while(Sim900Serial.available()!=0)
Serial.write(Sim900Serial.read());
}

void interrupt_handler()
{
  pulse_counter_ISR = pulse_counter_ISR + 1;
}

so could this affect my data sending? .... run a test to find out for sure

Did you forget to include a library from Sparkfun?

I run it and works, with and without interrupt(), but when I add more variables (4 or more) the AT-CIPSEND do not send the datas

Finally I split the comands in two functions (comandosAT_1 and comandosAT_2) with different variables. The first one do not works and the socond one works fine. Here are the code

Finally I split the comands in two functions (comandosAT_1 and comandosAT_2) with different variables. The first one do not works and the socond one works fine. Here are the code
void comandosAT_1(){
Sim900Serial.println("AT+CIPSTATUS");//Consultar el estado actual de la conexión
delay(2000);
Sim900Serial.println("AT+CIPMUX=0");//comando configura el dispositivo para una conexión IP única o múltiple 0=única
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CSTT=\"internet.simple\"");//comando configura el APN, nombre de usuario y contraseña."gprs.movistar.com.ar","wap","wap"->Movistar Arg.
delay(1000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIICR");//REALIZAR UNA CONEXIÓN INALÁMBRICA CON GPRS O CSD
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIFSR");// Obtenemos nuestra IP local
delay(2000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSPRT=0");//Establece un indicador '>' al enviar datos
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//Indicamos el tipo de conexión, url o dirección IP y puerto al que realizamos la conexión
delay(6000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSEND");//ENVÍA DATOS A TRAVÉS DE una CONEXIÓN TCP O UDP
delay(4000);
mostrarDatosSeriales();
String datos="GET https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXX&field1=0" + String(tempC) + "&field2=0" + String(humidity) + "&field3=0" + String(pressure);
Sim900Serial.println(datos);//Envía datos al servidor remoto
delay(4000);
mostrarDatosSeriales();
Sim900Serial.println((char)26);
delay(5000);//Ahora esperaremos una respuesta pero esto va a depender de las condiones de la red y este valor quizá debamos modificarlo dependiendo de las condiciones de la red
Sim900Serial.println();
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSHUT");//Cierra la conexión(Desactiva el contexto GPRS PDP)
delay(5000);
mostrarDatosSeriales();
}

void comandosAT_2(){
Sim900Serial.println("AT+CIPSTATUS");//Consultar el estado actual de la conexión
delay(2000);
Sim900Serial.println("AT+CIPMUX=0");//comando configura el dispositivo para una conexión IP única o múltiple 0=única
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CSTT=\"internet.simple\"");//comando configura el APN, nombre de usuario y contraseña."gprs.movistar.com.ar","wap","wap"->Movistar Arg.
delay(1000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIICR");//REALIZAR UNA CONEXIÓN INALÁMBRICA CON GPRS O CSD
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIFSR");// Obtenemos nuestra IP local
delay(2000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSPRT=0");//Establece un indicador '>' al enviar datos
delay(3000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//Indicamos el tipo de conexión, url o dirección IP y puerto al que realizamos la conexión
delay(6000);
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSEND");//ENVÍA DATOS A TRAVÉS DE una CONEXIÓN TCP O UDP
delay(4000);
mostrarDatosSeriales();
String datos="GET https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXX&field4=0" +  String(light_lvl) + "&field5=0" + String(mm) + "&field6=0" + String(windspeed_KMH);
Sim900Serial.println(datos);//Envía datos al servidor remoto
delay(4000);
mostrarDatosSeriales();
Sim900Serial.println((char)26);
delay(5000);//Ahora esperaremos una respuesta pero esto va a depender de las condiones de la red y este valor quizá debamos modificarlo dependiendo de las condiciones de la red
Sim900Serial.println();
mostrarDatosSeriales();
Sim900Serial.println("AT+CIPSHUT");//Cierra la conexión(Desactiva el contexto GPRS PDP)
delay(5000);
mostrarDatosSeriales();
}

And the first answer of the serial monitor is the following:
OK
AT+CIPSTATUS
OK
STATE: IP INITIAL
AT+AT+CSTT="internet.simple"
OK
AT+CIICR
OK
AT+CIFSR
10.254.14.23
AT+CIPSPRT=0
OK
AT+CIPSTART="TCP","api.thingspeak.com","80"
OK
CONNECT OKAT+CIPSEND
SEND OK
AT+CIPSHUT
SHUT OK
And the socond one is (that works)
AT+CIPSTATUS
OK
STATE: IP INITIAL
AT+CIPMUX=0
OK
AT+CSTT="internet.simple"
OK
AT+CIICR
OK
AT+CIFSR
10.110.2.23
AT+CIPSPRT=0
OK
AT+CIPSTART="TCP","api.thingspeak.com","80"
OK
CONNECT OKAT+CIPSEND
GET https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXXXX&
SEND OK
381
AT+CIPSHUT
SHUT OK
You can see that after the AT+CIPSEND command, the SIM answer "GET https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXXXX&" , then "SEND OK" and finally the number of the entry (381).
Any idea or suggestion?


text:
Using Arduino wireless SD Shield to save data to sd card and send to PC over wireless network
I'm using an Arduino Mega to monitor the current & voltage input to four different sensors. This works fine - the sensors work as expected and I can view the results via the Serial Monitor or Parallax DAQ for Excel.
SETUP
I also have an Arduino wireless SD shield (now retired) with an XBee module (shown in the below image):

Arduino Shield page
XBee module page

I would like to do the following:

Save the current/voltage sensors' output locally to the SD card
Send the data over a wifi connection for plotting using plotly API (see example  here)

I've seen a bunch of tutorials on how to get the shield to work but can't seem to figure it out:

Arduino WiFi shield example
Instructables
Can I connect to WiFi with an Arduino, "wireless SD shield" and XBee

Here's my code (removed the current/voltage sensor code for brevity):

#include <SPI.h>
#include <WiFi.h>
#include <SD.h>

void setup() {
  // initialize serial and wait for the port to open:
  Serial.begin(9600);
  while(!Serial) ;

  SPI.begin();

  Serial.println("Checking WiFi status:");
  Serial.print("\tWiFi Status: ");
  Serial.println(WiFi.status());

  if(WiFi.status() == WL_NO_SHIELD){
    Serial.println("\tNo Shield present.\n");
  }else{
    Serial.println("\tShield found.\n");
  }

  Serial.println("Initializing SD card:");
  if (!SD.begin(53)) {
    Serial.println("\tSD card initialization failed.\n");
    return;
  }else{
    Serial.println("\tSD card initialization successful.\n");
  }

  // attempt to connect using WEP encryption:
  Serial.println("Initializing Wifi:");
  printMacAddress();

  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
}

void loop() {
  delay(5000);
  // scan for existing networks:
  Serial.println("Scanning available networks:");
  listNetworks();
}

void printMacAddress() {
  // the MAC address of your Wifi shield
  byte mac[6];

  // print your MAC address:
  WiFi.macAddress(mac);
  Serial.print("\tMAC: ");

  for(int i = 0; i < 5; i++){
    Serial.print(mac[5-i],HEX);
    if(i != 5){
      Serial.print(":");
    }
  }
  Serial.println(" ");
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  byte numSsid = WiFi.scanNetworks();

  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);

  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet<numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    Serial.println(WiFi.encryptionType(thisNet));
  }
}

OUTPUT
Checking WiFi status:
    WiFi Status: 255
    No Shield present.

Initializing SD card:
    SD card initialization successful.

Initializing Wifi:
    MAC: 0:0:0:0:0:
Scanning available networks...
** Scan Networks **
number of available networks:0

Not sure what is going on here.

"Arduino Wireless SD shield" is not "Arduino WiFi shield".
The code you have is for the Arduino WiFi shield. But you have Arduino Wireless SD shield for a XBee module. XBee is not WiFi. Zigbee protocol is different protocol than WiFi.
You can save data to SD card with the SD library. Install the library in Library Manager and try the examples.
Arduino WiFi shield:

Note: the Arduino WiFi library is only for this shield and clones

Thanks, I am able to write to the SD card without problem. I have the shield and the XBee module, how do I get them to work together and discover/send data over available WiFi networks?

XBee can't send data over WiFi

So, what is the shield/module for? the Arduino example seems to suggest that the shield by itself is capable to atleast finding the WiFi networks and joining them. Right now, I can't even get the Mac address to be printed.

which example? what you have in question is for WIFI shield, not for Wireless shield. Zigbee protocol is different protocol then WiFi

I don't think I understand the difference - if you do, can you point out how/where I'm wrong or what I should be looking for? I'm a mechanical engineer without much experience in electronics. I'm clearly lost and don't want to ask a million irrelevant questions to find out that my initial premise was flawed.

it is software which communicates over the radio-frequency. WiFi is other software then Zigbee. they can't talk to each other


text:
Relay Module for water pump
I want to switch on/off my water pump by using arduino nano, I have 2 channel relay module. Is this module safe for controlling pump?
Specifications pump:
power = 746 watt (1HP) single phase,
voltage = 220V
Specifications relay:
5VDC
10A 250 VAC,
15A 125 VAC
this model actually (  tongling jqc-3ff-s-z )

Also, what will happen if we draw large current on relay than it can bear?

746 W / 230 V = 3.25 A. why would it draw more than the relay can bear?

@Juraj some motors have a higher current during startup.

I know, but there is 200% reserve to 10 A. And the relay will not be destroyed  at 10 A. I am sure it has a tolerance for short spike over 10 A.

Well you'll need to know the true maximum current for the pump. It may say 1HP (746 watts), which you'd like to think came out to a simple 3.5 amps. But there are a few other factors to consider, such as motor efficiency and power factor to name a few. You can see where if the efficiency were only 50%, you'd need to consume 2X the power to get that 1HP. Also, if the power factor were 60%, it would mean the 746 watts become 1243 VA (volt-amps), which would put you above 5 amps, and that's before efficiency concerns. Then there is the initial surge... how much current is drawn for the short interval during startup.
So what you need to do is really examine the name plate data on that pump. I've actually just done something like this (controlling a water pump for a pool), and I looked at some of those relay modules too. I personally like to see relay contacts that are at least 3X the expected run-time current when controlling a motor. And in the end those modules just did not offer enough extra safety margin for me. But you can make your own analysis.
What I ended up using were some low cost OMRON LY4F-DC12 relays. They have 4 10 amp contacts, and I had a conversation with an OMRON engineer about using the contacts in parallel to create one 40 amp relay, and he confirmed it was a workable solution. Here's one at Mouser Electronics, shown  with a mounting socket. You can safely drive this relay forever with a cheap 2N2222 transistor and a 12V supply, provided you put a revers blocking diode across the relay coil. then, put about a 1K resistor between the 1000 the arduino pin and the transistor's BASE pin. You need the transistor (or a MOSFET) because the relay needs about 100mA to operate, and because the coil needs 12V. I know you didn't count one a separate supply, but you can only push the arduino's 5V supply so far. And 12V switching supplied, good to 300mA, are small and can be had for a couple of bucks. Those supplies can also be powered with anything from about 90VAC to about 250VAC, with no mods.
Here's a piece of a schematic from my own project. It's ugly, but you get the idea. The bottom line is that with my motor, which i expected draw a maximum of 12 amps (mine is 125VAC), I can sleep easy knowing this relay will probably outlast the motor!

what about using a 30 A relay http://wiki.seeedstudio.com/Grove-SPDT_Relay_30A/

well whatever person gave a -1 to my answer is certainly a true asshole, and just the kind of person new stackexchange rules are trying to weed out.

@Juraj -- Note the 2X higher current needed compared to the OMRON relay I suggested. Also, there are some advantages (one of which is cost) working with1 12V relays, and you'll need a power supply eiether way.

I have two of this 30 A relays in my project which moved from Uno to Wemos D1 and then to M0. The relays are powered from 5 V pin (on-board regulator of the board) with no problems even if both hold the coil. I gave you -1 for overcomplicated solution.

@Juraj -- I know the arduino spec says they are good for 500mA, but I've found my NANO boards run a bit too hot for my comfort level. Also, the arduino's spec says no more than 40mA per pin, so I'm not sure how you're powering a 180mA relay coil. But in any case, most of my answer was in response to the question about safely controlling a pump, with a 10 amp/contact relay. And now the question was put on hold, and someone deducted points from me, so If the answer is useful copy it, because I may just delete the whole thing..

the coil is hold by the 5 V from 5 V pin. the digital pin gives only the signal to the circuit on the relay module (3.3 V in case of 3.3 V boards). the regulator heats up if the input voltage is high.

@Juraj and what voltage is powering the arduino VIn pin?

for 5 V boards, ideal is not to use the regulator but supply nice 5 V like the USB. If regulator, then better close to lower limit of the regulator. I use 9 V supply, because I could not find a 7 V one, which would have the right size.  And none of the regulators on the boards I used heated up. Project runs 24/7.

Randy, try to not take a down-vote personally. I've got quite a few in my time, and I know it is enraging. :)  However Stack Exchange gives people the ability to vote up and down, and the occasional down-vote is part of the process. Serial down-voting (ie. when someone stalks you and down-votes every post) is different and will be dealt with in an appropriate manner.

@Juraj I misunderstood. I usually consider Arduino projects to eventually be "stand alone" with no USB power.  So I usually just supply external power to VIN, as you did. I used the 12V switching supply because I had a 12V relay to drive. But if you want a lower voltage, here's an interesting find. Its a small 5VAC transformer, no-load 7VAC, good to 500mA. The filtered DC would be 10V no load (minus diode drops, should be 9V). At full load, 7VDC (about 6 with the diode drops). Looks pretty ideal, and very CHEAP for a xfmr!
http://www.goldmine-elec-products.com/prodinfo.asp?number=G22643

12 V is upper limit for regulator on Nano. no wonder it was heatingup. I didn"t mean to use USB connection for power. but you can connect a "good" 5 V power source to 5 V pin of Uno, Nano, Mega and other 5V Arduinos. then the regulator is bypassed and no heat is generated by powering circuit

@Juraj
people get away with it, but the official stance on supplying power directly to the 5V pin on the Arduino Uno is thus:
"5V. This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it."
reference: https://store.arduino.cc/usa/arduino-uno-rev3

but it is the same as supplying 5 V over USB connector with an USB power adapter

I suspect the reason it is not recommended its that you lose the isolation offered by the schlocky diodes.


text:
What value of resistance to put between the output of a 74hc595 and the LEDs?
I'm going to start a project to make an array of LEDs using the shift registers 74HC595, I've seen many tutorials and it's not really difficult using the Arduino plataform.
The situation is as follows: in the tutorials they put a resistance between the outputs of the 74HC595 (Qx) and the LEDs , but in each tutorial the resistance varies (between 200 and 575 Ohms).
Then the question would be: if feed with 5V to 74HC595 (the same power as the Arduino) and the resistance that I put between its outputs (Qx) and the LEDs is lower (let's say 200 Ohms), the LEDs will light brighter than if I do it with resistors with higher values (let's say 500 Ohms)?

What does the 74HC595 datasheet say about maximum current per output and maximum current for the entire IC? The Texas Instruments datasheet uses 560 ohms per LED on the Typical Application page.

@VE7JRO, the OP is asking, using a lot of words, if a 200 ohm series resistor will produce brighter LED output when compared to a 500 ohm series resistor.

I know the Ohm´s law, I just asking for experience, I Live in Cuba and is very dificult to me order pieces (when I buy them I have to wait almost 4 month to get them); so, when I order I try to order "things" that I would know that will work, I ask for this reason. Sorry

They say 25mA per output.

no need to apologize .... then you should be asking about what @VE7JRO mentioned in the above comment .... can the 74HC595 handle the load when all the LEDs are on?

You are correct that a lower resistance would offer higher brightness. The more current through the LED, the brighter it will be. The current is calculated by dividing the voltage across the resistor by resistance value. The voltage across the resistor would be your 5V - the voltage drop across the LED. this often varies by color. A RED LED might have a 1.2V drop, and GREEN or BLUE would be higher. So to get the same relative brightness in different color LEDS, you will often see a lower resistance used, to get the same current.
Lets say you have a 20mA Red LED, with a 1.2V drop. So (5 - 1.2)/.020 = 190 ohms. If the LED required 10mA, that would be 380 ohms.
Now you DO need to look at the data sheet for the chip driving the LED, and make sure it is up to the task. Can a pin source or sink 10mA? 20mA?


text:
Making simple on/off IR servo movement.
I'm new to Arduinos and programming. I'm getting into a project and one of my tasks was to learn how to incorporate servos into Arduino and learn about sensors. I wanted to combine both, but I'm having some problems in my syntax. Can I get some help?
This is my code:
// servo test
#include <Servo.h>
#include <IRremote.h>
#define START_BUTTON //place code for button // code recieved from start
button
#define STOP_BUTTON //place code for button // code recieved from stop
button

int servopin1 = 13; // first servo
int servopin2 = 12; // second servo

int pos = 0;

int receiver_pin = 4; // output pin
int vcc = 5; // vcc ir sensor
int gnd = 6; // gnd for ir sensor
IRrecv receiver(receiver_pin);
decode_results output;
Servo Servo1;
Servo Servo2;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  receiver.enableIRIn();
  pinMode(vcc, OUTPUT);
  pinMode(gnd, OUTPUT);
  digitalWrite(vcc, HIGH);

  Servo1.attach(servopin1);
  Servo2.attach(servopin2);
}

void loop() {
  // put your main code here, to run repeatedly:

    if (receiver.decode(&output)) {
    unsigned int value = output.value;
    switch(value) {
      case START_BUTTON:
        if (pos <= 180){
           Servo1.write(pos);
           delay(500);
           pos = pos + 30;}
        else {
           pos=0;
             }
        if (pos <= 180){
          Servo2.write(pos);
          delay(500);
          pos = pos + 30;}
        else {
            pos=0;}
      break;
      case STOP_BUTTON:
           Servo1.write(0);
           delay(200);
           Servo2.write(0);
           delay(200);
           break;
            }
     }
  }

  //^servo 2 positions and delays
}

I'm trying to figure out why I'm getting a the following error:
C:\Users\Alex\Documents\Arduino\Servo_test2Library\Servo_test2Library.ino:
In function 'void loop()':

Servo_test2Library:38: error: expected primary-expression before ':' token

       case START_BUTTON:

                        ^

Servo_test2Library:53: error: expected primary-expression before ':' token

       case STOP_BUTTON:

                       ^

C:\Users\Alex\Documents\Arduino\Servo_test2Library\Servo_test2Library.ino:
At global scope:

Servo_test2Library:64: error: expected declaration before '}' token

 }

 ^

Multiple libraries were found for "IRremote.h"
 Used: C:\Users\Alex\Documents\Arduino\libraries\IRremote-2.2.3
 Not used: C:\Users\Alex\Documents\Arduino\libraries\Arduino-IRremote-master
Using library Servo at version 1.1.2 in folder: C:\Program Files
(x86)\Arduino\libraries\Servo
Using library IRremote-2.2.3 at version 2.2.3 in folder:
C:\Users\Alex\Documents\Arduino\libraries\IRremote-2.2.3
exit status 1
expected primary-expression before ':' token

Up at the top of your code, you have:
#define START_BUTTON //place code for button // code recieved from start
button
#define STOP_BUTTON //place code for button // code recieved from stop
button

A #define needs 2 parts after it. The first is the new name being created, and the 2nd is the definition of the new name.
You should put the value that you expect for the START_BUTTON condition after the name, such as:
#define START_BUTTON 0x48
#define STOP_BUTTON 0x49

Or whatever your IR remote is sending.
Also, you have one too many closing braces (}) at the end.
      [...]
      case STOP_BUTTON:
           Servo1.write(0);
           delay(200);
           Servo2.write(0);
           delay(200);
           break;
            }  // THIS CLOSES THE SWITCH
     }  // THIS CLOSES THE IF STATEMENT
  }  // THIS CLOSES loop()

  //^servo 2 positions and delays
} // THIS IS NOT CLOSING ANYTHING THAT WAS OPENED


text:
everything works independitly but not together. Piezo not generating a tone
My goal with the code is simple. Let the Piezo buzz when temperature reaches 25 degrees. My piezo is hooked up correctly, because It makes a buzz when the arduino boots or when I put this line of code anywhere else in my code.
I also checked if the If statement was called. And yes it is! So the if statements is happening yet I don't hear a buzz.
I am aware that I am breaking my seven segmented screen by using the delay. But I don't mind the screen working when the buzzer is.
void loop()
{
  //local vars
  if (millis() % 5000 <= 10) {
      float lm35TempC = lm35.getTempC();
      sevseg.setNumber(lm35TempC, 2);
      if (lm35TempC > 25.00) {
        tone(1,500,1000);
        delay(3000);  <------- WHERE IT PROBABLY GOES WRONG
      }
      if (lm35TempC < 25.00) {
        noTone(1);
      }
  }
  sevseg.refreshDisplay(); // Must run repeatedly; don't use blocking code (ex: delay()) in the loop() function or this won't work right
}

To conclude: The If-statement is working yet I don't hear a buzz. How does this happen?
Thanks in Advance!

The windows of millis() % 5000 <= 10 is only 10ms every 5 second. How long does the function sevseg.refreshDisplay take? more than 10ms?

No I dont think that function will take much longer, but I have to admit its a ugly way of creating a delay of 5 seconds, but if I for example increase 10 to 50, my display will sometimes refresh twice within a short timeframe

Then stop doing it in a ugly way. Use https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay with an interval of 5 seconds. After that you have to fix the tone, I think that is ugly as well. A tone with duration will delay and does not need noTone. There might be hardware problems as well. Fix everything one by one.

You connected the piezo to pin 1? Chose other pin. Pin 1 is Serial TX. You 'pump' PWM to USB.
tone() function will make sound no matter if you have a delay there. You set 1 sec with 1000 as third parameter. It will sound 1 sec and the turn of. You do not need the delay() and noTone().
500 is low frequency. If it sounds only one second, can you catch it?
try tone(TONE_PIN, 4500, 500). with speaker it is a nice beeeep

You were right! The only reason I used pin 1 was, that I allready used all the other Digital Pins (expect 0 but that one is like 1). I have now configured an Analog Pin as output and it works Perfectly!


text:
Parse UNIX-time from char[]
I want to parse a large number to sync time on my arduino. For this i send it a string with the current time in Unix time format wich looks somethink like this:

1535441277

For this I just call a php script wich echos the time() function.
But with  string.toInt()I'm unable to parse it. I suppose the number is too large for an int or a long. But I can't put it directly into the setEpoch() method from the RTCzero libary because it accepts as input datatype only uint32_t. So how can I parse large numbers on a system where double isn't implemented. And I don't just try to parse the entire HTTP-Response. I iterate thru the response and at the relevant line I write all the chars into a char-Array. I also have removed the \r and \n chars.

On 32 bit systems, uint32_t is usually the same as unsigned int and unsigned long. You should be able to parse the number using strtoul(), which is quite standard and returns an unsigned long.

Thanks for the quick response. I also found another solution: Before echoing the time remove a large chuck of the time by just removing the current timestamp on the server-side. Later on I add the exact same amount when using the setEpoch() function. I know that's not very elegant but it works for me.

How do you share the time base (that large chunk) between the Arduino and the PC?

@DmitryGrigoryev, subtract epoch time of the first second of this year

So you already have current time set on both Arduino and the PC?

@DmitryGrigoryev, read the question. he gets the time with HTTP GET request to his service on the server

@Juraj I totally don't see that in the question.

@DmitryGrigoryev, It is expert's translation of " I just call a php script wich echos the time() function."

@Juraj But that's the string he's having a hard time parsing in the first place, isn't it? Also, GET request goes from Arduino to the server, and the output of time goes the other way around.


text:
What's wrong with my code
I use a mega as a master and a nano as a slave.
Both should convey texts. However, I get the master always only the answer that I send.
The text from the slave does not arrive.
Master:
#include <SPI.h>
volatile boolean senden;
volatile char Paket_vom_Slave;
volatile char Paket_zum_Slave;
char buf [100];
volatile byte pos;
String Paket = "";
char x;

void setup (void)

{
  Serial.begin(9600);
  pinMode(53, OUTPUT);
  pinMode(SS, OUTPUT);
  digitalWrite(SS, HIGH);  //SS Pin auf HIGH setzten
  SPI.begin ();  //Verbindung starten
  SPI.setClockDivider(SPI_CLOCK_DIV8);  //Geschwindigkeit verlangsamen
}

void loop (void)
{
  //Text_erstellen();

  digitalWrite(SS, LOW);    //starten der Kommunikation mit Slave

  for (const char * p = "TxT v Master\n" ; Paket_zum_Slave = *p; p++)
  {
    //Text_erstellen();
    Paket_vom_Slave = SPI.transfer(Paket_zum_Slave); //senden von Text
    Text_erstellen();
    delayMicroseconds (500);
    Serial.print("sent: ");
    Serial.print(Paket_zum_Slave);
    Serial.print("\t empfangen: ");
    //Serial.println(Paket_vom_Slave);
    Serial.println(Paket);
    delay(200);
  }
  digitalWrite(SS, HIGH);  //beenden der Kommunikation
  delay (1000);  //kurze pause

}

void Text_erstellen()
{
  char c = Paket_vom_Slave;  //kopieren der Daten von SPI Buffer
  if (pos < sizeof buf)
  {
    buf [pos++] = c;  //hinzufuegen des naechsten Zeichens
    if (c == '\n')
      senden = true;
  }
  if (senden)
  {
    buf[pos] = 0;
    Paket = (buf);
    x = buf;
    Paket.trim();
    Serial.println (("empfangen :--->") + (Paket));
    Serial.println (("empfangen :--->") + (Paket));
    Serial.println (("empfangen :--->") + (Paket));
    pos = 0;
    senden = false;

  }
}

Slave:
#include <SPI.h>
volatile boolean senden;
volatile boolean versandbereit;
//volatile byte Paket_Master,Sendung_Slave;
volatile char Paket_Master;
volatile char Sendung_Slave;
String Paket = "";
String Sendung = "";
int i = -1;
char buf[20];
char buf1[20];
volatile byte pos;
volatile byte pos1;

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

 pinMode(12, OUTPUT);
  pinMode(MISO, OUTPUT);
 SPCR |= _BV(SPE);         // turn on SPI in slave mode

  //SPCR |= bit (SPE);
  senden = false;
  SPCR |= _BV(SPIE);   // turn on interrupts
  SPI.attachInterrupt();
}

void loop(void)
{

  if ((versandbereit) == false);
  {
    Paket_Text();
  }

  if (senden)
  {
    i = i + 1;

    buf[pos] = 0;
    Paket = (buf);
    buf1[pos] = 0;
    Sendung = (buf1);

    if (i == 12)
    {
      SPDR = "\n";
    }
    else
    {
      SPDR = (buf1[i]);
    }
    Paket.trim();
    Sendung.trim();
    Serial.println (("empfangen :--->") + (Paket));
    Serial.println (buf1[i]);
    Serial.println (i);
    Serial.println (("gesendet  :--->") + (Sendung));

    pos = 0;
    senden = false;
  }

  if (i == 12) i = -1;
}

ISR(SPI_STC_vect)
{

  byte c = SPDR;  //kopieren der Daten von SPI Buffer
  if (pos < sizeof buf)
  {
    buf[pos++] = c;  //hinzufuegen des naechsten Zeichens
    if (c == '\n')
      senden = true;
  }
}

void Paket_Text()
{
  if (pos1 < sizeof buf1)
    for (const char * p = "Paket--Slave\n" ; char c = *p; p++)
    {
      buf1[pos1++] = c;
                            Serial.println (buf1);
      if (c == '\n')
        versandbereit = true;
    }
}

I've updated the code above.
The slave now sends bitwise the same text length as it should, but another text like the master sent.
Unfortunately, the master always receives what he sends, not what comes from the slave.

I'm getting on slowly :-)
But I currently have a problem with the data transfer.
I hand over at startup: char package_to_master [50] = "Start from the slave.";
and change SPI interrupt routine content with "new text"
but is sent "starting from the slave."
How should I change that?
// Slave
char Paket_zum_Master[50] = "Starten vom Slave.";
volatile int pos;
volatile bool active;
String Send_Paket;
ISR (SPI_STC_vect)    // SPI interrupt routine
{
  Send_Paket = "neuer Text";
  char Sendung = ((Send_Paket + "\n").c_str());
  Paket_zum_Master[50] = Sendung;
  byte c = SPDR;
  if (c == 1)  // starting new sequence?
  {
    active = true;
    pos = 0;
    SPDR = Paket_zum_Master[pos++];   // sendet erste byte
    return;
  }
  if (!active)
  {
    SPDR = 0;
    return;
  }
  SPDR = Paket_zum_Master[pos];
  if (Paket_zum_Master[pos] == 0 || ++pos >= sizeof(Paket_zum_Master))
    //wenn pos=0 oder größer 1
    active = false;
}  // end

Pin 10 at the nano and the master pin 53 but the hardware exchange is ok, I've already checked

http://www.gammon.com.au/forum/?id=10892&reply=1#reply1

Unrelated, but a more-descriptive title might be a good idea.

You do not have pinMode(SS, OUTPUT); in setup() of the master.

digitalWrite(SS, HIGH);

I think with the command it happened:

I tried it once but the problem persists :-(

to use digitalWrite  pinMode must be set

do not set it to output on slave. on slave the SS pin is handled by hardware

Yes Mega Master Pin52 Nano =pin10

did you add pinMode(SS, OUTPUT); to setup() on master?

pinMode(SS, OUTPUT);  digitalWrite(SS, HIGH);   SPI.begin ();  SPI.setClockDivider(SPI_CLOCK_DIV8); is registered but it is not yet

if it worked for a moment, check the wiring. ground is connected between boards?

I try to explain the mistake again, maybe someone has an idea for me.
I send to Master "TxT v Master \ n" at the character "\ n" the slave gives me the message correctly.
The slave sends back ____ "package - slave \ n", but the master only shows me the text he sends himself.
When I send something without a "\ n" character from the slave, the master does not put any text together
void text_create () no cancel. But since the slave sends the same character length, the transmission seems obvious.
When composing, however the master only puts together what he sends. Do I have the worm somewhere

Paket_vom_Sklave; is clearly the valid return and with "\ n" the slave comes with the demolition.
In case of an invalid return but not.
I hope my explanation is understandable Mfg Dieter

If I have to change the pin mod how do I do that where I am still a stupid. Maybe someone can tell me where exactly I have to enter.

try the examples by Nick Gammon in the link I added in a comment to the question. the code is very similar to yours, but not same

If I have to change the pin mod how do I do that where I am still a stupid. Maybe someone can tell me where exactly I have to enter.

Nick Gammon seine Beispiele sind gut die hab ich aber schon hin und her gelesen und probiert leider ist es mir nicht gelungen da ein Nutzen raus zu bekommen. Mir fehlt noch einiges an Erfahrung.

Nick Gammon his examples are good but I have already read back and forth and tried unfortunately I did not succeed in getting a benefit out. I still lack a lot of experience. oh sorry was not englisch bevor

I've tried it on with Arduino Pro Micro as a master and Arduino Uno as a slave. It is working.

In the 'Note about Slave Select (SS) pin on AVR based boards' https://www.arduino.cc/en/Reference/SPI, it is notified that the SS pin should be set always as OUTPUT, even though you use another one to select the device.
The answer contains the text inside the SPI data register, you have to change it inside isr https://www.avrfreaks.net/forum/how-fast-can-spi-slave-reply, else it is the same text as that received
const char *p = "Reponse Uno\n" ;
ISR(SPI_STC_vect)
{
  byte c = SPDR;  //kopieren der Daten von SPI Buffer
  buf[pos++] = c;  //hinzufuegen des naechsten Zeichens

  if (pos < 13)
    SPDR = p[pos-1];
  else
    SPDR = 0;

  if (c=='\n') {
    for (int i=0;i<pos;i++)
        bufi[i]=buf[i];
    posi = pos;
    pos = 0;
    senden = true;
  }
}

The result is

By the way, it is another issue to make it work with Arduino Pro Micro as a slave ...

the problem is he doesn't set the SS as output even he uses it to select the slave

Yes it works for me so far but in the master with you, the slave sends the same synonymous yes the same back what he sends. The master should actually receive another text.

Added the way the master can get another text to the answer.