texts: Getting 0 cm from ultrasonic sensor when nothing is in front

texts:
My Ultra sonic sensor (HC-SR04) is returning these types of values when it has nothing in front:

Ping: 144cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 105cm
Ping: 105cm
Ping: 94cm
Ping: 0cm
Ping: 378cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 106cm
Ping: 106cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 106cm
Ping: 250cm
Ping: 0cm
Ping: 108cm
Ping: 0cm
Ping: 108cm
Ping: 0cm

I am not able to understand why I am getting 0 cm. This value is critical in the program that I am using. Here is a test code which gives me these output:

#include <NewPing.h>

#define TRIGGER_PIN  A5
#define ECHO_PIN     A4
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN);

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

void loop() {
  delay(1000);
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm());
  Serial.println("cm");
}

Because  of these 0s my robot is making turns which are not expected.

Any idea why this might happen ?


texts: Is an atmega 2560 board compatible with the Adafruit Trellis?

texts: I want to build a custom midi controller for my computer, and yes, Adafruit has a mini Untz project. For my purposes, I need more analog inputs than the Leonardo, and the only other option I can find is the atmega 2560. Can i use that?


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

This is a list of the current equipment that will require power:

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

The shields will be stacked on top of each other.


texts:
I have an Arduino Uno which is going to receive a long binary string.  I know that this string will correspond to English when decoded.  How can I convert the incoming binary string to text, so that I can read it in the Serial Monitor?

Bonus Points: This string will almost definitely have random noise digits.  How would I noise-proof the string, or how could I have the code detect and ignore noise?

UPDATE: It might help if I mention my end goal.  So I have this contained clean space that is locked up to avoid contamination.  It is quite small, and used for growing silicon crystals.  I want to be able to take a greyscale image every hour, and transmit it to a receiver on the other end of the room, through a window.  The window is two half inch panes of glass with an inch of space between them.  I have on hand 2x Arduino Uno, 1x Arduino Beetle, and 1x Raspberry Pi.  The whole text string thing is just for testing purposes so that I can understand what I'm doing.  From what I've read on the subject previously, I need to take the image, convert it to Hex, convert that to binary, transmit it, receive it, convert back to Hex, convert back to an image.  I have 0 experience with Arduino or Raspberry, have a limited idea of how to execute this, and appreciate all the help I can get!


texts: Does ATmega328 on Uno need to be burned?

texts: I'm new to the Arduino world so please bear with me. I'm not sure whether the ATmega328 bootloader needs to be burned. What I'm reading is all that needs to be done is plug the board into the computer by USB cable. Then burning the 328 is also mentioned. I appreciate any help.


texts: How can I make motor vibrate using arduino depending on the ultrasonic distance?

texts:
I want to make the vibration motor vibrate depending on the distance to an obstacle, for example if the distance is too short it should vibrate quickly and vice versa.

How can i make motor vibrate using arduino depending on the distance?
Can you explain for me how can I use the delay in the vibration code?
I found this code in the internet for vibration:

digitalWrite(y, HIGH);
delay(50);
digitalWrite(y, LOW);
delay(50);

I know that I can change the delay, but how can we do it depending on our purpose?
Please help me .. I don't know the use of the delay :(


texts: PC Cannot Access HC-06 Bluetooth COM Port

texts:
I have an HC-06 Bluetooth module connected to an Arduino UNO board to allow for the data received by the Ultrasonic sensor to be transferred to my PC via bluetooth and serial communication. I am using the Putty program to view the data. The thing is, my PC says that it has paired with the bluetooth and I was able to see the COM number but when I opened Putty and entered the COM number while choosing the option 'serial' an error box appears saying: Unable to open serial port.

The way I am currently connecting my bluetooth to the arduino board is:

RX->pin 10

TX->pin 11

GND->GND pin

VCC-> 5V VCC

I am sure that the sketch in the arduino for serial communication via bluetooth is right as I have tested the system yesterday and it worked. Only after a time (say like 5-10 min) the connection breaks and I cant seem to figure out the problem. Oh and the Arduino is being powered by USB if that matters.


texts: Could someone help me with an Arduino Uno program?

texts:
I am thinking to do a gas leakage and fire detector using a GSM module in my home. I got all the contents like an Arduino Uno, MQ22 gas sensor, LM 35 heat sensor and GSM module SIM800L to send SMS and red and green LEDs.

About the program, I am thinking to make it like this: if there is a gas leak the GSM sends an SMS to my cellphone, whereas if there is a fire the GSM will send an SMS to the fire station.

About the LEDs, I want the green one to run when the state is stable, while the red one is on when there is a gas leak or fire.

Any help would be appreciated.


texts: Is it possible to run a binary from EEPROM?

texts: Say I wrote a compiled sketch to EEPROM then read it. Could I run the program from EEPROM? I guess the question is: Can an Arduino run software not in flash memory in the middle of executing the software in flash?


texts: Thermistor value correct on Uno backwards on Nano

texts:
EDIT: upon further investigation: I found out that if I wired it Thermistor > resistor > GND values go one direction. If I wired it Thermistor > Resistor > 5v, it goes the other direction. So my new question: Which way is correct? One sketch assumes it works one way, and one the other.

I have some Thermistors from here. I have an Arduino Nano and an Arduino Uno, both set up identically with pictures of the wiring below. On the sketch below, when I heat up the thermistor the value increases on the Uno and decreases on the Nano.

// which analog pin to connect
#define THERMISTORPIN A0
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 9800

int samples[NUMSAMPLES];

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

void loop(void) {
  uint8_t i;
  float average;

  // take N samples in a row, with a slight delay
  for (i=0; i< NUMSAMPLES; i++) {
       samples[i] = analogRead(THERMISTORPIN);
   delay(10);
  }

  // average all the samples out
  average = 0;
  for (i=0; i< NUMSAMPLES; i++) {
     average += samples[i];
  }
  average /= NUMSAMPLES;

  Serial.print("Average analog reading ");
  Serial.println(average);

  // convert the value to resistance
  average = 1023 / average - 1;
  average = SERIESRESISTOR / average;
  Serial.print("Thermistor resistance ");
  Serial.println(average);

  float steinhart;
  steinhart = average / THERMISTORNOMINAL;     // (R/Ro)
  steinhart = log(steinhart);                  // ln(R/Ro)
  steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
  steinhart = 1.0 / steinhart;                 // Invert
  steinhart -= 273.15;                         // convert to C

  Serial.print("Temperature ");
  Serial.print(steinhart);
  Serial.println(" *C");
  Serial.println();

  delay(1000);
}

On the sketch below, the Uno is backwards and the Nano is correct. I'm sure there's something simple I'm missing, but I sure can't find it. Any suggestions?

#include <math.h>

double Thermistor(int RawADC) {
 double Temp;
 Temp = log(10000.0*((1024.0/RawADC-1)));
 Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;
 Temp = (Temp * 9.0)/ 5.0 + 32.0;
 return Temp;
}

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

void loop() {
  int val;
  double temp;
  val=analogRead(7);
  temp=Thermistor(val);
  Serial.print("Temperature = ");
  Serial.print(temp);
  Serial.println(" F");
  delay(1000);
}

Nano Wiring

Uno Wiring


texts:
Is there any way to connect RFduino's via radio frequency? Or any capability to transmit information between RFduino's for distances up to 200 feet?

I would like to purchase a dev kit (for RF duino) but i'm not sure what parts I will need to transmit info longish (200 feet) distances.


texts: Arduino interface of push button and led using millis()

texts:
I am working on a project of blinking of led using push button without delay().The limitations of led blinking is in accordance with the no of times the push button is pressed the led should blink that many no of times(i.e,) when the push button is pressed for the first time it should blink once and when pressed 2nd time it should blink twice till number of times.Can someone please help me out in solving this.I am attaching the code. please someone help me in solving this.Thanks in advance.
int led =13;
int button= 4;
int buttonState = 0;
int count_value =0;
int prestate =0;
int ledState = LOW;
unsigned long currentMillis;
unsigned long previousMillis = 0;
const long interval = 1000;

void setup() {
 Serial.begin(9600);
 pinMode(led,OUTPUT);
 pinMode(button,INPUT);
}

void loop() {
 buttonState = digitalRead(button);
 while(buttonState == 1 && prestate == 0) {
  count_value++;
  Serial.print  ("count_value="); Serial.println(count_value);

   for(int j=0; j<=(count_value); j++)
   {
    currentMillis = millis();
    if(currentMillis - previousMillis >= interval) {
     digitalWrite(led, !digitalRead(led));
     previousMillis = currentMillis;
   }
  }
  prestate = 1;
 }
 if(buttonState == 0) {
    prestate = 0;
 }
}


texts:
I would like to make a makefile for compiling c programs for the arduino. I am somewhat familiar with make but have never used it with avr-gcc. What is the simplest way I could put the commands below in a makefile?

$ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c
$ avr-gcc -mmcu=atmega328p led.o -o led
$ avr-objcopy -O ihex -R .eeprom led led.hex
$ avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:led.hex


texts: What's a good alternative to an Arduino Nano that can be used with Neopixels?

texts: I'm doing an arduino project in school which requires neopixels, but the Arduino's too big. Is there an arduino I can use that's compatible with neopixels? Thanks!


texts:
I've recently bought a SIM900A A6 GSM module. Whenever I send a command it gives an error: +CME error 58.

Does anybody know what this means and how to solve it?


texts:
I tried to follow the answer here:
https://arduino.stackexchange.com/a/18545/51302

Unfortunately I can only get the interrupt to go once (on serial monitor is the time of that first interrupt), then nothing.
I know this has already been answered but I don't understand the mistake and would appreciate help.

What I'm trying to do:
get a button to set an interrupt to trigger foo and thus write the steps on the monitor.

I've left remarks to try and explain what I try to do, so it would be easier to understand what I left out or used incorrectly.
Thanks.

#define IRF520 A2
#define BUTTON 3
static unsigned long last_press = 0;
static bool button_state = HIGH;             //pull up resistor
volatile bool interrupt_flag = 0;            //when the interrupt fires, button press or noise
bool is_pressed = false;                     //after checking that the button was really pressed
bool was_pressed = false;                    //last state of the button
unsigned long button_pause_duration = 20;        //pause required to accept press in ms
unsigned long interrupt_time=0;

void button_interrupt() {
  interrupt_flag = true;                      //can be a false alarm
  Serial.print("interrupt time: ");         //this is the onlt step that works
  Serial.print(millis());
  Serial.print("\n");
}

void setup() {
  Serial.begin(9600);
  pinMode(IRF520, OUTPUT); //A2 controls IRF520
  pinMode(BUTTON, INPUT_PULLUP);  //pin D2 and D3 are sutible for interrupts
  attachInterrupt(digitalPinToInterrupt(BUTTON), button_interrupt, FALLING);
}

