texts: WiFiSSLClient will not connect to servers with LetsEncrypt certificates

texts:
I'm trying to send data from an Arduino program to an app running on Google App Engine but WiFiSSLClient.connect() always returns false.

This is despite

the server being up and running;
the code working when the web app was on a different server.

The only possible explanation I can come up with is that the App Engine app uses a LetsEncrypt certificate while the other server was using one by another company.

WiFiSSLClient client;
if (client.connect(server, 443)){
    // Connected to server
} else {
    // Failed to connect
}

Does anyone have any solutions to this problem? I had a look at WiFiClientSecure; it has the ability to set the CA certificate in code but this seems like a bit of a pain.


texts: How can TEENSY Microcontrollers read ASCI Variables from X-PLANE 11

texts:
TEENSY Boards have in the USB-MODE "FLIGHTSIM" direct access to the variables = DATAREFS
of X-PLANE 11.
You can use FLIGHTSIMINTEGER and FLIGHTSIMFLOAT but not a varible for CHARs like the ID of a waypoint
for example "IBZ" or "EDDF" .
I need to read the CHARs to use them in the Display of my FlightSimPanel.
ANY IDEA ?


texts: Communicate from Arudino to computer over 3.5mm port

texts: I'm wondering if it would be somehow possibly to have easy communication with a computer for Arduinos that don't have USB like the pro mini. That would make an easy way of having two-way communication with a computer. The computer could just play or record audio using software written specifically for this purpose. Would something like this require any special circuitry or would it just be a matter of connecting the right wires?


texts: Arduino Mega 2560 RFID Serial Communication

texts:
I have an RFID reader: http://img.tradeindia.com/fp/1/641/264.jpg

Something like above along with ITEAD TFT shield & GSM Modem. The RFID reader has an RS-232 port as well as GND, TX and 5V pins. I am using an Arduino Mega 2560 board. I have connected the TX, GND of RFID reader to RX3 pin 15 / GND (pin) of Arduino. Note I am supplying 12 V to RFID via an adapter.

Note the ITEAD TFT shield consumes the TX0, RX0 pins—so I cannot make use of the RX0 and TX0 pins. Though I have not written the code for GSM modem.

Now while running the program below, I am getting junk output both in my TFT display as well as the serial monitor:

#define __AVR__
#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(ITDB24,59,58,57,56);
String myString = "";

void setup() {
   Serial3.begin(9600);
   myGLCD.InitLCD();
   myGLCD.clrScr();
}

void loop() {
  myGLCD.setFont(BigFont);
  if (Serial3.available()) {
    int inByte = Serial3.read();
     myString += String(inByte);
    }
    if(myString.length() == 10)
      myGLCD.print(myString, CENTER, 0);
}

TFT Screen output:

1310494848

Serial Monitor Output: non printable junk character.

The value is incorrect, I am pretty sure, what am I doing wrong?

I found that the ITEAD shield is sending or rather using RX0/TX0 pins very frequently—some data is going through.

BTW what is the functionality of http://arduino.cc/en/Tutorial/SoftwareSerialExample?

How can I use 3 different Serial I/Os individually at the same time without disturbing any other I/O?


texts:
I am trying to write a pice of code which send to a receiver the frequency to listen.
As per its documentation, it should receive the following sequence:

