How can i increase the range of values that a light sensor gives?

The circuit is a current-to-voltage converter.  The - input to the op-amp is held at 0 (the voltage at the + input, since it is grounded) so there will be no voltage across the diodes.  The current drawn by the diodes is supplied by the op-amp output through the feedback resistor, so the larger that value, the greater the output voltage will be at any given current.  The short answer is that to increase the output voltage, you need to increase the feedback resistor. (7 ohms seems pretty small to me, unless your diodes draw a LOT of current.)
The other complicating issue is that this circuit depends on the op-amp having a low input offset voltage, since its value (~2 mV for the LM358) causes output errors.  Normally a low-offset-voltage op-amp would be used here, but maybe the use of so many diodes makes a large enough current to swamp the offset error.  If increasing the feedback R doesn't help, you might try a different op-amp (even another LM358) in case the offset of the one you have is trying to force a negative output and that's why you see 0.
Edit 11-8-20:  I looked up the sensor used in the PAR-BAR article that seems to be the source of your circuit.  It pulls about 10 microamps at 1000 lux, so 50 of them would give 500 microamps.  If you want to get (say) a 5V output at 1000 lux, you'd need a feedback resistor of 5/0.0005 = 10 kOhms.  That's without the 1.5 ohm shunt.  Also, are you applying your test illumination evenly over all 50 sensors?  The above calculation assumes that all get 1000 lux.
If you have a single sensor available, I'd recommend breadboarding with just that and a 500 kOhm feedback resistor, and no shunt.  That way there will be no issue about equal illumination.  If you still have problems, and you are committed to the LM358 for some reason, try using a simple circuit to compensate for input offset.  These typically involve a potentiometer (could be a trimmer in the final unit) that adjusts a very small voltage applied to the + input.  In your tests you may find that it needs to be negative, which you would have to apply from some external source (since there is no - supply on the Arduino).  If that's needed to resolve your problem, consider a better op-amp or a different circuit configuration.
Edit 11-9-20: Had another look at the PAR-bar article and noticed that they are measuring differential voltage across the photodiode array, which is not the same as your current-to-voltage converter (although that is indeed typical of photodiode circuits).  The voltages that they get are 30 mV or less.  I suggest you get a DMM and measure the voltage across the array, without any connection to other circuitry.  Cheap DMMs have 200 mV full-scale, which should at least show you what's going on.  The article used an expensive datalogger and only suggests that Arduino-type solutions may be possible, but gives no circuits.  You probably don't need a true differential amp, since the photo voltage is always in the same direction.


How can I set up outputs without using digitalWrite?

digitalWrite() is just a convenience function to hide away complexity from the user, so that she/he can just use a pin number and a value. This complexity takes some time to execute. If this is too slow for you, you need to go a bit deeper into the rabbit hole and use direct port manipulation:

Inside the microcontroller on the Arduino all the special functions for peripherals and such (digital IO, ADC, Serial(UART), SPI, Timer, ...) are configured via Special Function Registers (SFR). These are specific memory places, that are directly connected to the peripherals. You can configure the whole microcontroller by setting these registers to specific values.

For digital IO you first need to know, that the microcontrollers pins are ordered into groups of max 8 pins. These groups are called Ports. Each available port of the microcontroller gets a character, like PORTB. On the Arduino Nano for example PORTD includes the pins 0 to 7.

For each port we have 3 different SFRs (with the x being the character for the corresponding port), where each bit inside the registers corresponds to one pin:

DDRx controls the direction of the pins. If you set a bit to 1 in there, the corresponding pin is set as output. If you set it to zero, the pin will be an input (which is also called High-Z for high impedance, because a digital input pin has a very high resistance).
PORTx controls the output hardware of the digital pins. If you have set a pin as output (as described above) you can use the corresponding bit in the PORTx register to set it's state. If you write a 1 to the bit, the pin will become HIGH (means, the voltage on the pin will go to the same level as Vcc, the supply voltage of the micrcontroller). If you write a zero, the pin will go to LOW (meaning the same level as ground). The PORTx register has a different function, when you configured a pin as input. In this case, a 1 will turn on the interal pullup resistor of the pin, which pulls the level of the pin to HIGH, when nothing is pulling it down to ground (like a switch for example). A zero disables the pullup.
PINx reflects the current state of the pins. If you configured the pins as input, this is the voltage level, that currently lies at the corresponding pin (about the actual voltage levels, see below). A 1 at a bit means, that the corresponding pin is HIGH, else it is LOW.

You can read all of this in the datasheet of the used microcontroller. The datasheet is a must read (at least the relevant chapters), if you want to control the microcontroller via its registers. In most microcontrollers these registers are named as above. But some microcontrollers might define other names. The corresponding datasheet will list all the registers with rather detailed descriptions.

Now let's take that knowledge into actual code. Here I assume an Arduino Nano, though you can exchange that for most other microcontrollers.

// Configure pin D3 as output
DDRD |= (1 << PD3);
// Configure pin D2 as input
DDRD &= ~(1 << PD2);
// Check, if pin D2 is HIGH
if(PIND & (1 << PD2)){
    // Set pin D3 to HIGH
    PORTD |= (1 << PD3);
} else {
    // Set pin D3 to LOW
    PORTD &= ~(1 << PD3);
}

Excourse on bitwise operators: The code above can only be understood by knowing bitwise operators, which are very important for direct port manipulations. I will break down the operations, that are done there:

First we have PD2 and PD3. These are defines from the Arduino core. They are set to the index of the bit, that corresponds to the named pin. So PD2 is defined as 2, PD3 is defined as 3, PD0 as 0.
1 << PD3: The << operator does a bitwise left shift, which means all bits of the value on the left are shifted to the left by the amount standing on the right of the operator. We shift the value 1 three digits to the left here. In binary that looks like this:

0b00000001 << 3 = 0b00001000

That set bit in the result is exactly at the place, where the bits for pin PD3 will be in the Special Function Registers.
DDRD |= (1 << PD3):  This is the same as doing DDRD = DDRD | (1 << PD3), so the |= operator is just an abbreviation for it. The bitwise OR operator | will unite the bits from both sides. If a bit is set to 1 at either side, the result will also have set this bit to 1. This means, that we can set a bit to 1 with this.
~(1 << PD2): The tilde ~ takes the inversion of the data. Alike above, the value inside the paranthesis can be written as binary value 0b00000100. The inversion will flip all bits to the other value: 0b11111011
DDRD &= ~(1 << PD2): The abbreviation is similar to the above. The bitwise AND operator & will also unite the bits of the values around it, but it will only set the resulting bits to 1, if both of the corresponding bits of the values are also set. Here this results in the third bit (the one for D2) being cleared to zero. All other bits (where you can see a 1 at the right value) are left untouched.
PIND & (1 << PD2): This is similar to the above, but now we don't have an inversion. We are doing PIND & 0b00000100 here. All bits of the result will be set to zero, except for the bit for D2. It will only be zero, if the corresponding bit was zero in PIND. Thus we have isolated the needed bit by this way.

You can also combine the same operations on a single register. Let's say we want to set both D2 and D3 as output. Then we can either write this as two seperate statements

DDRD |= (1 << PD2);
DDRD |= (1 << PD3);

or we can combine them into one statement by connecting them with the bitwise OR

DDRD |= (1 << PD2) | (1 << PD3);

The Arduino documentation also provides a site to explain direct port manipulation. Also again you should take the time to look into the datasheet of your used microcontroller. At first it will seems very difficult, but doing these direct port manipulations is a great way of learning how to use the SFRs, and then you can do all sorts of cool stuff with your microcontroller. So it really is worth it. You don't need to read or understand the whole datasheet at once.

  How can I modify the LeftMotor method to achieve the same result without using digitalWrite?

After all this text now to the specific question. On the Nano pin 9 and 10 are PB1 and PB2. You used a conditional inside your digitalWrite() statement, which I will replace by a complete if statement here. So you can use

if(direction == Forward){
    PORTB &= ~(1 << PB1);
    PORTB |= (1 << PB2);
} else {
    PORTB |= (1 << PB1);
    PORTB &= ~(1 << PB2);
}

instead of your two digitalWrite() statements.


Possible to have different torque levels on MG966R servo with Rotary Potentiometer?

Generally it is not easy to control the torque of a standard servo, since mostly they aren't meant for that. A servo has an internal controller, which will read the input PWM signal and control the geared motor, so that the desired position will be reached. And to get there, the most servos will use the maximum torque. Also the torque of a servo motor depends on more variables, for example speed and type of load (See here for more information about this.

  I read that by adjusting the input voltage, you can run the servo at different speed

That's not really true. Most servos only support a rather small voltage range, where they will work. You can get more torque, if you use a higher voltage, but it is not a simple linear relationship, since the torque depends on way more variables. One way may be to always drive the servo to it's current maximum torque and change this maximum torque by changing the input voltage inside the working range. Though this might not get you 4 torque levels, that are different enough for you.

  Also wondering if changing angle stepsize of MG966R servo will affect torque in anyway?

It is unclear, what exactly you mean by "stepsize" here. If you mean to control the speed of the servo: Yes, it will affect the torque, but not in a linear way. And this greatly depends on the load, that you apply.

In the answer to this question, sensing the current of the servo is suggested as a measurement of (applied) torque. If you use a feedback loop with this, you might be able to control the (applied) torque. I haven't done this kind of thing, so I'm not sure, if this can really work.

That said, you should again think about wether a normal servo is really the best way to go here, since it controls electronics, that you don't control yourself. For example you may use a geared DC motor, which you can directly control without any other electronics getting in your way.


Compilation Error - Yellow LED blinking as I have installed & connected Arduino UNO board to Windows XP PC

The yellow LED may be flashing because there may be a "Blink" LED program pre-installed on the Arduino.

To diagnose the "Error compiling for board Arduino Uno", we need to see the sketch you are trying to upload, and detailed error messages. If you go to Arduino > Preferences, check the "compilation" and "upload" checkboxes beside Show verbose output during:. Display line numbers is another checkbox you could enable.


Which Arduino Board should I start with?