void debounce_button() {
  if (digitalRead(BUTTON) != button_state) {
    button_state = digitalRead(BUTTON);         //if button changed state remember the new state
    interrupt_time=millis();
  }
  if (button_state == LOW) {
    last_press = millis();
    Serial.print("last_press was updated to: ");
    Serial.print(last_press);
    Serial.print("\n");
  } else {
    last_press = 0;
    interrupt_flag = false;
  }
  if ( last_press && (millis() - last_press) > button_pause_duration) {
    last_press = 0;     //set to 0 for the next check
    is_pressed = true;   //button was really pressed
    Serial.print("last_press was set to 0 and is_pressed to true - BUTTON WAS PRESSED at: ");
    Serial.print(millis());
    Serial.print("\n");
  }
}

unsigned int foo(bool is_pressed) {
  if (is_pressed) {
    Serial.print("foo is active, MOSFET does its thing");
    Serial.print("\n");
    }
  }
}

void loop() {
 if(interrupt_flag){
    Serial.print("the button is now being pressed: ");
    Serial.print(millis());
    Serial.print("\n");
 }
 debounce_button();
 foo(is_pressed);
}


texts: Implement Visible Light communication using Arduino

texts:
I want to implement a simple VLC based communication system using two Arduinos and send messages/data/files between two PCs. For that I have a simple transmitter circuit with an LED on Tx side and a photo-transistor on the receiver side. The codes im using for transmission and reception are attached below, also the circuit image is attached below, but im unable to bring about any communication between the two PCs, the transmitter side works fine as the LED flickers indicating data is being transferred, but its not being received by the photo transistor. I don't know what im doing wrong. Any help would be appreciated, I am doing this as a part of my academics.
Transmitter Code :

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

  // Clear Timer on Compare Match (CTC) Mode
  bitWrite(TCCR1A, WGM10, 0);
  bitWrite(TCCR1A, WGM11, 0);
  bitWrite(TCCR1B, WGM12, 1);
  bitWrite(TCCR1B, WGM13, 0);

  // Toggle OC1A and OC1B on Compare Match.
  bitWrite(TCCR1A, COM1A0, 1);
  bitWrite(TCCR1A, COM1A1, 0);
  bitWrite(TCCR1A, COM1B0, 1);
  bitWrite(TCCR1A, COM1B1, 0);

  // No prescaling
  bitWrite(TCCR1B, CS10, 1);
  bitWrite(TCCR1B, CS11, 0);
  bitWrite(TCCR1B, CS12, 0);

  OCR1A = 210;
  OCR1B = 210;

  Serial.begin(2400);
}

void loop()
{
  Serial.println("testing testing testing");
  delay(500);
}

Receiver Code:

void setup()
{
  Serial.begin(2400);
  pinMode(13, OUTPUT);
}

void loop()
{
  // if incoming serial
  if (Serial.available()) {
    readSerial();
    digitalWrite(13, HIGH);
  }
  else {
    digitalWrite(13, LOW);
  }
  delay(500);
}
void readSerial() {
  char val = Serial.read();
  Serial.print(val);
}

the transmitter works fine, but the receiver is not receiving anything, I don't know what i'm doing wrong.


texts: Yun - replaced uhttpd with lighttpd - luci works but not /data access..?

texts:
Ok, utthpd is running on port 80 and lighttpd on port 81...both give access to the luci control panel...all well and good.

However the /data access to the yun data store only works from uhttpd.

Lighttpd returns error 404 (page not found).

Any idea what the solution might be..?


texts: How to add calibration to a humidity contoller using UNO and DHT22 sensor?

texts:
I am using a setup that helps controlling humidity in an enclosure used to store a humidity sensitive product.   My original posting is here.

I'm using a NANO and a DHT22 temperature/humidity sensor to acquire information on the actual condition in the enclosure; I am also using a 75% RH calibration kit to check the accuracy oh the humidity reading by the UNO and I found the value 9 percentage points higher than the kit's calibration value.   Right now, until I find a solution to calibrate the unit, I have set my setpoint 9 points higher to compensate for the error.
Any ideas on how to tackle this issue would be highly appreciated.

At the moment I can read the DHT sensor and show the humidity value on the LCD like this:

[...]
  int chk = DHT.read22(DHT22_PIN);
  lastcheck = millis();

  lcd.setCursor(0, 0);
  lcd.print("Humidity: ");
  lcd.setCursor(13, 0);
  lcd.print(DHT.humidity);
[...]

@Thomas_Weller,
I'm running tests with your calibration routine and other code changes; I'm using your arbitrary values for testing purposes only; the compensation algorithm works, as sampled below, however the LCD output is the actual DHT22 reading, not compensated.
I am testing with a different sensor, whose output is 9% below the actual RH value.
Here's a sample of the serial output:

DHT value: 58
Compensated to: 55
DHT value: 59
Compensated to: 56
DHT value: 60
Compensated to: 57
DHT value: 61
Compensated to: 58
DHT value: 62
Compensated to: 59
DHT value: 63
Compensated to: 60
DHT value: 64
Compensated to: 60

setpoint = 72
DHT read = 66.80%
displ + backlights off
humidifier ON, fan OFF
setpoint = 72
displ + backlights off
humidifier ON, fan OFF
setpoint = 72
displ + backlights off
humidifier ON, fan OFF
setpoint = 72
DHT read = 66.80%
displ + backlights off
humidifier ON, fan OFF
setpoint = 72
displ + backlights off
humidifier ON, fan OFF
setpoint = 72
displ + backlights off
humidifier ON, fan OFF


texts: The current direction for digital output pins