Example with 123.456 MHz
Command to send (frequency converted in 4 bytes, followed by 2 instruction bytes
0x12 0x23 0x56 0x00 0x01

To be able to memorize six frequencies, I fill an array:
uint32_t mem_freq[6] = {
   0x121050,
   0x126500,
   0x120500,
   0x121700,
   0x121825,
   0x118700,
};

My concern is that when I do :
Serial.write(mem_freq[mem_index]);
//Serial.write(0x00);
//Serial.write(0x01);

Only 1 byte is sent, and it's hard to debug as the serial console displays only ascii characters.
When I use Serial.print instead, mem_freq[2] shows correctly 0x120500
After Majenko's answer, I tried this:
Serial.print(0x123456 >> 16,HEX);
Serial.print(0x123456 >> 8,HEX);
Serial.print(0x123456,HEX);
Serial.print(0x00,HEX);
Serial.print(0x01,HEX);

And it outputs:

12123412345601

Is this normal ?


texts:
void setup() {
  pinMode(5, OUTPUT);
}

void loop() {
  analogWrite(5, 0);
  // or
  //digitalWrite(5, LOW);
}

Output is 0.003V and the tiny voltage causes the circuit to draw 20uA.

Is there anyway to get absolute 0V from Arduino PWM pin?


texts:
I'm making a NodeMCU based home automation. I adapted code I found on internet for controlling a device (say LED) via MQTT broker hosted on a Raspberry Pi. It works fine. But when I try to scale it up for more than one device, I'm hitting a wall.
void callback(char* topic, byte* payload, unsigned int length)
{

  const char* t_bedroom_light1 = "/home/bedroom/light1";

  Serial.print("Topic from MQTT broker is : ");
  Serial.print(topic);
  char p = payload[0];

  // if MQTT comes a 0 turn OFF pin D4
  if (topic == "/home/bedroom/light1" && p == '0')
  {
    digitalWrite(LIGHT_PIN, LOW);
    Serial.println(" Turn Light Off! ");
  }

  // if MQTT comes a 1, turn ON pin D4
  if (topic == "/home/bedroom/light1" && p == '1')
  {
    digitalWrite(LIGHT_PIN, HIGH);
    Serial.println(" Turn Light On! " );
  }
}

Serial monitor receives and prints the topic correctly from MQTT server. But topic == "/home/bedroom/light1" never returns true. If I delete that part then p =='0' or p=='1' works fine by itself. I've tried comparing the topic with the locally declared char array, tried converting it into String and doing strcmp. Nothing. What am I doing wrong? Here is the Serial monitor output
12:43:20.346 -> .......
12:43:24.187 -> WiFi connected
12:43:24.187 -> IP address:
12:43:24.187 -> 192.168.1.5
12:43:24.187 -> Attempting MQTT connection...connected
12:43:30.752 -> Topic from MQTT broker is : /home/bedroom/light1


texts: I need help creating a code that moves a DC motor CW or CCW based off of 2 different buttons

texts:
I know I can make the motor move backwards and forwards with buttons but I don't want it to move at full speed. I want it to increment in very small amounts to where it can be adjusted very small amounts at a time. I should also be able to hold the button so it moves continuously. I also have a motor with an encoder on it. Maybe there is a way to use the numbers on the encoder to increment? so press the CW button and now the motor wants to move till the encoder reaches +10 from where it was at? I understand what I want to do, just need help getting there. Thanks
HERE IS THE CODE I FIGURED OUT THAT MAKES MY DC MOTOR INCREMENT CW AND CCW

#define MOTOR_DIRECTION_PIN   2
#define MOTOR_SPEED_PIN       3

#define MOTOR_DIRECTION_CW    LOW
#define MOTOR_DIRECTION_CCW   HIGH

void setup()
{
  //button inputs
  //pullup so we do not need to include a physical resistor
  pinMode(12, INPUT_PULLUP);
  pinMode(13, INPUT_PULLUP);

  pinMode(MOTOR_DIRECTION_PIN, OUTPUT);
  pinMode(MOTOR_SPEED_PIN, OUTPUT);

  Serial.begin(9600);

  Serial.println("test");
}

void loop()
{
  int pushedButtonOne = digitalRead(12);
  int pushedButtonTwo = digitalRead(13);

  if(pushedButtonOne == LOW)
  {
    Serial.println("Button number 1 has been pushed");
    digitalWrite(MOTOR_DIRECTION_PIN, MOTOR_DIRECTION_CCW);
    analogWrite(MOTOR_SPEED_PIN, 50);
    delay(7);
    analogWrite(MOTOR_SPEED_PIN, 0);
  }

  else if(pushedButtonTwo == LOW)
  {
    Serial.println("Button number 2 has been pushed");
    digitalWrite(MOTOR_DIRECTION_PIN, MOTOR_DIRECTION_CW);
    analogWrite(MOTOR_SPEED_PIN, 50);
    delay(7);
    analogWrite(MOTOR_SPEED_PIN, 0);
  }
  else
  {
    Serial.println("nothing has been pushed");
  }

  //delay(100);

}


texts:
Could anybody please help me with my problem? My Arduino doesn't work correctly. I was between a project, and suddenly it started acting weird. First, it started taking about 4 minutes to compile and a minute to upload, I do not know why!

Second, now it doesn't accept any code at all. I will paste the error message below.

Also, could anything be damaged as I inserted the USB cable of the Arduino to my power bank, rated 5V 2A, for about 30 seconds as power source and then again inserted it to the computer itself.

Please help me. I have already tried searching on various forums, reinstalling the software and driver on my PC, pressing the reset button... No help so far.

  ERROR MESSAGE:
  Arduino: 1.6.7 (Windows 10), Board: "Arduino/Genuino Uno"

  avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
           Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
           Copyright (c) 2007-2009 Joerg Wunsch

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

Using Port                    : COM6
Using Programmer              : arduino
Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x49
Error opening serial port 'COM6'. (Port busy)
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x49

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.


texts: How to read sound sensor readings and light up sensor with water sensor if the readings is above threshold & when water is detected for 2 mins?

texts:
I am student that is new to Arduino and working on a project to trigger an alert if the sound level detected exceeds the threshold for a period of 2 mins. But I am stuck, would like to check how do I write a code to analog read sound sensor input and light up sensor if the readings is above datum for 2 mins? I had simple code but it triggers the light up immediately. :/

I have combined the coding together and this is the new code that worked with the help gotten:

    #define led 4 // led to D4
const int soundsensor= A0; //sound sensor to A0
const int threshold= 100; // to set the threshold value for sound sensor
int ssanalogread; //name of sound sensor analog read
bool wasOver;//add to globals
unsigned long firstDetect;

void setup() {
  Serial.begin(9600);
  pinMode(led,OUTPUT);
  pinMode(soundsensor,INPUT);// to get input from sound sensor

} // end void setup

void loop() {

     sound1();

} // close void loop

void sound1() {

  ssanalogread=analogRead(soundsensor); // reads analog data from sound sensor
  Serial.println(ssanalogread);

   if ((ssanalogread > threshold)){ //replace if else
      if(!wasOver){
       firstDetect = millis();
   }
   if(millis() - firstDetect > 1*10*1000){
      digitalWrite(led,HIGH); //turns led on if the sensor reads more than threshold
   } //end if
      wasOver = true;
   } // end first if
  else {
     wasOver = false;
     digitalWrite(led,LOW);
  } // end else

} //end loop

//this code works and is ok to run. can adjust the timing


texts: USB-C as power input and analog audio out

texts:
I currently use USB-C to charge an arduino with a battery. I also use a headphone jack to output audio.
I would like to combine those two and output the analog audio through USB-C (when it is not charging). (edit: to headphones plugged in with a usb-c to aux adapter)
Can someone point me to a curcuit to achieve this?
I am not sure what to look for exactly.


texts: Unable to upload any sketch but Serial Monitor keeps displaying "Start scan, Scan done, Network found" message

texts:
I have bought a new Mega 2560 with WiFi.
I tried to upload a sketch that worked OK with the previous Mega 2560 but the upload always fails with the following error message:
*************************************************************
Arduino: 1.8.13 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 2762 bytes (1%) of program storage space. Maximum is 253952 bytes.

Global variables use 391 bytes (4%) of dynamic memory, leaving 7801 bytes for local variables. Maximum is 8192 bytes.

C:\Users\warph\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\warph\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM3 -b115200 -D -Uflash:w:C:\Users\warph\AppData\Local\Temp\arduino_build_593938/2560-Mega-WiFi.ino.hex:i

avrdude: Version 6.3-20190619

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\warph\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM3

         Using Programmer              : wiring

         Overriding Baud Rate          : 115200

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

An error occurred while uploading the sketch

Can someone please help to get this issue fixed?


texts: Does the MKR WIFI 1010 support the arduino mouse and keyboard controller?

texts:
I am working on a project right now that needs to connect to my computer via bluetooth and access the arduino mouse and keyboard library. In my research, I've found that only the Leonardo, Due, and Micro can emulate cursor movements, but they need to have additional hardware like the HC05. I would like to keep the amount of hardware I use to a minimum, but I understand if there is no way around it. Is there any way to use the MKR WIFI 1010 like a Leonardo, or would I need to get one of the aforementioned boards and then get a bluetooth module hooked up?

PS this is my first dive into bluetooth, so any additional resources to aid me in my journey would be much appreciated.


texts: Is it advisable to use Serial.write in an ISR when loop() routinely uses Serial.read?

texts:
I do not know much electronics.
I have Nano v3 as I2C master, it reads 5-byte packets (of delimtted data) from PC's USB port, processes it and forwards it.
I now need to implement a way to signal PC if something went wrong down the line. I don't want to clutter I2C channel and its just a flag so I think interrupt is best for my purpose.
While writing the ISR function I am not sure if its advisable to write data using Serial, because loop might have read 2-3 bytes of the 5-byte message packet. And I don't know if it will overwrite data coming from PC or what...
What will happen if I Serial.write(0x1) (suddenly, in an ISR function) while loop() was reading data from same Serial?
I don't know how to test this myself.


texts: How to handle multiple simultaneous Arduino development environments?

texts:
I am developing for several different target microcontrollers (on OS X 10.11), which requires some unique combinations of (Arduino) IDE version, library versions, USB drivers, support software, etc.

What are the pros and cons of using separate logged-in users for each environment as opposed to using Virtual Machines? Are there other methods commonly in use to separate environments, and also keep the environments archived for any legacy needs?

Update: I also have a desire to keep these environments as standard as possible: installing released components (e.g., IDE, drivers) and customizing IDE app settings, but trying to avoid source-level forks. This is for my own sanity, and to give best chance of replicating the environment in the future.


texts:
Hey I'm very new to Arduino. I don't have very much knowledge in electrical engineering either.

My project: an EL wire working on Arduino. Since the Arduino can only support 5V and the wire needs 120V, how can I make sure that it works? (I assume the voltage provided by the Arduino is not high enough for the EL wire to operate.)


texts:
I understand that the official Arduino Scheduler doesn't support Uno, and there are several third-party schedulers to fill the gap, notably, Scheduler, Arduino-Scheduler and TaskScheduler. There are probably many more, though I see that many so-called "task schedulers" are actually just periodic function callers which don't handle context (i.e. they don't support yield()).
I need to make a choice of a scheduler to use in a project (a real one, with yield, not a periodic function caller). Is there any comparison of Arduino task schedulers? I'm specifically interested in the following aspects:

context switching time (the most important one)
RAM/ROM consumption estimation
list of supported boards


texts:
Note: Before i explain my issue i would like to note that I am a beginner in electronics. Please pay attention to that when providing solutions and explanations. Thank you.

I have succeeded at making an auto ranging Ohmmeter it is still ofcours experimental there for I would like to get some opinions and perhaps solutions to some of the issues I’m facing
How it works:

It is based on a simple voltage divider. After experimenting it seems that a voltage drop across the unknown resistor in a certain range (this case [3.135V, 0.99V] with a voltage source equal to 3.3V) gives the most precise results compared to other values.

This Ohmmeter has a very useful feature and that is auto ranging, it changes the range automatically when the voltage drop values are not in the previously mentioned interval ([3.135V, 0.99V]).
The accompanied image shows how the device works.

If the value of Rx is too small compared to (R1+R2+R3) the Arduino switches the analog reading from A0 to A1 if the problem still accurse the Arduino will change again to A2 meaning it is now measuring not the value of Rx but (Rx+R1+R2) in series after that the Arduino is programmed to do the subtraction accordingly.

This device presents some noticeable inconvenients  that need to be eliminated:

It depends on experimental values, so it is not certain if it’ll
function properly in different conditions.
For accurate (still not exact) measurements the value of Rx has to be greater than R1
It provides acceptable measurements compared to the actual value with an error that is not too big (less than 1% relative error) the precision was obtained by the use of some of the arduino functions (such as voltage reference) also I have chosen the voltage source to be 3.3V instead of 5V to reduce noise, now if one wishes to use a different microcontroller other than arduino will it still be possible to obtain the same precision.

I would like to know your professional opinion regarding these inconvenients and if you may solutions for them, I have accompanied the code for better understanding.

Thank you

#include <ResponsiveAnalogRead.h>
ResponsiveAnalogRead analogPin0(A0, true);
ResponsiveAnalogRead analogPin1(A1, true);
ResponsiveAnalogRead analogPin2(A2, true);

int raw1= 0,raw2=0,raw3=0;
int Vin= 3.3;
float Vout1= 0,Vout2=0,Vout3=0;

float R1= 10000,R2=100000,R3=1000000;
float Rx= 0;
float buffer= 0;

void setup()
{
  analogReference(EXTERNAL);

Serial.begin(9600);
}

void loop()
{
  analogPin0.update();
  analogPin1.update();
  analogPin2.update();
raw1=analogPin0.getValue();
buffer= raw1 * Vin;
Vout1= (buffer)/1024.0;
if(Vout1<=3.135&&Vout1>=0.99) //firstif
{

buffer= (Vin/Vout1) -1;
Rx= (R1+R2+R3) * buffer;
Serial.print("Vout1: ");
Serial.println(Vout1);
Serial.print("Rx: ");
Serial.println(Rx);
delay(1000);
}
   else //else1 of first if
   {

   raw2=analogPin1.getValue();
   buffer= raw2 * Vin;
   Vout2= (buffer)/1024.0;
      if(Vout2<=3.135&&Vout2>=0.99) //second if of first else
      {
      buffer= (Vin/Vout2) -1;
      Rx= (R2+R3) * buffer;
      Rx=Rx-R1;
      Serial.print("Vout2: ");
      Serial.println(Vout2);
      Serial.print("Rx: ");
      Serial.println(Rx);
      delay(1000);
      }
      else
      {
      raw3=analogPin2.getValue();
      buffer= raw3 * Vin;
      Vout3= (buffer)/1024.0;
          if(Vout3<=3.135&&Vout3>=0.99)
          {
          buffer= (Vin/Vout3) -1;
          Rx= R3 * buffer;
          Rx=Rx-(R1+R2);
          Serial.print("Vout3: ");
          Serial.println(Vout3);
          Serial.print("Rx: ");
          Serial.println(Rx);
          delay(1000);
          }
       }
   }
}

======================================================

to jot here are the results as i have previously explained the ohmmeter worked pretty well at the beginning but when i turned it off Then back on the value measured changed, the error got much bigger i tried changing the caliber aka R1 from 220 to 100 but the results were the same, the error was still big
thank you


texts:
I am currently learning pointers. I am following a book (Says Teach Yourself "Arduino Programming") in which there is an exemple about pointer and array.

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  char string1[] = "This is my test string";
  char string2[]="This is another string test";
  char *ptr2 = string2;
  char *ptr1 = string1;

  while (*ptr1 != '\0') { // not "\0"
    *prt2 = *prt1;
    ptr1++;
    prt2++;
  }
  Serial.println(string1);
  Serial.println(string2);
}

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

}

I get an error "ptr2 was not declare in this scope."

I don't know what is wrong...

That for your help.


texts:
I build photo gate, to detect throwing ball.
It works fine when delay time in main loop for max 40 milliseconds.
Problems start when I delay every loop only for 20 milliseconds, now my LED which indicates if something broke path between IR led and IR receiver, blinks occasionally, if I set delay for 10 milliseconds and turn on, then LED is off for 2 seconds, then start blinking very fast and is ON for rest time, until I break IR path. I think some physics is going on here which I don't understand.

I also would like to ask if it is possible to narrow IR wave path to be more like laser (going strait into one direction) and how I can control sensitivity of IR detection

This is schematic

IR transmiter
IR reciever

Code:

//define pins. I used pins 4 and 5
#define irLedPin 4          // IR Led on this pin
#define irSensorPin 5       // IR sensor on this pin
#define buzzerPin 2       // buzzer on this pin

int irRead(int readPin, int triggerPin); //function prototype