My advice:
 - get a model with USB port (some do not have one)
 - the DUE might seem attractive, but you have less libraries available and less examples, I'd recommend it more as follow up
 - you will get frustrated if you do not know how to code, at least a bit, so if you have not programmed before, you might want to spend some time trying simple stuff just with your PC
 - same about electronics: if you do not have previous experience, it might be preferable to play a bit with a breadboard and some components (LEDs, resistors, switches, etc.); this will reduce the likelyhood that you fry your Arduino. Remember to buy some cables MM/MF/FF, you will end up needing all of them, sooner or later. For powering the board, you can find nice power supplies that cn be powered by a USB cable.

I have bought UNOR3 clones at $4-$5 on ebay, so if you can afford it, I'd suggest you buy a couple, that will enable you playing with I2C master slave and similar configurations.


Displayng 2 error messages on a 16x02 display

I think before the disconnection is detected, it goes into overheating (maybe just for some milliseconds).
However, because there is a while (true) loop within the overheating part, it will never show the NO TC CONN error.
If you consider the NO TC CONN error to be higher than the OVERHEATING error, than check within the while loop of the OVERHEATING error also for the NO TC CONN error and display NO TC CONN when it is detected.


You may be able to fix this by taking some drastic action. Be aware this is somewhat advanced and will remove any boards you have installed via Boards Manager:

Click the link on the line following File > Preferences > More preferences can be edited directly in the file. This will open the Arduino15 (or similar name depending on OS) folder.
Delete all files and folders under the Arduino15 folder except for preferences.txt. Please be very careful when deleting things from your computer. When in doubt, back up!
Restart the Arduino IDE.
Verify you can now upload before re-installing any boards via Boards Manager.


Or you may exchange the whole controller with a power mosfet module connected to your arduino. And use pwm directly from your arduino.
http://store.arduino.cc/product/T010020


Found my error... on the ProMicro, the pins are not arranged 0, 1, 2, 3, 4, 5 etc instead they arranged 1, 0, 2, 3, 4, 5 etc... On the board I misread TXO and RXI as TX0 and RX1 and just didn't notice it on my pinout sheet.... so I had D0 and D1 swapped. All works well now. Learning more everyday! I appreciate your time...


SPI is a multi-slave bus. Unless you've run out of free pins to use for CS, or you have slaves that don't play nice, you can connect your RFID module to the SPI bus as well. Also your sketch will most likely compile if you only correct the offending line to simply Wire.begin(). Your library uses the standard Wire library but assumes the target is an ESP8266, whose version of Wire has an extended begin() method.