texts:
I am new to Arduino. The digital pins can be configured as output (https://www.arduino.cc/en/Tutorial/DigitalPins) for triggering some sensors. I am now setting a digital (output pin), say no. 7,which is connected to the in1 pin of a SRD relay (https://blog.siliconstraits.vn/relay-what-is-it-and-how-to-use-it/):

I am not very clear about the direction of current flowing in the wire connecting the arduino digital pin to in1. To my understanding, when digitalWrite(pin, HIGH), no current flow into the arduino pin, the relay is not triggered, while digitalWrite(pin, LOW), the current flow into the arduino, and the relay is triggered. Please correct me if I am wrong. Thanks.


texts: avrdude: stk500_recv(): programmer is not responding + avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x47

texts:
So I'm following a beginners arduino book and I made a blinking program and now I've coded another program but when I try to upload it, avrdude(whatever that is) gives me the errors in the title and repeats them 10 times.
I have tried this so far:

Restarting my windows 8
Pressing the reset button on my arduino uno R3

My guess is that since it worked the first time, my blinking program must be clogging up the space in my arduino.How can I fix this problem. Or if my guess is right, how can I get the blinking program out of arduino and go home to my bots folder?

My IDE is arduino 1.6.7 and my port is CPU1. and lots of people mention tools>serial port but there isn't a "serial port" button on my IDE.


texts: Can I use IO10 as digital IO while using SPI interface?

texts:
If my arduino is the master device in a SPI network, hence not using the slave select SS pin, can I use the same pin as IO10?

I am actually using an Intel Galileo, with the same pinout as an Arduino Uno Rev3.


texts: Arduino DUE deadlock problem, watchdog not working

texts:
I am using Arduino DUE in my project. The project is massive (about 7000 lines of code in total, with massive schematic), so I decided not to post the whole code and schematic, except explain the hardware and configuration I am working with:

Arduino DUE;
12V switching power supply;
LTC1660 DAC (used withstandard SPI library);
Nextion HMI (Used with standard library #include Nextion.h        //INCLUDE NEXTION LIBRARY);
DS3231 RTC module on I2C bus (Library used: Wire  #include <DS3231.h>)
24LC256 EEPROM on same I2C bus (Library used: Ext EEPROM #include <extEEPROM.h>)

The base line, is that on power-on the controller just freezes besides, it can't be the problem with power as I get this problem using both 12 V from switching PSU and 5 V USB cable. I can not really analyse the problem, as the deadlock occurs even before the program start to execute content of void setup(). My best guess is that the deadlock occurs due to infinite loops in the Arduino's twi.cpp where infinite loop can occur if the controller receives no acknowledge
bit. But then again I can not be sure here. However when I push restart button on the Arduino or enable Serial monitor in Arduino IDE when the circuit is powered on , it starts to work, and it works just as expected.

After reading the datasheet for the DUE's μC, I've found that it have the watchdog option embedded:

  After a Processor Reset, the value of WDV is 0xFFF, corresponding to
  the maximum value of the counter with the external reset generation
  enabled (field WDRSTEN at 1 after a Backup Reset). This means that a
  default Watchdog is running at reset, i.e., at power-up. The user must
  either disable it (by setting the WDDIS bit in WDT_MR) if he does
  not expect to use it or must reprogram it to meet the maximum Watchdog
  period the application requires. The Watchdog Mode Register (WDT_MR)
  can be written only once. Only a processor reset resets it. Writing
  the WDT_MR register reloads the timer with the newly programmed mode
  parameters.

I've started to explore it, and as I got it, the watchdog is ON by default, and its timer period is 16 seconds by default, so as it is not normally used in DUE, I assumed, that somewhere it is just disabled, and in main.cpp I found the following:

int main( void )
{
   // Initialize watchdog
   watchdogSetup();
   init();
   initVariant();

where watchdogSetup() led to:

void watchdogDisable(void)
{
   WDT_Disable (WDT);
}
void watchdogReset(void)
{
   WDT_Restart (WDT);
}
extern "C"
void _watchdogDefaultSetup (void)
{
   WDT_Disable (WDT);
}
void watchdogSetup (void) __attribute__ ((weak, alias("_watchdogDefaultSetup")));

As I got it, due to this, the watchdog was disabled for DUE by default, and commenting out watchdogSetup(); in int main() would allow the watchdog to work (as watchdog is on at power on by default, according to datasheet).

I've also added the WDT_Restart (WDT); to void loop() of the program in order to kick watchdog every program cycle.

Well, for some reason, that did not help me, and I'm still receiving the deadlock when I power on the controller, even through the watchdog is technically not disabled, after 16 seconds it still do not restart the system. And, pressing the reset button or the Serial monitor in Arduino IDE makes the system run as expected. Am I missing something out? Your help and suggestions are appreciated, shall any additional info be needed, just let me know, I need to get this project running so badly.

By the way, my void setup() function is quite long, and if I set the watchdog to 1 second, using
void watchdogEnable (uint32_t timeout) instead of commenting out watchdogSetup() in main.cpp, and use reset button after power on, I can see the watchdog working as it can't get to void loop() in time in order to reset watchdog (as void setup() takes about 3 seconds due to delays).


texts:
Trying to latch a 200 mS, LOW event to log the event.  LOW only occurs when external Watchdog timer sends reset pulse to the Arduino.

Is a D Latch suitable for this application?  It has been years since my digital class; help most appreciated.

How would you proceed?


texts: trying to make wemos d1 code modular causes collect2: error: ld returned 1 exit status exit status 1

texts:
#include "connection.h"

void setup() {
  Serial.begin(115200);
  Funcs::Connect conn;
  conn.connectWifi();
}

void loop() {

}

then connection.h file:

// connection.h

namespace Funcs
{
  class Connect
  {
    public:
      void connectWifi();
  };
}

and then connection.cpp

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "connection.h"
const char* ssid     = "ssid";
const char* password = "password";

namespace Funcs
{

  void connectWifi() {
    // Connect to WiFi network
    Serial.println();
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);

    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {
      delay(10);
      Serial.print(".");
    }
    Serial.println("");
    Serial.print("WiFi connected with ip ");
    Serial.println(WiFi.localIP());

  }
}

On compiling I get this error:

/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/HardwareSerial.h:76:
undefined reference to `Funcs::Connect::connectWifi()'

collect2: error: ld returned 1 exit status

collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board WeMos D1 R1.

But I do not have Funcs::Connect::connectWifi() in my code, it was in old code.


texts:
I'm running the following Sketch on my Arduino Uno:

const boolean verbose = true;

void debug(const char *s){
    if(verbose){
      char buf[8 + sizeof(s)] = "[DEBUG] ";
      strcat(buf, s);
      Serial.println(buf);
   }
}

void setup() {
  Serial.begin(115200);
  char str[] = "Lorem ipsum dolor sit amet, consetetur sad";

  Serial.print("Size of String: ");
  Serial.println(sizeof(str));
  debug(str);
}

void loop() {
}

The debug() function should be used to print debugging information to Serial. The Sketch like I posted it works wuite fine and prints the following to Serial:
    Size of String: 43
    [DEBUG] Lorem ipsum dolor sit amet, consetetur sad

But when I add one more character to the string (43 chars excluding null terminator) I get the only follwoing on Serial:

Size

This problem does not appaer when defining str as a global varaible. What does cause this issue and how can it be fixed?


texts:
I'm planning on an Arduino project for a restaurant I work at that would require determining how busy it is at any point in time, but I'm not sure how I would go about procuring this information.

I don't have access to any of their IT systems or I would have simply pulled the data from their till systems.

I was thinking perhaps measuring the ambient sound of the restaurant as it gets quite loud during peak time but that could be thrown off when the music volume is adjusted.


texts: Can I connect and control 12 Arduino's over USB/serial to my laptop?

texts:
I have 12 arduinos, each of them controlling some simple hardware peripherals. I want to interact with all of them over 1 USB connection to my laptop, where I have a python program communicating over serial.

The following seems like it could work: https://www.amazon.ca/Satechi-Power-Adapter-Control-Switches/dp/B0051PGX2I

Are there any electrical/other considerations to take into account for why this would/wouldn't work?


texts: Does enabling the Timer1 CompareA interrupt instantly triggers an interrupt?

texts:
I am learning Arduino interruptions and I am unable to explain the behavior of a minimalistic interrupt driven project. The project is the following: an Arduino UNO is connected to two LEDs, on ports 9 and 10, and a button on port 2. The button is listened to for RISING interruptions, which are expected to trigger the following 3 seconds sequence: LED1 HIGH (one second); both LEDs HIGH (one second); LED2 HIGH (one second); during which pressing the button should have no effect.

#define led1Pin 10
#define led2Pin 9
#define buttonPin 2

void setup() {

  cli();//stop interrupts

  pinMode(led1Pin, OUTPUT);
  pinMode(led2Pin, OUTPUT);
  pinMode(buttonPin, INPUT);
  digitalWrite(led1Pin, LOW);
  digitalWrite(led2Pin, LOW);
  attachInterrupt(digitalPinToInterrupt(buttonPin), f, RISING);

  TCCR0A = 0;// set TCCR2A register to 0
  TCCR0B = 0;// set TCCR2B register to 0 (sets timer0 prescaler values to "disable timer")
  TCCR2A = 0;// set TCCR2A register to 0
  TCCR2B = 0;// set TCCR2B register to 0 (sets timer2 prescaler values to "disable timer")

  //set timer1 interrupt at 1Hz
  TCCR1A = 0;// set TCCR1A register to 0
  TCCR1B = 0;// set TCCR1B register to 0

  // set compare match register for 1hz increments
  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1
  TCCR1B |= (1 << WGM12);   // turn on CTC mode 1 (compare to OCR1A)
  TCCR1B |= (1 << CS12) | (1 << CS10);// CS12|CS10 => Prescaler 1024
  TIMSK1 = 0;// disable timer compare interrupt

  sei();
}

volatile int index=0;

volatile byte previousState=LOW;
volatile byte state = LOW;

void loop() {
  if (state && !previousState) {
    digitalWrite(led1Pin, HIGH); index=1;
    TCNT1H = 0;
    TCNT1L = 0; //initialize counter value to 0
    TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
    previousState = HIGH;
  }
}

void f() {
  state = HIGH;
}

ISR(TIMER1_COMPA_vect){ //timer1 interrupt 1Hz
  switch(index) {
  case 1:
    digitalWrite(led2Pin, HIGH); index=2;
    break;
  case 2:
    digitalWrite(led1Pin, LOW); index=3;
    break;
  case 3:
    digitalWrite(led2Pin, LOW); index=0;
    state=LOW; previousState=LOW;
    TIMSK1 = 0;// disable timer compare interrupt
    break;
  default:
    break;
  }

}

Code adapted from https://www.instructables.com/id/Arduino-Timer-Interrupts/

Upon pressing the button, state is set to HIGH, which assuming previousState and state were LOW, should get the loop to perform a set of action once as it will set previousState HIGH.

These actions are the following: set led1Pin to HIGH, set TCNT1H and TCNT1L to 0, which should put the Timer1 counter to 0, and then set TIMSK1 to 0b00000010, that is, 1 << OCIE1A, to accept the interrupt when it will be triggered, supposedly one second from the instruction that set the counter to 0, as the timer fires interrupts at 1Hz.

But while the expected behaviour is LED 1 on for one second, both LEDs on for one second, then LED 2 on for one second, the observed behaviour is the following, from my tests:

First time pressing the button since Arduino reset : LED 1 and LED 2 on for one second, LED 2 on for one second.
Button presses properly ignored until LED 2 turns off.
Subsequent button presses : either proper behaviour (LED1 on, both LEDs on, LED2 on); or "first press" behaviour (both LEDs on, LED2 on). In both cases, the cycle sometimes instantly restart ([optional : LED1 on;] both LEDs on; LED2 on; LED1 on; both LEDs on; LED2 on), with each state taking one second.

The non-deterministic nature of the problem lets me think I'm mishandling interruptions. The project behaves as if enabling timer compare interrupts instantly triggered one, despite setting the relevant registers to 0 before that. I was unsuccessful in finding information regarding this that would explain the problem.

Is there asynchronous behaviour when setting the TCNT1H and TCNT1L registers to 0 ? Can a compare match interruption somehow be buffered ? And how comes the cycle sometimes execute twice ?


texts: Running out of pins in a 4x7-segment display clock

texts:
I've been playing around with the 7-segment displays and so far I've only been able to make 1 working display hooked up to a potentiometer that changes the number on the display with a switch that turns it into a counting-up timer

My main goal is to make a Clock but that uses 4 7-segment displays and I've already used up 7 pins for 1 display so now I either need to make more pins (I'm using Arduino Uno which has 14 Digital pins + 6 if you use the Analog In pins)
or use the 7-segment decoders

if I use the 7 segment decoder that will take up 4 per display which totals up to 16 which is well in range the required amount of Pins

so can someone teach me what is easier to do:

Making more pins using the 8-bit shift registers
or
Use the 7-segment decoders to make space

and if you think one is easier can you tell me how to use them because I have no idea and I've been tinkering with the decoder for the past hour or two
(btw the 7-segment displays are all Common Anode)


texts: Node MCU code is stuck in while (WiFi.status() != WL_CONNECTED)

texts:
I am using the Node MCu V3 board ESP8266MOD
Board Manager Version: 2.7.4
Arduino IDE: 1.8.12
My code is stuck in the while (WiFi.status() != WL_CONNECTED)
Here is code:
#include <ESP8266WiFi.h>        // Include the Wi-Fi library

const char* ssid = "ESP8266TestNet";  // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "ESP8266Test"; // The password of the Wi-Fi network

void setup() {
  Serial.begin(9600); // Start the Serial communication to send messages to the computer
  delay(10);
  Serial.println('\n');

  WiFi.begin(ssid, password); // Connect to the network

  Serial.print("Connecting to ");
  Serial.print(ssid);
  Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++i); Serial.print(' ');
  }
  Serial.println('\n');
  Serial.println("Connection established!");
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
}

void loop() {
  delay(10000);
  Serial.println(WiFi.status());
}

After downloading the code above for setup connection I am using mobile WiFi for connection.
In the mobile settings I can see the WiFi is connected to the ESP Board but when I monitor the Serial it seems that the code is stuck in the while loop.
If I comment out the while loop the board is giving a WDT reset.
Any ideas? I have been stuck for a long time.
Here I have attached the tools setting of the Arduino IDE:


texts:
I'm using botletics / SIM7000-LTE-Shield with Arduino Uno. I ran LTE-Demo example with the following adjustments based on this source:

fona.setNetworkSettings(F("jawalnet.com.sa"));
fona.setPreferredMode(2);
fona.setPreferredLTEMode(3);
fona.setOperatingBand("NB-IOT", 12);
fona.enableRTC(true);

But I'm getting no where and there is no registered network. I even tried Band (CAT-M) with no luck
I'm powering the shield from UNO with no external battery. 2 Green leds are led + blue led is flashing
Any Idea what am I doing wrong?

FONA basic test
Initializing....(May take several seconds)
Configuring to 9600 baud
Attempting to open comm with ATs
    ---> AT
    <--- AT
    ---> ATE0
    <--- ATE0
    ---> ATE0
    <--- OK
    ---> ATI
    <--- SIM7000G R1529

OK

    ---> AT+CPMS="SM","SM","SM"
    <--- +CPMS: 0,100,0,100,0,100
FONA is OK
Found SIM7000
    ---> AT+GSN
    <--- 869951031081155
Module IMEI: 869951031081155
    ---> AT+CFUN=1
    <--- OK
    ---> AT+CGDCONT=1,"IP","jawalnet.com.sa"
    <--- OK
    ---> AT+CNMP=2
    <--- OK
    ---> AT+CMNB=3
    <--- OK
    ---> AT+CBANDCFG="NB-IOT",12
    <--- OK
    ---> AT+CLTS=1
    <--- OK
    ---> AT&W
    <--- OK
-------------------------------------
[?] Print this menu
[a] Read the ADC; 2.8V max for SIM800/808, 0V-VBAT for SIM7000 shield
[b] Read supply voltage
[C] Read the SIM CCID
[U] Unlock SIM with PIN code
[i] Read signal strength (RSSI)
[n] Get network status
[1] Get network connection info
[c] Make phone Call
[A] Get call status
[h] Hang up phone
[p] Pick up phone
[N] Number of SMSs
[r] Read SMS #
[R] Read all SMS
[d] Delete SMS #
[s] Send SMS
[u] Send USSD
[y] Enable local time stamp (SIM800/808/70X0)
[Y] Enable NTP time sync (SIM800/808/70X0)
[t] Get network time
[G] Enable cellular data
[g] Disable cellular data
[l] Query GSMLOC (2G)
[O] Turn GPS on (SIM808/5320/7XX0)
[o] Turn GPS off (SIM808/5320/7XX0)
[L] Query GPS location (SIM808/5320/7XX0)

-------------------------------------

FONA> C
    ---> AT+CCID
    <--- 8996601730099550895f
SIM CCID = 8996601730099550895f
FONA> n
    ---> AT+CREG?
    <--- +CREG: 0,2
Network status 2: Not registered (searching)
FONA> l
    ---> AT+CIPGSMLOC=1,1
    <--- ERROR
Failed!
Fail code #2
FONA> n
    ---> AT+CREG?
    <--- +CREG: 0,2
Network status 2: Not registered (searching)
FONA>  n
---> AT+CREG?
<---
Network status 0: Not registered
FONA>


texts: How to connnect Arduino to Wemos D1 (send data)?

texts:
I made a project with an Arduino Uno, a 16x2 LCD display and a DS18B20 temperature sensor. It shows the temperature in the display:

I want to connect it to Internet so I got a Wemos D1 Mini. It works great: it send data through my router.

But I need to connect my project with the Wemos D1 Mini:

I think that I just need to send the data (temperatures grades) from my project to Wemos so then Wemos resolve it.

How can I do it?


texts:
So what I have done is followed all of the instructions in the following link:
https://learn.adafruit.com/adafruit-pygamer/setup
and have managed to get all the way up to https://learn.adafruit.com/adafruit-pygamer/arduino-libraries.
the board not has its own serial COM port and does work with a very basic blink example program which does not include any libraries at all. Shown on https://learn.adafruit.com/adafruit-pygamer/using-with-arduino-ide.
The next problem occuring is that now another error message is coming up within the code which I am not too sure it is trying to say:
Arduino\libraries\Adafruit_EPD\src\Adafruit_EPD.cpp: In member function 'void Adafruit_EPD::csHigh()':
and
libraries\Adafruit_EPD\src\Adafruit_EPD.cpp:649:12: error: 'class Adafruit_SPIDevice' has no member named 'endTransaction'.
Here is the github for the library I am using (its called adafruit arcada library), https://github.com/adafruit/Adafruit_Arcada.
Here is the code that I am trying to run using the adafruit_arcada library. I have checked it is installed in the right place in the arduino/library folder on the computer system.
Here is my code I am trying to run:
#include "Adafruit_Arcada.h"
Adafruit_Arcada arcada;

void setup(void) {
  Serial.begin(9600);
  Serial.print("Hello! Arcada TFT Test");

  // Start TFT and fill black
  if (!arcada.arcadaBegin()) {
    Serial.print("Failed to begin");
    while (1) delay(10);
  }
  arcada.displayBegin();

  // Turn on backlight
  arcada.setBacklight(255);
}

void loop() {
  arcada.display->fillScreen(ARCADA_RED);
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
  arcada.display2->fillScreen(ARCADA_RED);
#endif

  delay(100);

  arcada.display->fillScreen(ARCADA_GREEN);
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
  arcada.display2->fillScreen(ARCADA_GREEN);
#endif

  delay(100);

  arcada.display->fillScreen(ARCADA_BLUE);
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
  arcada.display2->fillScreen(ARCADA_BLUE);
#endif

  delay(100);

  arcada.display->fillScreen(ARCADA_BLACK);
#if defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
  arcada.display2->fillScreen(ARCADA_BLACK);
#endif

  delay(100);
}

However, something is telling me that something is either out of date or I might have potentially installed something wrong because in the guide that was sent there is 5 examples within the adafruit arcada library. But with the one I have installed, there is lots of examples. The guide itself was not updated too long ago (6th November 2020). The arcada library I have installed is the one installed from the library manger and the version of the library is 2.5.0 and the one on the tutorial on https://learn.adafruit.com/adafruit-pygamer/arduino-libraries seems to be saying the library is version 1.0.0. Perhaps the library is too update on my computer to date compared to the one in the guide which potentially might be more out of date than the one I have on my computer.


texts:
I have an arduino due sending and receiving data from a server using a GSM module (UBLOX SARA-U270). The issue I am having with it is that after a period of time working correctly the module stops replying or replies with random characters. It has been suggested to me that if I receive no reply to a command and continue to send commands it can cause issues like this and I need to take action before I send any more commands but I am unsure of what this action should be.

I was wondering is there a recommended action to be taken if I receive an empty response from an AT command to a GSM module after it has been previously working. I am currently working to find out the cause of the issue but I just wanted to know what should be done if an AT command that replies with nothing.

To try and correct this issue I have a function in place which if the module hasn't received data correctly for 1 minute will clear the modules setting using the AT+CFUN=1,1 command and resend all the setting to the module. My issue is that because the module is not replying, my AT+CFUN=1,1 command does nothing.  Physically removing the power to the module seems to be the only thing that will get it running correctly again.

And suggestions or advice would be greatly appreciated, Thanks guys.


texts: D1 mini does not resume operation as expected after deep sleep

texts:
I'm trying to get the D1 mini to return operation after ESP.deepsleep(). The code below compiles and gives the expected output for the first run. Five seconds after the announcement that that the device is going to sleep, there is a brief flash on the on board LED and I get a string of garbage on the serial monitor. Ideas for things to try would be appreciated.

// Testing d1 mini deep sleep
// D0 and RST are connected

/*  platformio.ini:
  [env:d1_mini]
  platform = espressif8266
  board = d1_mini
  framework = arduino
  monitor_speed = 115200
*/

#include <Arduino.h>

void blink();

void setup() {
  Serial.begin(115200);
  pinMode(D0, WAKEUP_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  blink();
  delay(1000);
  Serial.println("Going for some deep sleep");
  ESP.deepSleep(5e6); // 5e6 is 5 seconds
}

void blink() {
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
}

As you can guess I'm running this with platformio. The output on the serial monitor is:

stefan@Cameron ~/.../Projects/Deep sleep $ platformio device monitor --baud 115200
--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Going for some deep sleep
sl␀l��|␀�l�|␂␌␌␄�␄l�␌c|ǃ␃�␛�r�cd�c��gg�doo���␌cpp��$sd{d␛�{��o�c�gbx␀�

There is a blink of the LED on the first run, nothing there either after the apparent reset.


texts: What is the circular gold pad on arduino mega 2560 v2 and above?

texts:
Could someone point me to the documentation that describes the gold dot and surrounding gold circle on the front of my arduino mega v2 board. It is right above the ICSP header and reset button, and directly underneath the letter 'U' in the silk screened word 'communication'
I've not been able to find any reference to it anywhere. Is is a jumper, a test pad, RF pad???


texts:
I need to post an image to a website. Iam able to capture the image using OV7670 camera module. But don't know how to store and post the image to a website. I didn't get any idea to start this. Can anyone help me to do this.
I got the image capturing code and circuit from
 https://circuitdigest.com/microcontroller-projects/how-to-use-ov7670-camera-module-with-arduino

I have got the below components:

Arduino uno,
ESP 01 module,
OV7670


texts:
I've got an arduino due and I'm having great difficulty connecting to it. The problem seems to come and go, I was using it just fine only 3 or 4 hours ago but now it just won't connect. I've got the board set to the Arduino Due Native Port and the port set to the /dev/cu.usbmodem1421 (Arduino Due Native Port). Every time I try and upload the sketch however, it gives me this error:

    Arduino: 1.6.6 (Mac OS X), Board: "Arduino Due (Native USB Port)"

Sketch uses 10,316 bytes (1%) of program storage space. Maximum is 524,288 bytes.
processing.app.debug.RunnerException
    at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:130)
    at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)
    at processing.app.Sketch.upload(Sketch.java:1178)
    at processing.app.Sketch.exportApplet(Sketch.java:1152)
    at processing.app.Sketch.exportApplet(Sketch.java:1124)
    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2452)
    at java.lang.Thread.run(Thread.java:745)
Caused by: processing.app.SerialException: Error touching serial port '/dev/cu.usbmodem1421'.
    at processing.app.Serial.touchForCDCReset(Serial.java:87)
    at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:119)
    ... 6 more
Caused by: jssc.SerialPortException: Port name - /dev/cu.usbmodem1421; Method name - openPort(); Exception type - Port not found.
    at jssc.SerialPort.openPort(SerialPort.java:167)
    at processing.app.Serial.touchForCDCReset(Serial.java:81)
    ... 7 more
Error opening serial port '/dev/cu.usbmodem1421'. (Port not found)

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.


texts: Weird behavior when 2 functions are trying(?) to run at the same time

texts:
So I just finished my weak project which is a remote controlled car.

My problem is that when I press the button for going reverse (as an example) while the opposite action is currently in progress, going forwards the built_in led flashes in the exact same pattern when the Arduino is restarted (you know, pressing the reset button) and the car just stops and becomes responsive again after the led stops doing it's thing.

I believe the problem might be with the functions that I made, those being Forward(), Reverse(), Left(), Right(), Stop();

Note that if i press 5 (which translates to Stop() in this case) it is behaving as expected.

Here's the code: (functions at the bottom)

#include <IRremote.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

int IN1 = 12;
int IN2 = 11;
int IN3 = 10;
int IN4 = 9;

void setup()
{
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  Serial.begin(9600);

  irrecv.enableIRIn();
  irrecv.blink13(true);
}

void loop()
{
  if (irrecv.decode(&results)){
        Serial.println(results.value, HEX);
        switch(results.value){

          case 0xFF18E7: // in fata  - 2
          Forward();
          break;

          case 0xFF4AB5: // in spate - 8
          Reverse();
          break;

          case 0xFF10EF: //   stanga - 4
          Left();
          break;

          case 0xFF5AA5: //  dreapta - 6
          Right();
          break;

          case 0xFF38C7: //   stop  - 5
          Stop();
          break;

        }
        irrecv.resume();
  }
}

void Forward()
{
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  Serial.print("Motor 1 Forward");
  Serial.println();

  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  Serial.println("Motor 2 Forward");
  Serial.println();
}

void Reverse()
{
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  Serial.print("Motor 1 Reverse");
  Serial.println();

  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  Serial.println("Motor 2 Reverse");
  Serial.println();
}

void Left()
{
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  Serial.print("Motor 1 Reverse");
  Serial.println();

  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  Serial.println("Motor 2 Forward");
  Serial.println();
}

void Right()
{
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  Serial.print("Motor 1 Forward");
  Serial.println();

  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  Serial.println("Motor 2 Reverse");
  Serial.println();
}

void Stop()
{
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
    Serial.print("Motor 1 Stop");
    Serial.println();

    digitalWrite(IN3, LOW);
    digitalWrite(IN4, LOW);
    Serial.println("Motor 2 Stop");
    Serial.println();

}


texts: what is the max frequency of external interrupt for esp8266 arduino?

texts:
i am using esp7 with AttachInterrupt() (Arduino) to count incremental encoder. I need to know what is the maximum frequency of pulses that esp7 can acquire.
also, need to know what frequency atmega328 can go with interrupt handling for an incremental encoder. my encoder 1000ppr.


texts: Writing and reading an ID to/from an Arduino reliably

texts:
I need a way to both ID (a sketch/compiled hex) and later on, identify based on this ID the project that got uploaded to my Arduino microcontroller. As of right now, I have explored multiple options for storing the ID and reading the ID from the Arduino. The ID would be a custom string or later on multiple strings. Here are the 3 options I have been thinking about with their pros and cons:

Option 1:

Writing: A custom function that would be added to every sketch before compilation, containing the ID information and a serial connection setup

Reading: The function would dump the ID over the serial connection using a fixed baud, after this, the projects original serial and baud would be initialized. The microcontroller would need to be rebooted in order for the user to be able to read the ID from it.

Pros: Easy to implement.

Cons: Would require manual or software restart of the microcontroller in order to read the ID

Option 2:

Writing: writing the ID to the EEPROM

Reading: reading the ID from the EEPROM over the serial connection.

Pros: Would probably not interference with the original code

Cons: it wears the EEPROM, it might need its own function in the sketch to read the ID from the EEPROM thus making it a complicated Option1.

Option 3: Editing the HEX file to include a signature

Writing: add the ID to the hex file itself (hex editing), after compiling it.

Reading: dumping the hex file and decoding the string.

Pros: No baud or serial needed to be set?

Cons: Probably slow, can end up producing a bad hex file, hard to implement properly with larger ID-s and structures

Example data:

project="marlin2.1",
config="prusa",
version="8.80",
env1="pin2"

As said, the basic idea is storing an ID but I would late want to expand this and store more information like a struct.  This solution should be able to Target as many Arduino models as possible. I am looking for the best way that I might have missed to achieve this task or any recommendations.


texts: I am making a simple heater with the help of ESP8266 wemos d1 mini. Heaters will use 12V DC power suply and ESP8266 must turn the heater on and off with the help of 5V DC relax. I want to avoid the use of anything else then ESP8366 and relay. I will need 2 such relays. So the question is, can i control 5V output on ESP8266 ? Or do i need to find a 3V DC relay and use that ? If the latter is the case, can i get some ebay link to 3V DC relay ?


texts: Better way for connecting to Arduino pins to a sensor than jumper cable

texts:
Well I have an dht21 and arduino mega. Dht21 leads look like this

If I use jumper cable and soldering dht21 leads with jumper cable than plug-in my arduino's socket. it looks like this below image. It dont looks safe. If the device falls to the ground or something, the cables may come out of place or the place may loosen over time. If I solder the cables under the arduino, it will be hard and looks like ugly. What is the best solution to plug-in a sensor to arduino board.


texts:
I was wondering if I can use the Rx and Tx Hardware on the Arduino Uno and also add another Rx/Tx pins using SoftwareSerial at the same time ? cause I need two to communicate with two motor Controllers (Roboclaw controller)
Thx


texts:
How can I get the exact rotation of the Genuino 101? I would like to create a plumb rule.

I tried the example app with processing, Arduino/Genuino 101 CurieIMU Orientation Visualiser, but it didn't get the correct rotation. Sometimes the object on the screen has a different rotation from the board itself.


texts: Is possible to set a pin faster than digitalWrite?

texts:
I am currently using arduino library to logically set my digital pins high or low, but I just realized how slowly it actually sets those pins, which is especially problem as i am doing this in a ISR routine. Can't this be done faster by actually acessing the direct port, and setting the current pin?

How do I convert something like this

  digitalWrite(11, !digitalRead(11));

To something faster?

I am using a Arduino UNO..


texts: How do I connect a vibration sensor/switch to a breadboard?

texts:
I have the following vibration sensor:

It has one short/firm-er terminal and one long/flimsy terminal.  Now the shorter terminal slides easily into my breadboard but the flimsy one clearly does not.  A few related questions:

1) How do I go about connecting this to my breadboard (simply plugging it in doesn't work)?  Do I have to solder a wire onto the flimsy end?

2) Why is this switch manufactured this way (with a flimsy end)?

3) Is it right to assume that the longer end is positive (+) and the shorter end is negative (-)?

Thanks!


texts: Can I access individual pixels on my 16x2 LCD display

texts: I have a generic 16x2 LCD display connected to my Arduino.  I can use the standard LCD library to display characters, but are there way to turn on and of individual pixels?


texts: Serial input parallel output shift registers with arduino

texts:
I need a way to rewrite the switch case part in a more efficient way.

int y , x ;
byte dataArray[6];

void setup () {
   pinMode(8,OUTPUT);
   pinMode(11,OUTPUT);
   pinMode(12,OUTPUT);

   Serial.begin(9600);
   dataArray[0] = 0x3 ; //00000011
   dataArray[1] = 0x5 ; //00000101
   dataArray[2] = 0x9 ; //00001001
   dataArray[3] = 0x11; //00010001
   dataArray[4] = 0x21; //00100001
   dataArray[5] = 0x41; //01000001
}

void loop () {
   while (Serial.available()>0) {
     y = Serial.read();
     x = Serial.read();
     switch ( x ) {
     case 1:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,dataArray[y]);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;

     case 2:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,dataArray[y]);
        shiftOut(11,12,LSBFIRST,0);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;

     case 3:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,dataArray[y]);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;

      case 4:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,dataArray[y]);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;

      case 5:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,dataArray[y]);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;

      case 6:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,dataArray[y]);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;

     default:
        digitalWrite(8,LOW);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        shiftOut(11,12,LSBFIRST,0);
        digitalWrite(8,HIGH);
        delay(10);
        digitalWrite(8,LOW);
     break;
     }
   }
 }


texts:
I am working on a project, trying to construct an 80 button keypad. My problem is how to multiplex it so that i only feed the arduino with two sets of BCD or binary(whichever is easier) which are supposed to drive a 75 led display board simultaneously with a pair of 7 segments. The led display board is remote, which means i should drive the boards serially. The other 5 buttons remaining out of 80 are for other functions such as clear last number etc.
Please help!


texts:
I'm planning an ESP8266 project, where I connect a soil moisture sensor to an ESP8266 chip (only the chip, not a board like the NodeMCU) (Analog Input). Since the whole setup will be battery-powered, I'm trying to minimize the quiescent current as much as possible. Now my question is: is there a quiescent current through the analog input pin of the ESP8266? and if yes, how large is this current approximately?

Thanks in advance


texts: How do I install the latest Arduino IDE on Ubuntu 14.04LTS?

texts:
What I've tried:

I downloaded the package for 1.6.7 on Ubuntu 14.04 LTS but when I open it no matter what I try it will not start.
I installed 1.0.5 from the Ubuntu Software Center. I tried to update it but found no solution.

UPDATE: I found my answer in talamaki's answer on that other question linked above.


texts:
Just a quick question. Picking up some stepper motors, but confused at what voltage/current things are running off.

Ordering:
2 x Stepper Motor
2 x EasyDriver

An article says

  You need some 12V source to the EasyDriver (the motor in this article
  is 12V) - This will be powering the stepper - Im using a 12V adapter -
  similar to the one in the illustration. Just make sure it is rated at
  least 750ma - A higher rating is better, and just means it wont burn
  out.

So does that mean if I got a plug which is regulated 12V 1A and powered the Arduino from that I could power a rail with VIN pin and that would safely supply the EasyDrivers? And I could then use the 5V pin to power everything else?

Just don't want to break anything! Thanks


texts: Arduino Command Line Interface - How to change boardsmanager.additional.urls

texts:
I am building a Travis CI job to test my Arduino Library and it needs to install external board definitions.

Is there a way that I can set the boardsmanager.additional.urls from the command prompt like it would have been done in the Preferences window?

Or should I create preferences.txt file? (If so where does that live in a Linux environment)


texts:
On my first big Arduino-project I made a game using the following Arduino's and the I2C-protocol:

1x Mega as master
4x Mega as slave
2x Uno as slave

The Arduino's controll a physical game where the players have to push 96 different buttons, according to how certain lights are controlled by relays. The two uno's are used for a MP3-shield and a timer.

My code might not be perfect at all, but I'm happy with how it works. The only problem is that sometimes my master freezes. This is on different moments, but always when the master processes multiple I2C-communications. Sometimes it completes the whole game without problem, but other times it freezes at different moments.

I used a 1ms delay at the end of the loop on all arduino's, because it looked like this might make the connection most stable. The I2C-cables are up to about 1m long, I can't make them shorter. I added 5K1-resesistors from the 5v-line of the master-Mega on the SDA and SCL line. Alle buttons and relays in the game are connected to seperate power sources and don't use the internal pullups.

The code is quite long, so I uploaded the code of the master and the code of 1 mega slave to Github: https://github.com/mrcbrgrs/Arduino-mega-buttons-game. Some comments might be in Dutch, sorry for that.

Who has an idea how I can stop the Mega from freezing?


texts: I have a control module that accepts 8V PWM signals.  My goal is to send a 500Hz PWM signal from an Arduino to an 8V PWM input on the control module.  Looks like everything generated from the Arduino is 5V.  Is there a way to generate an 8V PWM output or method of manipulating that signal to reach 8V?


texts:
I wrote an app that listens on the network for command over UDP and sends back an answer. Whatever I try to put into my answer never get sent. The string is always empty. The following code prints a length of 0:

String result;
for(uint8_t i =0; i <6; i++)
{
    result.concat( GetInput(i));
    if(i < 5)
       result.concat(':');
}
    result = "WTF???";
    Serial.print("GetAllOutput => ");
    Serial.println(result.length());
    return result;

I've been trying to debug and I can't figure what is going on. Initializing result to "" doesn't change anything.


texts: Does HC-05 module buffers the data received?

texts:
I am using HC-05 bluetooth module for sending large data(80-100KByte) from my phone to arduino-uno.
I had found that this module has a flash chip of 8Mbit  (SST39VF800A) but the datasheet of HC-05 has nothing about buffering of the data to be transmitted or data received.
I need clarity about the buffering of data so that I can change the data rate from the phone for better communication.


texts: How to connect Sparkfun M6E Nano UHF Rfid reader and ESP8266 NodeMCU 0.1

texts: I am using an ESP8266 NodeMCU v0.1 and Sparkfun M6E Nano UHF Rfid reader. How to connect NodeMCU to M6E Nano UHF Rfid reader?


texts: Mechanical requirements for Arduino compatibility

texts:
If I want to design an Arduino-compatible board I guess I'll have to use the same outline, and connector positions to fit existing enclosures. (Beats me why they didn't choose a simple rectangular board, which would have been cheaper.) But I wonder if the ICSP header's position is standardized. Some enclosures have a hole above it, but many don't. Can I move the ICSP header to another position?

(Can somebody add a "compatibility" tag? Thanks. Also, neither "mechanical" nor "board" nor "layout" seem to exist as tags. Feel free to improve my generic tagging.)
The "shield" tag was suggested, but this isn't about shields, it's about the ICSP header.


texts:
I'm new to Arduino, electronics, and this forum.

I have made up a little project that connects an HC-SR04 ultrasonic range detector, and displays the distance on a 4 digit, 7 segment LED display.

When I have it plugged into my laptop for power, it runs beautifully on an Uno board.

But I want to mount all this in a Nerf gun (Nerf N-Strike Elite Firestrike) using a Nano board.

The Nerf gun has a built in "laser" (red light) that is powered by 2 x AAA batteries, which makes 3 V, I think. I want to rig this up so that pulling the laser/light trigger also triggers the range detector and display.

I want to run the range sensor and the display off the Nerf guns batteries, but they both use 5 V. Is there a way to do this? Or do I need a separate 5 V power supply?


texts:
int scvVal = 6;
int drvVal = 9;
int sensorVal = A1;
void setup() {
    Serial.begin(9600);
    pinMode(6, OUTPUT);
    pinMode(9, OUTPUT);
 }
void loop(){
 sensorVal = analogRead(A1);

 Serial.print("Sensor Value: ");
 Serial.print(sensorVal);

 float voltage = (sensorVal*5.0)/1024.0;
    Serial.print("Volts: ");
    Serial.print(voltage);

 float pressure_pascal = (400.0*((float)voltage-0.5))*1000000.0;
 float pressure_bar = pressure_pascal/10e5;
   Serial.print("Pressure = ");
   Serial.print(pressure_bar);
   Serial.println(" bars");
   Serial.print("Pressure = ");
   {
 for(int a = 255; a>=0;a--)
 {
   analogWrite(6,a);
 if (pressure_bar = 1600){
   analogWrite (6, a);
 if (pressure_bar > 1600){
   analogWrite (6, a);
 }
 for(int a = 0; a<256; a++)
 {
  analogWrite(6, a);
 {
 if(pressure_bar < 1600){
  analogWrite (6, a);
 }
 for(int b = 255; b>=0;b--)
 {
 analogWrite(9, b);
 {
 if (pressure_bar == 1600){
   analogWrite (9, b);
 if(pressure_bar < 1600){
   analogWrite (9, b);
}
 for(int b = 0; b<256; b++)
 {
   analogWrite(9, b);
 {
if (pressure_bar > 1600){
   analogWrite (9, b);
   }
  }


texts: Digispark uploading not working in KDE Neon (Linux)

texts:
I am using KDE Neon and have downloaded the Arduino IDE via the Snap store. It worked well with the ESP8266 and other Arduions. But when I tried to upload a simple sketch or an example sketch to my Digispark, I get an error message. I have selected the right Board and the micronucleus programmer. I have also installed libusb. But I always get the following error message:
/home/myusername/snap/arduino/41/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus: error while loading shared libraries: libusb-0.1.so.4: cannot open shared object file: No such file or directory


texts: Can I use a HC-05 and a GPS without a breadboard on a Arduino Uno?

texts:
I was wondering if I can use a GPS (in my case a U-BLOX) and a hc-05 at the same time connected to a arduino uno without a breadboard? I have tried my GPS on the arduino uno alone and it works very good. Now my question is, can I add a hc-05 on the board directly and put the VCC on the empty 5v?

I put together a schematic of what I had in mind below:

Would this schematic work or would I need a breadboard?


texts: Arduino Due: ADC gain adjustment problem

texts:
I want to increase gain of the ADC channel. To achieve this I'm using adc_set_channel_input_gain function from adc.h. Here is the entire sketch:

const byte aPin = A6;

void setup() {
  analogReadResolution(12);

  // Configure ADC gain
  // Arduino/hardware/arduino/sam/system/libsam/include/adc.h
  adc_channel_num_t ch = (adc_channel_num_t)(g_APinDescription[aPin].ulADCChannelNumber);
  adc_set_channel_input_gain(ADC, ch, ADC_GAINVALUE_3);
  Serial.begin(9600);

  // Delay for serial stabilization
  Serial.println("Begin.");
  delay(2000);
}

void loop() {
  int analog = analogRead(aPin);
  Serial.println(analog);
  delay(500);
}

The problem is that output values are not depending on the gain value.


texts: im planing to make my very own arduino design based on the Arduino PRO mini. I picked this board instead of the UNO mostly because it's way more simpler compared with the UNO since the USB-to-Serial part is missing. As many of you know the MINI uses the 328P-AU which is the SMD version of the 328P however since the AU version is too small for me i would like to use the PU (UNO's chip) instead. From the datasheets the only difference is a small change in the pins position. And the one million dollar question is: Is there any difference on those 2 chips? If i try to use the same design just with the PU model is it gonna work?


texts:
I'm trying to understand the implementation of attachInterrupt. For LOW, CHANGE, RISING and FALLING it seems simple enough; it sets some chip-specific registers and stores the given callback in intFunc, then invokes the callback from inside its own thin wrapper callback.

But the documentation says that on the Arduino Due, Zero and MKR1000, it can also accept HIGH. I can't find any reference to this in the code, and I can see that HIGH (= 0x01) and CHANGE (= 1) would be indistinguishable after preprocessing, so I can only assume a macro is involved somewhere, but I can't see one in the source.

How does the library implement this? Where is the code?


texts: Powering an Arduino Pro Mini directly from a LiPo

texts: I've recently purchased an Arduino Pro Mini, 3.3V version. I've planned to use it in a diy remote: I've empty a ps2 remote, just left the buttons, and the board will be inside. The remote will be wireless: I use an xbee, which also fit inside the ps2 controller. To power it, I use a one cell Lipo, which will empower the Arduino and the XBee, here comes my issue: As you've seen, there will be many things an a single ps2 controller, so I try to minimize connections and external components. But, the XBee will take more than the maximum 150mA provided by internal regulator of the Arduino. So, either I use an external regulator, or I directly plug the lipo in the VCC pin if the Arduino. Can the board survive? If the voltage is greater than 3.3V, will it damage the board?


texts: Power supply change change gps readings?

texts:
I was powering a GPS Sensor from the 3v3 pin of a raspberry pi and my reading for my GPS sensor had some strange symbols in the mix, but when i switched to the 3v3 on the arduino, my reading came back to normal. This wasted several hours of my time.

Any idea why i would get weird readings when using a different power source?? (even though it is the same voltage)

Note: Both the raspberry pi and the arduino are getting their power form the USB that is connected to my PC.


texts: How to wire a small quadcopter drone with resistor and breadboard (If possible)?

texts:
http://www.instructables.com/id/SpeechVoice-Controlled-Arduino-Drone/?ALLSTEPS

Hi guys!

I am following this project but I do however not have all the items currently at home so I was thinking if there is an optional solution.

I do not have any resistors or a breadboard currently at home so I was wondering if there is an optional solution.

What I have is, arduino uno + arduino mini and hc-05 bluetooth and of course 4 small drone motors. On top of this I have TIP-122 transistors and a l293d motor driver.

Could I somehow make it work with that considering i do not have resistors or a breadboard at home?

I know how to solder of course so if I need to solder wires that is not a problem. I appreciate any help very much!!


texts: can I create an on/off switch for my Arduino using the reset pin?

texts: If i connect a switch to the reset pin, can I create an effective way of turning off the Arduino (overnight) without removing its power supply?


texts:
I am new to Arduino. I am learning from Arduino Cookbook. I was using tinkercad.com for running my Arduino code. But it is not working.
The Serial monitor should show the key which I have pressed on the keypad.
I think there is some syntactical error in the code, I believe the connection is all right.
Any suggestion will be appreciated.
Please look into this:

const char keymap[4][4]={
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
 };
const int rpin[]={9,8,7,6};
const int cpin[]={5,4,3,2};
void setup()
{
  Serial.begin(9600);
  Serial.println("Program starting");//for debugging purpose and canbe removed later
  for(int i=0;i<4;i++)
  {
    pinMode(rpin[i],INPUT);
    digitalWrite(rpin[i],HIGH);
  }
  for(int j=0;j<4;j++)
  {
    pinMode(cpin[j],INPUT);
    digitalWrite(cpin[j],HIGH);
  }
}
void loop()
{
  char key=getkey();
  if(key!=0)
  {
   Serial.println(key);
  }
}
char getkey()
{
  char key=0;
  for(int i=0;i<4;i++)
  {
    digitalWrite(rpin[i],LOW);
    for(int j=0;j<4;j++)
    {
      if (digitalRead(cpin[j])==LOW)
      key=keymap[i][j];
    }
    digitalWrite(rpin[i],HIGH);
  }
  return key;
}

and the connection pic:

update 1:


texts: possible to preform VIO from two cameras/imu's on a dual-core esp32?

texts:
Like the title says, I want to take in the synchronised data from two NXP breakout boards and two Ueye 1220LE Cameras, and use VIO to fuse their data and get positions for both setups. Alot of people have suggested running things like SLAM, which is simmilar to VIO, on something stronger than an arduino, some specifically suggested using a version of a raspi.

Now, I know that raspi's are stronger than an esp-32, but esp-32's are stronger than arduino's, and since raspi's are more expensive than an esp-32 and I need wifi capabilities, before I bought a raspi, I was wondering If it would be possible to preform this on my dual core esp-32. And if the raspi wasnt overkill and I needed all the processing power I could get, what version should I use? the zero? The 3.0? The 4.0? Do let me know. Thank you all. =)


texts:
Using the Arduino Due on a project, I have found that I commonly run into the issue Flash Page is Locked when attempting to upload.

I have used the library write functions of DueFlashStorage that lock and unlock addresses on each write. I believe a combination of this locking/unlocking and power loss during writes has caused my woes. This lib has added functions that avoid locking/unlocking memory on each write so this problem could be averted in that way.

My question is, are there other common actions that can cause the flash to lock? If I ran blink on a Due for a long period of time power cycling it randomly would the same error eventually occur? This seems to be a common issue with the due but beyond this library I have not found other causes.


texts: Hibernate Arduino for 12hrs with rtc1302 module

texts: ok, Good morning, guys, with a data acquisition project, in this, I get data every 12 hours, even if it's only 12 hours, the arduino gets connected directly, and it's being powered by a 9v battery, for longer life of this battery, to try to hibernate the arduino with real time, using the real time clock 1302, you could help me to make a code for this clock, for I have never used it before! thank you


texts: How can I read this digital pin for Nano by using AVR's Atmel Studo?

texts:
How can I read digital pin 6 in AVR?

I set the pin as input as follows:

DDRD = B0100000; //this will set pin 6 as input

But how can I now digital read this pin?:

Another way of putting it: how can I convert this Arduino code to be used in Atmel Studio?:

digitalRead(DATA_PIN);

Edit:

while (1) {

        unsigned long data = 0;//32 bit variable to store encoder data

        for (int i=0; i<25; i++) {//25 bit encoder data, first 12 bit is CCW count data and the rest 13 bit is the position angle data
        data <<= 1;//shift all read data left one bit
        PORTD &= ~(1 << 5);//clock pin goes low
        _delay_us(2);
        PORTD |= (1 << 5);//clock pin goes high
        _delay_us(2);

        data |= digitalRead(DATA_PIN);//cat the new read bit to the whole read data
        }

I want to use usual C code for AVR instead of using digitalRead above. data is an 32 bit array storing 25 bit encoder data. It is bit by bit filled by digitalRaed.

I think I found it:

while (1) {

        unsigned long data = 0;//32 bit variable to store encoder data
        uint8_t val;

        for (int i=0; i<25; i++) {//25 bit encoder data, first 12 bit is CCW count data and the rest 13 bit is the position angle data
        data <<= 1;//shift all read data left one bit
        PORTD &= ~(1 << 5);//clock pin goes low
        _delay_us(2);
        PORTD |= (1 << 5);//clock pin goes high
        _delay_us(2);

        if ( (PIND & (1 << PIND6)) == (1 << PIND6) ) {
            val = 1;
            } else {
            val = 0;
        }

        data |= val;//cat the new read bit to the whole read data
        }


texts:
I use an ESP32 to open an access point and listen for TCP connections over a WiFiServer object.

When I get a client on the server I want to know when it has disconnected.

Currently I have a simple piece of code on both the client and the server side. I connect using a TcpClient in C#.

When I call client.close() on the client side, the client.connected() loop on the server just continues forever.

Here is the ESP code:

void setup()
{
   WiFi.mode(WIFI_AP);

   WiFi.softAP("test");

   WiFi.softAPConfig(IPAddress(192, 168, 4, 1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255, 0));

   Serial.println(WiFi.localIP());

   server.begin();
}

void loop()
{
    while (!client)
    {
        client = server.available();

        delay(10);
    }

    while (client.connected())
    {
        Serial.println("ok");

        delay(1000);

        client.read();
    }
}

C# code:

static void Main(string[] args)
{
     TcpClient client = new TcpClient("192.168.4.1", 222);

     client.Close();
}


texts: Standalone Arduino with ATMEGA328P / Serial working, but serial programming not (only once after buning bootloader)

texts:
For my master thesis I've designed a board with an ATMEGA328P-AU as micro controller.

As I want to use some libraries and I like the simplicity, I want to use "Arduino" to program it.
Everything works fine to a point:
I took an Arduino Uno and uploaded the "ArduinoISP" sketch.
I connected the ISP pins and burned the bootloader with board set to "Arduino Duemilanove / Diecimila" - got the message, bootloader burned.
I disconnected the ISP pins, took the ATMEGA out of its socket on the UNO board and connected the serial pins.
Here comes the problem I cant figure out:
Once I have done a above procedure I can upload a sketch and Serial communication is working. But I can only upload it once! The second time (no matter if during the same power-up or at another time) I push the upload sketch button, I get no response for several minutes (I once waited up to 10min to confirm there is nothing coming anymore :)). If I unplug either USB or the TX/RX cables I get the error (or for the USB cable something similar):

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

When I upload the bootloader again I can once again upload a sketch same as before. Then the same problem happens again.
I checked several question on Stackexchange already (specially all points in this one here) and googled the problem, but until now I am not able to find a solution.
As you can imagine it is quite annoying to always unplug the RX/TX cable and hook up the ISP cable again and burn the bootloader.
So my question: What could cause this problem and how can I solve it?
Btw. I am using the Arduino software version I'm using is 1.6.9


texts: error in uploading code to arduino uno r3

texts:
i bought genuino uno uno r3. installed ide on win 10 IDE version 1.8.9.few days ago it was working fine.two days ago it stoped uploading code with error..

"Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

Sketch uses 930 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:C:\Users\Kashif\AppData\Local\Temp\arduino_build_499702/Blink.ino.hex:i

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

     Using Port                    : COM4
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20

avrdude done.  Thank you.

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences."
note: it is blink code,
i tried all possible option (uninstalled driver,ide and checking ports etc) nothing worked for me. even tried a method described in a thread with test scripts to check if my usb chip atmega-u2 and micro controller are working correctly they are both okay.and also double check it on an other pc but no luck.this problem begin when i connect my friend arduino uno with my pc after that i could not upload any sketch to my arduino .but that arduino is working without any problem on that pc and cable without any problem.
arduino is showingup in IDE tools/board and port is also showing up.when i try to upload sketch to arduino tx and rx led also blink but right after that this error shows up in IDE.any help will be appreciated thanks,


texts: Motor shield and Arduino Led not turning on when connected to laptop and Arduino is heating up

texts: I have a problem like that....As I connect my Arduino to the laptop with the usb cable and the motor shield connected, my led won't turn on neither does the led on the Arduino. And the small chip like thingy beside the usb cable also heats up really bad...please help!


texts:
Sim800L's library can not compile on Arduino Due. Is there any way to create a library for Arduino Due?

#include <Sim800l.h>
#include <SoftwareSerial.h>

Sim800l Sim800l;
char* text;
char* number;
bool error;

void setup(){
    Sim800l.begin();
    text = "Testing Sms";
    number = "2926451386";
    error = Sim800l.sendSms(number,text);
    // OR
    //Sim800l.sendSms("+540111111111","the text go here")
}

void loop(){
    //do nothing
}

I guess that the problem is the software serial library, too. However, I don't know how to replace this library for Arduino Due.

Any help appreciated.


texts: What functions are disabled with noInterrupts()?

texts:
The Arduino page for noInterrupts() says:

  Some functions will not work while interrupts are disabled, and incoming communication may be ignored.

While it may not be possible to give a complete listing of what would be disabled, having an incomplete list of functions which definitely are disabled would be useful.

I was thinking of calling a DHT sensor library which internally uses millis() while interrupts were disabled to avoid both bit banging and servicing interrupts simultaneously if possible (the interrupt would hold and be processed after).

Which functions are definitely disabled when interrupts are disabled?

What about incoming communication? My guess is that it would be slightly worse on the ATmega32U4 (eg Leonardo) as the one processor does USB and everything else as well.


texts: What is the variable pot exactly for in arduino sensors boards?

texts:
I have a MQ135 gas sensor from keyestudio, and a light sensor from a chinese manufacturer. They are both on their own PCB with resistors, small eeprom and a variable pot.

Turning the variable pot fine tune the calibration of the sensor, but is there anyone who could explain me exactly what is it doing? Does it have an effect on signal amplification? or only adding more or less resistance to the signal output by the light sensor in order to fine tune the reading ?


texts:
Using an Arduino Nano and a current transformer  (CT), I'm trying to sense the current flowing through a 120 V 60 Hz line.

Circuit

CT outputs 0-1&nbsp;V according to its specifications. This output is biased AREF/2 = 2.5 V.

analogRead Values

The x-axis represents the index number of the ADC sample, while the y-axis represent the ADC value (0-1024). Sampling rate is about 9 kHz. Peak-to-peak difference is about 1026 samples.

Is this waveform what you would expect from the CT? Why are there regions where the values are flat, rather than varying continuously?

Furthermore, if we look at the curve part of the plot, why is Arduino reading values both above 512 and below 512 alternately? It reads a value above 512, then a value below 512, then a value above 512 and so on.

Time taken for an analogRead was measured to be 110 microseconds for my setup and there are 1026 samples between the waveform peaks. That means there will be about 9 peaks in 1 second, although I would expect 60 peaks since we are sensing a 60 Hz line. What do you make out of this? There's a capacitor, C1, in the circuit, would it have anything to do with this?

Are these analogRead values suitable to be used to calculate the RMS voltage, and hence the RMS current passing through the wire being sensed? The final goal of this is to calculate the power usage after determining the RMS current flowing through the wire.

Sketch used to get values for plot

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

void loop() {
   double sensorValue = analogRead(1);
   Serial.println(sensorValue)
}

Actual analogRead data points in the bump regions

487
534
487
535
488
537
484
536
487
538
486
536
484
540
484
539
485
540
483
540
484
541
481
539
481
540
484
540
480
543
484
539
481
540
484
541
486
542
485
538
485
538
488
535
489
534
491
530
491
529
493
531
492
526
498
526
499
524
499
520
503
518
502
518
507

Plot of analogRead values

The analogRead values are now stored in a buffer before being transmitted over Serial. There are now 55 ADC datapoints making up 1 period. Considering the analogRead time is 110 µs, each cycle takes 6.05 ms, giving us a frequency of 165 Hz! What may have gone wrong?

void loop() {
    double sensorValue = analogRead(1);
    char buf[32];

    dtostrf(sensorValue, 8, 2, buf);
    value = buf;

    if (stop == 0) {
        if (i < 10000) {
            message += ',';
            message += value;
            i++;
        }
        else {
            stop = 1;
            Serial.println(message);
        }
    }
}


texts:
I am working with a combination of Teensy++ 2.0 and Sparkfun Bluetooth Modem.

The Arduino program, inside the loop, continuously reads a sensor value. If the value read is above a threshold, the Arduino transmits a "CHARACTER" over Bluetooth for any receiver.

So, inside the same loop, I check for the availability of data, and print the received character. The problem is, the received character is not what is transmitted. The received character is some garbage value.

Please let me know what is going wrong here.

#include <SoftwareSerial.h>

#define bluetooth Serial1

#define BAUDRATE 9600

// Analog read 0 is pin 38
int sensorValue = 0;
int SENSOR_ANALOG_READ_PIN = 0;
int LED = 17;

char toPrint = '\0';
bool sent = false;
char state = ' ';

void setup()
{

// put your setup code here, to run once:

  pinMode(LED, OUTPUT);

  Serial.begin(BAUDRATE);

  bluetooth.begin(BAUDRATE);

}

void loop() {

  // put your main code here, to run repeatedly:

  sensorValue = analogRead(SENSOR_ANALOG_READ_PIN);

  if(value > 500)

  {
      //Serial.println("HIGH");

      digitalWrite(LED, HIGH);

      bluetooth.write(state);

      bluetooth.flush();

      sent = true;

      digitalWrite(LED, LOW);

  }

  else

  {

      delay(100);

  }

  ///////////////////////////////////////////////////////////
  if((bluetooth.available()) && (sent == true))

  {

        Serial.println("printing : ");

        toPrint = (char)bluetooth.read();

        Serial.println((char)toPrint);

        sent = false;

   }

}

Output:

printing :
1
printing :
ˆ
printing :
Ì
printing :
¦
printing :
È
printing :
Ì
printing :
Ì
printing :


texts:
Background:
I am using a Teensy 3.6 to data log over a dozen sensors. I am printing to Serial1 for local Serial access, Serial3 for remote access (via xbee, same data is on Serial1 as on Serail3, just different physical connection) as well as datalog to SDCard (CSV format). My code is expanding and is incredibly repetitive, and I am looking for a more efficient way of writing the following. I am trying to move a lot of the rest of my code to classes using this and this tutorial, but I'm not sure this is the best option for the datalogging as there are many more strings in this portion.
The variables we are dealing with:

Live sensor value (eOilTempF)
A visual flag for if the sensor is out of bounds (checkEngine)
A auditory alarm if it's further out of bounds (eOilTempAlarm)
The max value we've recorded (engineOilStats.maximum())
The minimum value (engineOilStats.minimum())

As well as all the little bits to make it attractive and human readable for the Serial stuff.
Code:
Local serial:
Serial.print("Engine Oil Temp:\t");
Serial.print(eOilTempF);
Serial.print("F\t   ");
Serial.print("Flag: ");
Serial.print(checkEngine);
Serial.print("\t Alarm:");
Serial.print(eOilTempAlarm);
Serial.print("\tMAX: ");
Serial.print(engineOilStats.maximum());
Serial.print(" F");
Serial.print("\t\t\t\tAVG: ");
Serial.print(engineOilStats.average());
Serial.println(" F");

Xbee serial:
Serial3.print("Engine Oil Temp:\t");
Serial3.print(eOilTempF);
Serial3.print("F\t   ");
Serial3.print("Flag: ");
Serial3.print(checkEngine);
Serial3.print("\t Alarm:");
Serial3.print(eOilTempAlarm);
Serial3.print("\tMAX: ");
Serial3.print(engineOilStats.maximum());
Serial3.print(" F");
Serial3.print("\t\t\t\tAVG: ");
Serial3.print(engineOilStats.average());
Serial3.println(" F");

SD Card Logging:
logfile.print(eOilTempF);
logfile.print(",");
logfile.print(checkEngine);
logfile.print(",");
logfile.print(engineOilStats.maximum());
logfile.print(",");
logfile.print(engineOilStats.average());
logfile.print(",");

tl;dr
My datalogging section of my sketch is 567 lines of mostly repeated code, and I'm new at programming and need some tutorials/terms to google to make it more effecient.


texts: How to add Ultrasonic Sensor to the board?

texts:
I am making an RC car , have combined the Arduino UNO R3 with the AR 293d, and pluged in the HC-SR04 sensor to the SRO4 hole at the left top corner in the below graph. However, besides one sensor  I would like to add three more HC-SR04 sensor.

Reference:
http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/

The problems are

1) is the board sufficient to plug three more sensor ?

2) or what extra board I need if not sufficient and how to combine those board

2) also, can I plug in other hole?

Thanks for helping

Update: breadboard connection

So I have to get a stuff like this?

http://www.tandyonline.co.uk/small-solderless-breadboard.html

and one more question, sorry for begin newbie, there are many holes on breadboard, which hole I should connect those three sensor on it, and the hold I should connect the breadboard with the AR-293D board?

And for programming, is there any way to get the pin at the breadboard as I have read some program before, the pin is assign with a number?

Thanks again for helping.


texts: Arduino Micro blue light dimms and turns off when I plug in my circuit

texts:
I have a PING Ultrasonic Sensor, Adafruit Absolute Orientation Sensor, and a Continuous rotation servo. All pins are connected to an Arduino Micro. However because the micro only has one 5V output, I used a rail from a breadboard. I connected the + & - leads from all the devices to the rail and then plugged in two leads connecting 5V and GND from the Micro to the rail. My goal was two send power from the Arduino Micro down the rail to all three devices.

I plugged in the Micro, and instead of seeing green lights on the sensor (powered on), the blue light on the Micro turned off and the servo twitched. I have no idea why. Do I need external power for the 5V?


texts:
I recently bought a breakout board for an AD9833 waveform generator, but discovered pretty quickly that VDD and GND were shorted out. Assuming that there must have been some manufacturing defect, I checked the board over but could see nothing unusual. I got hold of a replacement module and exactly the same issue presented itself. I simply can't figure out what the problem is. Does anyone know of an issue with these boards, or am I just missing something blindingly obvious? Any thoughts much appreciated.

Thanks for the responses. I discovered the short initially by connecting power from an Arduino and seeing the Uno's LED turn off. I then tested with a DMM and confirmed the short. Thinking that I could have damaged the module, I got another one and this time tested with a DMM first, with the same result. The resistance reads as 0.4 ohms (the resistance of my probes) so I am convinced that it is a dead short. I've checked the soldering carefully and can see no bridges etc. This was admittedly a cheap product from eBay, but I'm surprised that two in a row had the same issue. I could just buy a different version, but this type seemed the most convenient for prototyping.
Pictures as requested:


texts: The STM32YYXX chip series is not defined in boards.txt? How can I solve this? I am using Windows 10 with Arduino IDE 1.6.6


texts:
I have paired 2 BT modules HC-05 and HC-06. When I write something through Serial Monitor and send it from HC-05 to HC-06, everything works well. But when I send continuous data through loop, HC-06 receives only specific amount and then just stops! Is it because of BT module, or there is something else?
My code for HC-05:

#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3);
void setup()
{
    Serial.begin(9600);
    BTserial.begin(38400);
}

void loop()
{
        BTserial.write('1');
}

Code for HC-06:

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3);
void setup()
{
    Serial.begin(9600);
    BTSerial.begin(9600);
}
void loop()
{
if (BTSerial.available())
    Serial.write(BTSerial.read());
}

Baud rates are good.
Thanks!


texts: Function declared in another file not recognized (undefined reference to)

texts:
I am making a multi-file arduino project, but the compiler can't recognize a function.
I am using the arduino-cli version 0.10.0
This is the error I received
undefined reference to pin_init() collect2.exe: error: ld returned 1 exit status Error during build: exit status 1
This is the command:
arduino-cli compile -b arduino:avr:uno C:\Users\Cioccarelli\Desktop\transmitterCopy\main

main.ino:
#include "C:\Users\Cioccarelli\Desktop\transmitter\automation\automation.h"

void setup() {
    pin_init();
}

void loop() {}

automation.h:
#pragma once

// This is where the components input pins are stored, they are put here by the add_pin function
byte pinSetup[0];
byte pinSetupSize = 0;

// This function is called in the setup() and it initializes every pin listed in pinSetup[] as input
void pin_init();

automation.cpp:
#include "C:\Users\Cioccarelli\Desktop\transmitter\automation\automation.h"

extern pinSetup;
extern pinSetupSize;

void pin_init() {
    for (int i = 0; i < pinSetupSize; i++)
        pinMode(i, INPUT);
}

I think this issue might have to do with the fact that I don't completely understand file inclusion, but I haven't found anything useful in my research

Update: today I rebuilt the project with different names and I cut everything which wasn't related to the problem, in hope to identify it.
new main:
#include "C:\Arduino\transmitter\nightmare\nightmare.h"

void setup() {
    pin_init();
}

void loop() {}

new automation.h (nightmare.h):
#pragma once

// This function is called in the setup() and it initializes every pin listed
//in pinSetup[] as input
void pin_init();

new automation.cpp (nightmare.cpp):
#include "C:\Arduino\transmitter\nightmare\nightmare.h"

void pin_init() {}

new file structure:

I also made a copy and made some changes so it could become a C++ file
(substituting the setup() with main() and replace every "byte" type with "int")
I then put it in Visual studio, it compiled perfectly.
The arduino IDE gives the same error


texts: How to reset an Arduino with node-serial?

texts:
I was reading about using an Arduino with a Makefile. In the Makefile-Arduino project there is a reference to the Python serial library required to reset the board.
Looking into the usage of PySerial to reset the board, there is some reference to DTR or here

What is DTR?
How to control this bit with node-serial and reset the Arduino?


texts: Migrating an Arduino Project to Beetle Bluno

texts:
So I have a working project with Arduino Uno. I now want to migrate it to the Beetle Bluno. I tried running the code on the Beetle and it does work. I cannot seem to get the Bluetooth to work though. The code is below:

#include <Bounce2.h>
#include <SoftwareSerial.h>
//#include <Wire.h>
//SoftwareSerial bluetooth_port(10, 11);

// Connect each button with one connection
// to GND and the other to a digital pin.
const byte buttonPinBLE1 = 2;
const byte buttonPinBLE2 = 3;

class Button{

  private:

    byte m_buttonPin;
    byte m_counter = 0;
    unsigned long m_buttonPressTimeout;
    unsigned long m_previousMillis;

  public:

    Button(byte buttonPin):
      m_buttonPin(buttonPin),
      m_counter(0),
      m_buttonPressTimeout(1500), // Button press timeout in ms.
      m_previousMillis(0){}

    void Update(){
      if(m_counter > 0 && millis() - m_previousMillis >= m_buttonPressTimeout)
      {
        //Serial.print("Count from Update() just before it's reset to 0 = ");
        Serial.println(GetCounter());
        m_counter = 0;
      }
    }

    void IncrementCounter(){
      m_counter++;
      if(m_counter > 4){m_counter = 4;}
      if(m_counter == 1)
      {
        m_previousMillis = millis();
      }
    }

    friend void IncrementCounter(Button&);

    void IncrementCounter(Button&){
      IncrementCounter();
    }

    byte GetCounter(){
      return m_counter;
    }

};

Bounce buttonOneDebouncer = Bounce();
Bounce buttonTwoDebouncer = Bounce();
Button ButtonOne(buttonPinBLE1);
Button ButtonTwo(buttonPinBLE2);

void setup(){
  //Serial.begin(9600);
  Serial.begin(115200);
  pinMode(buttonPinBLE1, INPUT_PULLUP);
  pinMode(buttonPinBLE2, INPUT_PULLUP);
  buttonOneDebouncer.attach(buttonPinBLE1);
  buttonTwoDebouncer.attach(buttonPinBLE2);
  buttonOneDebouncer.interval(25);
  buttonTwoDebouncer.interval(25);
}

void loop(){

  // Call the Update function as fast as possible.
  ButtonOne.Update();
  ButtonTwo.Update();

  // Button one pressed.
  if(buttonOneDebouncer.update()){
    if(buttonOneDebouncer.fell()){
      if(digitalRead(buttonPinBLE2) == 0){
        ButtonOne.IncrementCounter();
      }
    }
  }

  // Button two pressed.
  if(buttonTwoDebouncer.update()){
    if(buttonTwoDebouncer.fell()){
      if(digitalRead(buttonPinBLE1) == 0){
        ButtonOne.IncrementCounter(ButtonTwo);
      }
    }
  }
  if(digitalRead(buttonPinBLE1) == 0 && (digitalRead(buttonPinBLE2) == 0))
  {
  Serial.println("9");
  }

}

Does anyone know how I can get the device to communicate with my computer via Bluetooth? I have no experience with the Beetle and I cannot seem to find much help online.


texts:
Today i bought my second NANO(First one was made of Gravitech).I have some doubts that if it is a counterfeit product.I have noticed some points & they are as follows.

1)No "NANO" printed on the top of the board.

2)The atmega328p is in MLF package.

3)A diode soldered on the back side of a board is not properly positioned.

4)No version is printed anywhere.

5)The word "ICSP" not printed near the ICSP header.

6)No pin marking(white dot) for ICSP pin#1.

The seller is a very reputable one in India.That's why i can't be 100% sure if it is a counterfeit product.
I am attaching some pics.Please take a look & give your valuable feedback.

enter image description here