void setup()
{
  pinMode(irSensorPin, INPUT);
  pinMode(irLedPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  Serial.begin(9600);
  // prints title with ending line break
  Serial.println("Program Starting");
  // wait for the long string to be sent
  delay(100);
}

void loop()
{

  bool isOn = irRead(irSensorPin, irLedPin);
  //Serial.println(isOn); //display the results
  if(isOn == true)
  {
    digitalWrite(buzzerPin, HIGH);
  }
  else
  {
     digitalWrite(buzzerPin, LOW);
  }
  delay(10);
}

int irRead(int readPin, int triggerPin)
{
  int halfPeriod = 13; //one period at 38.5khZ is aproximately 26 microseconds
  int cycles = 23; //26 microseconds * 23 is more or less 600 us
  int i;
  for (i=0; i <=cycles; i++)
  {
    digitalWrite(triggerPin, HIGH);
    delayMicroseconds(halfPeriod);
    digitalWrite(triggerPin, LOW);
    delayMicroseconds(halfPeriod - 1);     // - 1 to make up for digitaWrite overhead
  }
  return digitalRead(readPin);
}


texts: How do I make two (or more) pins available on my server url?

texts:
I have a webserver configured on my esp8266 with is set to fire off electrical relay0 on my 8 port relay board.
The device initializes relay0 perfectly and without errors.
But when I configure the second relay1, i get no response from my second url.
//note, when you write to low, you turn the switchport on. It's backwards for some reason
#include <ESP8266WiFi.h>
#define statusLed 2   // built-in led for the ESP8266-12

const char* ssid = "myssid";
const char* password = "mypass";

int switchPin0 = 16;
int switchPin1 = 5;
int switch0;
int switch1;

WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);

  pinMode(statusLed, OUTPUT);
  pinMode(switchPin0, OUTPUT);
  digitalWrite(switchPin0, HIGH);

  // 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(500);
    Serial.print(".");
  }
  digitalWrite(statusLed, HIGH);
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.print("Use this URL : ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");

}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);

  client.flush();

  // Match the request

  int value = HIGH;
  if (request.indexOf("/SWITCH=0") != -1){
    digitalWrite(switchPin0, LOW);
    digitalWrite(statusLed, LOW);   // blink led
    delay(1);
    digitalWrite(statusLed, HIGH);
    //set water pump time here
    delay(8000);
    digitalWrite(switchPin0, HIGH);
    value = HIGH;
    ++switch0;
  } else if (request.indexOf("/SWITCH=1") != -1){
    digitalWrite(switchPin1, LOW);
    digitalWrite(statusLed, LOW);   // blink led
    delay(1);
    digitalWrite(statusLed, HIGH);
    //set water pump time here
    delay(8000);
    digitalWrite(switchPin1, HIGH);
    value = HIGH;
    ++switch1;
  } else {

    }

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("");

  client.print("Switch pin is now: ");

  if(value == HIGH) {
    client.print("Off");
  } else {
    client.print("On");
  }
  client.println("

");
  client.println("Switch 0");
  client.println("Click here  to send a measured amount
");
  client.println("Number of times plant 0 has been fed is ");
  client.println(switch0);
  client.println("

");
  client.println("Switch 1");
  client.println("Click here  to send a measured amount
");
  client.println("Number of times plant 1 has been fed is ");
  client.println(switch1);
  client.println("");

  delay(1);
  Serial.println("Client disconnected");
  Serial.println("");
  digitalWrite(statusLed, LOW);   // blink led
  delay(1);
  digitalWrite(statusLed, HIGH);

}

my counter will update, but the relay pin never fires for relay1. relay0 works fine. I can swap the ports and then the second relay will work and not the first. I just can't manage both.
How do I get a second (or more) relay ports to initialize via webpage?


texts:
hey guys so i get this error when plugging in my arduino and not sure why:

  Blockquote

  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.
  avrdude: ser_open(): can't open device "\.\COM5": The system cannot find the file specified.

  Problem uploading to board.  See
  http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

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

How can i solve it? It used to work and not sure what's happened... also does anyone know if the Braccio robotic arm can be connected to arduino via just the arduino/usb cable alone? Because when i connect the braccio shield v4 to both th arduino(and to laptop) and to the wall, it actually causes my laptop to switch off ??


texts: Is there a way to reuse an old robot using arduino?

texts:
I had purchased a simple robot (named Qu-Bot) for a school project a couple of years ago. After the project, it just went into the attic. A few days ago, I purchased an Arduino Uno and started learning the how to operate it. But, before I could purchase LEDs, sensors, LCD, etc, a total lockdown was implemented in my country due to coronavirus.

Is there a way I could program that old robot in Arduino IDE like I program my Uno?

  I'm not sure if this is useful or not, but, when I execute $ lsusb , the bot appears as Bus 001 Device 018: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

Here's a link to some documentation of the bot:
http://www.technogravity.com/products/qu_bot/qu_bot_downloads.php

Here are photos of all the 3 chips I can see on the board of the bot:


texts:
Need help for this Tutorial. I tried to compile the code, but I'm getting compiling error.

I tried to ask on that forum too but got no answer, the error is:

In file included from C:\Program Files (x86)\Arduino\libraries\SD\src/utility/SdFat.h:32:0,
Multiple libraries were found for "SD.h"from C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:20,
 Used: C:\Program from D:\FEMV3FKI7YLJVQQ\FEMV3FKI7YLJVQQ.ino:1:
 Not used: C:\Users\IBNUM
C:\Program Files (x86)\Arduino\libraries\SD\src/utility/BlockDriver.h:31:10: fatal error: FatLib/BaseBlockDriver.h: No such file or directory
Multiple libraries were found for "SPI.h"
 #include "FatLib/BaseBlockDriver.h"
 Used: C:\Program
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

How can I fix this Arduino compile error?


texts: Combing two codes to make it work on the same time but not affecting the other code?

texts:
I am trying to make a game where there are arrows going towards an object (in this case I printed x) and you have to evade the arrows. When you press the button it is supposed to print x on the top row and clear the bottom row with printing nothing and if you don't press the button its supposed to print x on the bottom row and nothing on the top. Then the for loop is supposed to print arrows randomly going from right to left.

Problem: When I actually run the code I only see the x every time the arrow hits the (0,1) or (0,0) position.

I want the x to be there all the time.

#include <LiquidCrystal.h>
// init the lcd display according to the circuit
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);

String line2 = " x ";
int xPosition;
int yPosition;
int yConstant;

void setup()  {
  lcd.begin(16, 2);
  // put your setup code here, to run once:
  int switchState = 0;
  pinMode(7, INPUT);
  int leftjump = 0;
  pinMode(8, INPUT);
}

void loop() {
  ///////////////////////////////
  //supose tp print arrow randomly going from right to left
  xPosition = 15;
  yPosition = random(0, 10);
  if (yPosition > 5) {
    yConstant = 1;
  }
  else yConstant = 0;
  lcd.setCursor(xPosition, yConstant);
  for (int xPosition = 15; xPosition > 1; xPosition--) {
    lcd.print("<-");
    delay(100);
    lcd.clear();
    lcd.setCursor((xPosition), yConstant);
  }
  ////////////////////////////
  // suppose to print x on the top row and print nothing on buttom row
  //and otherwise when button is not pressed print x on bottom and
  //print nothing on top row
  int rightjump = 0;
  rightjump = digitalRead(7);
  if (rightjump == 1 ) {
    lcd.setCursor(0, 0);
    //delay(10);
    lcd.print(line2);
    //delay(200);
    lcd.setCursor(0, 1);
    lcd.print("  ");
  }
  else if ( rightjump == 0 ) {
    lcd.setCursor(0, 1);
    //delay(10);
    lcd.print(line2);
    //delay(200);
    lcd.setCursor(0, 0);
    lcd.print("  ");
  }
}


texts: Write file to SD card using SDFat.h and ESP8266

texts:
I have simple problem with not simple solution.
My workflow is:

Read CID from SD card
Send CID via Http to clodud
Download specific text from cloud
Write this text to file in same SD card

All is working except last step. I cannot figure out how to write to file using SDFat lib. I have to use SDFat for reading CID and other low lvl data from card. Im strugling on "open File" step. Have numerous problems with multiple declarations and none of combinations SD.h SDFat.h and FS.h not working for me. Please, help me, how to open file.
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include "SdFat.h"
#include "sdios.h"

SdFat sd;

...

void WriteToFile(String payload) {
  fs::File myFile;

  myFile = sd.open("test.txt", FILE_WRITE);

  myFile.println(payload);

  myFile.flush();
  myFile.close();
}

So what is wrong: Using ESP8266 I cannot compile code due to multiple occurence of fs::File and File32.
C:\...\Arduino\libraries\SdFat\src/SdFat.h:400:16: error: 'typedef class File32 File' conflicts with a previous declaration
 typedef File32 File;
                ^

Now I rebuild whole code for ESP32 chip. I can compile and upload code. It can read CID send it, read incoming file and ope SD card. But when writing to file I got
error: Cannot open file
Check SD format.

I tried several formats, Fat16, Fat32, exFat on several SD cards from 2 to 64Gbs. All of them were unlocked, all of them were formated to 2 partitions (thats what I want) and 1 partition (for testing) withouth difference. I was also tweeking SPI speed When I set more than 16MHz, it fails (Using ESP32 Wroom)
EDIT2: When I first open volume, call chvol() on volume (not sd card) then it works and I can open file and write to it. Wtf?
  if (!volume.begin(sd.card())) {
    Serial.println("Could not find exFat partition.\nMake sure you've formatted the card");
    return;
  }

  volume.chvol();


texts:
I am using Arduino in an IOT application where I have to read impulses coming from a sensor and send a mean value of these impulses without missing any impulse while sending the value so is it possible to achieve such operation knowing that Arduino is a single core chip.

I read about Protothreading libraries but it may miss an impulse during the check phase so I want to know if there is another solution


texts: Arduino Uno not working after Short-circuit

texts: While wiring up my new Arduino Uno R3, I accidentally shorted the 5V pin and the GND pin (for less than a sec). It was powered by a 12V 500mAh power supply through the Arduino DC power jack. . The ON, Rx, X1 and L LED's are glowing continuously, and also, pressing the reset button doesn't have any effect on the LED's and arduino doesn't restarts. How can I get my arduino working again?


texts: What is the call to cli(); routine in interrupt service routine for SPI?

texts: I see this in examples of ISR code but what is it?


texts:
Is there a DTMF signal detection method in the smartphone [SIM] call?ex) keypad value or signal value [not frequency signal]
If you press the keypad button while you're on the phone with two iPhones, you don't hear the signal. So does the SAMSUNG phone.Please let me know how to detect DTMF signals after installing the aduino SIM.
Quectel EC25


texts:
I am working on a project which requires communication from an Arduino Due (Master) and an FDC2214Q1 C to D IC (Slave), but there is some variability as to whether the code works or not depending on seemingly random variables.

I have narrowed the issue to the function I am using to read 2 bytes from the slave. The code is pretty standard, and is as follows:

// Read 2 byte from the FDC at 'address'
uint16_t FDC2214::read16FDC(uint16_t address) {

    uint16_t data;

    Wire.beginTransmission(_i2caddr);
    Wire.write(address);
    Wire.endTransmission(false); //restart
    Wire.requestFrom(_i2caddr, (uint8_t) 2);

    while (!Wire.available());
    data = Wire.read();
    data <<= 8;

    while (!Wire.available());
    data |= Wire.read();
    Wire.endTransmission(true); //end

    return data;
}

The code seems to get hung up sometimes on while (!Wire.available()) and if I simply remove that step, I never get the correct Device ID.

However, if I simply unplug the DUE and close the Serial Monitor and replug in and upload, it works. I just kind of upload and disconnect a few times and open and close the Serial Monitor and sometimes it works great, other times it gets hung up?

Any ideas what could be causing such and issue?

Code based on this library: https://github.com/zharijs/FDC2214/blob/master/src/FDC2214.cpp

Final code that has been working, removes need for While loop:

uint16_t FDC2214::read16FDC(uint16_t address) {

    uint16_t data;
        Wire.beginTransmission(_i2caddr); //queuing the slave address
        Wire.write(address); //queuing the register address/pointing regsiter
        byte busStatus = Wire.endTransmission(); //transmit all queued data and bring STOP condition on I2C Bus
        if(busStatus != 0x00)
        {
           Serial.print("Transmission Error....!");//transmissiion error wait here for ever
           while(1);
        }

        Wire.requestFrom(_i2caddr, (uint8_t) 2);     //this is looping code; when 2-byte has arrived, the loop terminates
        data = Wire.read();   //read the first byte from FIFO Buffer
        data = (data <<8)| Wire.read();   //16-bit data is formed
        Wire.endTransmission(true); //end
        return data;
}


texts: avrdude: verification error, first mismatch at byte 0x0000 : 0x00 != 0x16 using USBasp

texts:
I'm having this strange error, which pops up around 90% of the time. I am trying to program my attiny25 using USBasp and the Arduino IDE / library. Sometimes it works, most times it doesn't.. This error occurs on large sketches as well as new sketches, with just the empty setup() and loop() functions. The error looks quite random to me, because my program just uploaded after trying around 10 times. Compiling goes fine. The error always occurs at byte 0x0000, and always in the format 0x00 != 0x _ _. I have six wires (correctly) connected from the USBasp to the attiny25. I do not use any resistors, capacitors etc.

Could anyone tell me what could possibly cause this error, and what to do to fix it?


texts: mp3 trigger, output to antoher input, no switch

texts:
I have two Arduinos: one is transferring on its output pin to other Arduino's input_pullup low or high signal depend on servo action (rotating/stop).

I need an action on slave Arduino with dfmini player: actually I need a code with which mp3 sample is triggered on slave Arduino.

servo rotates -output pin goes low = sample is played just once until servo reaches desired position

servo stopped -output pin goes high = sample stops

solving this issue will be really helpful for my project.

here is example code

tnx.

***************************************************
  DFPlayer - A Mini MP3 Player For Arduino
  <https://www.dfrobot.com/index.php?route=product/product&product_id=1121>

 ***************************************************
  This example shows the basic function of library for DFPlayer.

  Created 2016-12-07
  By [Angelo qiao](Angelo.qiao@dfrobot.com)

  GNU Lesser General Public License.
  See <http://www.gnu.org/licenses/> for details.
  All above must be included in any redistribution
 ****************************************************/

/***********Notice and Trouble shooting***************
  1.Connection and Diagram can be found here
  <https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299#Connection_Diagram>
  2.This code is tested on Arduino Uno, Leonardo, Mega boards.
 ****************************************************/

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#define pin 2 // connect to master digital output "pin"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

void setup()
{
 mySoftwareSerial.begin(9600);
 Serial.begin(115200);
 pinMode(2,INPUT_PULLUP);

 Serial.println();
 Serial.println(F("DFRobot DFPlayer Mini Demo"));
 Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

 if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
   Serial.println(F("Unable to begin:"));
   Serial.println(F("1.Please recheck the connection!"));
   Serial.println(F("2.Please insert the SD card!"));
   while (true);
 }
 Serial.println(F("DFPlayer Mini online."));

 myDFPlayer.volume(15);  //Set volume value. From 0 to 30
}