But this may all be no use since the MFRC522 you have (assuming it's the cheap blue module) is hardwired to use only the SPI interface. Unless you're ready to modify the PCB (cut traces, etc) as others have done.


Adafruit Feather 32u4 Bluefruit LE and HC-05 Bluetooth module

HC-05 does not support BLE as far as I know but you can use a HM-10 if you can get your hands on one; Its almost about the same cost as a HC-05, maybe a little more;


The SIM7000 doesn't have a microphone or speaker pin.  Instead it provides a PCM interface to connect to an external CODEC chip.

As it says in the Hardware Design Manual:

  SIM7000 provides a PCM interface for external codec, which can be used in master mode with short sync and 16 bits linear format.

If you want to use it for phone calls then you will need a module that also incorporates said CODEC chip and all the associated circuitry to connect to a microphone and speaker.


Continous running light with fading trail

If you look at the surrounding methods, you'll see that 'fadeToBlackBy' will give a fading effect on anything you feed in. You'll want to locate method 'beatsin16' and then edit it yourself so that it doesn't bounce back but restarts the counter at the first LED. (hint: phase_offset)

You'll find the code snippet you want to copy in lib8tion.h

/// beatsin16 generates a 16-bit sine wave at a given BPM,
///           that oscillates within a given range.
LIB8STATIC uint16_t beatsin16( accum88 beats_per_minute, uint16_t lowest = 0, uint16_t highest = 65535,
                               uint32_t timebase = 0, uint16_t phase_offset = 0)
{
    uint16_t beat = beat16( beats_per_minute, timebase);
    uint16_t beatsin = (sin16( beat + phase_offset) + 32768);
    uint16_t rangewidth = highest - lowest;
    uint16_t scaledbeat = scale16( beatsin, rangewidth);
    uint16_t result = lowest + scaledbeat;
    return result;
}


AVR307 describes implementation of a half duplex UART implementation using the USI. Note that full duplex is not possible due to the synchronous design of the USI.


How can Arduino control with a servo with only one wire?

The return signal is probably the other wire's servo. This only works when the control pulses to both servos are not in sync. Pull one signal wire off the breadboard and both servos will stop working.

You need to interconnect grounds or you will get strange effects sooner or later.


Teensy 3.1 no overclock option for 168 MHz

Using the latest Teensyduino distribution as of this writing, 1.25, you have to uncomment the higher overclocking options in the boards.txt file, located here in my install-
/hardware/teensy/avr/boards.txt

The options look like this, just remove the # symbol-

#uncomment these if you want to try faster overclocking
#teensy31.menu.speed.168opt=168 MHz optimized (overclock)
#teensy31.menu.speed.144opt=144 MHz optimized (overclock)
#teensy31.menu.speed.120opt=120 MHz optimized (overclock)`


How can I write an integer to a Mifare RFID card using the RFID library?

The dataBlock[] variable is an array of bytes. One byte can represent an integer ranging from -128 to 127, or a positive integer ranging from 0 to 255. If your integer value will always be in one of those ranges, then you can just put your integer in the first element of the array and zero out the remaining.

byte dataBlock[]    = {
    0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00
};

(That saves a value of 1 to the first element, and zeros to the rest. If you want to change the first element:

dataBlock[0] = yourValue;

If your integer is a 2-byte integer, as is typically found in Arduino with type int, you need to split your value into the high byte and low byte:

dataBlock[0] = (byte)(yourValue & 0xFF); // Low byte
dataBlock[1] = (byte)(yourValue >> 8);   // High byte

Then you write the data block as per the example. To get your 2-byte integer value back:

yourValue = ((int)dataBlock[1])<<8 | dataBlock[0];  // Shift high byte, OR with low byte.


Serial.begin(9600) doesn't actually print anything. For that you'd want to use Serial.print("Hello world!") to print the text "Hello world!" to the serial console. Rather it initializes the serial connection at 9600 bits per second.

Both sides of the serial connection (i.e. the Arduino and your computer) need to be set to use the same speed serial connection in order to get any sort of intelligible data. If there's a mismatch between what the two systems think the speed is then the data will be garbled.

9600 bits per second is the default for the Arduino, and is perfectly adequate for the majority of users, but you could change it to other speeds: Serial.begin(57600) would set the Arduino to transmit at 57600 bits per second. You'd need to set whatever software you're using on your computer (like the Arduino IDE's serial monitor) to the same speed in order to see the data being sent.


how to use arduino to detect an 8Mhz ultrasonic pulse using piezo disc as receiver?

In a word: no.

Let's crunch some numbers...  You want detail like an oscilloscope.  Okay...

My scope is 50MHz bandwidth and runs at 1 giga samples per second.

Drop that down to 8MHz with the same kind of resolution, and you get (1,000,000,000 * (8/50)) = 160,000,000 samples per second.

That's 10 times more samples per second that the clock speed of the Arduino, and it takes at least 1664 clock cycles to take one sample.

So, no.  You need a board with an ADC which can run in the hundreds of millions of samples per second. The Arduino can only run at just under 10 thousand samples per second.

A slight discrepancy.

Even the Arduino Due can only get as good as 1Msps. I have seen MCUs with 15Msps theoretical maximum, but for the kind of output you want you would need considerably more.

So no, there won't be a cheap development "Arduino-like" board around that will do what you want. There may be an expensive one with a very fast CPU, DSP, ultra-high-speed ADC, etc, but you won't be programming it with Arduino, and you most likely won't be able to afford it to just play with.


Maybe a Windows driver problem.
Do your uno and nano use a ch340? (It is the component translating USB to uart (serial pins of atmega328).
Windows has no software way to differenciate boards using this component. It is a common use on cheap clones to lower price.
Official arduinos use a second atmega (atmega16u2 natively supporting usb) instead of the ch340. Allowing windows to identify the arduino model.

You should try to update your ch340 driver as you have the same problem with the 2 boards. here is the download page of the manufacturer (ch341ser.exe is the package you want)

You can also try to connect your board to an usb2 port as some problems (and solutions to try) are posted here (arduino forum)
And even try to use an usb2 hub...


BLDC geared motor with encoder - How to wire the encoder? (6 wires)

This should be in the documentation of the motor or encoder, and that is the first place to look.
If you don't have any documentation, here is my best guess:
ABZ suggests it is an incremental encoder with channel A and B for quadrature encoding (giving direction and speed), with Z as the index pulse for getting absolute position once every rotation. FG is most probably Frame Ground, or maybe be the Fault signal.
How you wire it all depends on what you want to do with it, but knowing what each signal is should make it easy enough.


I suppose "at desktop readings" means you have your sensor resting on the desktop so you where looking for a constant output value over the time. Well, there are some mechanical limitations about gyroscope's accuracy, resolution and external factor like temperature that make noisy or non-sense readings.

What you are obtaining from this library is a calculated orientation that carries or accumulate an error over time. Basically there is not a perfect algorithm to calculate orientation as at MEM's scale electrons still moving due to temperature and other radiations.

Solution depends on your application scenario: if your sensor will be most the time quite, maybe just mathematical compensate with inverted slope (about 4-5 degrees per minute) and look for more rapid changes to determine movement. If your application will be on constant move maybe it is not required any compensation. Trade off must be considered if both scenarios will take place on your application. Anyway, reading measures on your actual application will give you more clue on how to handle this.

Below the L3GD20's mechanical characteristics


Is it possible to make an arbitrary lake bottom generator?

A common method of generating realistic-ish 3d terrain is as follows:

Start with a square (as seen top-down), described by the lengths of it's side (all the same), and the height of each of the corners.

Divide each edge in half; for example, add a new point halfway between the north-west point and the north-east point; it's altitude will be the average of the altitude of the two existing points, plus or minus a random number.

Now add a point in the center of the existing square; it's altitude being the average of the north, east, west and south points you've just created, plus or minus a random number.

You now have 4 smaller squares. Repeat this process on the four smaller squares, then the smaller squares within that, and so forth.

You might want to manually do the first few points, tweaking it to get the shape you want, then leave the details to the algorithm. Your random number for the adjustments of the "middle point" heights should be proportionate to the length of the sides; for example, the random altitude adjustment might be a random number up to X% the length; then subtract half of X% of the length. Adjusting X% will give you an area that is more or less "pointy".


Using multiple RTC libraries in one program

can I load several RTC libraries into my code and then use the functions I like from each one?

It will depend on the libraries. Most likely they had some persistent variables, global to the routines, that help information exchange. If only some of the routines are used and others not, values in those variables may not be consistent.

  Will there be some conflict

That will depend on the way those libraries are implemented. No way of telling without seeing the code.

The point of doing this is a little bit suspect. It is not clear to me why you would want to have more than 1 RTC in an environment. If you are thinking about giving your program the option to function with multiple RTCs (but using one RTC at any given time), you can use either macro (at compile time) or wrap the RTCs in a logic layer (at run time).

For example, you can have a rtc_init() to reset different RTCs; and rtc_read() to return the time from the rtc. rtc_read() can be implemented based on which RTC is detected during initialization...


2 Arduino controller boards - 1 shared input

You don't need to add anymore components to your schematic. But you can leave some components.

Before you're adding a button to your schematic please consider first how you want to detect your signal. A logic 1 as if a button is pressed? Or logic 0 as if a button is pressed. You can do this using pull-up and pull-down resistors. These resistors should be wired like this.

(The 100Ohm resistor in an internal resistor from the MCU)

Using the pull-down resistor means that when the button is pressed you'd get a logic 1.
Using pull-up resistors means that when the button is pressed you'd get a logic 0.

When I see your schematic it seems like you're trying to make a pushbutton with pull-down resistor. Then you should wire your arduino like this.

Another option is to use the Arduino internal pull-up resistors. That way you don't have to add the 10k resistor in your schematic. And your schematic will look like this.

To use the internal pull-up resistors from the Arduino you'll need to put this in your setup(): pinMode(pin, INPUT_PULLUP); where pin should be your pin number. Please keep in mind that when you use the internal pull-up resistor a logic 0 means the button is pressed.


Is there any way to use the serial port as an interruption source?

Use millis() for the timing of the temperature reading, then you can read from the serial in between time and won't need to use any interrupts.

unsigned long last_measure = 0;

const byte buffer_size = 16;
char buffer[buffer_size] = "";
byte buffer_i = 0;

// setup() and other stuff

void loop() {
    if (millis() - last_measure > 10000) { // read the temperature like in the "blink without delay" example
        last_measure = millis();
        int value = readSensor();
        Serial.println(value);
    }
    while (Serial.available()) {
        char c = Serial.read();
        if (c == '\n') { // end of line, which means we got the whole string
            if (strcmp(buffer, "magic") == 0) { // compare if it matches the magic word
                int value = readSensor(); // read and print the temperature
                Serial.println(value);
            }
            buffer_i = 0; // reset the index
            buffer[buffer_i] = 0;
        }
        else if (buffer_i < buffer_size-1) { // if the buffer is not full
            buffer[buffer_i++] = c; // add char to buffer
            buffer[buffer_i] = 0; // and null terminate the string
        }
    }
}


Try using analogWrite().

Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite()) on the same pin. The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz.

Source: https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/


Thermostats would save the set point to eeprom once when the set point it set by the user. On startup it would just read the set point.

The analogue pins measure relative to VCC. So if you short the analogue pint to VCC the result will remain at max even as the voltage drops.

Instead use a diode to separate the measurement point from the power supply.

simulate this circuit – Schematic created using CircuitLab

As long as power is supplied the gpio input will be high. As soon as the power is removed the gpio pin will be low and the capacitor will need hold enough charge to save the position.

However what would happen if the positioner is manipulated when the arduino is off? Most devices have a callibration routine using end-of-travel detection or something similar they run on startup to find the home position.


Controlling a NC connection from two sources?

Are you certain that your existing circuit is NC?

The typical garage door opener button is a momentary switch. Many third party remote devices, including two that I have installed, tap directly into this circuit. Because the contacts short across the existing switch, activating one, two or three is insignificant. These switches are connected in parallel.

It would be a good idea to use an external isolation circuit to the Arduino, either a relay or SSR in order to ensure that there is no "injected" power from your circuit to the garage door circuit.

If your circuit is indeed an NC type, you would connect your new relay or SSR in series, using the device's NC connections. The locations for tapping into the circuit would be where your existing button resides or where those two wires engage your garage door mechanism.

I suppose my older garage door opener is NO, while newer models would use a different architecture, aka NC.


View Arduino Serial Monitor window after it has been minimised on Mac Big Sur

The app does not have the normal Window top option, but you can use the keys CMD + '`' to cycle through the windows.


How to acheive fast and reliable communication between NodeMCUs?

WiFiClient object wraps a TCP socket. A normal TCP socket is connected to IP address and port. WiFiServer starts a listening socket on a port. If server on listening socket is contacted by a remote client socket, it creates a local socket connected with the remote client socket on a free port and returns a WiFiClient object wrapping the socket. Everything you write or print to a WiFiClient is send to that one remote socket.

If one of your client boards creates a WiFiClient and connects it to IP address and port of the WiFiServer on your 'server' board, then you get there a WiFiClient from server.available() and this two WiFiClient objects are connected. What you write/print on one side you read from the WiFiClient object on the other side.

client socket

if (client.connect(serverIP, PORT)) {
  client.print("request\n");
  String response = client.readStringUntil('\n');
  Serial.println(response);
  client.stop();
}

server side

WiFiClient client = server.available();
if (client && client.connected()) {
  String request = client.readStringUntil('\n');
  Serial.println(request);
  client.print("response\n");
  client.stop();
}


You can reduce the current by simply reducing the duty cycle. For example, to display red, rather than sending 255 as the red component, send 42.

If you divide each of the R/G/B values by the same figure you get the same colour, just duller. In a quick test I found that a 24-pixel strip only used 67 mA if I sent red=0, green=0, blue=42 which made them look a dull blue. If you send a value of 8 (in a single channel) then it takes 25 mA for 24 pixels.

A bit more testing reveals a base consumption of 21 mA even if you are sending black. That is, the overhead is 21 mA, which works out at about 1.1 mA per neoPixel.

Based on that, you would consume 335 mA to make 120 NeoPixels show a moderately bright red.

I don't think there is going to be some "magic bullet" that lets you light up 120 LEDs brightly, but not use much power. However using the NeoPixels which lets you have fine control over the brightness of each of the R/G/B pixels is probably going to be about as close as you can get.

The figure of 50 mA which you quoted is to have "full brightness" on all three colours (ie. bright white).


Digital pins are no longer outputting enough to click a relay

Not knowing the reference of your relay, my answer is generic but should suit your needs.
Relays need 2 things in order to work properly: a sufficient voltage source, and one that can provide enough current.
The Arduino output pins provide 5V on 5V boards or 3.3V on 3.3V boards. BUT, most Arduino GPIO can provide only 20 mA of current. That might not be enough for your relay. The solution here is to use a transistor to drive the relay.
Also, relay coils are inductive loads that generate voltage spikes when current is turned off. That voltage can rise much higher than 5V and damage your Arduino pins and weaken or destroy them. The solution to this problem is to add a flyback diode.
This is what a typical circuit with relay driven by an Arduino looks like:

When the Arduino pin is LOW, the transistor is turned off and no current goes through the relay.
When the Arduino pin turned ON, the transistor turns on fully saturated and the relay coil is energized.
When the Arduino pin is turned LOW, the coil generates a negative voltage and current is allowed to go through the diode, dissipating energy in the relay coil. More information on flyback diodes: https://en.wikipedia.org/wiki/Flyback_diode


In fact, there would be nothing to do now I guess, as TinyWireM is now included tiny boards packages.

If you just include Wire as usual, it should work as on an UNO.
Except for setting a different clock, if I remember well, it is fixed to 400kHz.


digitalRead() function of Arduino doesn't read Input value sent by sensor after detecting the object

a == digitalRead(2) must be a = digitalRead(2). You also better change the if clause to if(a) to avoid true/HIGH/1 confusions.
If you had formatted the code properly, you'd have safed some time (you just need to select the code and press the {} button).
You also better replace the relay with a voltage divider (as I mentioned in my comment), because as long as you don't have a datasheet for the sensor you can't be sure that the sensor is designed to source that much current. If the sensor is supposed to drive a TTL logic, it will eventually fail, just like you don't drive relays with GPIOs directly. And beside that you need a freewheeling diode across the relay coil to deal with back EMF which will also harm the sensor.


is using two UARTs wiser compared to I2C and UART with Arduino + Xbee + BNO055 Sensor

All software serial solutions are much less efficient than HardwareSerial (i.e., Serial).  SoftwareSerial is particularly bad, because it disables interrupts for long periods of time.  95% of the MCU time can be spent twiddling its thumbs, waiting for each bit to come in.

Using the I2C interface for the BNO055 means that the Arduino hardware will independently and concurrently handle each byte of data from the BNO055 and from Serial (i.e., the XBee).  Your sketch can continue to do other things while each byte arrives.  This is most efficient.

Software serial port libraries handle each bit of data, sometimes to the exclusion of all other activity.


Can I get the arduino to run ESP8266 code?

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

There are two ways of working with an ESP8266:

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

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

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

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


SoftwareSerial runs out of "text" space on ATtiny

Your sketch doesn't fit into program memory of the ATtiny. If you comment out the println of the array, the compiler evaluates that the array is not used and doesn't attach it to the program. Then the program fits into memory.

EDIT
Chad suggests some good alternatives below, if you need to store more data than flash or PROGMEM will allow.


Rfid reader and SD card shield won't work together

SD cards (or really their breakout boards) don't tend to obey the rules with regards to SPI. In particular the MISO pin isn't set to high impedance when the slave select is not selected.

You can fix this with a tri-state buffer that you feed the SD card's miso line to and controlled by the slave select. The output from the buffer goes to the arduino's MISO.


That quote you mention says it all really.  It's purpose is to discharge the Sample And Hold capacitor.

That capacitor is used (as I'm sure you are aware) to store the incoming voltage while it's being sampled by the ADC.  The ADC operated in two main phases:

Acquisition
Sampling

During acquisition the capacitor is connected to the incoming voltage.  During sampling it is disconnected from the incoming voltage and the voltage it stores is read into the internal registers.

It takes a certain amount of time for the voltage in the capacitor to equal that of the incoming voltage.    If you try reading at higher speeds then what voltage was in the capacitor from the previous sample can affect the new reading.  However, if you do each sample always from a known voltage in the capacitor (0V) then you get much more stable results.

Another good use for it is when using the ADC as a Charge Time Measurement Unit.  This is the proper way of performing capacitative sensing.  You apply a constant (tiny) current to an external capacitor (the sensing plates) for a specific period of time.  When that time is up you disconnect the constant current source and measure the voltage that has developed across that capacitance.  The capacitances and currents are small, and if there is a charge in your S&H capacitor at the time you do the sampling that will be back-fed into the touch sensor capacitative plates changing the voltage.  By ensuring that the S&H capacitor is at 0V before you sample the plates you won't be adversely affecting the voltage on the plates with successive readings (well, you will, but it will be consistently in the same way every time so it won't affect your overall results).


If you have a byte variable b, you can

write(b) it as it is. if it is ASCII code of a readable character, the Serial Monitor will display it as that character, for example for 65 it will printt 'A'
print it as decimal number with print(b). for 65 it will print "65"
print it as hexadecimal number with print(b, HEX). for 65 it will print "41"
print it as a number in other base with print(b, base), for example print(b, 2) will print 1000001 if b is 65 in decimal


Connect GPS module (WeeBee) to Arduino Uno

The article on the Arduino website means that you can't upload sketches from your PC to the Arduino or receive any sort of data, through the serial monitor or otherwise, from your PC, while the GPS module uses the RX pin. Any attempt to send data from PC to Uno in this condition would cause the Arduino to receive only corrupted data, since 2 devices (GPS module and PC) would be trying to send data at the same time, with the same line. This limitation is easily resolved by connecting the GPS module to a SoftwareSerial port instead; this keeps the HardwareSerial port (pins 0 & 1) free for bidirectional PC-Arduino communication.
The datasheet says that the maximum power supply voltage is 5 V. However, the serial connections are 3.3 V logic, so yes, you will need logic level shifters. A simple voltage divider will serve. However, 'external decoupling' refers to circuitry used in decoupling/smoothing out any spikes or dips that may occur in the supply voltage. An untamed spike could damage the device, while a dip (perhaps from large current draw) could cause the device to stop working, if the voltage falls low enough to be considered under-voltage. A 10uF electrolytic capacitor, connected from Vcc to GND close to the GPS module, should be okay.


How to drive a strip of 12 V no-addressable LEDs?

EDIT: I'm sorry, I misunderstood! I assumed your LEDs were the 4pin serial version, whereas it makes more sense to me that they are the 6pin analog version. I must've brushed over the part where you said you grounded the colored wires and got that corresponding color.

You will provide 12V to the Power wire. To light the strip Red, you'd ground the Red wire, ground Blue for Blue, etc. Ground Red and Blue to light Purple, mixing colors etc etc.

So what if you wanted teal? or maybe a different shade of green? You'll need a way to generate PWM on the R, G, and B pins. Basically if you have an 80% duty cycle on Blue, that means it's only grounded 80% of the time. This corresponds to 80% brightness of the blue LEDs, then you could mix that with say 60% red and 10% green, or whatever you wanted to get a full 16 million colors. This is most easily accomplished with a microcontroller, and so I'll provide schematic and code tips for the simplest solution: an Arduino.

Schematic

simulate this circuit – Schematic created using CircuitLab

I chose Pins 9, 10, and 11 of the Arduino because they are all PWM; you can choose any PWM pins you want (denoted by ~ or # usually). Just reflect those changes in the sketch.

Arduino pins are also only capable of sinking about 40mA if I remember correctly, so you'll need to control some MOSFETs with the PWM. I find you can't go wrong with the IRFZ44N, but that's just what I've had available to me.

Arduino Sketch

How you control it is up to you; sensors, potentiometers, networked, bluetooth, constant fade pattern, there's a slew of options. So this code will tell you the necessary functions, but from there it's a matter of programming and integration of whatever else you want.

void setup(){
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop(){
  //255 -> 100%   ;   0 -> 0%
  analogWrite(9, 255); // turn red to 100%
  analogWrite(10, 0); // turn green to 0%
  analogWrite(11, 128); // turn blue to 50%
}

If this doesn't work, please let me know and I'll fix it. I forget if analogWrite is okay with being called in a simple, unrestrained loop over and over, and I also forget if Arduino pins have internal pull-downs


WiFiClient object wraps a TCP socket. A normal TCP socket is connected to IP address and port. WiFiServer starts a listening socket on a port. If server on listening socket is contacted by a remote client socket, it creates a local socket connected with the remote client socket on a free port and returns a WiFiClient object wrapping the socket. Everything you write or print to a WiFiClient is send to that one remote socket.

If one of your client boards creates a WiFiClient and connects it to IP address and port of the WiFiServer on your 'server' board, then you get there a WiFiClient from server.available() and this two WiFiClient objects are connected. What you write/print on one side you read only from the WiFiClient object on the other side.

client socket

if (client.connect(serverIP, PORT)) {
  client.print("request\n");
  String response = client.readStringUntil('\n');
  Serial.println(response);
  client.stop();
}

server side

WiFiClient client = server.available();
if (client && client.connected()) {
  String request = client.readStringUntil('\n');
  Serial.println(request);
  client.print("response\n");
  client.stop();
}


It's perfectly doable. As Chris Stratton puts it, it's all about
implementing non-blocking serial communication:

whenever you receive a character, you store it in a buffer
whenever you have a complete command in the buffer, you process it and
reset the buffer

For a line-oriented protocol, it may look something like:

/* Process incoming characters if any. */
while (Serial.available()) {
    static char buffer[BUF_LENGTH];  // incoming command
    static int length = 0;           // command length

    int data = Serial.read();
    if (data == '\r') {              // complete command
        buffer[length] = '\0';       // terminate the string
        if (length)
            exec_command(buffer);    // process
        length = 0;                  // reset buffer
    }
    else if (length < BUF_LENGTH - 1)
        buffer[length++] = data;     // buffer incoming character
}

For a more complete example, you may want to take a look at this simple
Arduino command line interpreter. You connect a terminal
emulator to the Arduino at 9600/8N1, type the "help" command and it
displays:

mode <pin> <mode>: pinMode()
read <pin>: digitalRead()
aread <pin>: analogRead()
write <pin> <value>: digitalWrite()
awrite <pin> <value>: analogWrite()
echo <value>: set echo off (0) or on (1)

You can use it as a template, replace existing commands or add new ones
(the interpreter is just a long if ... else if ...) and – since
it's all non-blocking – add whatever you want to loop().


What alternatives are there to the Optiboot bootloader?

Optiboot is about the smallest bootloader available.

But, there is a much more powerful (with inbuilt console for hardware testing, RAM and Flash contents checking, etc) bootloader with a more developed and robust stk500v2 communications protocol between avrdude and the AVR bootloader.

I've used it on the ATmega2560 and on the ATmega1284p. It works for both 3 byte and 2 byte program counter MCU.

I have a STK500v2 Bootloader version on Sourceforge.

This bootloader is based the Peter Fleury STK500v2 bootloader, updated by Mark Sproul. I've made edits to have it supporting with the Goldilocks (an ATmega1284p) board.

The key feature is to use the STK500v2 protocol for uploading the Flash image to the Arduino. This protocol is more robust and gives better error capabilities than the avr109 protocol. As an aside the avr109 protocol is called "Arduino" in the Arduino world, because it toggles DTR (to reset the board and automatically enter the bootloader), and the STK500v2 protocol is called "Wiring" in the Arduino world, because of the same reason.

The Fleury/Sproul STK500v2 bootloader is designed to work with the ATmega2560 which has a 3 byte program register, because of the larger Flash size. But, it also supports normal 2 byte boards (everything else really).

For boards with plenty of Flash (like Goldilocks 1284p), there is a hardware monitor that can be used to query Flash, SRAM and hardware; you can check connections without additional code, and check the actual contents of Flash and EEPROM. Because the 1284p supports 2 USART, I added the ability to have debugging on USART1, so that the upload process via USART0 isn't disturbed.


IEEE 754 is the specification for floating point values. Integers aren't floating point values so this function of yours can have nothing to do with integers.

On an Arduino (8-bit):

A float value is 4 bytes in IEEE-754 format.
A long value is 4 bytes in little-endian format.
An int value is 2 bytes in little-endian format.
A byte is a byte.

To convert 4 bytes into a long you can use:

long val = (payload[3] << 24) | (payload[2] << 16) | (payload[1] << 8) | payload[0];

An int value is just the lower two bytes of the same kind of conversion:

int val = (payload[1] << 8) | payload[0];

You can use the same method (albeit backwards) to get the bytes to put in your payload:

long val = 12345678L
payload[0] = val & 0xFF;
payload[1] = (val >> 8) & 0xFF;
payload[2] = (val >> 16) & 0xFF;
payload[3] = (val >> 24) & 0xFF;

You can also use the same technique as your existing function with different datatypes, since all you care about is the byte content not the format or meaning of the bits within it:

void int2payload( int val, int pos) {
  byte* array = (byte*) &val;
  for (int i = 0 ; i < 2 ; i++) {
      payload[pos + i] = array[i];
  }
}

void long2payload( long val, int pos) {
  byte* array = (byte*) &val;
  for (int i = 0 ; i < 4 ; i++) {
      payload[pos + i] = array[i];
  }
}


I cannot find the I2C device by scanning

I'm not sure on your program, but I bought a LCD display from Deal Extreme. I use the following address to communicate with the display:

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27

It seems as that is the correct address for the LCD.


No.  On Arduino-style boards which use distinct chips for the main processor (ATmega328p) and Serial interface (CH34x/ATmega8u2/ATmega16u2/FT2232 etc) the presence or absence of a bootloader on the main processor has no bearing on the recognition of a USB/Virtual Serial device by a host.

However on ATmega32u4 and some ARM-based boards it can.

Since you are describing a classic board with distinct chips, whatever your actual issue is, it is something else.


Controlling a digital 12V addressable RGB led strip with Arduino?

The only signal you need to worry about is DIN (data in) which is normally 5V from an Arduino. Use that to switch a MOSFET or transistor to convert the digital pulses to 12V. In other words, the Arduino switches the transistor, the transistor outputs 0 or 12 V.

Judging by this link you still just send 5V digital switching to the strip.

  The data signal never needs to be 12 volts. The 12 volt pixels all drop the voltage down to about 5 volts to operate the chip. Usually just a resistor and a zener diode, sometimes just a resistor.

In other words, connect the "power" pin to +12V, and the ground pin to Gnd from your power supply.

Connect the Din (data in) to your Arduino pin directly. Of course, also connect the Arduino ground to the ground pin.

Also see this Youtube video. On the comments he says:

  These 12v WS2811 "pixels" still use 5v signalling. You simply connect the 12v source power directly to the strip, tie the ground to the arduino and then treat them as if they were a 5v strip.


Your wiring sounds wrong.

Tie CHPD to Vcc (3.3v) to enable the device.

Tie GPIO0 to ground as you power up, to put it into programming mode.

RST can be left floating, or PULL (not tie!) up to Vcc through a resistor, say 10k.

That diode level shifter arrangement is unusual. A potential divider on the ESP's RxD is all you need - say 1k and 2k.


perform an action maximum x times per hour

Sure it's possible. It would be better if you had a real time clock module. Then you could use time-of-day.

You need to define your problem a little better. Would it be ok to run the sprinkler every 5 minutes, then not again for 40 minutes, for a total of 4 sprays in an hour, but clustered together? Do you want to prevent 4 sprays in a clock hour, or not go over an average of 4 sprays per hour?

Without a realtime clock module, I guess here's what I would do:

After a spray, record the time (in millis). Then in your loop, don't spray again for 15 minutes (15*1000*3600 milliseconds.)

The code would look something like this: (not real code, more like pseudocode)

const unsigned long fifteenMinutes = 15*1000*3600;
unsigned long nextSprayTime = 0;

loop()
{
  if (millis() >= nextSprayTime)
  {
    if (humidity < 50)
    {
      spray();
      nextSprayTime = millis() + fifteenMinutes;
    }
  }
}

Edit: You said, in comments:

  i want it not to go over 4 sprays an hour,i have the ds1307 rtc
  module. situation: ist an automatic egg incubator and the humidity
  must be between 50% and 60%.i control the sprayer whit a dht11 sensor
  an a servo connected to an spray bottle. if the humidity is below 50 %
  the servo starts whit spraying.the servo keeps on spraying every
  second until that 60% mark is reached and then shuts of.so the amount
  of water in the box is way to much and so the humidity keeps on
  climbing until the 100% mark whit is deadly for the eggs

Ok, that gives your readers a clearer picture.

You're dealing with a process control problem, not just a hardware or software problem.

When you spray water, it will likely take several minutes for the change in humidity to stabilize and be detected by your sensor.

Your current approach sounds wrong because you dump far too much water into the system, and don't give it time to reach a new equilibrium before adding more water.

You need to collect some data.

There is going to be a significant lag between putting a spray into the incubator and sensing the increase in humidity, and when the increase reaches it's max.

You need to measure that lag.

You also need to know how much a single spray increases the humidity.

You should probably **ALSO* figure out how many sprays at a time you can spray before water droplets form on the walls of your incubator and on your eggs, since I assume that is very bad and to be avoided at all costs. Thus I would add a moisture detector to your system (A small piece of cloth with electrodes on it at 2 locations a couple of CM apart, and a sensitive conductivity sensor that detects the change from insulator to weak conductor that takes place when the cloth becomes saturated with water.)

You should also figure out how fast the humidity in your incubator drops if you don't add any water, for a variety of different conditions. (Likely affected by current humidity, outside temp and outside relative humidity, so you probably want 2 humidity sensors, one inside and one outside the incubator, and to record all the variables and graph them.)

I would suggest writing a data collection program. You might want to run it with the serial cable connected to a PC constantly, or install an SD card and save your data there.

In all your tests, you probably want to wait a significant time (15 minutes? 1/2 hour? 1 hour?) for the incubator to reach equilibrium before beginning your test.

You want the conditions of your incubator to be as close to your real-world conditions as possible. You might want to put eggs (dummy eggs, grocery store eggs at room temp, or something like that) in the incubator during the test to allow for the amount of water they absorb. You want the outside temp to be as close to your real-world temp as possible. If the incubator will be exposed to direct sunlight, air vents, wind, etc, then you want those same conditions.

At each step in every test you should record the current time, the current outside temp and humidity, and the current incubator temp and humidity, and the time of each spray you trigger.

Add your condensation detector at the beginning, and any time it detects condensation you should sound an alarm, record the time that it trips, and abort the current test. If you get liquid condensation you've done something wrong and need to adjust.

Write a program for your computer that graphs all your data points over time. Every time you run a test (other than the very first test) graph all the data and look at it. Patterns will probably jump out at you.

Test 1:

Record the time and the current humidity. Add one spray of water, and then record the humidity for 15 minutes. Look for an increase in humidity and when it peaks. The time from adding a spray to the peak increase in humidity is what you want.

Test 2:

Then modify your program to log the spray-to-peak-humidity-increase time, and each time it detects the humidity starting to drop again, spray once more, log the current outside temp and humidity, the inside humidity and outside time of the spray, and repeat.

This will give you spray-to-peak-humitity lag times over a range of humidity values. Graph that data with starting relative humidity on the x axis and the lag time on the y axis and look at it. Is it a constant value? A straight line? Is it a geometric curve? Exponential? Come up with a curve that fits the data fairly well.

Test 3:

A test that uses an increasing number of sprays, looking for how many sprays you can do at once before you cause condensation.

Start with 2 sprays.

Look for the peak increase in humidity, and once the humidity starts to drop, increment your spray counter to 3, spray that many times, and repeat. When the condensation alarm trips, stop the test.

Note that the number of consecutive sprays you can do before the moisture alarm trips will probably change for different starting humidity levels. My guess is that the max number of sprays you can add without triggering condensation will be highest at your lowest humidity level, and as the humidity increases, you'll get condensation with less and less sprays.

Test 4:

Figure out how to measure the max number of sprays that trigger condensation when you start at less than your minimum humidity, at your minimum humidity, at halfway between min and max, and at max. (This experiment will take some thought since it's not easy to get to a given humidity level, and once you trigger condensation you'll have to stop, dry everything out, and start again.)

Test 5:

Get your incubator as close to the maximum acceptable humidity (60%) as you can at the beginning of the test, or even a little above. Simply record the humidity every minute until it drops to the lowest acceptable level (50%). Graph the data. That will show you how fast the humidity drops if you do nothing.

Test 6:

Repeat test 5 for the range of outside conditions you might find in your production environment. (If you're in a climate-controlled space, do you have summer and winter thermostat settings? Test for those upper and lower ranges. How much does your indoor humidity level vary?)

Now what?

Now you have lots and lots of data.

More than likely you have an idea of how many sprays you can add at a time without triggering condensation over your humidity range. This should be fairly simple: (for example, at humidity < 50% to 52%, you can use 3 sprays.  AT 53-55%, 2 sprays. Above 55%, 1 spray.) You should also have a rough idea how much increase you'll get in humidity for a given number of sprays.

You have an idea of how fast the humidity drops if you don't add water.

You have an idea how long it takes for a spray set of sprays to cause a peak in the humidity level.

Write a program that strives to keep the incubator in the middle of your desired range. If 50% is your absolute minimum humidity level and 60% is your max, then trigger sprays at 52%, not 50%. Spray as many sprays as you can without causing condensation (or overshooting your max humidity), then lock out sprays for the time period you calculated as the time it takes for your sprays to cause the maximum increase in humidity.

If you've found that the max number of sprays you can do at a time is different for different humidity levels, use code that comes up with a number of sprays that stays below that limit. Also try to estimate how much increase in humidity you get per spray, and each time you trigger a series of sprays, stay below the number of sprays that reaches your max humidity.

If you've found that the conditions outside the incubator have a big effect on your system, adjust your code to compensate for those changing conditions.

You want a system that uses small adjustments over time to keep a system at near equilibrium. Big adjustments will likely cause wild variations in conditions that go outside of the acceptable range.

Other considerations:

Do you need to open the incubator at regular intervals to check on the eggs or turn them, or do you have an egg turner? If you do need to open the incubator, you will need to figure out the effect this has on your temp and humidity levels for the range of outside conditions you face. You can probably build your system with a door sensor that detects you opening the door, the outside temp and humidity, and how long the door is open. Once you close the door, it would note the new inside temp and humidity and make an educated guess as to how much the humidity will drop after being open, and add water accordingly.


Is this method to a String from a function going to cause memory corruption?

You are better off passing the string by reference, like this:

bool getStringOrTimeout(String & s)
{
  if (timed_out)
    return false;
  s = "foo";
  return true;

}

That means the caller's string will be modified. And you no longer need to pass down a pointer to a string.


Grounding Arduino UNO with external voltage source

The circuit in the image shows the plan of the Arduino Uno, as you can see the GND pin under AREF and in the GND under the Power pin VCC are connected.
you can double-check this with a tester and figure it out.
so yes, they are internally connected.
now, in your breadboard you have connected GND to VIN, that's the problem, Vin is an input voltage that is regulated to supply 3.3V and 5V.

So remember to share grounds with external voltage supplies (DC-DC), that set the circuit to the same reference.


Note, you haven't specified, which Arduino you are using. I'm assuming a Atmega328p based Arduino (Uno, Nano, Mini) here, though the principle works with every AVR microcontroller, that has this hardware).
With analogWrite() are are not sending data bitwise out of a pin. It configures the hardware Timer for setting that pin at a specific frequency and with a specific duty cycle. So analogWrite() actives a totally different piece of hardware inside the microcontroller.
To do this without the Arduino function analogWrite(), you first need to decide, which way to go:

You can generate an interrupt through the hardware Timer and then set the wanted pin by software inside the ISR (which gives you free choice of the pin, but also introduces some jitter in the signal)
or you can let the hardware Timer itself toggle the pin, which does not involve any software for running (that means you can only use one of the 2 pins, that are associated with the corresponding Timer, but you will get a much more stable signal)

There are lots of tutorials on the web on how to do that. A search for "arduino timer register pwm" gave me some promising results, for example this one, where they explain, how to get PWM with the Timer1 registers and a free to choose frequency. (That is a 3 part series, one part for each Timer. Part 1 for Timer 0 is here, though you might want to keep Timer 0 as it is, so that functions like delay() and millis() still work as normal). There are also many such questions on this site, for example this one.
Another very important source for anything hardware related is the datasheet of the corresponding microcontroller. For the Uno, Nano or Mini that is the Atmega328p, which datasheet can be found on the microchip site here (or when googling for the microcontroller name)


Issue with Arduino car bot, the servo motor moves randomly also it turns hot pretty quickly

I think you need to do some rigorous testing of the individual functions of your bot.

Step 1: rename your loop function to "loop_temp" which means it won't run, but it will be retained for later.

Step 2: write a new "loop" function, which sets the LeftMotorForward for 1 second, then stop for 1 second.  And observe the results.

Step 3: repeat Step 2 with LeftMotorBackward, RightMotorForward, etc

Step 4: using serial print, experiment with the output from the sonar to make sure it's delivering the expected results.

Step 5: one at a time introduce your functions and ensure they are each working properly.

Step 6: hopefully you've discovered a bug/fault somewhere, and you can re-introduce your original "loop" function.  Otherwise that function may be the issue.

I've had a look at your code, but don't see anything obviously amiss.  So I'm afraid it may be a process of elimination.


Fade LED strip using proximity and map() function

The biggest problem is that by forcing the code to use integral inches you've restricted it to 31 discrete values. And since the brightness response of a PWMed LED is non-linear you effectively have very large steps in brightness when the LED is dim.

pulseIn() has much more flexibility with regards to its range so use the raw value directly instead of converting it to "pretty" values.

val = map(pulse, ..., ..., 0, 255);


I finally figured it out. Apparently, when I call Serial.read() and assign it to "int rc", It sort of converts the actual ASCII values into integer. So reading the number 3 from the Serial monitor and assigning it to rc stores 51 in rc. So the trick I found to that was to use
int rc = Serial.read()-'0'

That way, I am storing 51-48 which is, 3 (Since 48 is the ASCII value for 0).
Thanks.


ESP8266 does not respond after changing baud rate to 9600

This is a common issue. Using the AT+IPR command seems to brick the module. Try to re-flash your module, like you did the first time. If it works, use this command: AT+UART_DEF=9600,8,1,0,0 instead to change the baud rate.


When powered through USB there is a resettable polymeric ("poly") fuse. If you draw more than about 500mA this fuse will cut out and isolate the power.  When you remove the load the fuse will reset and allow power back to the board.

"Poly" fuses are in fact "Positive Temperature Coefficient" (PTC) thermistors. As they get hot their resistance increases (as opposed to the NTC thermistors you use for temperature sensing where the resistance decreases as they get hotter).  The current flowing through the PTC causes it to warm up. Too much current and it gets too hot, and the resistance gets too high (it's non-linear, so the resistance suddenly increases a lot).


Where can I find the code for Arduino's "attachInterrupt"?

It's in the core in WInterrupts.c

On my install it's at:

arduino-1.8.5/hardware/arduino/avr/cores/arduino/WInterrupts.c


Arduino slave with 2 masters sharing the same I2C Bus?

The situation you describe is called MultiMaster. It is normally done in hardware using the I2C peripheral in the MCU. However the ESP8266 doesn't have one (or if it does, it's not used), and uses bit-banging to implement I2C in software. If you can add MultiMaster functionality to the ESP8266's Wire library then possibly yes, you could do it.

Another option is to have some other communication channel between the two masters (it could be as simple as a wire with a pullup resistor - see below) so that only one master communicates at a time.

Electrically there is no problem with your setup - I2C is a fully open-drain system (or should be implemented as such - hence the pullup resistors needed on the SCL and SDA pins), so multiple devices can drive the lines at the same time. It's just that if they do you will get data corruption and communication won't happen.

Example: Semaphore Wire Implementation

Connect any two GPIO pins together with a wire. Add a pullup resistor to the wire (10kΩ should suffice).
Both GPIO pins are set to INPUT.

When a master wants to send it first reads the GPIO pin:

If it is HIGH then it is "clear to send". So it sets the GPIO to OUTPUT and pulls the line LOW.
If it is LOW then it waits for a random amount of time and tries again.

Once communication is finished the master sets the GPIO pin to INPUT again.


Not directly, no.  You have basically have 4 UARTs on the Mega2560 - one of them (USART0, pins 0&1) is connected to the USB interface chip, and the others are left unassigned for you to use as you like.  It's the USB interface chip that is being seen in your computer as /dev/ttyUSB0, not the UARTs in the Mega2560 chip.

That's not to say that what you are after is not possible - it is perfectly possible, but it will require some clever programming on your part.  You will need to:

Define a protocol that will multiplex 3 streams of serial data through the one USB serial connection
Write a sketch that works with that protocol to direct the incoming data to the right UART ports and multiplex the UART traffic into the protocol stream you have defined
Write software on your computer to perform a similar task - read in data and multiplex it, and read the multiplexed data stream and split it out to three separate destinations.

What the destinations on the PC end can be is a bit of a wooly area.  If you want to make it look like serial ports in /dev then you can use a pty pair, which is a master/slave pair of pseudo TTY devices that you can use to pass data through.  On most Linux systems they are numbered devices in /dev/pts, so /dev/pts/1 would be an example.

The function openpty(...) creates and opens a pty pair for you to use in your program.  You would do that 3 times to make three pairs and each one would be the endpoint to a sub-stream in your multiplexed data.

For instance, here is a bit of code I use to open a pty pair:

struct termios options;
openpty(&_masterfd, &_slavefd, _dev, NULL, NULL);
fcntl(_masterfd, F_SETFL, 0);
tcgetattr(_masterfd, &_savedOptions);
tcgetattr(_masterfd, &options);
cfmakeraw(&options);
options.c_cflag |= (CLOCAL | CREAD);
if (tcsetattr(_masterfd, TCSANOW, &options) != 0) {
    fprintf(stderr, "Can't set up PTY\n");
}

That makes it appear to almost be a serial connection in style.  Of course you don't have the concept of a baud rate over a pty connection, so it will be down to your software to define how you control the baud rate (probably easiest to have it hard coded to the baud rates you need).

In that snippet you talk internally to the _masterfd with normal read() and write() functions as you would any other device or file.  Some other piece of software would open the other end of the pty pair (the _slavefd), the name of which is placed in _dev when the pty pair are opened.  You could use that _dev name to then create a symbolic link to a better named device instead of using the /dev/pts/x name that could change without warning from one run to the next.


How do I convert a program made on Notepad to my Arduino on Proteus

Besides displaying source code and letting you edit it, the IDE uses avr-gcc (and half a dozen other avr- utilities, like avr-objcopy, avr-ar, avr-nm) to compile and link the code and convert it to an elf or hex form, then uses avrdude to download it.  Using proteus, you can get by without  avrdude, but not without a suitable compiler and linker.

If you have a micro-SD slot on your phone, perhaps you can download the IDE to a card and then move the card to your computer to install the IDE.


Print Byte Array in Serial monitor screen of Arduino IDE

You can’t print an array in that way.

If you want to print an array of hexadecimal value (with two digits), you have to use sprintf function and change declaration of b array.

uint8_t b[]= {0x7E, 0x00, 0x1C, 0x90, 0x00, 0x13, 0XA2, 0x00,
              0x41, 0x58, 0x1C, 0xCB, 0xFF, 0xFE, 0xC1, 0x7C,
              0x00, 0x0F, 0x00, 0x01, 0x00, 0x00, 0x37, 0x46,
              0x46, 0x46, 0x00, 0x00, 0x00, 0xE7};
int i;

void printHex(uint8_t num) {
  char hexCar[2];

  sprintf(hexCar, "%02X", num);
  Serial.print(hexCar);
}

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

void loop() {
  for(i=0; i<sizeof(b); i++){
    printHex(b[i]);
 }

 Serial.println();
 delay(500);
}

The output produced is:

  7E001C900013A20041581CCBFFFEC17C000F0001000037464646000000E7
  7E001C900013A20041581CCBFFFEC17C000F0001000037464646000000E7
  7E001C900013A20041581CCBFFFEC17C000F0001000037464646000000E7


How to change LDR output in simulator 123D Circuits?

Ok, so I found it myself. You can click on LDR during simulation and bar to adjust lighting appears above it.


If all you are interested in is the voltages on the D+ and D- lines you could wire those direct into two ADC inputs on the Arduino and wire +5V and GND into the +5V and GND pin.  The Arduino can then sample the voltages and compare them to valid or invalid ranges.


Increase PWM bit resolution on only one timer 2 output

As long as you don't use PWM (i.e. analogWrite) on pin 9, any changes made to timer1 won't affect pin 9.

It will change both outputs, as both use the same (single) timer.

But you can use code to convert a 8-bit PWM value to a 16-bit value by simply multiplying the 8-bit value by 256.


ESP8266 Aes encryption using Arduino IDE

I don't know whether this is the only problem, but the way you are building up the string is bad: you are appending the decimal value of each byte of the cipher - so if your cipher array were, say, { 0x52, 0x11, 0x115, 0x137, 0x255, 0x215, 0x40, 0x1, 0x20 .... } you'd get the string you're getting: 521111513725521540120...  That's probably not what you want.

Probably what you want for that part is to base64-encode cipher, which you can find out how to do, for example, here.  (If you see encrypted stuff in printable format, usually it's base64 encoded.)


The problem was indeed running out of memory (as suggested by Juraj). After finding smaller libraries I was able to get it to work together just fine.


Please see the comments in the code:

// SDMacAdress is zero terminated
// (it should be because you use strcp not strncp)
// char arr[12]; you need one extra byte for the zero
char arr[13];
strcpy(arr, SDMacAddress);

auto getNum = [](char c)
{
  // you forgot upercase HEX letters (A-F)
  // don't use sophisticated code
  // the best programmers produce understandable code IMHO at least ;-)
  // perhaps you copied it from the internet
  // return c > '9' ? c - 'a' + 10 : c - '0';

  if ( c >= '0' && c <= '9' ) return c - '0';
  if ( c >= 'a' && c <= 'f' ) return 10 + c - 'a';
  if ( c >= 'A' && c <= 'F' ) return 10 + c - 'A';

  return 0;
};

byte *ptr = ByteMacAddress;

for(char *idx = arr ; *idx ; ++idx, ++ptr )
{
  *ptr = (getNum( *idx++ ) << 4) + getNum( *idx );
}


I suggest a simple setup (similar to my temperature and humidity sensor but less complex).

You can run from 3 x AA batteries, and have an RTC clock to keep track of the time. You can use a MOSFET to turn on your analog clock when required.

The processor can be asleep most of the time, using the watchdog timer to wake up and check the time from the RTC. Don't use an Arduino "board" unless you are running from a wall-wart because the voltage regulator, USB interface, and power LED, will consume too much power.


why you should put your variables in flash memory instead of SRAM

Because the Arduino has only a very small amount of memory. If you have data that will never change it's better to store it in flash (of which there is much more) so as to leave the SRAM free for data that does change.

Also, I could not understand the definition of R"====()====", what is meant by this in arduino?

The R means "Treat everything between these delimiters as a raw string".  That is, everything between "=====( and )=====". It's not an Arduino thing, but a general C++ thing (see here). The ===== can be anything you like (within certain bounds) as long as it's the same at both the start and end of the string.  So you could use R"-=(This is "text")=-" which would assign the string This is "text". It's a great way of working with long strings that may want to contain " as otherwise you would have to escape each and every " as \". So the string I showed just now would otherwise have to be written as: "This is \"text\"", which can get very messy if there are lots of " in there.  The important thing to remember is that )===== mustn't appear in your text anywhere, so make sure it's something really obscure.


analogRead() inside a loop always returns 0

voltage[i]=analogRead(sensors_pin[i])*(5/1023)

Is equivalent to

voltage[i]= analogRead(sensors_pin[i])*0
          = 0;

You are using an integer division, not a floating point divsion. 5 / 1023 evaluates to 0, 5.0f / 1023 evalues to 0.00488... You have repeated this error throughout your lower loop code, which is why you're only getting 0.

In your outer loop you printed it as

Serial.println(analogRead(A5)*500/1023);

Which will first multiply by 500, then divide by 1023, which works. But since you put the above expression in parenthesis, it was first evaluated.


Solved by updating the Adafruit sdd1306 library and the Adafruit GFX library

EDIT: Why am I being downvoted?


Can I remove soldered atmega328P from arduino board, using hot air gun, without damaging it?

web search reveals the peak reflow temperature is 260°C

the chip will withstand that for 15 seconds or so

here is an example graph of a reflow oven temperature during the reflow process


Arduino Uno: external power supply +5V and serial communication with pc over USB

I have a similar rig using a 4-channel optically isolated relay, but I use different power supplies for the Arduino and for the relay. (It works perfectly.) My guess is that the relays are causing the voltage on your arduino to droop when they switch on. I suggest using separate power supplies.

As @Majenko suggests, you might try adding a filtering cap (capacitor) between +5V and ground very near the Arduino. The cap should slow the drop in voltage to the Arduino long enough for the power supply to recover, but separate power supplies is the surest fix.


Reset I2C connection with arduino as slave

You have a misconception about how I2C works. Unlike Serial (UART) I2C is a strictly master-slave interface. The slave cannot do anything without the master, since only the master controls the clock. Thus you don't need to reset the I2C interface to stop the transmission from the slave to the master.

When the master requests data from the slave the following happens: First the master sends the address of the targeted slave, including the direction bit set for "reading from slave". The slave with this address reacts with an acknowledgement (ACK) and start to transmit one byte. This byte get's acknowledged by the master. When the master decides, that it has received enough data, it does not acknowledge (NACK), which let's the slave stop it's transmission. Then the master sends a STOP condition to stop the I2C transmission.

I don't know, how you implemented the I2C communication on the Pi. Normally, when you initiate a read transaction from the master, you provide a number of bytes, that you want to request from the slave. The I2C module/library will then request data from the slave, until is has received all the requested bytes.

Thus you don't need to reset the I2C connection on the Arduino. The master totally controls the communication. When you end the transmission on the master, the slave cannot send further data.

Setting TWCR to zero in the middle of transaction will disrupt the I2C communication protocol. Thus you get an error on the Pi, that states an error in the I2C communication protocol. Just use the correct implementation of the I2C protocol to end the transmission correctly.


Override #define statements in libraries

You're allowed to modify the header file.  The version I looked at says

#define USE_SOFTWARE_SERIAL //Comment this line for use  HardwareSerial

...but I think he meant "comment this line out to use HardwareSerial".  Or conversely, "uncomment this line to use SoftwareSerial."

Then you just pass your SoftwareSerial instance into the Nextion constructor:

SoftwareSerial HMI( 8,9 );
Nextion nextion( HMI );

void setup()
{
   HMI.begin( 9600 ); // or whatever speed...

However, because you are using pins 8 & 9, I would strongly recommend using AltSoftSerial instead.  It is much more reliable and efficient.  MUCH.

You would have to modify the Nextion files to either (1) search and replace all occurrences of SoftwareSerial with AltSoftSerial, or (2) add a third choice to the author's #ifdef/#endif sections.  For example:

#define USE_SOFTWARE_SERIAL // uncomment this line to use SoftwareSerial
#define USE_ALTSOFT_SERIAL  // uncomment this line to use AltSoftSerial
                            // comment both above  to use HardwareSerial

#if defined(USE_SOFTWARE_SERIAL)
#include <SoftwareSerial.h>
#elsif definied(USE_ALT_SOFTSERIAL)
#include <AltSoftSerial.h>
#endif

class Nextion{
 private:
  void flushSerial();
#if defined(USE_SOFTWARE_SERIAL)
  SoftwareSerial *nextion;
#elsif defined(USE_ALTSOFT_SERIAL)
  AltSoftSerial *nextion;
#else
  HardwareSerial *nextion;
#endif

Do either one of those things in all files that refer to the Nextion serial member; Nextion.CPP certainly needs it.


Baudrate is set to 9600 automatically even if specifying a different value

The whole concept of Baud Rate with USB communication is completely meaningless.  There is no such thing as "baud rate" over USB.

What there is, and what you are confusing with "baud rate" is a configuration item which the host can send to the device which is a "I would like you to communicate with other devices at this speed" configuration item.

This is intended for use with USB to UART adaptors where it is used to configure the baud rate of a physical UART interface for downstream communication.

When you set the baud rate in your code it is ignored, since it has no meaning.

When you set the baud rate on your computer it sends it as this configuration value, which you can then retrieve, should you have an interest in that value, using the Serial.baud() function.


Cannot communicate with Serial Monitor - Arduino Yun

When using the Yun over wifi, you cannot user Serial, you need to use Bridge Console object. Serial is bound to the usb cable.

Give a spin to ConsoleRead example.


Do arduino librarys require the arduino to be connected to a computer?

No.  Arduino libraries (strictly speaking only the utilized parts) are permanently built-in parts of your compiled sketch.  Effectively they are "statically linked" unlike the situation with modern RAM-based computer operating systems where compiled dynamic link library code may be separately loaded into memory for a program to call at runtime.

(This isn't even really a design choice, as the basic AVR Arduino's cannot load new program code into executable memory at runtime anyway - except by reflashing themselves like the bootloader does, which would be a bit slow compared to normal dynamic linking)

Of course if you have a library which is intended to perform communication with a computer, then that connection would probably be required for it to fully operate.


Connecting the grounds would work.

You could also connect the 7.2V lipo to the Vin pin on the UNO. The UNO will automatically switch from USB to Vin, if it's present.


Serial.println using too much memory (not Strings)

Probably if you don't print them then the compiler sees that array is never used for anything so it gets optimized away.  It sees that it is useless code that doesn't affect anything and simply removes it.  Once you print it then it actually has to be included in the compiled code.

Think about this.  The Arduino you are using has 2000 bytes of memory.  One int takes 2 bytes.  You want 10,000 of them.  That's 20,000 bytes of memory.  20,000 bytes will never ever fit into 2,000 bytes.  You need to choose a more reasonable number of samples.


Power small hobby motor using Vin pin on Arduino and 9V battery, safe?

If you use a transistor circuit as shown below, back EMF would not cause any trouble.


Arduino hangs after 3-4 minutes on battery power, but not on USB

As somebody else suggested, 9V batteries are pretty weak. They only provide a very small number of mAh (milliamp/hours) before their voltage starts to drop. Once the voltage drops to around 7 volts, the regulator in the Arduino can't keep providing 5 volts, so your Arduino resets.

Wire up 6 AA batteries in series. That will provide a much "stiffer" 9 volt supply (more instantaneous current) plus a lot more mAh of total power. If you REALLY want long life, wire up 6 C or D batteries in series, or an external 9V supply through a "wall wart" power supply.


WiFi module ESP8266-01 for Arduino not working

Use this code to send commands to the ESP:

#include <SoftwareSerial.h>

    SoftwareSerial esp8266(2, 3);

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

      esp8266.begin(9600);
    }

    void loop() {
      while(esp8266.available()) {
         Serial.write(esp8266.read());
      }

      while(Serial.available()) {
        esp8266.write(Serial.read());
      }
    }

This simply reads everything from the ESP chip and sends it to the console and vica versa.

To modify the baud rate on the chip, send the following command in the serial monitor:

AT+UART_DEF=9600,8,1,0,0

This sets the baud rate to 9600 and remembers it for further use.


shiftIn() and shiftOut() are designed for communicating with different types of shift registers. These are typically external components which don't run code themselves, such as the 74HC595.

You can't use shiftIn() to read data that's been written using shiftOut(). The reason is that both functions try to act as the host in the communication -- i.e. the one that controls the clock line.

When you call shiftIn(), the clock line is pulsed each time it's ready to read a bit (i.e. it tells the shift register when to write). When you call shiftOut(), the clock line is pulsed each time it writes a bit (i.e. it tells the shift register when to read).

Neither one will respond to a clock line provided externally. The result is that your ATTiny's aren't synchronised so they won't be reading/writing at the same time.

A much simpler approach would be to setup a conventional serial connection between the two microcontrollers. You could do that either using software or hardware serial. The only caveat is that the sender would need to ensure the receiver is up-and-running before it transmits anything. This could be done using some kind of handshake at startup -- one device repeatedly sends something until the other replies.


Arduino to AtTiny change of pin interrupt behaviour?

After going through a lot of documentation, it seemed best and more efficient to attach the interrupt without functions.
EIMSK  |=  (1<< INT0);//Attaches the interrupt
MCUCR  |=  (1<< SM1)  //Power-down mode
         | (1<<ISC01) //The rising edge of INT0
         | (1<<ISC00);// generates an interrupt request


The fastest way to read out a digital pin state in an Arduino Due

If the pin is declared as input, let's say pin 13:

uint32_t pin_status;
pin_status = PIOB->PIO_PDSR & PIO_PDSR_P27;

If the pin is declared as output, let's say pin 13:

uint32_t pin_status;
pin_status = PIOB->PIO_ODSR & PIO_ODSR_P27;


FTDI adapters often don't provide enough current to run the power-hungry wifi features of the ESP8266. So as soon as you fire up wifi, you brownout the chip and cause it to reset.

Use a battery, a dedicated ESP8266 flasher, a 3.3v LDO, or something besides the on-board 3.3v connection the USB-Serial adapter provides.


Stateful questbox

A GPS powered box that makes you visit a few spots before opening

Description

It is similar to questbox, but it stores a small amount state of information in EEPROM, so you have to visit two or three different places before it opens.

Design

Needed hardware:

Arduino Uno
Reverse Geocache Version 2 (or a protoshield)
GlobalSat EM-406A GPS module
2×8 blue LCD with connector header and cable
Hitec HS-55 servo motor
4-40 push rod and clevis for latch (some versions provide a Z-bend rod instead)
2 AA battery holder
Metallic push button with embedded blue LED and 4-pin cable
Pololu low voltage switch
Pololu 5 V boost regulator
JST connector for EM-406A GPS module
Straight and right-angle header pins for the display, servo, and pushbutton connectors
Two resistors for current limiting and display contrast adjustment
Two small capacitors for power smoothing
larger capacitor for display contrast circuit

Total hardware cost: 137$ + shipping

Aditional materials:

A nice box
Epoxy glue, wood to cover pieces, tools

You can find assembling instructions in sundial page (you can buy most materials from them)

I will upload stateful code and post a link here, unfortunately I wont get all need hardware on time, so this is just an idea :)

Code written so far:

Persistent state machine library

Inspiration:

Conclusion

Learned how to integrate many components and libraries all toghether, I'll have to travel a bit to test it :)

Budget can be cut quite a bit changing the concept a bit:

Change GPS with a numerical keypad: the 'player' has to guess/obtain a code instead of traveling to a location
Polulu switch and regulator can be exchanged for a latching relay with capacitance coupling


Read battery voltage from battery which is powering arduino

You can read the Arduino's supply voltage see here How to measure the supply voltage of Arduino without using an analog pin Alternatively use the internal 1.1V reference and a suitable voltage divider to read the lipo's voltage


If you are willing to go the “barebones” route, you can turn an
ATmega328P (the MCU at the heart of the Arduino Uno) into a very
accurate RTC by hooking a watch crystal to it's clock pins. Given proper
calibration, you can get an accuracy of a few seconds per year.

This would require some coding though, and is not as straightforward as
using an off-the-shelf RTC. C.f.
this answer for the details.


Can I use ----THIS---- part instead of the basic 22pf capacitor and the big 16Mhz crystal?

No. That is just a crystal. You still need the capacitors.  If you want a single device then you need a ceramic resonator.

Also you're lacking any decoupling capacitors in your circuit. You may find it works for now, but it will become flaky when you start getting it to do things.


avrdude.conf: programmer type must be written as "id_type"?

After looking at the source repo it looks like quotes are now required:

  type  = "wiring";


Problems with serial communication from Arduino to ESP8266

The cause of the issue was that the ESP was reading chars too quickly, meaning that it would give up before the next char could be sent from the Arduino. To fix the issue I simply added a 10 ms delay between each Serial.read() call on the ESP.


Weird RTC DS3231 Output only when saving the dates to variables

You used single quotes instead of double quotes. Single quotes are for single characters. Double quotes are for strings (or character arrays).
Serial.print('  Time:');

should be
Serial.print("  Time:");


I actaully found this this week that I was suing ASK RF receiver module, when I needed FSK.
I have used RC Switch, and no luck, along with Radio head.
However as mentioned the key fob will not work with ASK. I am trying to find a library for FSK but no luck as of now.
-Pete


ESP8266 Supply Voltage dropping below 3.3V

The ESP8266 will do an analog calibration when it is running the user code. This will typically be the worst case power requirement. The peak current requirement can be as much as 1/2 an amp. While your regulator probably can supply that I would bet your interconnecting wiring, and maybe the power source, are causing too much voltage drop.

The fact that you can see the voltage go down to 2.9 volts makes me thin that you have serious problems.

Early on when I started with the ESP8266 I was getting flaky operation. I put it down to bad code. But eventually I ruled that out. I took my setup to work (where I design electronic products) and looked at the power connections with a digital scope at the module. Right at the last point before the traces run under the shield. (I use the ESP-12 modules) It dipped just under 3.0 volts for two microseconds, and that was enough to cause a reset.

These things are not tolerant to any power dips. And this is why I recommend anyone starting with the ESP8266 to buy a Nodemcu or a Wemos type module. Something that has the regulator right at the processor.


Trying to make a heart rate analyser with Arduino that will calculate the BPM of a person

// Record the start time into time1
if(count==0) {
  time1=millis();
}

// Set time2 to the current time
time2=millis();

// Read the sensor
sensorValue = analogRead(sensorPin);

// If the sensor value is high enough, increment the beat counter
if(sensorValue>156) {
  increment();
}

// If the current time is greater than, or equal to, the start time
// plus 10,000 milliseconds (10 seconds), show the heart rate
if(time2>=time1+10000) {
 counter();
}


const int Hallsensor=3;
int HallValue;
int LastHallValue;
int Hcount =0;

unsigned long timer = 0;
unsigned long lastChangeTime = 0;

void setup()
{

  pinMode(Hallsensor, INPUT);
  Serial.begin(9600);
   counting = true;
    start_time = millis();

}

void loop()
{

    LastHallValue = HallValue;
    HallValue = digitalRead(Hallsensor);
    if (HallValue == LOW and LastHallValue == HIGH){
        Hcount++;
        lastChangeTime = millis();
        Serial.println(Hcount);
    }
    else{
        if(counting == true){
            Serial.print("Count is");
            Serial.println(Hcount);
            counting = false;
            // Serial.println(LastHallValue);
        }
    }

    if( (Hcount>0) && (millis() - lastChangeTime) >= 1000){
        Hcount = 0;// reset count when it hasn't increased in the last second.
    }

}


Why does increasing resistance make a capacitive sensor more sensitive?

A capacitor is created from two conductors with a dielectric between them. The capacitance of the capacitor is determined by the surface area of the conductors and the distance between them. The larger the conductive surface, the higher the capacitance. The further apart the conductors, the smaller the capacitance. Using a higher resistance means that you can use a smaller capacitance, i.e. be further away from the sensor, to get the same results.


Failed HC-05 Bluetooth sketch upload - (port and board correct)

when uploading the code, did you ensure disconnecting the Rx, Tx pins from the Arduino? Coz this is a similar error you get when you upload code with your comm pins connected. Try uploading the code with no wires connected.


Unless you want to replace the headers with something else, which means soldering, then you will be soldering.

The options are:

Solder different connectors in the place of the existing headers
Remove the existing headers and solder wires directly in their place
Get a prototyping shield and solder wires in to that
Get a prototyping shield and solder different connectors to it.

Whatever you choose you will be soldering.

Don't be scared of soldering - it's the most basic thing you need to be able to do when you are working with electronics.


How to set Alarms on the DS3231 easily so the Nano doesn't have to go to sleep with delay statements?

Here it is:

https://github.com/sleemanj/DS3231_Simple

Example:  https://github.com/sleemanj/DS3231_Simple/blob/master/examples/z2_Alarms/Alarm/Alarm.ino

This is what I was looking for.

My system needs to be able to respond to radio remote commands while asleep, and the long delay() statements were preventing that.

These alarms solve the problem.


Can't upload code to Arduino board on Mac

I finally solved the problem.
Although the Board has no information about being a clone (it only says "Uno" and was provided by the faculty so I think it is official), I was looking on the web for similar problems and found out that installing CH340 Driver was working for a lot of users.
So that was what I did and now it works like a charm.


The variables previousMillis (1-3) are not properly initialised.  So if you wait a while before pressing the button, that delay time becomes part of the time that the LED is illuminated for.

If your taskExecute() function sets them before the loop, this will fix that:

void taskExecute(int tMotor1, int tMotor2, int tMotor3)
{
    int ledState1 = HIGH;
    int ledState2 = HIGH;
    int ledState3 = HIGH;

    digitalWrite(ledPin1, ledState1);
    digitalWrite(ledPin2, ledState2);
    digitalWrite(ledPin3, ledState3);

    unsigned long time_now = millis();
    previousMillis1 = time_now;
    previousMillis2 = time_now;
    previousMillis3 = time_now;

    do
    {
        ...
    } while (ledState1 == HIGH || ledState2 == HIGH || ledState3 == HIGH);
    state = 0;
}

On a coding-style note - I did not initially see the resetting of the global variable state=0 at the end of the taskExecute() function.  It might be better to move this up to underneath the initial call to taskExecute() so all the state handling is in one place.


Two power source for Arduino and a relay

The uno can't provide enough power to power an ESP8266 reliably.  I suggest you power it from a separate source.

When ever you use separate power supplies for a circuit you need to "tie the grounds together", connect them.  Otherwise the circuits don't use the same definition of zero.


Visibility of #define between sketch and library

You need a common place that the building of all the places can get the definition from.

That isn't the sketch. The sketch is one of the things that would have to look at that common place.

That can either be a single shared header that everything else (that needs it) includes, or it can be a -D flag added to the compilation command.

For instance, adding:

-DDEBUG=1

to your compilation command is the same as adding

#define DEBUG 1

to every single file you compile.