void loop(){
  if (digitalRead(2)==LOW) myDFPlayer.play(1); // 5 sec mp3 sample, turn on , then debounce or return ?

}

}

wiring scheme

output cobmination on master arduino


texts: How to control a Nema 17 stepper motor with an arduino? (too much current / heat)

texts:
I am trying to control a Nema 17 motor with a L298n dual bridge and an Arduino Mega.

My wiring is from this Instructable:

http://www.instructables.com/id/Control-DC-and-stepper-motors-with-L298N-Dual-Moto/?ALLSTEPS

When I connect it to my laboratory power supply the current limitation blinks. Normally when there is too much current needed the LED is all the time on and not blinking.

So I increase the current limit and the motor just starts moving on 3.1A @ 12V (doesn't move if less current) and in the description of the motor on amazon
they say "Rated Current/Phase:1.2A" so I am wondering what did I do wrong here?

From my understanding "Rated Current/Phase:1.2A" means that I should run this motor (it's a bipolar stepper motor with 2 phases) not higher than 2.4A?

These are the informations from amazon about this motor:

Specifications:

Led screw diameter: 8mm
Lead screw length: 300mm
Step angle :1.8 degree
Nut material: Brass
Holding Torque: 400mN*m
Thrust(full step): 12.5kg
Rated Current/Phase:1.2A
Rate Voltage: 3.3v
Rated Resistance/Phase:2.2±10%ohm

What would be a good voltage to run this motor? I thought 12V is a good idea with.

The motor L298n gets really hot when I run it at 3.2A or more so I think my setup will destroy the dual bridge and / or the motor.

I really appreciate help on this! :-)


texts: is it possible to power esp8266 with button cell

texts:
is it possible to power esp8266 wifi module with button cell for long period(1 year ) real time applications??
 Needs only wifi features (no need of gpio)

what will be voltage and current of the cell??


texts:
HDOP is supposed to be greater than 1: https://en.wikipedia.org/wiki/Dilution_of_precision_(navigation)
But I get HDOP about 0.7. What does it mean?

Where can I found explanation of the output parameters?


texts: I need to shift a PWM signal from a ESP32 (3.3V) to receiver that supports 5V. The signal is at maximum of 400Hz. Can this shifter do the job ?


texts: Some noob questions regarding Arduino Nano based drones

texts:
Foreword: I am doing my Bachelors in Aerospace Engineering and part of the requirements to graduate (and get a good grade) is that I must complete 3 projects of my choice, and it must be unique. So in order for one to be unique my only choice is to make a drone that does something unique and important/useful, which requires a lot of electronics & programming. So as you'd guess I have small knowledge on electronics and programming. I am also completely new to drone electronics and Arduino. Doing a project that involves aerodynamics and mechanics takes a lot of research and time (which I am short on), and I am going to reserve that for my M.Sc.

Moving on, I am using an Arduino nano and an accelerometer as my flight control board for the esc's+motors. So I want to connect my 4 esc's in which each have a power/signal/ground wire, to the nano. In total there are 12 wires. For the nano, should I only be connecting the signal wires to one i/o? If so, what happens to the power and ground wires?

Also, part of my set up requires that the Vcc on my accelerometer is connected to a 5V supply. Should I just connect it to the 5V pin on the arduino? A link of the set up of the drone is here: https://www.dropbox.com/sh/qcfd27buc7o9ep0/AAAjgNwChewsASVR9SUxpiUXa?dl=0&preview=Schematics.png

The motor/pdb/esc connections are easy and I don't need much help with that.

I have another project in mind, which has an Arduino Nano Vin pin connected to 7.5V. How do I achieve this?

I already got help from the link above with setting up an Arduino programme to govern the esc's. It would be easier to just get a ready made flight controller and connect the 4 esc's to their three power/signal/ground wires to each port but I wanted to challenge myself a bit more by building an Arduino based flight controller.


texts: Restarting Arduino changes cursor position on OLED

texts:
I got an 16x2 OLED Display (DEP 16201-Y , compatible to the HD44780 controller) for my Arduino Uno and I got it to work in 4-bit Mode.

Code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup()
{
//lcd.clear();
   lcd.begin(16, 2);
   lcd.clear();
   lcd.setCursor(0,1);
   lcd.print("Hello there");
   delay(1000);
}

void loop()
{
   lcd.setCursor(0,1);
   lcd.print("Hello World");

   lcd.setCursor(0,0);
   lcd.print("ABCDEFGHIJKLM");

   delay(1800);

   lcd.clear();

}

I'm using the LiquidCrystal library as it is written for this controller.

The code is uploaded to the Arduino and now I power it via a normal power supply with 9V.
Then it is pure luck at which position the Text appears. Most of the times at the programmed position but sometimes the hole text is shifted to the right or to the left.

In read in the .cpp file and it says, that the display won't be reseted when the Arduino is reset, so I assume the problem lays there, but I don't know how to fix it.

Thanks!


texts: Is it safe to power Arduino project using a power bank and wall charger?

texts:
I got an Arduino project that need a constant source of power. Rather than dealing with batteries, I want to use a power bank like this:

Better yet, I want to keep the power bank plugged in to the wall outlet using a wall charger like this:

The USB wire coming out of the power bank, I can modify it and connect it to the 5V on the Arduino (Pro Mini 5V version). Is it safe to do so? The application uses a stepper motor that draws around 200mA and only runs intermittently.

Thanks


texts: Arduino Mega PWM - 100ms Period - SSR and Heater

texts:
I'm not very advanced in Arduino "core" functions, so I need your help.

I'm using a Solid State Relay in order to control a heating element, with a PID Library (PID_v1.h) to obtain the OUTPUT of the PWM.

The code itself is not a problem, so that I'll not post it here.

Summarizing, this is the code where I send the PWM to the Relay:
    analogWrite(RELAY_OUT, outputValue);

I've found in this article that:
"The analogWrite function is used to set the duty cycle of a PWM pulse train that operates at approximately 500 Hz. Thus, with a frequency = 500 Hz, the period is = 2 ms."

My concern is that the response time of the relay (FOTEK SSR-60 DA) is 10ms (to turn on or to turn off), but I DO NOT KNOW how to configure Arduino PWM to work accordingly to this Relay, in a period greater than 10ms.

I've found in some pages some people changing the clock frequency in order to have a "fast pwm", but I need to know what values I have to use to get a "slow pwm", for a period greater then 10ms.

Can you help me with that? I've been searching a lot for this answer, but I could not find any "definitive"answer.

Thank you in advance!

Everton


texts: Galileo - servo motor moves only in one direction and it doesn't turn back

texts:
I have an Intel Galileo (1st gen) and a servo motor (Tower Pro SG90).

My problem: my servo moves only in one direction and it doesn't turn back.
I want to perform a movement from 0° to 90° and then from 90° to 0° again.

At the moment, I have just tried the official arduino snippet for servo motor that should perform a similar movement. But, as said before, the servo doesn't turn back.

Here the code

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

Obviously I have made the attachments like on arduino tutorial.

Every help will be greatly appreciated! :)
Thanks in advance


texts: How to assign a string-variable to a StackString based on the StackString-library?

texts:
I'm trying to use the StackString-library which offers not to eat up RAM over time by re-assigning values to strings. I started from scratch and wrote a very basic democode which works.
Then I added an assignment to a STackString-variable from a normal string or a function with return-value string
See code below
If I try to compile
I get a compiler-error saying
no matching function for call to 'Stack::StackString<50>::append(String&)'

here is the code

#include <StackString.hpp>
using namespace Stack;  // it is very important to have this line of code. Otherwise the code won't compile

StackString<50> myString = StackString<50>("Hello, World!");

String NormalString = "1234Test";

void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println();
  Serial.println(myString.c_str());

  myString.prepend("Everybody say: ");
  Serial.println(myString.c_str());

  myString.append(" How are you doing?");
  Serial.println(myString.c_str());
  Serial.println();

  //myString = NormalString;
  myString.append(NormalString);

}

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

}

Do I have to do some typecasting? and if yes how does it look like?
WHat I want to do is assigning a StackString a new value. This means the STackString is on the left side of the "="  assigning operator. I have tried different variants to no avail.

Could this be a problem of the special construction as a "namespace" ?
No idea no clue

you find the STackString-library here:
https://gitlab.com/arduino-libraries/stackstring

best regards

Stefan


texts: Is there a module for driving 2 stepper simultaneously?

texts: I'm looking for a module (not a shield) to drive 2 stepper motors simultaneously. The solution I found for now is 2 TB6612FNG modules, but if someone knows something that can work with 2 steppers simultaneously, it will be better and efficient. Thanks for your help.


texts: does eeprom_write_block function of avr.eeprom.h writes a NULL terminated string or we have to manually null terminate it

texts:
http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html

I am trying to figure out that if we use eeprom_write_block function or eeprom_update_block function do we need to manually null terminate it?

I came across this tutorial on avr-freaks where in one comment it is said that you have to read the strings and null terminate them but there is no word about writing. Couldnt get anything the avr-libc manual as well.

UPDATE

I have reserved some parts of eeprom using EEMEM  and they are strings. I am not sure how long the string would be except that it would be smaller than a max value. Now When I would read the string back from the eeprom I would just be reading the maximum number of bytes as again I would have no idea of the size of the string. If the eeprom has a null value at the end of the string when writing to it, the read string will have that null at the correct place.

Situation

I am saving mobile numbers of users as:

uint8_t EEMEM users[numberOfUsers][maxChar4Number];

Now when I get a number parsed and then save it to eeprom

#define eepu(message, EEADDR, BLKSIZE) eeprom_update_block((const void *)message, (void *)EEADDR, BLKSIZE);

eepu(user, users[0], strlen(user)); //strlen(user) will be less than the maxChar4Number

This will write the number to eeprom. When I read the i would be reading maxChar4Number bytes and a number could have been shorter than that length.


texts:
Hello is there an Arduino Simulator for Windows that can be detected by Arduino IDE through a Virtual COM Port?

I've seen simulator online but I can't seem to find a simulator that can be programmed using the Arduino IDE through a Virtual COM port.


texts: Install Arduino IDE in Raspberry Pi 3 model B

texts:
I am trying to install Arduino IDE in my Raspberry Pi model 3 but it is unable to locate file path.

I use the following steps

sudo apt-get update && sudo apt-get install arduino

and in result I found this

pi@raspberrypi:~ $ sudo apt-get update && sudo apt-get install arduino
Hit:1 http://archive.raspberrypi.org/debian stretch InRelease
Ign:2 http://repository.pi4j.com wheezy InRelease
Hit:3 http://repository.pi4j.com wheezy Release
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package arduino

I am searching for a solution but not able to understand what's the problem here.

Any ideas to make it work will be helpful.


texts: Can Arduino post multiple sensor data to one Google Spreadsheet?

texts:
Let's say I have one MQ5 gas sensor at home and one MQ135 gas sensor at the park. They are wirelessly hooked to Arduino.

My questions are:

Can Arduino post the data from two or more sensors to one Google Spreadsheet and organize it in two different charts?

Can only one Arduino accomplish this?

If not, what are the alternatives?


texts: Arduino UNO does not get recognized by PC(no USB connecting sound), also TX and RX not blinking, neither are lit

texts:
I am trying to build a robot, which needs motors to roll around. So I was trying to control two DC motors with H-Bridge that comes with Arduino StarterKit(H-bridge motor driver [L293D]). I used Sketch that looks something like that

I did read that Arduino needs separate powering, but i did not use any only USB connection. I connected 5V that comes from arduino to where + pin from battery should have been connected and motors were controlled and working.
However when i tried using 9V battery and connecting it as seen on above picture ,H-bridge did not control mototrs and nothing was working.
There is also another aspect - when robot was touching the surface then wheels did not move aka motors did not rotate and when you picked it up motors accelerated to quite some speed. Also when robot was on the surface and connected via USB, the PC made these USB connecting sounds repeatedly.
I am not sure when RX and TX stopped working. Power LED and L13 LED do work correctly.

Any ideas? Is it Fixable?


texts: Control a stepper motor wireless with a radio module?

texts: I'm new in this arduino stuff and i was wondering if it's possible to control a stepper motor wirelessly with an encoder using 2 arduinos and a transceiver module?


texts: Which tft works on both Arduino Uno and Raspberry pi

texts:
Ideally I'd like a 2.8 inch and it to be touch screen.
But most of all I'd rather it work on both boards without much hassle.


texts: lcd doesn't show any characters , is the problem in the lcd itself?

texts:
That's my wiring besides another part of a project ( ultrasonic sensor) which works correctly on the same breadboard, Rs 12 , En 11 , d4 8 , d5 9 , d6 10 , d7 13 I tried to change power of arduino from 5 to 3.3 volt & I tried to use a power adapter

the lcd sometimes show me dark boxes for seconds when I use the potentiometer often in the first row of the display
i used the simulation of tinker cad & it's working but doesn't work on my project & i used the default arduino code with changing the pins number

code :

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 8, d5 = 9, d6 = 10, d7 = 13;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the display:
  lcd.noDisplay();
  delay(50000);
  // Turn on the display:
  lcd.display();
  delay(50000);
}

[![enter image description here][2]][2]


texts: LM335Z temperature sensor gives very varying values

texts:
I'm trying to get consistent values from the LM335Z temperature sensor. But it behaves very strange.
I'm using an arduino nano and it's powered via USB from a Raspberry Pi. The circuit also has two little reed relays (SIP-1A05), a button and a potentiometer.
It's connected like this:

Additionally I'm using analogReference(EXTERNAL) in an attempt to get consistent values, so I've connected the Arduinos 5V output to the reference voltage pin.
Here's the code for reading the thermometer:
int getTemperature() {
  int rawvoltage = analogRead(0);
  float millivolts = (rawvoltage / 1024.0) * 5000;
  float kelvin = (millivolts / 10);
  float celsius = kelvin - 273.15;
  return round(celsius);
}

Then it just waits for me to say "get" in the serial monitor and it replies with:
void sendData(){
  String data = (String)getTemperature();
  data += ',';
  data += (String)map(getTablePos(), 0, 1023, 0, 100); //Potentiometer
  data += ',';
  data += (String)getTableActive(); //1 or 0
  Serial.println(data);
}

I also read somewhere that the first couple of readings are unreliable, and that you should read a couple of times in startup, which I do:
for(int i = 0; i < 10; i++){
    analogRead(0);
    delay(1);
  }

Yesterday the termometer reported 37 degrees. Today it started by reporting 49 degrees. After asking for the temperature a couple of times it said 56. Then now, about an hour later it says 52. And if one of they relays is active it says 77 degrees.
My two other (non Arduino) thermometers have ben on a steady 25 all this time.
What should I do to get reliable values from the LM335z?

Edit
Added dots to the intersections of the circuit diagram for better readability.
I've also found a way to get the thermometer to work, kind of. I removed the external analog reference and only have one 1kOhm resistor for the LM335Z.
Then I have this code instead:
const float cal = 4.62; //Voltage between 5V and GND, measured with multimeter

float getTemperature() {
    float input = (float) analogRead(0);
    input = (input*cal)/1024.0;
    return (input/0.01)-273.15;
}

It worked perfectly standalone on an Arduino Uno powered via USB3.0. When I moved it over into my project with the Nano it gave a few degrees off, but that can be combated by just subtracting the difference I guess.
Then I tried switching to a USB2.0-port on my keyboard, and the values started jumping all over the place.
Here's a comparison using Arduinos rather spartan plotter:

Left: USB2.0 via keyboard hub. Right: Front panel USB3.0.
Also, the temperature dubbels when a relay is on.
How do I tackle this? I'd like keep powering it from my Raspberry pi 3, if possible.


texts: Not able to get response from esp using Arduino uno

texts:
I am new to Arduino & ESP modules, here am trying to communicate with ESP-01 via Arduino UNO. I have gone through multiple websites for initial setup. But when i upload my code to UNO, ESP is not responding back.Below is the code i have used.

#include<SoftwareSerial.h>
SoftwareSerial ESP(0,1); // RX, TX
//ESP RX-->1(UNO) TX-->0(UNO)

void setup() {
// Open serial communications and wait for port to open:

    Serial.begin(9600);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
    }

   // Serial.println("Goodnight moon!");

    // set the data rate for the SoftwareSerial port
    ESP.begin(9600);

}

void loop() {
      ESP.write("AT\r\n"); //Normally ESP responds to AT command with "OK"
    while (ESP.available()) {
        char inData = ESP.read();
        Serial.println("Got reponse from ESP8266: ");
        Serial.write(inData);
    }

}

Source: Link of the url

My observation on this is

ESP is blinking blue light when i reset UNO
UNO TX onboard LED is blinking
when i am trying to do  Serial.println("Goodnight moon!"); it is printing
Serial.println("Got reponse from ESP8266: ");         Serial.write(inData); is not printing

My questions are:

Is there any need to flash ESP with Firmware or is it default enabled.(i have 3 esp's with me all of them not responding with above code)
If no need then what is the possible mistake i am doing.

Here is the screenshot https://i.stack.imgur.com/mOklg.png

Note: I haven't used breadboard for connection, directly connected UNO-TX -> ESP RX and UNO-RX -> ESP TX, 3.3v VCC and ground.In the above screenshot on upload nothing prints, only when i type something "Got reponse from ESP8266: " is printing


texts:
If I want to use a MAXIM 485 for a RS485 communication, is there any option to include the Control DE and RE' pin in a natural manner in the code, instead changing the control pin everytime I made a Serial.print()?

Should I overload the HardwareSerial object in order to add those pin operations everytime?


texts: Portable power for an UNO with a nrf24l01+ attached?

texts: Okay so I have an UNO that has an nrf24l01+ attached. I want it to be completely wireless so free of the 5v USB power and the 12V wall plug. In this case what can I use? I do not wish to plug the power directly into the Vin as I am relatively new and afraid that it might fry the board. So I wish to plug it into the barrel jack. So I have read that using a 9v battery to power UNO is a waste of power as most of the power is translated into heat. Also, using 4 AA batteries seem to be a good solution except that I'm not sure if it has enough power for nrf24l01+ as I've read that an arduino with nrf24l01+ on batteries creates an unstable wireless node. I would like some help on what I can power the UNO with.


texts: How can I indicate that I am using ATmega2560 so that Arduino libraries understand it?

texts:
I am developing AVR microcontollers in Atmle Studio and sometimes I am using Arduino libraries(such as LiquidCrystal).

When I initialize LiquidCrystal lcd(12, 11, 5, 4, 3, 2); I don't think Arduino Libraries use registers and ports of ATmega2560, although I am building my code with the device selection ATmega2560 option of Atmel Studio. Atmel Studio works in order to program 2560 but how can I tell Arduino libraries that I am using 2560?


texts: What are the specific pins to connect the following : DHT 11, ULTRASONIC SENSOR, ESP8266 and arduino uno?

texts:
I researched a lot on how to connect this devices to each other to get the data from ultrasonic sensor and DHT11. But it wasn't clear on how I will connect the devices on their pins.

I found one image which is exactly what I need. The problem is that the source doesn't show instruction on how it was connected through PINS.

Original image


texts: What is the quickest and simplest way for two Arduinos, with network shields, to communicate?

texts: I have two Arduinos, each with a network shield.  What is the quickest and simplest way to connect a cat5 cable between these two Arduinos and have them exchange strings?


texts: How can I break the loop if it hasn't finished in 10 seconds?

texts:
Currently I am using OneButton.h library to code  my push button project.
When I press button1, it will loop for 10sec and print TRIG, and after that it will break the loop.
However, now I want to program it where when I pressed button1, it will jump to void(singleclick) function, but right now, during the 4th seconds (anytime before 10th sec) , I pressed other button, thus Arduino will break the 10sec loop and run other function.
Thus, I need help how to make sure Arduino actively read other button and when pressed, it will break the current loop/function to other related functions.
#include <OneButton.h>

OneButton button1(2, true);
OneButton button2(3, true);
OneButton button3(4, true);
OneButton button4(5, true);

int led1=12;
int led2=11;
int led3=10;
int led4=9;

int flag;

unsigned long mode;

void setup()
{

  Serial.begin(9600);
  pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  pinMode(led3,OUTPUT);
  pinMode(led4,OUTPUT);

  button1.attachClick(singleclick1);
  button1.attachLongPressStop(longclick);

  button2.attachClick(singleclick2);
  button3.attachClick(singleclick3);
  button4.attachClick(singleclick4);

   digitalWrite(led1,HIGH);
   digitalWrite(led2,HIGH);
   digitalWrite(led3,HIGH);
   digitalWrite(led4,HIGH);

}

void loop()
{
  button1.tick();
  delay(20);

  button2.tick();
  delay(20);

  button3.tick();
  delay(20);

  button4.tick();
  delay(20);

  Serial.println("No button");

}

void singleclick1()
{
   mode=millis();

   flag=1;

   while(flag==1)
   {
     Serial.println("button1");
     digitalWrite(led1,HIGH);
     digitalWrite(led2,LOW);
     digitalWrite(led3,LOW);
     digitalWrite(led4,LOW);

     if(millis()-mode>5000)
     {
      Serial.println("TRIG");
      flag=0;

      button2.tick();
      delay(20);

      button3.tick();
      delay(20);

      button4.tick();
      delay(20);

      return;
     }
   }
}

void singleclick2()
{
   Serial.println("button2");
   digitalWrite(led1,LOW);
   digitalWrite(led2,HIGH);
   digitalWrite(led3,LOW);
   digitalWrite(led4,LOW);
}


texts:
I am trying to make Ken Sherriff's version of the TV-Be-Gone with the Arduino using the updated v1.2 software.  He uses this setup:

His Setup

My Setup

I used the Arduino Nano with same MCU (Atmel ATmega328) as Uno but changed a few other things also. For power I supplied 9v to the vin pin but supplied the transistor with 5v from the 5v pin. I used this Instructable by the same person.  The only major change was I used a PN2222A transistor instead of 2N4401.

Problem

My problem is that even though when I push the button the infrared light blinks for a while sending the different codes my receiver won't pick it up. I checked my receiver with other remotes and it works and I tried at close and far range. My receiver just blinks if it senses any infrared command regardless of what type of remote but it doesn't work with my Arduino TV-Be-Gone. I haven't tried it with a real TV yet but would like for it to work before I try it on a real one.


texts: Cant upload arduino code when ESP8266-01 module is connected

texts:
I'm using this tutorial to connect my ESP8266-01 WiFi Module to Arduino UNO with Arduino IDE v. 1.8.13.

It works and the module can connect to my WiFi.
However, when I try to upload my code, it says:
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30
What could be the problem, since when I remove the reset pin it uploads the code, but now the WiFi goes down.


texts: How do I stop the slave from running the code until master sends a new value? I2C

texts:
I'm a total noob when it comes to Arduino. I'm slowly learning stuff. I was trying this code which basically gets input in Arduino1(master) and displays the character in serial monitor of Arduino2(slave). The code words just find but I just need the slave to wait until the master sends the next character. Right now, the slave is continuously printing the character.

Master code:

    #include "Wire.h"
    char ch;

    void setup() {

      Serial.begin(9600);
      Wire.begin();

    }

     void loop() {
      while(Serial.available()==0)
      {}
      ch=Serial.read();
      delay(1000);
      Serial.print("The character that you entered is ");
      Serial.println(ch);

      Wire.beginTransmission(9);
      Wire.write(ch);
      Wire.endTransmission();

        }

Slave code:

#include "Wire.h"
char x;

void setup() {

  Serial.begin(9600);
  Wire.begin(9);
  Wire.onReceive(Event);

}
void Event(char bytes){
  x = Wire.read();
}

void loop() {

  Serial.print("The character that you entered in the other Arduino is ");
  Serial.println(x);
}

I know that this will be simple but I just can't quite figure out what to do. Please help me out


texts: How to setup Uno + xbee shield 1.1 + wee wifi chip?

texts:
I am an absolute beginner with electronics and Arduino.
I have this hardware:

arduino uno
xbee shield 1.1
wee wifi chip

I've tried to make them work (to connect my Uno to the Internet) but I can't find the right tutorial.

Are there good resources I should look at, or do you know how set this up?


texts: Driver shield providing 24+ pins at 100mA (for Mega 2560)

texts: Do any shields (or similar boards) exist to let the Mega 2560 (or Due) output a full 100mA per pin on at least 24 pins, in a digital on/off fashion? I know there is a motor shield, but it looks to have only a handful of outputs. It seems very common that people need to output higher current than the MCU can provide safely (if at all), but there do not appear to be any shields for this. Of course individual transistors are fine for a few outputs, and some chips can do up to 8, but what about the rest of us who want to use all those nice pins on the Mega, Due, or similar but who need more power?


texts: Cheapest and easiest Arduino board for 12 bit ADC, thinking of M0

texts:
I need an Arduino board for simple ADC, but 10 bits of resolution is sadly not enough. I am going to buy a board with 12 bits of resolution, but really couldnt decide on the exact model. It needs to be easily accessable and wont be used for anything else other then ADC. I have my eye on MO, but cant decide if i should buy the pro or the normal one, or just another Arduino board.

I take the data through USB port and the instrument will also be powered with the same USB cable.

* My only option is to use an Arduino*

I know i can use the Aref pin or do oversampling but i really am not intrested in those options. thanks for your input


texts:
if(pin10==HIGH)
  val=analog.read (potpin);
  val=map(val,0,1023,0,180);
  servowrite(val);
else
  val=map(0,1023,0,90);
    servo.write(val);}


texts: What kind of data type can be use store a binary bit-stream which is more than 64-bits?

texts: I'm wondering if one needs to assign a bit-stream of 78 bits to a variable(later on to be processed), what datatype can be used? What is the max bit can be stored into a variable in C?


texts: Where is the documentation for writing an Arduino core?

texts:
I'm interested in writing an "Arduino core" (i. e. porting Arduino to a new MCU and new board(s)).  I'm having trouble finding much documentation on how to do so.  Am I missing something?
This page says "anyone may develop a core for their own boards following the rules and requirements we have issued."  So, where are those "rules and requirements?"
I found something called the "Platform Specification", which sounded promising, but it only documents the config files; it does not say anything about the code that needs to be written to support a new platform.
I found ArduinoCore-API, which says it is the "hardware independent layer of Arduino core."  But it doesn't mention anything about how to write the hardware-dependent part of the core.
I'd be grateful if anyone could point me to the Arduino core documentation.  It's not turning up in my web searches.  Thanks!
Clarifications:

Yes, I can look at existing cores as examples, but I'd rather have the documentation, as well.  Especially since existing cores may be of varying quality, or may not be up to the latest standard.  Documentation is always a good thing.
The reason I want to write a core is because... I want to use an MCU which is not currently supported!  (Specifically, I want to add support for the GD32F350, but really that shouldn't be relevant to answering "Where is the documentation?")


texts:
i have a project to control a relay by sms and call by arduino and sim800L gsm modem
and i need to modify the code below to by adding command to reboot or reset the modem ever hour
i mean delete all sms and call history and reboot the modem because the modem is always on for long time and the modem after few days of operation becomes not responsive
any one can help me and solve the problem

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);  // (Rx,Tx  > Tx,Rx)

char incomingByte;
String inputString;
int relay = 4; // Output for Relay Control
int LEDG = 8;
int buzzer = 5;
int LED = 6;
int buttonPin = 2;
int buttonState = 0;
void setup()
{
      pinMode(relay, OUTPUT);
      pinMode(buzzer, OUTPUT);
      pinMode(LED , OUTPUT);
        pinMode(LEDG , OUTPUT);
      pinMode(buttonPin, INPUT);
      digitalWrite(relay, LOW); // Initial state of the relay
       digitalWrite(buzzer, LOW);
        digitalWrite(LED, LOW);
        digitalWrite(LEDG, LOW);

      Serial.begin(9600);
      mySerial.begin(9600);

     while(!mySerial.available()){
        mySerial.println("AT");
        delay(1000);
        Serial.println("Connecting...");
        }
      Serial.println("Connected!");
      delay(30000);

      mySerial.println("AT+CMGF=1");  //Set SMS to Text Mode

      delay(1000);

      mySerial.println("AT+CNMI=1,2,0,0,0");  //Procedure to handle newly arrived messages(command name in text: new message indications to TE)
      delay(1000);
      mySerial.println("AT+CMGL=\"REC UNREAD\""); // Read Unread Messages
      delay(1000);
       mySerial.println("AT+CLIP=1");
        delay(1000);
      digitalWrite( LEDG , HIGH);
     }

void loop()
{

 m:
  if(mySerial.available()> 0){
      delay(100);

    inputString = mySerial.readString();
    Serial.println(inputString);

     if(inputString.indexOf("0000000") > 0)
      {
             mySerial.println("ATH");
             delay(250);
            digitalWrite(relay, HIGH);
            delay(250);
            digitalWrite( buzzer , HIGH);
            delay(250);
            digitalWrite( LED , HIGH);
            delay(300);
            digitalWrite( relay , LOW);

            while(1){
               inputString = mySerial.readString();
                    Serial.println(inputString);
                  if (inputString.indexOf("00000000")>0 && inputString.indexOf("OFF") > -1){

                     digitalWrite( buzzer , LOW);
                     digitalWrite( LED , LOW);
                     goto m;
                  }
            buttonState = digitalRead(buttonPin);
           if (buttonState == HIGH) {
                    digitalWrite( buzzer , LOW);
                     digitalWrite( LED , LOW);
                   goto m ;
                   }
                   }

          }

    if(inputString.indexOf("000000") >0 && inputString.indexOf("1") > -1 )
      {

            digitalWrite(relay, HIGH);
            delay(250);
            digitalWrite( buzzer , HIGH);
            delay(250);
            digitalWrite( LED , HIGH);
            delay(300);
            digitalWrite( relay , LOW);
               while(1){
                   inputString = mySerial.readString();
                    Serial.println(inputString);
                  if (inputString.indexOf("00000000")>0 && inputString.indexOf("OFF") > -1){

                     digitalWrite( buzzer , LOW);
                     digitalWrite( LED , LOW);
                     goto m;
                  }

           buttonState = digitalRead(buttonPin);
           if (buttonState == HIGH) {
                    digitalWrite( buzzer , LOW);
                      digitalWrite( LED , LOW);

                       goto m;
                   }

                   }

          }

  }
}


texts: Building your own ESP8266 development board

texts:
I was wondering if someone could help me out?
I have been looking for a project that would test my existing skills and force me to learn new ones, and I thought that trying to build my own ESP8266 development board might be the best thing for me to try out.
I got some ESP 12-F boards and some veroboards that support it, it has a space for the ESP-12 and pads that lead to holes you can solder to.
However, I am a little confused at the moment. On a NodeMCU, for instance, you have way more connections than the ESP 12 offers out of the box. Is there a resource or guide that explains how these are broken out so that I can figure out how to provide those connections on my little dev board project? Like on the example here:
https://randomnerdtutorials.com/getting-started-with-esp8266-wifi-transceiver-review/
I get that I need to add the UART logic, I have that on order right now. I am just confused at the moment on how to break out the rest of the pins.
I hope this makes sense, please be gentle on me, this really is my first serious project and I wanted it to be challenging in order to learn.
Cheers,
Rafa


texts: How can I record a push button sequence and store it in an array

texts: I have 3 push buttons and I want to record the sequence in which they are pressed in array of size 10,i.e, I want to record 10 values for example {1,1,2,2,3,3,1,1,1,3}. I want to blink an array of 3 LED in the same pattern in which the buttons were pressed. I have two extra push buttons for putting the arduino in record and play modes respectively. If any one can suggest how I can store the values in the array I will really be very thankful. I am also facing the problem because it's very difficult to manage the bouncing of the buttons simultaneously.


texts: Proxying streaming i2c data(int values) to serial

texts:
The following code works correctly in reading single int values. It also works correctly for 3-4 seconds if I 'stream' the values in constantly (Mouse move coordinates) before I get an IO error and the i2C bus connection is dropped. I assume this is some sort of buffer overrun...or? Can anyone get me on the right track here? What changes do I need to make so that I can constantly stream in serial data?

    #include <Wire.h>

#define SLAVE_ADDRESS 0x04
int zeroByte;
int state = 0;
int receivedValue = 0;

int numBytes = 0;

bool newData = false;

void setup() {
    pinMode(13, OUTPUT);
    Serial.begin(9600);         // start serial for output
    // initialize i2c as slave
    Wire.begin(SLAVE_ADDRESS);

    // define callbacks for i2c communication
    Wire.onReceive(receiveData);
    Wire.onRequest(sendData);

    Serial.println("Ready!");
}

void loop() {
    delay(100);
    if(newData){

      Serial.println(receivedValue);
      newData=false;
    }
}

// callback for received data
void receiveData(int byteCount){

    while(Wire.available()) {
        newData = true;
        zeroByte = Wire.read();

         if(Wire.available() == 2)
  {
    receivedValue = Wire.read() | Wire.read() << 8;

  }

     }
}

// callback for sending data
void sendData(){

    Wire.write(receivedValue);
}


texts:
I'm working on a project where my arduino talks to another device that uses serial communication. I've connected my USB cable to a USB-to-serial adapter, so it can communicate with the device.

The problem I'm running into is powering the device: if I'm using the USB for serial, I can't use it for power. I have made sure that the device isn't turning on by putting

pinMode(13, OUTPUT);
for (int i = 0; i < 10; i ++) {
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);
}

at the start of the setup function: if it works, it should start by blinking LED 13.

I tried powering it with a 5V power supply through the power jack, next to the USB connector, but that didn't work. Is there something I'm missing? Do I need a different type of power supply?


texts: How to return a message when calling by a TCP connection?

texts:
I am working on a communication between Android and Arduino board.

The Android makes a TCP connection with the board and successfully sends some strings to the board.

The problem is, there is an int in my Arduino code (e.g. int distance) and I would like to pass that back to my Android device.

I have handled the Android side already, but I do not know how to return a message from Arduino.

in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

                //in this while the client listens for the messages sent by the server
                while (mRun) {
                    serverMessage = in.readLine();

                    if (serverMessage != null && mMessageListener != null) {
                        //call the method messageReceived from MyActivity class
                        mMessageListener.messageReceived(serverMessage);
                    }
                    serverMessage = null;

                }

This is the Android side code but I think that it is not a specific Android problem, there should be some way for Arduino to make a response of an integer variable (without concern what is the source device)?

What I should do in Arduino for making that response?


texts: Modify Arduino Due's Bootloader to flash when reset

texts:
I bought an Arduino Due, and I noticed unlike the other boards, the onboard LED does not flash after reset. I prefer this behavior, so I want to modify the bootloader to do this behavior when it starts. I have burnt bootloaders before, but I never modified one before.

How can I do this?


texts:
I have a ESP8266 on a Wemos D1 mini board. Simple "Rainbow with FastLED" animation. Shouldn't do much but the board gets so hot I can't touch it and it drains a 2500mAh battery in less than an hour.

Any idea what I'm doing wrong? Especially as a comparable micropython implementation just doesn't get that hot and the same battery keeps for about 5 hrs...

Here's the code

#define FASTLED_ALLOW_INTERRUPTS 0
#include "FastLED.h"
#include <EEPROM.h>

// How many leds in your strip?
#define NUM_LEDS 60
#define DATA_PIN 13
#define CLOCK_PIN 14
#define COLOR_ORDER RGB
int starthue = 0;
int incrementer = 255/NUM_LEDS;
CRGB leds[NUM_LEDS*2];
int address = 0;
int max_modes = 4;
int colormode;

void setup() {
  Serial.begin(9600);
  // put your setup code here, to run once:
  FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS*2);
    EEPROM.begin(512);
  colormode = EEPROM.read(address);
  Serial.println(colormode);
  int new_mode = (colormode == max_modes) ? 1 : ++colormode;
  Serial.println(new_mode);
  new_mode = (colormode == 0) ? 1: new_mode;
  Serial.println(new_mode);
  EEPROM.write(address, new_mode);
  EEPROM.commit();
  EEPROM.end();
}

void rainbow_mid(int howfast) {
  while (true) {
    fill_rainbow(leds, NUM_LEDS, starthue, incrementer);
    for (int i =0; i< NUM_LEDS; i++) {
      leds[NUM_LEDS-i-1] = leds[i];
      leds[NUM_LEDS*2-i-1] = leds[i];
    }
    FastLED.show();
    delay(howfast);
    starthue++;
  }
}

void rainbow(int howfast) {
  while (true) {
    fill_rainbow(leds, NUM_LEDS, starthue, incrementer);
    //addGlitter(80);
    for (int i =0; i< NUM_LEDS; i++) {
      //leds[NUM_LEDS-i-1] = leds[i];
      leds[NUM_LEDS*2-i-1] = leds[i];
    }
    FastLED.show();
    delay(howfast);
    starthue++;
  }

}

void loop() {
  switch(colormode) {
    case 1: rainbow_mid(10); break;
    case 2: rainbow_mid(50); break;
    case 3: rainbow(10); break;
    case 4: rainbow(50); break;
  }

}


texts: ESP8266(01) doesn't work when servo connected to GPIO-2

texts:
the wiki here says http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations

0 Low
1 High
x floating
MODE                   GPIO15   GPIO0   GPIO2
SDIO (BootSDCard)       1       x        x
UART (UploadCode)       0       0        x or 1
FLASH (NormalRunning)   0       1        x or 1

Can connecting my GPIO 2 to a servo Signal Wire cause it to go LOW? because some how my ESP8266 doen't boot when I have a servo hooked up to it.
I tried to change it to RX (which is GPIO3 on ESP8266) and everything seems to work fine. But I wanna know the reason why GPIO2 didn't work.

Thank you.

p/s:http://www.goodluckbuy.com/ld-1501mg-metal-gear-digital-servo-17kg-for-rc-robot.html this is the servo, if it matters. Also GPIO-2 works when I use another servo of different type instead (I don't know its name though)


texts: Infrared receiver gives only zeroes for results

texts:
I bought a 37 in 1 sensor kit from Aliexpress.

Now am trying to use the infrared receiver with a TV commander.

My problem is that it returns as result only zeroes. The wiring is right. The code is from an example and includes not much.

I did a serial print to see if the receiver is working. It gives zeroes back so it is working.

I thought maybe a different library will help and downloaded irlib2 library and set the folders into the library folder.

But it can not find it the library so i must use IRremote library.

#include <IRremote.h>

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

void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
}

void loop(){
Serial.println(results.decode_type);

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

    Serial.println(results.value, HEX);
    irrecv.resume();
}
}

What can i do to find what causes the zeroes?


texts: Audio Frequency White Noise generation using Arduino Mini Pro

texts:
For DIY, how to program Arduino Mini Pro to act as an Audio Frequency White Noise generator?

Presumably,

a) using one Digital Output pin

b) feed to a simple passive RC low pass filter to reduce out of band signal

c) feed to a simple class-D IC chip audio amplifier and speaker

d) since it is DIY and noise, lo-fi (not hi-fi) is good enough.

Specific questions,

a) How to program?

b) Wonder if it is better to use to chip act a Pulse Width Modulated 'digital to analogue converter'?

c) How to calculate value for RC filter (assume amplifier has high input impedance)?

Many years ago, I have programmed a hardware sound generator chip as part of a game machine. It has two registers for amplitude and 'frequency' control (band of 'white' noise). It worked very well. I once looked at the output using oscilloscope and it was square wave. I believe that it works, basically, using the above principles. Since I do not have the chip now, I cannot verify it. Now, I would like to duplicate its function using Arduino in software.


texts:
What I would like to do is control my garden lights using the ESP8266. For this I use the Arduino approach from here. This works great, I use bootstrap and jquery even :D all is well!

Switching lights on and off using my code is fine but now I'd like to switch some continues routines, like blinking. I can start the blinking from the webpage but this code is a loop so I cannot get back to turn it  off again.

I could make it blink for a set amount of loops, so eventually it will stop blinking and show the control webpage again.
Or I can add the blinking to the hardware, maybe use a 555 for the first time?
But there might be a better way of implementing this..

Using Google I found information about Break and Interrupts, not yet what I am looking for.

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char *ssid = "mynetwork";
const char *password = "mypassword";

ESP8266WebServer server ( 80 );

const int led = 5;
String webPage =
"<!DOCTYPE html>\
\
\
  <title>Funny Bunny Control</title>\
  <meta charset='utf-8'>\
  <meta name='viewport' content='width=device-width, initial-scale=1'>\
  <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>\
  \
  \
\
\

\

\

Funny Bunny v0.1
\

\

Omdat snuffelen er bij hoort.
\

Niet voeren aub.
\

\

aan
\

uit
\

\

\
\
";

void handleRoot() {
  server.send(200, "text/html", webPage);
}

void aan() {
  digitalWrite ( led, 1 );
  server.send(200, "text/html", webPage);
}

void uit() {
  digitalWrite ( led, 0 );
  server.send(200, "text/html", webPage);
}

void setup ( void ) {
  pinMode ( led, OUTPUT );
  digitalWrite ( led, 0 );
  Serial.begin ( 115200 );
  WiFi.begin ( ssid, password );
  Serial.println ( "" );

  // Wait for connection
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  Serial.println ( "" );
  Serial.print ( "Connected to " );
  Serial.println ( ssid );
  Serial.print ( "IP address: " );
  Serial.println ( WiFi.localIP() );

  if ( MDNS.begin ( "esp8266" ) ) {
    Serial.println ( "MDNS responder started" );
  }

  server.on ( "/", handleRoot );
  server.on ( "/aan", aan );
  server.on ( "/uit", uit );
  server.onNotFound ( handleRoot );
  server.begin();
  Serial.println ( "HTTP server started" );
}

void loop ( void ) {
  server.handleClient();
}


texts: Stopping / starting DC motor with Limit Switches and on/off button

texts:
I have an Arduino UNO with 3 switches attached (2 limit switches, 1 activation switch). I'm trying to make the activation switch turn the motor forwards once hit, then wait for any of the limit switches to be hit and stop the motor. The next step is to wait for the activation switch to be hit again and turn the motor in the opposite direction and wait for the limit switch to be hit and stop the motor.

But the issue I'm facing right now is when i press the activation switch the arduino board and H bridge board restart. The LED's turn on and off and the code restarts. And nothing happens. I know all the switches and motor is working because i have tested them by simplifying the code with just the functions.

(edit) Here is a picture of the schematic:

Can someone please review my code below to see if my logic is correct.

const byte  frontButtonPin = 2;
const byte  backButtonPin = 4;
const byte  onOffButtonPin = 11;
const int   motorPin =  8;
const int   motorPin2 =  7;

boolean  frontButtonState = 0;
boolean  backButtonState = 0;
boolean  onOffButtonState = 0;

/**
    setup inputs for switches and outs for motor pins
    serial begin to read the switches to test for errors
*/
void setup() {
  // initialize the pin as an inputs:
  pinMode(motorPin, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(frontButtonPin, INPUT);
  pinMode(backButtonPin, INPUT);
  pinMode(onOffButtonPin, INPUT);
  Serial.begin(9600);
}

/**
   this function turns motor foward
*/
void drawMovesForward() {
  // turn motor foward:
  digitalWrite(motorPin, LOW);
  digitalWrite(motorPin2, HIGH);
}

/**
   this function turns motor backwards
*/
void drawMovesBackward() {
  // turn motor in other direction:
  digitalWrite(motorPin, HIGH);
  digitalWrite(motorPin2, LOW);
}

/**
   Stop the motor form moving
*/
void stopDrawFromMoving() {
  digitalWrite(motorPin, LOW);
  digitalWrite(motorPin2, LOW);

}

/**

*/
void loop() {

  frontButtonState = digitalRead(frontButtonPin);
  backButtonState  = digitalRead(backButtonPin);
  onOffButtonState = digitalRead(onOffButtonPin);

  if (onOffButtonState == HIGH) {
    if ( frontButtonState == LOW ) {
      drawMovesForward();

    }

    else if (backButtonState == LOW ) {
      drawMovesBackward();
    }

  }
  else {
    if ( frontButtonState == HIGH ) {
      stopDrawFromMoving();
    }

    else if (backButtonState == HIGH ) {
      stopDrawFromMoving();
    }
  }
}


texts: Using two MIDI inputs with Arduino UNO (with one serial)

texts:
Would it be possible to use TWO MIDI inputs (and a MIDI output) on an Arduino having only one RX/TX serial port? Timing will be somewhat critical so a software serial port is not usable probably. I need to listen continuously to both MIDI (in) ports not to miss messages.

Or is it better to use an Arduino Mega having 4 serial ports?


texts: Reading NFC card (PN532) with Arduino Uno

texts:
I am trying to detect a RFID card using the NFC-PN532 module and Adafruit_PN532 library.

Initialization code:-

#include <Adafruit_PN532.h>
#include <Wire.h>

#define SCK  (13)
#define MISO (12)
#define MOSI (11)
#define SS   (10)
Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing please wait.......");
  delay(3000);
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata)
  {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }

  Serial.print("Device Found PN5 Chip");
  Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware version > ");
  Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.println((versiondata>>8) & 0xFF, DEC);
  nfc.SAMConfig(); //Set to read RFID tags
  Serial.println("Waiting for RFID Card ...");
}

Main loop:-

void loop()
{
  uint8_t success = 0;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
  uint8_t uidLength;
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
  if (success)
  {
      Serial.println("Card Detected!");
  }
  else
  {
      Serial.println("Card Not Detected or Removed!");
  }
}

Whenever i place a valid card on the PN532, Card Detected! is printed on the serial monitor.

However, when i remove the card, Card Not Detected or Removed! does not get printed.

How can i make the program  to loop in such a way that it can detect when the card is present/removed?


texts:
Using an ATSAMD21 with the Arduino core, I'm running into an issue where the RTCZero alarm callback won't continue running the loop() function. If I schedule another alarm inside the callback, the second alarm will execute the loop() function after the callback is done. Every second time it works, every other time it doesn't.

Minimal example in which I expect the LED to change state every 2 seconds, which does not happen:

#include <RTCZero.h>
#include <time.h>

RTCZero rtc;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  rtc.begin();
  rtc.attachInterrupt(alarmMatch);
  schedule_wake_up();
  rtc.enableAlarm(rtc.MATCH_HHMMSS);
}

void loop()
{
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  schedule_wake_up();
  rtc.standbyMode();    // Sleep until next alarm match
}

void schedule_wake_up() {
  time_t wakeupTimestamp = rtc.getEpoch();
  wakeupTimestamp += 2;
  struct tm *wakeupTimeStruct = gmtime(&wakeupTimestamp);

  rtc.setAlarmSeconds( wakeupTimeStruct->tm_sec );
  rtc.setAlarmMinutes( wakeupTimeStruct->tm_min );
  rtc.setAlarmHours( wakeupTimeStruct->tm_hour );
}

void alarmMatch()
{
  // Do nothing, just wake up
}

Arduino IDE 1.8.9
RTCZero ver 1.6.0
SAMD core ver 1.8.4 and 1.6.20 tried


texts:
I am trying to connect my Android smartphone with my Arduino Uno by sending a NDEF message to my phone.
I know that the MIME type for bluetooth is application/vnd.bluetooth.ep.oob but in my PN532 library I don't know what's the right prefix.

You can see prefixes here : https://github.com/Seeed-Studio/PN532/blob/master/PN532/PN532.h#L66

Thank you


texts: Arduino outputs garbage values on serial monitor with ESP8266

texts:
I have connected my Arduino with an ESP8266.

When I check the ESP8266, by manually entering commands at serial monitor, I get correct results.

However, when I run this program

#include<SoftwareSerial.h>

SoftwareSerial esp8266(2,3);

void setup() {
  Serial.setTimeout(5000);
  Serial.begin(115200);
  esp8266.begin(115200);
  delay(1000);
}

void loop() {
  delay(2000);
  String command="AT";

  esp8266.println(command);
  if(esp8266.available())
  {
    while(esp8266.available())
    {
      char c=esp8266.read();
      Serial.write(c);
    }
  }
}

I get garbage values where sometimes it has an OK in between the output:

  " Received: "ÁT OK " Received: "AÔ ÏË " Received: "AÔ OK " Received: "ÁT ÏË " Received: "ÁT OË " Received: "ÁÔ OK " Received: "Á¬ OK " Received: "ÁT OË "

Could someone help me?


texts: Change one specific byte of an IP address

texts:
So if I have an IP address IP Address: 192.64.5.1, is it somehow possible to change a specific byte of that IP to like IP Address: 192.64.**6**.1

My idea is to change the IP Address into variables IP Address: a.b.c.d
Now I could say a= 192; b= 64; c= 5 + 1; d= 1

But what if I receive the IP Address: 192.64.5.1 as a String. Is it somehow possible to split it up into 4 parts that I can each individually assign to an integer (a, b, c or d)?


texts: Resistors/capacitor used in connecting 23LC1024 SRAM 1 Mbit

texts:
Yesterday I received by 23LC1024 SRAM with 1 Mbit memory.

I tried to search for some libraries and ways how to connect it.

So I searched around on internet first for the connections and saw some different ways of doing it, especially regarding the pullup resistors.

E.g. in Example1 two resistors are mentioned for pin 3 and 7.
In Example 2 only one resistor is used.
In YouTube example 3 three resistors and a capacitor is used. See around 5:25.

My questions:

Is one of those three better (and why)?
Is the capacitor in the youtube example 3 connected to GND or 5v? I cannot map the schema with the breadboard since the capacitor should run between +5 and GND but I don't see the +5 or GND connection (depending on where the capacitor is connected to which I cannot see or deduce).

Btw, I got it working with the 2 resistor solution but just wondering if example 1 is good enough or example 3 is better.