texts: Help to get Arduino UNO with 4 SoftwareSerial transmit only ports

texts:
I just started with my Arduino UNO so please pardon my ignorance with SoftwareSerial but I need help. My goal is to make a system of 4 SoftwareSerial ports. Port1 will receive a burst of 5-10 characters and I will then transmit on eventually Port2,3 & 4. Maybe all or just 1 depending on an operator setting. I made the simplest system to try it where I receive on port1 and display on Serial Monitor. All works well until I do a begin to the second port which is commented out in the listing. When it is not commented out it looks like Port1 receives nothing, no display Port1 never says "available" therefore nothing. Any ideas would be most appreciated.

#include <SoftwareSerial.h>
SoftwareSerial RotorPort1 (8, 9); //RX, TX
SoftwareSerial RotorPort2 (10, 11);

int RotorPortSpeed = 9600;

void setup() {
  Serial.begin(9600);
 RotorPort1.begin(RotorPortSpeed);
  //  RotorPort2.begin(RotorPortSpeed);
  delay(200);
 }

void loop() {
 if (RotorPort1.available()) {
    byte incomingByte = RotorPort1.read();
    Serial.print ("data= ");
    Serial.print(incomingByte);
    Serial.print("  ");
    Serial.print(char (incomingByte));
    Serial.println();
    delay (300);

  }
}


texts: I got a missignatured ATmega328-PU. How can I fix that?

texts:
Sometime in the past, I was burning bootloaders on a fresh batch of four ATmega328-PU using the Arduino IDE (notice there's no P after 328 - it's the slightly cheaper non-picopower version of the MCU, not to be confused with the ATmega328P-PU with a P), and was surprised with the following message from avrdude:

avrdude: Device signature = 0x1e950F
avrdude: Expected signature for ATMEGA328 is 1E 95 14
Double check chip, or use -F to override this check.

That means avrdude thought the chip was not what its label said. Then I changed the chip type on my Arduino IDE to ATmega328P-PU and avrdude burned the bootloader without complaints. What that means is that the chip was labelled as one MCU and internally it responded as another, slightly different.

What I would like to know is:

How rare is this event? Has anyone had a similar experience? (Original question, off-topic)
Is it possible to fix this? How can I fix the signature so that avrdude recognize the chip correctly?

This is a cross-post from EE.SE. I posted this question there but didn't attract much attention, so I wanted to see if anyone from our community had a similar experience.


texts:
I'm using the ArduinoJson library. There is a great example for parsing a single JSON object in the source code. I am attempting to iterate over an array of JSON objects:

#include <JsonParser.h>

using namespace ArduinoJson::Parser;

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

  char json[] = "[{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}, \
    {\"sensor\":\"gps\",\"time\":1351824140,\"data\":[50.756080,21.302038]}]";

  JsonParser<32> parser;
  JsonArray root = parser.parse(json);

  if (!root.success()) {
    Serial.println("JsonParser.parse() failed");
    return;
  }

  for (JsonArrayIterator item = root.begin(); item != root.end(); ++item) {
    // unsure of what to do here.

    Serial.println((*item)["data"]);
    // results in:
    // ParseJsonArray:21: error: call of overloaded
    //   'println(ArduinoJson::Parser::JsonValue)' is ambiguous

    JsonObject something = JsonObject(*item);
    Serial.println(something["sensor"]);
    // results in :
    // ParseJsonArray:26: error: call of overloaded
    //   'println(ArduinoJson::Parser::JsonValue)' is ambiguous
  }
}

void loop() {}

item is of type JsonValue. I would like to treat it as a JsonObject and pull some data out of it.


texts:
How can I fix this sketch to make it so that once the button is pressed, it performs some action for a certain amount of time and then returns back to a low state until it is pressed again. For example, I need to run a pump for 5 seconds when the button is pressed and then turn off automatically. And then, when I press the button again it will repeat, etc. I am not trying to use a relay module if it is not necessary. Here is my current sketch and a Lab View of the components:

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

int switchPin = 8;
int ledPin = 13;
int buttonPresses = 0;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean ledOn = false;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  Serial.begin(9600);
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  lcd.begin(16, 2);
}

boolean debounce(boolean last) //just a debounce function
{
  boolean current = digitalRead(switchPin);
  if (last != current)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;
}

void loop()
{
  {currentButton = debounce(lastButton);
  if (lastButton == LOW && currentButton == HIGH)
  {
    ledOn = !ledOn;

    buttonPresses++;
    lcd.clear();
    lcd.print("Number of Button ");
    lcd.setCursor(0,1);
    lcd.print("Presses = ");
    lcd.print(buttonPresses);
  }
   lastButton = currentButton;
   digitalWrite(ledPin, ledOn);
  }
}

THANK YOU!


texts: Is there a simple (permissive license) Leonardo driver for a USB-to-USART bridge to substitute an FTDI chip?

texts:
I'm making an ESP32 development board and I'm thinking about putting an Arduino Leonardo chip between the USB port and the ESP32's USART pins to act as a USB/USART converter instead of the FTDI chip so that I can program the ESP32 through a USB serial port like any other Arduino board.

Is there a library/sketch licensed under a permissive license (MIT, BSD, Apache, etc.) which can make the Leonardo chip act as a HID Serial Port device which has a device name I want for easy identification in Device Manager and which requires no special driver installation in Windows and Linux once plugged into the computer?

Thank you for your time.


texts:
Can anyone help me with the code-ing to allow the robot to stop at a certain distance when the robot is approaching the tracked object. I am trying to implement it as a colour tracking wheel chair. For Example, the motorized wheelchair is able to track the colour of the shirt of the person infront is wearing and follow the person, and at the same time it is able to leave a distance between the person infront and the wheelchair to prevent collision.

the pixy robot : https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/overview

The code :https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/the-code

Currently the code is only able to track the object till it reaches the object. But my objective is to let it chase the object, but at the same time, leaving a 1 metre distance
away from the object.

Please help me. Thank you


texts:
I am using Arduino Nano to test a code that will be ported on an ATTiny chip, which will need to perform operations at a frequency near clock maximum, calling for a very succinct coding.
My goal: to streamline coding for two different chips in one file with the least repetitions and operations possible.
Specifically, I have a pin
#ifdef TIMSK0 //Nano vs atTiny
const byte  wavePin  = 5,
            waveBit  = B100000;
      byte *wavePort = &PORTD;
#define NANO
#else
const byte  wavePin  = 0,
            waveBit  = PB1;
      byte *wavePort = &PORTB;
#endif

Notice the pointer? It works, but I have the impression this may not be the most efficient option, as it adds an operation (by looking up the reference). I have also planned to do constantly check which chip we are loading it in this fashion
#ifdef NANO
  PORTD
#else
  PORTB
#endif
  |=   waveBit *  waveOn);
#ifdef NANO
  PORTD
#else
  PORTB
#endif
  &= ~(waveBit * !waveOn));

But again, while this may be perfectly fine in operations, it hurts the eyes and is rather repetitive.
Is there a way to create a direct access to a port?


texts:
I'd like to know how much current can supply the 5V pin and the 3.3V pin on an Arduino Leonardo board. I've been lead not to trust the specs on Arduino's website. And, as an added question, can the 5V pin supply enough power for an LM741 opamp?

Thanks!


texts: need to make my partners pill box turnover sensitive

texts: ive done some arduino stuff back in uni like 7 years ago; and reserached premade items-ive looked online at many pill organisers and the best and cheapest one is $149 and isn't shipping to the UK rite now. but basically my partner needs to take 1 pill a day without fail. second set of pills is less urgent and not an issue if he misses, but basically is there like a thing I could whip together to sense when he has turned the pill case over that day or not? maybe sync to phone(would be super useful)  so he knows when he has actually taken it.


texts:
I took an Arduino from a friend yesterday but when I connect it to the laptop there is no light blinking from the Arduino and the laptop doesn't detect any device.

Is there a problem with the Arduino or is there a possibility that the USB has problems?


texts: How do I generate a graph from Arduino sensor data?


texts: How to execute commands on Arduino (via PC) without touching the current sketch?

texts:
I am working on my first Arduino project. It's a Reverse Geocache. Basically, it's a puzzle where a battery-powered Arduino is mounted inside a locked box, and is able to unlock the box if the user brings the box to the correct GPS coordinates and presses a push-button (that activates the Arduino, that runs a sketch, that checks the GPS, and operates a servo to release the lock).

It's all working, but I am trying to build in a backdoor, so I can unlock the box when I need to.

I have made the Arduino USB port accessible, and my hope is that I could connect a PC, and execute the appropriate command to operate the servo to unlock the box. The command is:

servo.write(OPEN_ANGLE);

The sketch that drives the whole puzzle depends on these libraries, but I am guessing the only one needed to operate the servo is PWMServo.h:

#include <PWMServo.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <EEPROM.h>
#include <LiquidCrystal.h>

I would like to be able to operate the servo without altering/replacing the uploaded sketch.

Is it possible to execute code "command prompt" style? Or can I somehow detect from within the sketch code that there is a USB connection, and have that trigger the unlock?

Finally (not the main question, but I would appreciate clarification), I have been told that the power to the Arduino should be disconnected before uploading new sketches (not sure why or if this is true). If forcing an unlock via the backdoor required uploading a new sketch, I seem to have a problem... For the puzzle to work within the locked box, the battery must be permanently connected, and also connecting to a PC via the USB seems to immediately power up the Arduino too. Does this mean uploading a new sketch would be impossible?


texts: Arduino Uno and ESP8266 serial monitor issue

texts:
I plugged in the Arduino Uno and the ESP8266 following this schema:

When I enter "AT" in the serial monitor, I get an "OK". I can also connect to my wifi using typical ESP8266 commands.

What doesn't work is passing these commands using an Arduino Script. For example, if I use this script, I don't get an "OK" from the ESP8266.

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

 void loop() {
  // put your main code here, to run repeatedly:
 Serial.println("AT");
 delay(10000);
   if(Serial.find("OK")){
    Serial.println("OK");
     }
     else{
     Serial.println("NOT OK");
  }
}

I tried a bunch of different codes,and nothing works. What am I doing wrong?


texts: Run Code Based on Time From GSM Module (SIM900)

texts:
I am trying to check the time from the GSM module to let my code run or do nothing.

If I send the command, AT+CCLK? to the SIM900. This is the response:

AT+CCLK?

+CCLK: "17/02/14,16:58:25-20"

OK

How do I parse the time information from the SIM900 and setup a loop for my code to run if it is past 6pm but before 6am?

My code currently:

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7,8); //RX,TX

void setup() {
  PowerOn(); //power on GSM Module
  delay(10000); //delay 10 seconds
  SIM900.begin(19200); //software serial for GSM Shield
  delay(500);
}

void loop() {

// if time is past 6pm and before 6am send text message else do nothing

SendTextMessage();

}

///GetTime
void GetTime()
{
    SIM900.print("AT+CCLK?");
}

///SendTextMessage
void SendTextMessage()
{
    SIM900.print("AT+CMGF=1\r");//Because we want to send the SMS in text mode
    delay(100);
    SIM900.println("AT + CMGS = \"+12137777777\"");//send sms message, be careful need to add a country code before the cellphone number
    delay(100);
    SIM900.println("Motion Detected!");//the content of the message
    delay(100);
    SIM900.println((char)26);//the ASCII code of the ctrl+z is 26
    delay(100);
    SIM900.println();
}

///PowerOn
void PowerOn()
{
  ///software equivalent of pressing the GSM shield "power" button
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(7000);
}


texts: Why is my LCD I/F PIN ADAPTER won't work

texts:
I bought this on the store near us. Here is the PDF for it.

https://www.e-gizmo.net/oc/kits%20documents/new%20LCD%20with%20converter/LCD%20IF%20pin%20adapter.pdf

I followed the instructions below and uploaded the code and all I've got is this

I've reconnected it and used a different jumper wires, still the same result.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

void setup(){
  lcd.begin(16,2);
  lcd.print("ntest");
}

void loop(){

  lcd.setCursor(0,1);
  lcd.print(millis()/1000);

}


texts: Sending multiple channels with bluetooth

texts:
I have ordered my HC-05 BT modules.
My question is this:
Is it possible to send multiple channels over bluetooth. For example, stereo sound has two channels. I think i have seen people do this but i'm not sure.

If it is possible, could you please provide some more information on how its done?
Thanks!


texts: Using a lot of interrupts on a single Arduino

texts:
I'm doing a little project that requires a lot of sensors. Right now I'm using 4, but i want to reach up to 60 sensors, and a minimum of 16 (for me that's a lot).
So, I have an Arduino MEGA 2560, and I'm new to Arduino (Had a little experience with PIC before).

I've started my project with buttons and leds to simulate the sensor, but my sensors work normally HIGH, and when something pass in front of it, it goes quickly to LOW and back. English is not my first language so I don't recall the name of this sensor, kind of like movement sensor(?).

A lot of stuff pass normally, up to 50/s, in front of it, so it should keep "bouncing" between HIGH and LOW. But when I changed the buttons for the sensors, sometimes my processor won't react, and I think it's because the signal goes back to HIGH before the code reads it. Maybe it's not a problem when it's sensing lot of things, but I can't test it right now with a lot of sensors, and it's not something that can keep getting errors.

So I got to interrupts, reading the awesome gammon review. I understood a lot of new things that i didn't know and I searched for a interrupt Library, but the one I found can't use too many sensors.

I forgot to tell, but I'm using a touch 2,4" shield too, so a lot of interrupts pins can't be used.

Will I be able to use all the sensors I want? If not, could I do it with 2 Arduinos and 1 screen? Am i missing something about the interrupts? Where can I find something to help me?

Edit 1: All the sensor are the same


texts: Is it possible to reprogram an atMega328 chip inside of a pcb?

texts: I have already soldered the atMega chip with instructions onto the perfboard, and I may need to make changes to it. Is it possible to reprogram it without taking it out of the PCB?


texts: Problem with STM32 and SDFat lib on other SPI port

texts:
I am using STM32F103C8 and I am triing to compile a code with SDFat library. The problem is I need to use the second channel of the SPI1 (pins PB5,PB4,PB3, PA15):

I found out that is possible to use SDFat lib and include SPIClass inside its constructor. Then I could use this code:
SPIClass SPI_1(PB5,PB4,PB3, PA15);
SdFat sd(&SPI_1);

The problem is this compliation error:
no matching function for call to 'SdFat::SdFat(SPIClass*)'

Do you have any idea how to solve this error or how to work with SD card on different pins?
Here is source code of this library:
https://github.com/greiman/SdFat/blob/master/src/SdFat.h


texts: Get a internal temperatura form ATMega328

texts:
I am making a circuit which takes three kinds of monitor temperature of the chip itself, in this case ATMega328 at room temperature, which is influenced by external thinks such as lasers, which will be obtained with LM35, and the temperature of a heatsink get with a NTC.

The reading of external temperature with LM35 and the NTC were successful, however when trying the code below to read the internal temperature of the ATmega328P-PU all readings become invalid.

//https://code.google.com/p/tinkerit/wiki/SecretThermometer
double readInternalTemp() {
  ADMUX = _BV(REFS1) | _BV(REFS0) |  _BV(MUX3);

  ADCSRA |= _BV(ADEN);  // enable the ADC

  delay(20);

  // descarto a primeira leitura;
  ADCSRA |= _BV(ADSC);
  while (bit_is_set(ADCSRA, ADSC));

  double temp = 0;
  byte mean = 0;
  for (; mean < MEAN_TEMP_INTERNAL; mean++) {
    ADCSRA |= _BV(ADSC);
    while (bit_is_set(ADCSRA, ADSC));
    int l = ADCL;
    int h = ADCH;
    temp += (( h << 8) | l);
    delay(2);
  }
  temp /= mean;

  temp = (temp - TEMP_INTERNAL_TOS) / TEMP_INTERNAL_K;
  return temp;
}

The following are the other two readings.

double readRoomTemp() {
#if (TEMP_AREF == (DEFAULT))  // para leitura com 5V de referencia
  ADMUX =  _BV(REFS0) ; // 5V (VCC)
  const double fator = .48828125;
#elif (TEMP_AREF == (INTERNAL))  // para leitura com 1.1V de referencia
  ADMUX = _BV(REFS1) | _BV(REFS0); // 1.1V (VCC)
  const double fator  = .107421875;
#else
  ADMUX = _BV(REFS1) | _BV(REFS0); // 1.1V, mas esta aqui nao ' configurado
  const double fator = 0;
#endif
  ADCSRB = 0;
  ADCSRA |= _BV(ADEN);  // enable the ADC

  ADMUX |= _BV(MUX0); // porta A1
  ADCSRA |= _BV(ADEN);  // enable the ADC
  delay(20);

  // descarto a primeira leitura
  ADCSRA |= _BV(ADSC);
  while (bit_is_set(ADCSRA, ADSC));

  double temp = 0;
  byte mean = 0;
  for (; mean < MEAN_TEMP_INTERNAL; mean++) {
    ADCSRA |= _BV(ADSC);
    while (bit_is_set(ADCSRA, ADSC));
    byte l = ADCL;
    int h = ADCH;
    temp += (( h << 8) | l);
    delay(2);
  }
  temp /= mean;

  temp  *= fator;
  return temp;
}

/*
 * baseado no codigo: http://playground.arduino.cc/ComponentLib/Thermistor2
 */
double readHeatSinkTemp() {
  ADMUX =  _BV(REFS0); // nao precisa setar o MUX porque todos sao 0000, porta A0
  ADCSRA |= _BV(ADEN);  // enable the ADC
  delay(20);

  //descarto a primeira leitura
  ADCSRA |= _BV(ADSC);
  while (bit_is_set(ADCSRA, ADSC));

  double temp = 0;
  byte mean = 0;
  for (; mean < MEAN_TEMP_INTERNAL; mean++) {
    ADCSRA |= _BV(ADSC);
    while (bit_is_set(ADCSRA, ADSC));
    byte l = ADCL;
    int h = ADCH;
    temp += (( h << 8) | l);
    delay(2);
  }
  temp /= mean;

  temp = log(10000.0 * (1024.0 / temp - 1));
//  temp = log(10000.0 / (1024.0 / temp - 1)); // for pull-up configuration
  temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temp * temp )) * temp );
  temp -= 273.15;            // Convert Kelvin to Celcius

  return temp;
}


texts:
I just got to play around with Arduino lately so I'm really new on this stuff and sorry for the grammar error.

I got a work where I need to turn the LED on all the time, my plan is to add a slow fade in and fade out later but the problem occurs when I add the servo.

Everytime servo starts moving slowly or fast the LED kinda flickering/dim like it lost power and come back to normal after the servo stops moving.

Here's the scheme I used and the code, I only change some delay to 5ms and so to test it out but no matter what the led is keep flickering.

Im using nano v.3 clone if its matter.

#include <Servo.h>
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 100;    // variable to store the servo position
int ledpin3 = 3;

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

void loop() {
  digitalWrite(ledpin3, HIGH);
  delay(1000);

  for (pos = 99; pos <= 150; 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 = 150; pos >= 30; 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
  }

  for (pos = 30; pos <= 99; 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
  }
}


texts: embedXcode: Link Error using an Arduino library (Servo.h) within a header file

texts:
For various reasons, I am moving from the Arduino IDE to Xcode using the embedXcode plugin. The code in question compiles and uploads fine from the Arduino IDE, so I think the issue is related to library definitions in embedXcode. The board I am using is an Arduino Mega 2560 (actually it is a Freetronics EtherMega).

The error thrown is:

Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2

More specifically:

    5.3-LINK                    Builds/embeddedcomputing.elf

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -o Builds/embeddedcomputing.elf Builds/main.cpp.o Builds/embeddedcomputing.a -Os -w -mmcu=atmega2560 -Wl,--gc-sections  -LBuilds -lm
Builds/main.cpp.o: In function `Robot::Robot()':
main.cpp:(.text._ZN5RobotC2Ev[Robot::Robot()]+0x5e): undefined reference to `Servo::Servo()'
Builds/main.cpp.o: In function `Robot::begin()':
main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x5a): undefined reference to `Servo::attach(int)'
main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x64): undefined reference to `Servo::write(int)'
main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0xea): undefined reference to `Servo::write(int)'
main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x112): undefined reference to `Servo::write(int)'
main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x132): undefined reference to `Servo::write(int)'
Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::HB25MotorControl(unsigned char)':
HB25MotorControl.cpp:(.text._ZN16HB25MotorControlC2Eh+0x14): undefined reference to `Servo::Servo()'
Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::begin()':
HB25MotorControl.cpp:(.text._ZN16HB25MotorControl5beginEv+0x42): undefined reference to `Servo::attach(int, int, int)'
HB25MotorControl.cpp:(.text._ZN16HB25MotorControl5beginEv+0x58): undefined reference to `Servo::writeMicroseconds(int)'
Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::stop()':
HB25MotorControl.cpp:(.text._ZN16HB25MotorControl4stopEv+0x12): undefined reference to `Servo::writeMicroseconds(int)'
Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::moveAtSpeed(int)':
HB25MotorControl.cpp:(.text._ZN16HB25MotorControl11moveAtSpeedEi+0x44): undefined reference to `Servo::writeMicroseconds(int)'
collect2: error: ld returned 1 exit status
make: *** [Builds/embeddedcomputing.elf] Error 1
Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2

Robot.h contains a robot class which defines a Servo (for a turret) and two HB-25 MotorControl objects (which control the drive motors). The HB25MotorControl is a custom library that I have written for the Parallax HB-25 Motor Controller. It also uses the Servo library.

To answer the obvious questions:

Yes I have #include <Servo.h> in my HB25MotorControl library. You
can see the library code by following the link above. It is also
included in the main sketch.
I have compiled, linked and uploaded other sketches which use Arduino and custom libraries in Xcode using the embedXcode plugin.
My embedXcode Makefile definitions include
    the Servo library and the HB25MotorControl library. See extract
    below.

APP_LIBS_LIST = Wire Servo SoftwareSerial

USER_LIBS_LIST = NewPing Time DS3232RTC HB25MotorControl

Any suggestions on how to fix this error and get my code to build in Xcode would be greatly appreciated.


texts: DS18B20 sending variable via Enthernet shield

texts:
I am trying to send temperature read from DS18B20 to a web server. I know two things: to read a temperature, and to send something to web server. What I don't know is how to convert float that temperature reading function is giving to me to string that I need to send to the server.

I am reading temperature with OneWire and DallasTemperature libraries (just a standard sketch ending with:

sensors.requestTemperatures();
Serial.println(sensors.getTempCByIndex(0));//sensors.getTempCBy... returns float, from my understanding

I am sending data via ethernet shield, and important part is:

 client.println("GET /led-ekran-vremenska-prognoza/?temp1=" + String(sensors.getTempCByIndex(0)) + "&temp2=" + String(dht.readTemperature()) + "&humidity="+String(dht.readHumidity())+"&secret=111 HTTP/1.1");

I know that the problem is that String(sensors.getTempCByIndex(0)) is not converting to right value. Arduino just stops working there, if that makes sense. At least serial communication stops working, since I don't see any more output...

Basically, TL:DR, I think that the question is how to convert float to string in Arduino? I have read a million topics on this but still cant figure it out, especially sicne it works for temp2 and humidity in example above.


texts:
I would like to use 7 MCP23S17 as output expanders on one SPI bus. Every IC has its own address from 0 to 6. The first MCP23S17 can be written with no problem. The second chip did not work properly. The CS pin of the MCP23S17 is set like at the all other 4 ICs.

Does anybody have experience with more then 4 MCP23S17 on SPI? Could anyone help?

#include <SPI.h>
#include <MCP23S17.h>

MCP A(0, 10);
MCP B(1, 8);
int d = 250;

void setup() {
  A.begin();
  B.begin();
  for (int k = 1; k <= 16; k++) {
    A.pinMode(k, OUTPUT);
    B.pinMode(k, OUTPUT);
  }
}

void loop() {
  //////////// ON THE LIGHT ONE BY ONE  FROM BEGGING
  for (int f = 1; f <= 16; f++) {
    A.digitalWrite(f, HIGH);
    delay(d );
  }
  for (int f = 1; f <= 16; f++) {
    B.digitalWrite(f, HIGH);
    delay(d );
  }
  ////////////  OFF THE LIGHT ONE BY ONE  FROM BEGINNIG
  for (int f = 1; f <= 16; f++) {
    A.digitalWrite(f, LOW);
    delay(d);
  }
  for (int f = 1; f <= 16; f++) {
    B.digitalWrite(f, LOW);
    delay(d);
  }
}


texts: Negative value conversion for modbus slave

texts:
I have an analog sensor which reads values 0-5v, -75 degrees to 75 degrees. Now I have converted to +75 degrees and -75 degrees format depend on the voltage.

From 2.5v to 5v data is read properly (i.e 0-75 degree), but from 0-2.5v they are negative values -75 degree to 0. In the below image array holding register is reading 65493 and 65491 which are negative value. How do I make it readable format? Since my code is very big, only part of code is pasted.

#define ID   1

int Wind_Speed=30;
int Wind_Kmph=67;
signed int tracker_des_angle=-45;
signed int tracker_actual_pos=-43;
Modbus slave(ID, 0, 0);
boolean led;
int8_t state = 0;
unsigned long tempus;
// data array for modbus network sharing
uint16_t au16data[14];

void setup() {

  // start communication
  slave.begin( 9600 );
  rtcSetup();

  tempus = millis() + 100;
  digitalWrite(13, HIGH );
}

void loop() {
  // poll messages
  // blink led pin on each valid message
  state = slave.poll( au16data, 14);
  if (state > 4) {
    tempus = millis() + 50;
    digitalWrite(13, HIGH);
  }
  if (millis() > tempus) digitalWrite(13, LOW );
  calcTime();
  convertUTCtoLocal();

  au16data[0]=local_year;
  au16data[1]=local_month;
  au16data[2]=local_day;
  au16data[3]=wkDay;
  au16data[4]=local_h;
  au16data[5]=local_m;
  au16data[6]=local_s;
  au16data[7]=Wind_Speed;
  au16data[8]=Wind_Kmph;
  au16data[9]=tracker_des_angle;
  au16data[10]=tracker_actual_pos;

  au16data[11] = slave.getInCnt();
  au16data[12] = slave.getOutCnt();
  au16data[13] = slave.getErrCnt();
}


texts: Arduino on breadboard, and then soldered using a board made on Eagle but won't work

texts:
So I'm looking to create an arduino clone to mount on one of my robots. I started off making the arduino on a breadboard, using the instructions found on Arduino's own website and I succeeded. It works as well, I've checked it with the "blink" project.

I then drew the schematic in Eagle:

Next, I created a board and routed it, giving the following result:

Finally, I transferred it onto a copper clad, soldered it, but it doesn't work. Tried pretty much everything I could think of but there seems to be something wrong and I cant work out what it is.

Can someone please help?

Hassan


texts:
I build a macro keyboard and one thing I do alot is add a set amount to numbers mostly in 3d modeling programs. I add and remove 0.25 and 0.125 all the time. I want to make a macro that copies selected text, adds or subtracts a value then pastes it back.
I known the simple copy and paste commands but how do I get my arduino program to grab that copied value?
Can this even be done?


texts: I have an Arduino Uno and I'd like to read a signal from a co-ax cable with it. The cable carries 12VDC (power for other components) along with a signal (of about 1 Ghz frequency). How do I go about recording this signal with my Uno? I'm new to this field so I don't know the full capabilities of the ADC. Also, the Uno can't handle >5 VDC, so what should I do to make the signal readable?


texts:
Is the Arduino Uno the best one to purchase for a complete beginner?

I eventually want to get into building Nodebots since I already have experience writing Nodejs web-based applications.

Or should I go directly to purchasing an Arduino Starter Kit? SparkFun Inventors Kit? Adafruit ARDX Experimentation Kit for Arduino? Seeed Studio ARDX starter kit? or Freetronics Experimenter’s Kit for Arduino?

I don't know the difference between these and based off what I have shared about my situation so far, which one should I start with to A. Learn the Basics, B. Evolve into developing Nodebots.


texts:
I'm trying to make a human following robot.Tried using ultrasonic sensors to follow a specific person by Having ultrasonic sensor with the person to send echo to the robot,But it didn't workout.
Any way to track a specific person and follow ?
Any sensors/algorithm to track fast moving object(a person but not specific)?


texts: Using Raspberry Pi to Receive Float from Arduino using NRF24L01

texts:
Good day. I've been learning on how to transfer data from Arduino to Raspberry Pi wirelessly using NRF24L01 based on the following reference:
Raspberry Pi 3 Tutorial 14 – Wireless Pi to Arduino Communication with NRF24L01+.

The reason why I want to do this is to log temperature and humidity data wirelessly using DHT22 sensors.

The Arduino code is shown below:

//SendReceive.ino

#include<SPI.h>
#include<RF24.h>

// CE, CSN pins
RF24 radio(9, 10);

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

    radio.begin();
    radio.setPALevel(RF24_PA_MAX);
    radio.setChannel(0x76);
    radio.openWritingPipe(0xF0F0F0F0E1LL);
    const uint64_t pipe = (0xE8E8F0F0E1LL);
    radio.openReadingPipe(1, pipe);

    radio.enableDynamicPayloads();
    radio.powerUp();

}

void loop(void){
    radio.startListening();
    Serial.println("Starting loop. Radio on.");
    char receivedMessage[32] = {0};
    if(radio.available()){
        radio.read(receivedMessage, sizeof(receivedMessage));
        Serial.println(receivedMessage);
        Serial.println("Turning off the radio.");
        radio.stopListening();

        String stringMessage(receivedMessage);

        if(stringMessage == "GETSTRING"){
            Serial.println("Looks like they want a string!");
            const char text[] = "Yo wassup, haha";
            radio.write(text, sizeof(text));
            Serial.println("We sent our message.");
        }
    }
    delay(100);

}

Meanwhile, the Raspberry Pi code is shown below:

import RPi.GPIO as GPIO
from lib_nrf24 import NRF24
import time
import spidev

GPIO.setmode(GPIO.BCM)

pipes = [[0xE8, 0xE8, 0xF0, 0xF0, 0xE1], [0xF0, 0xF0, 0xF0, 0xF0, 0xE1]]

radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(0, 17)

radio.setPayloadSize(32)
radio.setChannel(0x76)
radio.setDataRate(NRF24.BR_1MBPS)
radio.setPALevel(NRF24.PA_MIN)

radio.setAutoAck(True)
radio.enableDynamicPayloads()
radio.enableAckPayload()

radio.openWritingPipe(pipes[0])
radio.openReadingPipe(1, pipes[1])
radio.printDetails()
# radio.startListening()

message = list("GETSTRING")
while len(message) &lt; 32:
    message.append(0)

while(1):
    start = time.time()
    radio.write(message)
    print("Sent the message: {}".format(message))
    radio.startListening()

    while not radio.available(0):
        time.sleep(1 / 100)
        if time.time() - start &gt; 2:
            print("Timed out.")
            break

    receivedMessage = []
    radio.read(receivedMessage, radio.getDynamicPayloadSize())
    print("Received: {}".format(receivedMessage))

    print("Translating the receivedMessage into unicode characters")
    string = ""
    for n in receivedMessage:
        # Decode into standard unicode set
        if (n &gt;= 32 and n &lt;= 126):
            string += chr(n)
    print("Out received message decodes to: {}".format(string))

    radio.stopListening()
    time.sleep(1)

Based on the Arduino code above, the code that shows the data that is transmitted is shown below:

const char text[] = "Yo wassup, haha";

Based on the Raspberry code above, the codes that decode the received data from Arduino are shown below:

for n in receivedMessage:
    # Decode into standard unicode set
    if (n &gt;= 32 and n &lt;= 126):
        string += chr(n)

However, these decoding code only works if I transmit string or integer from Arduino to Raspberry Pi. It doesn't work if I transmit float. Since DHT22 records temperature and humidity up until 1 decimal point, it is required for me to transmit float. Can anyone here please teach me how to decode the float values?

Thank you very much.


texts: How to use relay shield to control dc motor speed and direction?

texts:
I tried l298n before but its output voltage wasn't high

so I use relay shield but  it seems that the car can only go forward or stop

Can I control the speed and direction of dc motors?


texts: I want to play a sound based on my ultrason sensor reading

texts:
The idea is to play the tone that is given by the center value read it by the center ultrasound sensor.

The code that is in Arduino is this one:

#include NewPing.h

#define PING_CENTER  2  // Arduino pin tied to both trigger and echo pins on the ultrasonic sensor.
#define PING_RIGHT  3
#define PING_LEFT  4
#define PING_MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
#define buzzerPin = 10

long buzzerFreq1; // The frequency to buzz the buzzer
unsigned int BUZZ_FREQ_MAX = 2500; // Maximum frequency for the buzzer
unsigned int US_MAX = 2023; // Maximum value for ultrason sensor
int c1;

NewPing sonar2(PING_CENTER, PING_CENTER, PING_MAX_DISTANCE); // NewPing setup of pin and maximum distance.
NewPing sonar3(PING_RIGHT, PING_RIGHT, PING_MAX_DISTANCE);
NewPing sonar4(PING_LEFT, PING_LEFT, PING_MAX_DISTANCE);

void setup() {
  Serial.begin(9600);
  pinMode(buzzerPin, OUTPUT); // set pin for buzzer output
}

void loop() {
  buzzerFreq1 = (center * BUZZ_FREQ_MAX) / US_MAX;
  buzz(buzzerPin,buzzerFreq1,10);
  // tone(buzzerPin, center);
  delay(500);  // Wait 500ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  unsigned int center = sonar2.ping() / US_ROUNDTRIP_CM; // Send ping, get ping time in microseconds (uS) and convert it to centimeters (cm)
  unsigned int right = sonar3.ping() / US_ROUNDTRIP_CM;
  unsigned int left = sonar4.ping() / US_ROUNDTRIP_CM;
  // Serial.println("Distance: " + String(distanceInCms) + "cm");

  Serial.println(center);
  Serial.println(right);
  Serial.println(left);

}

 // buzz(buzzerPin, buzzerFreq1, 10);
 void buzz(int targetPin, long frequency, long length) {
 // int c1 = center;
  buzzerFreq1 = (center * BUZZ_FREQ_MAX) / US_MAX;
  long delayValue = 1000000/frequency/2;

  int numCycles = frequency * length/1000;

  for (int i=0; i < numCycles; i++){
    digitalWrite(targetPin,HIGH);
    delayMicroseconds(delayValue);
    digitalWrite(targetPin,LOW);
    delayMicroseconds(delayValue);
  }
}

And I receive the following error that I have no idea how to solve it.

ultrason_onewire_sound.cpp: In function ‘void setup()’:
ultrason_onewire_sound.cpp:26:11: error: expected primary-expression before ‘=’ token
ultrason_onewire_sound.cpp: In function ‘void loop()’:
ultrason_onewire_sound.cpp:38:8: error: expected primary-expression before ‘=’ token
ultrason_onewire_sound.cpp: In function ‘void buzz(int, long int, long int)’:
ultrason_onewire_sound.cpp:48:18: error: ‘center’ was not declared in this scope


texts: How do I configure the Arduino IDE to look for source code in a subdirectory within the directory that holds my sketch?

texts:
I'm writing an Arduino program that contains various .h and .cpp files. Due to organizational needs, I have configured the directory that contains my Arduino sketch (.ino) to possess a subdirectory. This subdirectory contains related source code.

An example layout of my project directory is located below:

mysketch
    mysketch.ino
    mycode.h
    mycode.cpp
    mylibs
        mylib1.h
        mylib1.cpp
        mylib2.h
        mylib2.cpp
        mylib3.h
        mylib3.cpp

With this, I'm able to successfully #include the header files. However, the compiler then complains that mylib1.cpp, mylib2.cpp, and mylib3.cpp are not defined (however they are). I'm guessing that the Arduino only looks for source files within the same directory that the sketch lives in. Thus subdirectories contains source code are ignored.

I can then modify my directory layout such that all of the 'mylib.h/.cpp's' are in the same directory and the project compiles fine.

So my question: how do I configure the Arduino IDE to reference source code within a subdirectory? Also, I would prefer that the mylibs exist within the same directory, and not within the Arduino 'library' directory. This will allow me to then easily distribute the code as a single zipped folder.


texts: How to indicate an End of a stream on USB

texts:
I am making a Lora-USB passthrough device using arduino and somehow I want to indicate that a stream over some data has ended.

So far I have done:

void onLoRaReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return

  byte[packetSize] buffer=[];

  while (LoRa.available()) {
    site_t recievedData=LoRa.readBytes(buffer,packetSize);
    Serial.write(buffer,recievedData);
  }
}

So what I want to know is how the software reading from the serial interface will know that a packet has ended; One way I thought is by sending an EOF byte but I am afraid of "rogue" EOF values in packet data.

An another way is to send the packet size through the Serial interface as well but how I will make it understand that what I am sending now is the size and expect X size of data?


texts: Running two NEMA 17 motors, one by one, using the Arduino Uno

texts:
I am new to Arduino. I am trying to run two stepper motors NEMA 17 through respective A4988 driver and controlling via Arduino Uno.

The thought is that first stepper motor will carry out a first horizontal scan and then as it reaches to its initial position, second stepper motor will move a single step in vertical direction. This is a kind of raster scan that I want to perform with both motors.

When I am running the code, only horizontal scan motor is running and vertical scan motor is not moving. I have checked my circuit, motors and drivers and everything is working fine. I think there is some mistake in my code. It is a basic level code and I would really appreciate the help for helping me out.

int x, y; //stepper motor 'x' and stepper motor 'y'
#define BAUD (9600)

void setup()
{
  Serial.begin(BAUD);
  pinMode(6,OUTPUT); // Enable for x
  pinMode(5,OUTPUT); // Step for x
  pinMode(4,OUTPUT); // Dir for x
  digitalWrite(6,LOW); // Set Enable low for x

  pinMode(9,OUTPUT); // Enable for y
  pinMode(8,OUTPUT); // Step for y
  pinMode(7,OUTPUT); // Dir for y
  digitalWrite(9,LOW); // Set Enable low for y
}

void loop()
{

  digitalWrite(9,LOW); // Set Enable low for y

  for(y = 0; y < 20; y++)
  {
     digitalWrite(6,LOW); // Set Enable low for x
     digitalWrite(4,HIGH); // Set Dir high for x - Clockwise

     Serial.println("CLOCKWISE HORIZONTAL SCANNING IN PROGRESS");

     for(x = 0; x < 50; x++) // Loop 50 times
     {
      digitalWrite(5,HIGH); // Output high for x
      delay(10); // Wait
      digitalWrite(5,LOW); // Output low for x
      delay(100); // Wait
     }

    digitalWrite(6,LOW); // Set Enable low for x
    digitalWrite(4,LOW); // Set Dir low for x - Anticlockwise

    Serial.println("ANTICLOCKWISE HORIZONTAL SCANNING IN PROGRESS");

    for(x = 0; x < 50; x++) // Loop 50 times
    {
      digitalWrite(5,HIGH); // Output high
      delay(10); // Wait
      digitalWrite(5,LOW); // Output low
      delay(100); // Wait
    }

    Serial.println("ONE STEP CLIMB ON VERTCAL AXIS");

    digitalWrite(7,HIGH); // Set Dir high for y

    digitalWrite(8,HIGH); // Output high for y
    delay(100); // Wait
    digitalWrite(8,LOW); // Output low for y
    delay(100); // Wait
  }

  digitalWrite(9,LOW); // Set Enable low for y
  digitalWrite(7,LOW); // Set Dir low for y

  Serial.println("RESETTING ON VERTCAL AXIS");

  for(y = 0; y < 20; y++) // Loop 20 times
    {
      digitalWrite(8,HIGH); // Output high for y
      delay(10); // Wait
      digitalWrite(8,LOW); // Output low for y
      delay(100); // Wait
    }

}

Do i need to look after the delay being provided??


texts: Read sensor data repeatedly after specified time?

texts:
I want to read sensor data using analogRead() after every 5ms. I have read other answers to similar questions but what I'm confused about is:

let's say, I made a loop to read sensor data using analogRead() at the end of which I write delay(50)
it means it'll take some time to read data(adc) , then it'll wait for 50ms
time to execute loop isn't same for every iteration so we get the pattern as: some time for loop execution, delay of 50ms, some time for next iteration........and so on
I want to ask if I want arduino to read sensor data exactly every 5ms, what should I do?
Thanks


texts: How to Write a function or Loop or program to receive fixed number of Integers or characters over Serial?

texts:
I am want to receive a 5 character hexadecimal input from user over serial port of arduino Uno.

int count = 0;                                    // count = 0
char userInput[5];

void setup()
{
  delay(1000);
  Serial.begin(19200);                            // begin serial port with baud rate 9600bps

}
void loop()
{
  if (Serial.available() > 5)
  {
    Serial.read();
  }

  else if (Serial.available() < 4)
  {
    Serial.read();
  }

  else if (Serial.available() == 5)
  {
    for (int i = 0; i < 5; i++)
    {
      userInput[i] = Serial.read();
    }

    Serial.print("User Input - ");
    Serial.println(userInput);
  }

  delayMicroseconds(10000);
}

But I want to discard the input if user inters less than 5 characters or more than 5?

Since the Serial.flush() have a different meaning now, I can not clear the buffer if user enters less than or more than 5 characters and the characters gets added to next input.

e.g. If I upload above program and entered input in following sequence:

abcde
abcd
abcd
abcd
abcd
abcdef
abcde

I got the following output:

User Input - abcde
User Input - dabcd
User Input - dacbd
User Input - bcdef
User Input - abcde

Two invisible characters appear in output which are not visible but when I copied the output from serial monitor but these characters appear when I copy paste the output into Text Editor.

So How can I modify the program to receive only 5 hex character input from user (Which user will input from Hex Keypad)? And if user enters more or less character I want to clear the input buffer for next user input so that characters from previous input doesn't get added to next one.


texts:
I am attempting to connect an Arduino Uno to a Modern Device RBB Arduino. One is the base and the other the remote. They need to set up a simple handshake to communicate an on and off condition from the remote.The hardware and software work for both the base and remote using Tera Term to simulate the opposite node. I am running Tera Term on a notebook connecting to the node through a BT dongle. In other words if I manually respond to the opposite node on the Tera Term they both operate as they should individually. When I try to get them to interact autonomously they will not handshake. The HC05s are paired and connected but the handshake data will not flow back and forth.

Remote Code:

 int pinInt =2; //interrupt pin

 int ack = 2; //acknowledge

 void setup() {

  pinMode(3,OUTPUT); //power to bluetooth

  pinMode(pinInt,INPUT); //interrupt pin mode

}
// Still needs sleep and interrupt processing

  void loop() {

  delay(5000);//sim sleep remove or adjust for wake up delay

  digitalWrite(3,HIGH);//switches power to bluetooth

  delay(10000);//BT active adjust as necessary

  Serial.begin(9600);

  Serial.print('?');//send am I connected

   while(Serial.available()==0){}//idle until incoming serial

     int heatCall=digitalRead(pinInt);//read interrupt pin

     if (Serial.available() > 0) {ack = Serial.read();}//read ack

     if (ack=='1'){Serial.print(heatCall);}//send state of heatCall

  while(Serial.available()==0){}//idle until incoming serial

    if (Serial.available() > 0) {ack = Serial.read();}//read ack

    if (ack=='0'){Serial.end();digitalWrite(3,LOW);}//BT off

   //sleepNow();//put back to sleep

}

Base Code:

int relayPin =13; //relay pin

 char itsOn = 0; //remote calling variable

 int heatCall = 0; //state of TH135

 int ack = 2; //hand shake

  void setup() {

  pinMode(relayPin,OUTPUT); //power to relay
  Serial.begin(9600);
}

  void loop() {

  while (Serial.available()==0);{}//idle until incoming serial

  if (Serial.available() > 0) {itsOn = Serial.read();//remote calling

    if (itsOn=='?')ack=1;Serial.print(ack);}//send connected ack

  while (Serial.available()==0);{}//idle until incoming serial

  if (Serial.available() > 0) {heatCall = Serial.read();}//incoming heatCall

    if (heatCall=='1'){digitalWrite(relayPin,HIGH);}//turn zone relay ON

     else {digitalWrite(relayPin,LOW);}//turn zone relay OFF

  delay(5000);
  ack=0;
  Serial.print(ack);//turn remote BT OFF
  }

Is there some BT protocol that I am missing?

UPDATE: I have determined that data is being transferred from remote to base and back. The data is not the expected values.


texts: Can you make it so, when your phone connects to the Hc-05 on a Arduino, a variable changes?

texts:
So whenever my phone gets close, and it connects to the Hc-05, the Arduino changes a variable? I want to avoid the use of apps, where the user has to do anything after first time connecting. The project is an automatic door opener, wherein the user for whatever reason can't use their hands, like if they have groceries in their hands.

Thank you for your time


texts:
I have recently bought a L293D shield and 2 BO motors. Whenever I connect the motors to the shield it makes a beeping noise. I searched online and found that I need to change PWM frequency but I know nothing about it and anyone please tell me about the PWM frequency and how to change it.

I have used almost every sketch found online but condition remains same. I am using 9V battery as External power supply and it is absolutely new. Please help me.


texts:
I have a trouble with following, few lines code.
For some reason after few seconds Arduino uno stops responding into void loop section of code.
I tried to remove serial communication, all print and println without any success. Is the problem comming from MMA_7455.h?

#include <MMA_7455.h>
#include <Servo.h>

int servoPin = 9;
int servoAngle = 0;

Servo servo;

MMA_7455 accel = MMA_7455();
char yVal;
char yVal_bkp;

void setup() {
    servo.attach(servoPin);
    accel.initSensitivity(2);
    accel.calibrateOffset(1.0, 26.0, -69.0);
}

void loop() {
    yVal = accel.readAxis('y'); //Read out the 'y' Axis

    if(yVal_bkp != yVal + 2 || yVal_bkp != yVal -2)
    {
        servo.write(90 + yVal);
        yVal_bkp = yVal;
    }
}

P.S. Servo is normal G90


texts:
I have connected ESP8266 to my Raspberry Pi's WiFi network and assigned a static IP.

My Arduino code

#include "SoftwareSerial.h"

String ssid = "Rpi";
String password = "raspberry";

SoftwareSerial esp(3, 2);// RX, TX

String server = "192.168.50.1"; //my Host

void setup() {
  esp.begin(115200);
  Serial.begin(115200);
  connectWifi();
  httpget();
  delay(1000);
}

void connectWifi() {
  String cmd = "AT+CWJAP=\"" + ssid + "\",\"" + password + "\"";
  esp.println(cmd);
  delay(4000);
  if (esp.find("OK")) {
    Serial.println("Connected!");
  }
  else {
    Serial.println("Cannot connect to wifi ! Connecting again...");
  }
  connectWifi();
}

/////////////////////////////GET METHOD///////////////////////////////
void httpget() {
  esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",1234");//start a TCP connection.
  if ( esp.find("OK")) {
    Serial.println("TCP connection ready");
  }
  delay(1000);
  /*
    String getRequest =
    "GET " + uri + " HTTP/1.0\r\n" +
    "Host: " + server + "\r\n" +
    "Accept: *" + "/" + "*\r\n" +
    "Content-Type: application/json\r\n" +
    "\r\n";
  */
  String sendCmd = "AT+CIPSEND=";
  esp.print(sendCmd);
  //esp.println(getRequest.length() );
  delay(500);
  if (esp.find(">")) {
    Serial.println("Sending..");
    //  esp.print(getRequest);
    if ( esp.find("SEND OK")) {
      Serial.println("Packet sent");
      while (esp.available()) {
        String response = esp.readString();
      }
      esp.println("AT+CIPCLOSE");
    }
  }
}

void loop() {
  httpget();
}

I get this message

    Cannot connect to wifi ! Connecting again...

In my Raspberry Pi I am constantly sending a signal to this IP address.

import socket

TCP_IP = '192.168.50.1' #Local Host
TCP_PORT = 1234            #Listening Port
BUFFER_SIZE = 12

SERVER_IP = '192.168.50.18'  #Arduino IP
SERVER_PORT = 3007            #Server Port

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((TCP_IP,TCP_PORT))
#s.listen(1)

#(conn,addr) = s.accept()
#print 'Connection address: ',addr
while True:
    print 'Sending message'
    s.sendto('1',(SERVER_IP,SERVER_PORT))
    print 'Waiting for response'
    data,addr = s.recvfrom(BUFFER_SIZE)
    if not data: break
    print 'received data: ',data
    print 'data recieved from: ',addr
    conn.close()
s.close()

But I can not see it in my Serial Monitor. Do I need to create a separate program for getting from WiFi?


texts:
So in the fields of robotics sometimes you need multiple boards and or computers linked together to share information or save statistical data. Currently I need to send a few different variables over a serial connection and was wondering what was the best way to go about doing such?

So far I've determined that sending structures would probably be the easier way to send data. Does anyone know of any other way that might be more efficient?

Please keep in mind that I will essentially be having to send the data for 4 motors, compressor, different temperatures, random things, and the 3 sections of the arm.


texts: Function parameter of type int not working as expected

texts:
I am attempting to write a small sketch with the Arduino IDE (1.8.10) to set the colour of an RGB LED, however my function for setting the colour of the LED is behaving strangely.

Here is the full sketch code:

#define RED 9
#define GREEN 10
#define BLUE 11

void setup()
{
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  digitalWrite(RED, LOW);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);
  Serial.begin(9600);
}

int gRed = 20;
int gGreen = 21;
int gBlue = 22;

void setRGB(int r, int g, int b)
{
  Serial.println(r);
  Serial.println(g);
  Serial.println(b);
  analogWrite(RED, r);
  analogWrite(GREEN, g);
  analogWrite(BLUE, b);
}

void loop()
{
  //setRGB(gRed, gGreen, gBlue); // WORKS - White-ish
  setRGB(20, 21, 22); // DOESN'T WORK - Blue =/
}

As you may tell from the comments, when I pass "global" variables in to setRGB() the LED lights up the expected colour. But, when I pass literals in it does not.

The Serial monitor shows the following output when using the literals:

20
21⸮20
21
20
21
20
21⸮
etc....

Can anybody help me figure out what I'm doing wrong?

Board in use is a Mega2560.


texts: I need help wiring the DFRobot LCD keypad shield to my Arduino Uno. I plan on making a text-based adventure played on Arduino if that helps.


texts: How to properly run 4 DC motors with an Arduino?

texts:
I am working on a project where I have 4 DC motors that is controlled by 2 L293D motor drivers.  2 of the motors act as the wheels of the robot, and the other 2 act as a mop.

The Arduino board is powered through the USB port.  The DC motors are powered by the L293D motor driver through the 5V pin on the Arduino.  Alongside the motors, an ultrasonic sensor and a water sensor is also using the 5V pin.

This is what the robot should be doing:
The robot will move forward.  If it senses an obstacle through the ultrasonic sensor, it will turn right.  If it senses water through the water sensor, the robot will stop moving and the mop will start spinning.  After cleaning the water spillage, it will move forward again, just like what it did before.

It seems like the motors are not getting enough power, because whenever I place it on the floor, it doesn't move.

The base / platform of the robot is a plywood, which is heavy for the robot, and also which I think is a factor that affects the spinning of the wheels.

I also have a 9V battery, which I think could power the motors, but I don't know how to connect it.  How am I supposed to connect it to the L293D motor driver? I think, I should connect the positive side of the 9V battery to the VCC 2 pin of the L293D motor driver. But, where should I connect the negative side of the 9V battery?


texts: Rotary encoder on Uno and interrupts issue

texts:
This question is regarding a project using an Arduino Uno.

I have one of these quadrature rotary encoders.

I'm using a slightly modified version of the code from the article, Quadrature Encoder too Fast for Arduino (with Solution), which uses a library called digitalwritefast.

My version of the code on pastebin - I modified to use different pins for the Uno and a single encoder:

#include <digitalWriteFast.h>  // library for high performance reads and writes by jrraines

#define c_LeftEncoderInterrupt 0
#define c_LeftEncoderPinA 2
#define c_LeftEncoderPinB 3

volatile bool _LeftEncoderBSet;
volatile long _LeftEncoderTicks = 0;

void setup()
{
  Serial.begin(115200);
  pinMode(c_LeftEncoderPinA, INPUT);
  digitalWrite(c_LeftEncoderPinA, LOW);
  pinMode(c_LeftEncoderPinB, INPUT);
  digitalWrite(c_LeftEncoderPinB, LOW);
  attachInterrupt(c_LeftEncoderInterrupt, HandleLeftMotorInterruptA, RISING);
}

// Interrupt service routines for the left motor's quadrature encoder
void HandleLeftMotorInterruptA()
{
  _LeftEncoderBSet = digitalReadFast2(c_LeftEncoderPinB);   // read the input pin
  _LeftEncoderTicks -= _LeftEncoderBSet ? -1 : +1;
}

void loop()
{
  Serial.print(_LeftEncoderTicks);
  Serial.print("\n");
  delay(20);
}

I am attaching output A of the encoder to pin 2 and output B to pin 3.

This setup works fine and I can detect turns in both directions, but my problem is, if I set pin B to any other pin, I get positive direction only (regardless of the direction in which the encoder is turned) - as if pin B isn't plugged in at all (I am modifying c_LeftEncoderPinB accordingly).

I'm assuming that this is something to do with pin 3 being the only other interrupt pin on the Uno (I can't see anything else unique about that pin). Yet I don't know why because the interrupt is on pin A (we're reading the value of pin B in that interrupt, though).


texts:
Basically I'm trying to output a string based upon a value in an array, the following code is what I have come up with to achieve my desired result, but I have a feeling that there is a better way to do it.

String day(int day) {
  if (day == 1) return "Sunday";
  if (day == 2) return "Monday";
  if (day == 3) return "Tuesday";
  if (day == 4) return "Wednesday";
  if (day == 5) return "Thursday";
  if (day == 6) return "Friday";
  if (day == 7) return "Saturday";
  else return "Undefined";
}

void setup() {
  Serial.begin(57600);
  while (!Serial);
  Serial.println(day(1));
}

void loop() {
;
}

This prints "Sunday" in the Serial monitor

I would appreciate any input on how to optimize this code, thank you!


texts: TinyDuino RadioHead compile error with TinyZero

texts:
I have a stack of TinyDuino boards including

TinyZero and 433MHZ Long Range Radio TinyShield.

I previously has this processor and had no problem compiling the sketch
and uploading it.

With the TinyZero now I get the following error.

RadioHead.h:463:29: error: RHutil/atomic.h: No such file or directory
   #include <RHutil/atomic.h>

Obviously there is a file missing, when I tried to copy the file from the web
I got another error saying:

    sketch/RHHardwareSPI.cpp: In member function 'virtual void RHHardwareSPI::begin()':
RHHardwareSPI.cpp:99:58: error: invalid conversion from 'uint8_t {aka unsigned char}' to 'BitOrder' [-fpermissive]
     _settings = SPISettings(frequency32, bOrder, dataMode);
                                                          ^
In file included from sketch/RHGenericSPI.h:13:0,
                 from sketch/RHHardwareSPI.h:10,
                 from sketch/RHHardwareSPI.cpp:7:
/home/ktsirakos/.arduino15/packages/TinyCircuits/hardware/samd/1.0.8/libraries/SPI/SPI.h:50:3: error:   initializing argument 2 of 'SPISettings::SPISettings(uint32_t, BitOrder, uint8_t)' [-fpermissive]
   SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) {
   ^

What the board does is to get Accelerometer values and send it to a receiver with the same RadioHead board.

I think it is because of the ARM of the TinyZero processor because the RadioHead.h header file includes these lines of code.

    // This is an attempt to make a portable atomic block
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
#if defined(__arm__)
  #include "atomic.h"
 #else
  #include <util/atomic.h>
 #endif
 #define ATOMIC_BLOCK_START     ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
 #define ATOMIC_BLOCK_END }
#elif (RH_PLATFORM == RH_PLATFORM_UNO32)
 #include <peripheral/int.h>
 #define ATOMIC_BLOCK_START unsigned int __status = INTDisableInterrupts(); {
 #define ATOMIC_BLOCK_END } INTRestoreInterrupts(__status);
#else
 // TO BE DONE:
 #define ATOMIC_BLOCK_START
 #define ATOMIC_BLOCK_END
#endif

Any suggestion if it is possible to run these 2 together? (TinyZero and RadioHead)?

Thank you very much in advance.


texts: Serial device file no longer shows up in /dev/ after working fine for months

texts:
I am using an Arduino MEGA connected to my Linux workstation via USB. I have been using this setup for several months with no issues.

A few days ago, the usual serial device file (/dev/ttyACM0) stopped showing up when I plug in the device)

Haven't re-flashed recently.
Unable to reflash.
Removing the devices only shield does not do anything.
Have not changed my physical setup recently.
Connector cable is confirmed working with a different device.

Is this a case of bad hardware, or is there a possible fix other than buying a new device?

dmesg results: None (cleared buffer and re-ran dmesg after plugging / unplugging device)
usb-devices:

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=03.13
S:  Manufacturer=Linux 3.13.0-37-generic ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1a.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 6
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=8087 ProdID=0024 Rev=00.00
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=03.13
S:  Manufacturer=Linux 3.13.0-37-generic ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1d.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 6
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=8087 ProdID=0024 Rev=00.00
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=02 Lev=02 Prnt=02 Port=03 Cnt=01 Dev#=  3 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1bcf ProdID=2805 Rev=20.15
S:  Manufacturer=6047B0021601A0218M7NB
S:  Product=HP HD Webcam [Fixed]
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
I:  If#= 1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo

T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=02 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0bda ProdID=0001 Rev=68.17
S:  Product=CSR BS8510
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=03.13
S:  Manufacturer=Linux 3.13.0-37-generic xhci_hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:26:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 2
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=03.13
S:  Manufacturer=Linux 3.13.0-37-generic xhci_hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:26:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

ls-usb:

Bus 002 Device 004: ID 0bda:0001 Realtek Semiconductor Corp.
Bus 002 Device 003: ID 1bcf:2805 Sunplus Innovation Technology Inc.
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


texts: Formatting variables from a variadic function

texts:
I have a function that concatenates a print line, however I am having trouble getting some of the strings to format correctly.

Using Serial.print formats the output from keypad.getKey() correctly, however when I try to output the same format using printConcatLine() it does not give me the same output. I've tried casting it as both a char and an int...

void printConcatLine(const char* mask, ...) {
    va_list params;
    va_start(params, mask);

    while(*mask != '\0') {
      if (*mask == 'i') {
          Serial.print(va_arg(params, int));
      } else if(*mask == 'c') {
          Serial.print(va_arg(params, const char *));
      } else if (*mask == 'f' || *mask == 'd') {
          Serial.print(va_arg(params, double));
      }
      ++mask;
    }

    va_end(params);
    Serial.println();
}

char btnPressed = keypad.getKey();
  if (btnPressed) {
    Serial.print("BtnPressed: ");
    Serial.println(btnPressed);
    // Output: "BtnPressed: 1"

    printConcatLine("ci", "BtnPressed: ", btnPressed);
    // Output: "BtnPressed: 49"

    printConcatLine("cc", "BtnPressed: ", btnPressed);
    // Output: "BtnPressed: "
  }

I also tried changing:

  va_arg(params, const char *)

to

  va_arg(params, char)

which also did nothing.

How can I modify the call to va_arg() to properly output the same output as Serial.print()?


texts: Nodemcu is connected to 5v relay with logic converter but still not working

texts:
I am using a bi-directional 3.3-5V logic converter to control 5V relay with 3.3V D5 pin of nodemcu. link of logic  converter is here

However, I expected to control the relay but it didn't work. I don't think there is a problem with electrical connection or code since that is simple.

3.3V sides of nodemcu is connected to LV and 5V side of Relay is connected to HV.

Code:-

void setup() {
  // put your setup code here, to run once:
pinMode(D5, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(D5, HIGH);
delay(2000);
digitalWrite(D5, LOW);
delay(2000);
}

My Observations:-
1) When relay is removed, multimeter shows 3.3V at the LV & HV side. (so logic converter is not working i guess)
2) When relay  is  connected, multimeter shows 2.5V on  both sides.

Everything is powered from nodemcu pins. Does  it means that i have to supply extenal power or something wrong with logic converter?[![enter image description here][2]][2]

What do you guys think?

PS  - I  soldered the pins another way around on logic converter. Does it change anything?

circuit image, nodemcu is powered by the laptop USB


texts: Arduino Uno - MQTT message using PUBSUB on ESP8266

texts:
I'm trying to write code involving MQTT messages to operate an ESP8266 relay ( a Sonoff device ), using PubSub library.

For some, unknown for me, reason - messages larger than 99 chars are not sent. It this a known limitation ? can it be changed ?

void pub_msg(char *inmsg){
        char tmpmsg[255];
        // sprintf(tmpmsg,"[Cl:oc:k] [%s] %s",deviceTopic, inmsg);   ---> wish to add a time stamp
        sprintf(tmpmsg,"[][%s] %s",deviceTopic, inmsg);  ---> using this line just to find that 99 chars sent OK
        Serial.print("published MSG:");
        Serial.println(tmpmsg);
        Serial.print("Total chars:");
        Serial.println(strlen(tmpmsg));
        client.publish(msgTopic, tmpmsg);

}


texts:
I'm new to Arduinos but researched thoroughly before buying one. Just for context I'm an IT Professional with 20 years in the game, I'm comfortable with Linux/Unix, Windows, Raspberry Pi's, electronics, hardware, software and monitoring/switching COM ports.

I've purchased my first Arduino (actually a Elegoo Uno R3 clone) and have just tried it out of the box connected to two different systems; one Windows 7 64bit Enterprise the other Kubuntu. Despite having the correct COM port selected on both I'm getting similar error messages:

**avrdude: ser_open(): can't open device "\\.\COM15": The system cannot find the file specified.**

or

**avrdude: ser_open(): can't open device "\\.\COM6": Access is denied.**

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

Yes I have tried different COM ports.

Yes I have tried turning off Firewalls

Yes I have tried different USB cables.

I have a solid green LED and a intermittently blinking orange LED.

The suggested Troubleshooting guide + many Forum Threads do not seem to cover this exact error I'm encountering - well they do but they tend to be people with the simple issue of them not selecting the correct COM port or having the same COM port tied up with another task. Then choose the correct port and it works. I'm confident I have the correct COM port and when I click Get Board Info it pulls down the correct board information and serial number etc.

On the Linux system I was seeing a similar behavior with slightly different wording: Permission Denied

On my Windows 7 system I run as a Standard User (as one should, not as an Administrator), but regardless I have tried running the Arduino application normally and as an Administrator user but it has the same result. And it seems strange that it encounters the same style of error across multiple different operating systems.

Have I just been really unlucky and got a dud for my first Arduino or am I missing something obvious?

Thanks for your time and help.


texts: ISR executes even though an interrupt is not triggered

texts:
I am trying to implement a function queue scheduling system. INT1 is connected to a button and int1task causes an LED to flash.

typedef void (*funcptr)(void);
TPrioQueue *queue = NULL;

void int1ISR() {
  if (debounce(&int1time)) // Checks if the interrupt is caused by switch bouncing
    enq(queue, (void*) int1task, 1);
}

Next, I execute the function in loop() by:

typedef void (*funcptr)(void);

void loop(){
  funcptr func = (funcptr) deq(queue);
  if (func != NULL)
    (*func)(); // Stuck in a loop
}

For some reason, the LED keeps flashing even though I have not pressed the button. Why does this happen?

When I remove the line below, the ISR works properly.

enq(queue, (void*) int1task, 1)

The relevant sections of the code:

int debounce(unsigned long *debTimer) {
  unsigned long tmp = *debTimer;
  unsigned long currTime = millis();

  if ((currTime-tmp) > 500){
    *debTimer = currTime;
    return 1;
  }
  else
    return 0;
}

// Flashes LED at pin 6 five times at 2 Hz
void int1task(){
  for(int i=0; i<5; i++){
    digitalWrite(6, HIGH);
    delay(250);
    digitalWrite(6, LOW);
    delay(250);
  }
}

void setup() {
  pinMode(6, OUTPUT);
  attachInterrupt(1, int1ISR, RISING);
  Serial.begin(115200);
}

Code I used for the queue

Here is the schematic I am using:


texts: Which Arduino for many analogue sensors (and WiFi)?

texts:
For context, I come from a very software-heavy background so I know very little about hardware.
I'm looking to build a system that requires at least 6 sensors (pH, electrical conductivity, humidity, temperature, light intensity, flow rate), and I want to send all of this input over WiFi at ~10 minute intervals. Most of these sensors will be analogue.
I noticed that for example the Arduino Uno only has 6 analogue inputs. Plus from research, I would need to connect a WiFi module to the Uno which seems too much of a hassle and added cost.
I'm looking at the ARDUINO NANO 33 IOT right now. It seems perfect for what I want to do since it's cheap, has 8 analogue pins, and has WiFi out-of-the-box. Is my reasoning correct in choosing this Arduino? I'm wondering why something with WiFi capability and more pins is cheaper than the Uno.
Thanks in advance!


texts: Removing Robot IR Arduino Library on Macbook

texts:
I'm trying to use my IR receiver on my Arduino Uno Board.  First I need to remove my IR Robot library because it interferes with the IRremote library. On my Mac, I have gone into the Arduino/library folder, but the name of the library I have to remove is not there.

I cannot figure out how to remove this. Please help!!


texts: AVR (Arduino Uno) Serial.print and Serial.println only printing 1 or 2 chars

texts:
I first used the Arduino IDE but now I'm using PlatformIO which is awesome. But I have some big trouble with Serial.print() and Serial.println(). To show this error I have the following example code:

#include <avr/io.h>
#include <util/delay.h>
#include "Arduino.h"
#include "main.h"

int main(int argc, char const *argv[]) {
  Serial.begin(9600);

  section5ex34();

  return 0;
}

void section5ex34() {
  // Initialization
  DDRC = 0b00000100; // Port C2 as output and the rest (including Port C3) as input. (Port C2 is used for a led that indicates when en bit is being read)

  uint8_t b = 0b00000000;

  // here the code reads bits from PORTC3
  for (int i = 0; i < 8; i++) {
    _delay_ms(1000);
    PORTC |= _BV(PORTC2); // Make Port C2 high (indicates a bit will be read)

    if ((PINC & (0b1 << 3)) != 0) {
      b |= (1 << i);
    }

    _delay_ms(100); // Wait for the user to prepare the next bit (because this is now done by hand)
    PORTC &= ~_BV(PORTC2); // Then make Port C2 low
  }

  Serial.println(b, HEX);
}

When I have the code like this, it prints the right Hexadecimal value corresponding with the 8 read bits.

When I add Serial.println("test"); after the print, it doesn't print that.

Or when I change Serial.println(b, HEX); to Serial.println(b, BIN); it prints 11.

When I replace those 2 prints with Serial.println("Hi test test."); it prints Hi, so it seems like it can only print 2 characters.

When I add Serial.println("Hello world . hello . hi"); four times after Serial.begin(9600);, it prints Hello world . h and nothing more. So here it seems like it can print more than 2 characters, but not all. If I wait a few seconds it adds ello to this, so it says Hello world . hello.

In the initial code, when I replace the if-statement with

if ((PINC & (0b1 << 3)) != 0) {
  b |= (1 << i);
  Serial.println("1");
} else {
  Serial.println("0");
}

and when the input is connected to 5v (so high) it prints a 1 once and nothing else, not even a hexadecimal value when the reading is finished.

This problem drives me crazy.

I have an Arduino Uno and use a baudrate of 9600 , 8,N,1.

I hope someone can help me out with this.


texts: Arduino servo seems to time out after code runs for some amount of time

texts:
I am running a simple servo program that swings the servo back and forth, it is essentially pressing a button continuously. However, after some time the servo stops moving and it seems like the code stops. I have no code in the program to tell it to stop and I am uploading from a sketch. Can anyone tell me why the servo will stop after some amount of time? is this some kind of safety or programmatic end that is used when you use the sketch compiler to run code?

Here is my code:

#include <Servo.h>

int servoPin = 9;
Servo servo;

int servoAngle = 0;

void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    servo.attach(servoPin);
}

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

    int randnum = rand()%(40000-1000 + 1) + 1000;
    int randnumreturn = rand()%(600-350 + 1) + 350;
    servo.write(45);
    delay(randnum);
    servo.write(22);
    delay(randnumreturn);
}


texts:
I'm using an Atmega328p SMD with 32 pins.  I'm trying to get several pins on Port D to function as inputs.  As outputs, they work fine, but for some reason, not as inputs.  Here's a simple example of what I'm dealing with.

void setup() {

DDRB |= (1<<PB3);  //Set up an output on PB3 for an LED
DDRD = B00000000;  //All of Port D set as inputs
DDRC = B00000000;  //All of Port C set as inputs
}

void loop() {

int Power = (PIND & (1 << PORTD5));  //Read input

  if(Power == 1){
PORTB |= (1 << PORTB3);      //set high
  }
  else{
  PORTB &= ~(1 << PORTB3);  // set  low
}

I get no response from my LED like this, no matter which pin on Port D I use as an input.  But when I simply change over to Port C, it works fine.

int Power = (PINC & (1 << PORTC5));  //Read input

Ideas?


texts: I have 4 motors connected to their own ESC (that is connected to a power distribution board), how do I connect this to Arduino uno? (Drone)

texts:
I am currently working with a bigger drone that I want to connect with an arduino uno.

The motor and ESC that are already soldered together and connected are these: https://hobbyking.com/en_us/mt1806-brushless-combo-include-esc-5030cw-ccw.html

I have also connected it to a power distribution board where I succesfully can connect my 3s lipo battery.

What is currently missing is where I should put the 3 pins on each ESC onto the arduino board. So there are 12 pins in total.

The color on the 3 wires on each ESC are: yellow, red and brown.

Yellow is the signal if i am not mistaken and those should be connected on the PWM pins where I control each motor in the code.

When it comes to the red it is + power and should I ignore to connect these pins? I would like for my battery to power both the motors and the arduino so of course I would prefer to connect it to the arduino uno if it is possible.


texts: Read RFID Card Number in Processing over Serial

texts:
I have successfully setup up a RFID reader with Arduino Uno and EM-18 Card Reader Module.

Its program for Arduino is below:

int count = 0; // count = 0

char input[12];                                         // character array of size 12

boolean flag = 0;                                       // flag =0

void setup()
{
   Serial.begin(9600);                                  // begin serial port with baud rate 9600bps
}

void loop()
{
   if(Serial.available())

{

count = 0;

while(Serial.available() && count < 12)          // Read 12 characters and store them in input array

{
input[count] = Serial.read();
count++;
delay(5);
}

//Serial.print("Card ID - ");

Serial.print(input);      // Print RFID tag number

}

}

But when try to read the code over serial in the program for locking/unlocking mouse in Processing the values of strings don't match.
Hence the mouse doesn't get unlocked.

The program for processing is as below:

import processing.serial.*;
import java.awt.AWTException;
import java.awt.Robot;

Robot robot;
boolean locked = false;
Serial port;
void setup()
{
  println(Serial.list()); //Prints available ports

  port = new Serial(this, Serial.list()[36], 9600); //Chooses the first available port
  try
  {
    robot = new Robot(); //Creates robot
  }
  catch (AWTException e)
  {
    e.printStackTrace();
  }
}

void draw()
{
  if (locked == true) robot.mouseMove(0, 0); //If locked, moves mouse to top left corner
  while (port.available() > 0)
  {
    String input = port.readString();
    //println(input);
    if (input.equals("11006F26DC84") == true) locked = false; //If it read my card it will unloack.
  }
}

void keyPressed ()
{
  if (key == 'l')
  {
    locked = true; //Locks it
  }

  if (key == 'u')
  {
    locked = false; //Unlocks it
  }

  if (key == ESC)
  {
    key = 0; //Disables escape as quit
  }
}

Please point the incorrect syntax and suggest correct one.


texts:
I am trying to understand what each pin on my Arduino Due is and what it is used for, and so I have been searching for things like "Arduino Due pinout", "Arduino Due pin mapping" and similar.

The best I could find was this table, however it doesn't help you out at all if you are completely new to electronics and have no idea what TX2, SDA or NPCSO mean, etc.

Does anybody know of Arduino/Due documentation that explains what each I/O pin is?


texts: I just received my starter kit from oddwires.com today and it came with a split-able ribbon cable for prototyping. I was curious if it is possible to split each wire off and use only what I need to for the tutorials or is that a bad idea? I am very excited to start playing around and learning this as it has been a interest of mine for many years.


texts:
Most of my Arduino work has been on a PC, but now I am on a Mac. I need to modify Print.h to give me printf facilities, as detailed here.

I can find Print.h buried within my application files, but changing it has no effect. A search across my disk reveals no further Print.h files.

Where on a Mac should I find and edit the Print.h file?

Can someone tell me what I am missing please?

Thanks,

Martin


texts:
Have a DFRobot Arduino Pro Mini.

Seems odd to me, but according to their specs the voltage regulator on board cannot handle more than 8-volt input. I can find no documentation, or have they answered me concerning what specific regulator they use on the board.

I would like to be able to run this board from a 9-volt battery. What is the best / most eloquent way to do this, keeping the smallest component footprint for a home etched board ?

An additional regulator ?? Could a diode clamp the voltage down ?

Many thanks in advance.


texts:
I found a batch of DS1820 in my drawers; they worked 10 years ago on a DS9097U-09 onewire to RS232 converter.
Note, not DS18B20

I use them in parasite power mode; pin 1 and 3 together to gnd.

But when I connect them to an Arduino scetch, they are identified, but read no temperature, only FF FF FF FF FF FF FF FF with correct CRC C9, so it's not data being garbled; it must be the polling of data which is not right.

Are the DS18(S)20 compatible with the standard Arduino lib?

I'm using this:

https://www.elec-cafe.com/temperature-sensor-on-the-web-with-esp8266-and-ds18b20/

shown with the irellevant parts removed below:

#include <OneWire.h>

OneWire  ds(D7);  // on pin 7 (a 4.7K resistor is necessary)

void loop() {

  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;

  if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    Serial.println();
    ds.reset_search();
    delay(1000);
    return;
  }

  Serial.print("ROM =");
  for ( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }

 if (OneWire::crc8(addr, 7) != addr[7]) {
    Serial.println("CRC is not valid!");
    return;
  }
  Serial.println();

  // the first ROM byte indicates which chip
 switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
     type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  }

  ds.reset();
  ds.select(addr);
 ds.write(0x44, 1);        // start conversion, with parasite power on at the end

  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.

  present = ds.reset();
  ds.select(addr);
  ds.write(0xBE);         // Read Scratchpad

  Serial.print("  Data = ");
  Serial.print(present, HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print(OneWire::crc8(data, 8), HEX);
  Serial.println();

  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.println(" Celsius, ");
}

I get this (I have a string of 6 on a 10m at least 2-wire cable),

ROM = 10 28 6A C6 0 8 0 6
  Chip = DS18S20
  Data = 1 FF FF FF FF FF FF FF FF FF  CRC=C9
  Temperature = -0.50 Celsius,
ROM = 10 CC 49 C6 0 8 0 45
  Chip = DS18S20
  Data = 1 FF FF FF FF FF FF FF FF FF  CRC=C9
  Temperature = -0.50 Celsius,
...
No more addresses.

I get the same result if I only use one DS18(S)20.

Another sketch using DallasTemperature.h is not working either:

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS D7

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
....
void setup(void){
  DS18B20.begin();
}

float getTemperature() {
  float temp;
  do {
    DS18B20.requestTemperatures();
    temp = DS18B20.getTempCByIndex(0);
    delay(1000);
    Serial.println(".");
  } while (temp == 85.0 || temp == (-127.0));
  return temp;
}

.. just hangs in this while loop.


texts: Two 300RPM 12V DC motors connected to arduino motor shield r3 power supply

texts:
I have two 300RPM 12V DC motors connected to arduino motor shield r3 that is mounted on arduino uno board.

Problem is my motors  runs very slow some times not even running.

After googling I found I need to use external power supply. I did  supplied 9 volt dc power to arduino motor shield r3.
But still motor is running very slow what could be the issue.

My other questions.

When supplying power to arduino motor shield r3  via external power supply pins do I need still need to provide separate power to arduino uno board via power jack.

Can I use 9 volt dc for arduino uno board and another 9 volt batter to arduino motor shield r3.

Is single 9 volt batter enough for running two 300RPM 12 dc motor.

My circuit.

My program

          void setup() {

          //Setup Channel A
          pinMode(12, OUTPUT); //Initiates Motor Channel A pin
          pinMode(9, OUTPUT); //Initiates Brake Channel A pin

          //Setup Channel B
          pinMode(13, OUTPUT); //Initiates Motor Channel A pin
          pinMode(8, OUTPUT);  //Initiates Brake Channel A pin

        }

        void loop(){

          //Motor A forward @ full speed
          digitalWrite(12, HIGH); //Establishes forward direction of Channel A
          digitalWrite(9, LOW);   //Disengage the Brake for Channel A
          analogWrite(3, 255);   //Spins the motor on Channel A at full speed

          //Motor B backward @ half speed
          digitalWrite(13, LOW);  //Establishes backward direction of Channel B
          digitalWrite(8, LOW);   //Disengage the Brake for Channel B
          analogWrite(11, 123);    //Spins the motor on Channel B at half speed

          delay(3000);

          digitalWrite(9, HIGH);  //Engage the Brake for Channel A
          digitalWrite(9, HIGH);  //Engage the Brake for Channel B

          delay(1000);

          //Motor A forward @ full speed
          digitalWrite(12, LOW);  //Establishes backward direction of Channel A
          digitalWrite(9, LOW);   //Disengage the Brake for Channel A
          analogWrite(3, 123);    //Spins the motor on Channel A at half speed

          //Motor B forward @ full speed
          digitalWrite(13, HIGH); //Establishes forward direction of Channel B
          digitalWrite(8, LOW);   //Disengage the Brake for Channel B
          analogWrite(11, 255);   //Spins the motor on Channel B at full speed

          delay(3000);

          digitalWrite(9, HIGH);  //Engage the Brake for Channel A
          digitalWrite(9, HIGH);  //Engage the Brake for Channel B

          delay(1000);

        }


texts: Can I power ESP8266 with more than 3.5 V?

texts:
I am concerned whether I need to use a voltage divider to power my ESP8266 module. My concerns stem from the warnings that I have heard in multiple tutorials. Everyone seems to regard the ESP8266 as being very sensitive to supply voltage.

Has anyone use the ESP8266 with an supply voltage greater than 3.5 V? What were the effects? Is it even necessary to make a voltage divider?

I am asking because my application has limited real estate.


texts: Unsure how to connect the anode in this circuit

texts: I am making a game of X and O’s and ran out of pins on the Arduino. After searching on the internet I found out about connecting it in a grid connecting all the anodes in columns and the different colours in rows but I don't know how to connect the anodes so it only turns on only one of the LEDs rather than the other 2 in the grid if they are all connected to ground. The wires I am unsure to connect are the orange ones in the diagram below (bottom left corner). Note the Red on the RGBs are not used so don't need to be connected


texts: CC1101 sniffing 868Mhz Protocol from thermostat

texts:
Hello i buyed a cc1101 because I want to sniff thermostat protocol which works with 868 Mhz.

I found this repo https://github.com/veonik/arduino-cc1101.
I tried to download the repo and include the zip file as libary.
First error was cc1101.h not found. So I moved the files from .src folder one level up.
Then I get error SPI.h no file directroy. So I imported this libary.
Now I have no errors and uploaded it to arduino mega.
Then I have no serial output. I have a cc1101 with 868 mhz. And I want to log the informations from a MAX! thermostat. Somebody can help me?
Here is photo from my wiring.


texts: ESP8266 client.connect() generates a memory leak

texts:
I have an ESP8266 that has to run 24/7, it sends some data to server every our, everything works fine for about 2-3 days after that it crashes. Sometimes it resets sometimes it freezes. I got to the root of the problem, sending function generates a memory leak. Below the code and serial output.

Code:

Serial.print("-------------------before -----------------");
Serial.print("FlashChipSize: ");
Serial.println(ESP.getFlashChipSize());
Serial.print("FlashChipRealSize: ");
Serial.println(ESP.getFlashChipRealSize());
Serial.print("FlashChipSizeByChipId: ");
Serial.println(ESP.getFlashChipSizeByChipId());
Serial.print("FreeHeap: ");
Serial.println(ESP.getFreeHeap());
if (client.connect(serverName, 80)) {
    client.println("POST /script.php HTTP/1.1");
    client.println("Host: www.site.com");
    client.println("User-Agent: Arduino/1.0");
    client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded;");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.println(data);
    Serial.println("sended");
    client.println("GET /index.html HTTP/1.1");
}
else {
    Serial.println("No conn...");
}
client.stop();
Serial.print("-------------------after-----------------");
Serial.print("FlashChipSize: ");
Serial.println(ESP.getFlashChipSize());
Serial.print("FlashChipRealSize: ");
Serial.println(ESP.getFlashChipRealSize());
Serial.print("FlashChipSizeByChipId: ");
Serial.println(ESP.getFlashChipSizeByChipId());
Serial.print("FreeHeap: ");
Serial.println(ESP.getFreeHeap());

Serial.print("-------------------done-----------------");

outputs this in serial terminal:

-------------------before -----------------
FlashChipSize: 4194304
FlashChipRealSize: 4194304
FlashChipSizeByChipId: 4194304
FreeHeap: 43288
sended
-------------------after-----------------FlashChipSize: 4194304
FlashChipRealSize: 4194304
FlashChipSizeByChipId: 4194304
FreeHeap: 41584
-------------------done-----------------0


texts: Use SD Card while Pin 11 is being used for PWM

texts:
On Arduino Uno Rev3, I just ran the speaker_pcm demo that used TIMER1 and TIMER2 to generate a PWM wave. However, this means that the Pins 3, 9, 10 and 11 can not be used anymore; according to the documentation:

Takes over Timer 1 (16-bit) for the 8000 Hz timer. This breaks PWM
(analogWrite()) for Arduino pins 9 and 10. Takes Timer 2 (8-bit)
for the pulse width modulation, breaking PWM for pins 11 & 3.

I wanted to change the program such that the WAV data was read from a SD card. However, this is what documentation for SD.h library says:

The communication between the microcontroller and the SD card uses SPI,
which takes place on digital pins 11, 12, and 13 (on most Arduino boards)

This means both the SD.h and speaker_pcm want to use pin 11, and the requirement to use these pins is dictated by the hardware. I am guessing that this clash will create problems.

Is there any way I can make this work? Can I switch between SD card reading and Audio playing somehow (essentially multiplexing in software)? Or will this collision of pin usage not be a problem?


texts: Is there any way to use a JTAG programmer with the Arduino IDE?

texts: I am doing a lot of work with custom boards I've designed with the ATSAMD21G. I'd like to get away from using USB to program my boards since the USB port takes up space on the PCB and consumes extra pins. Is there any recommended way to configure the Arduino IDE to simply dump out the compiled program into a JLink debugger, much like the Atmel Studio IDE can?


texts: Manage multiple Arduinos with LORA SX1276

texts:
well, Lora seems to be the perfect device to wirelessly communicate over very long distances

But I want to comminicate with multiple Arduinos in a group. in our Factory there are lots of machines I want to read rpm of macihines with arduino (I will use 23 arduinos) and collect in a Master arduino than send to internet. at this video he use wire.h and solved this problem. But how can I use common ground in wireless. Do you have any idea for communicating multiple device with wireless via LORA SX1276


texts: Why does my Arduino IDE hang/crash so often?

texts:
I've traditionally used a text editor with avr-gcc and makefiles for working with Arduino boards. I'm now trying to develop projects for the wider Arduino user-base, so I am trying to use the Arduino libraries and common IDEs for ease of use.

I started using Stino, but then found out that the Arduino IDE has some toolchain "quirks" that mean I will need to test everything in Arduino IDE expressly.

Since starting to use it more, I have found it frequently hangs or crashes. The triggers for this are:

Creating a new sketch takes about 15s, and shows me the OS X beach
ball.
Saving a sketch takes about 15s.
Going to File->Examples frequently crashes the IDE - I need to force quit.
Going to
File->Sketchbook always crashes the IDE.
It sometimes randomly hangs.

I don't have any other stability issues and other Java based IDEs like Pycharm work flawlessly.

I have installed numerous libraries, including the entire Teensyduino suite (which is a lot of libraries!). Outside of that, no changes have been made.

Is this a common issue? Is there any logging or anyway I can try and work out what is causing this issue?

This is happening with:
 - Arduino 1.05
 - Arduino 1.55

I have tried uninstalling and reinstalling.


texts: How do I use the additional serial ports on an Arduino UNO R3 clone?

texts: I bought this Arduino clone over eBay. It seems to have an extra SPI and serial ports. How do I use these?


texts: Using c_str() on String for IPAddress with NTPClient provides wrong values

texts:
Libraries

NTPClient

Board

Olimex ESP32-POE board

Behaviour

I have written a code that connects the board to a local NTP Server (which is an embedded board). I tried assigning the IP Address of the above NTP Server using IPAddress and then convert it to c_str() to pass into the NTPClient constructor as follows:

 WiFiUDP ntpUDP; // udp socket object for NTP

 IPAddress NTPServer(192.168.3.11); // Local NTP Server IP Address

 NTPClient timeClient(ntpUDP, NTPServer.toString().c_str(), 0, 60000);

The reason for this is because the NTPClient class uses const char* for the IP Address of the NTP Server.

The values that are obtained once the code is flashed on the board are wrong because the timestamps are have the year 2106.

On the contrary, when I use

 NTPClient timeClient(ntpUDP, "192.168.3.11", 0, 60000);

and run the code on the board, this provides me perfect values of UTC time.

Why is there some discrepancy here?

Code

#include <Wire.h>
#include <ETH.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
#include <RTClib.h>

WiFiUDP ntpUDP;
/* IP CONF for NODE */
///////// >>>> MODIFY Values Here <<<< ////////
const IPAddress node_static_ip(192, 168, 3, 101);
const IPAddress default_gateway(192, 168, 3, 250);
const IPAddress subnet_mask(255, 255, 255, 0);
const IPAddress dns_add(192, 168, 3, 250);
const IPAddress NTPServer(192, 168, 3, 11);

NTPClient timeClient(ntpUDP, "192.168.3.11", 0, 60000); // This works
NTPClient timeClient(ntpUDP, NTPServer.toString().c_str(), 0, 60000); // This won't (provides timestamps of 2106)

void setup() {
  // put your setup code here, to run once:
  Wire.begin(I2C_SDA, I2C_SCL);
  Serial.begin(115200);
  ETH.begin();
  ETH.config(node_static_ip, default_gateway, subnet_mask, dns_add);
  delay(1000);
  if (!rtc.begin()) {
    Serial.println("No RTC");
  }
  timeClient.begin();

}
void loop() {
  // put your main code here, to run repeatedly:
  timeClient.update();
  Serial.println(timeClient.getEpochTime());
  DateTime now_time(timeClient.getEpochTime());
  Serial.print(now_time.year(), DEC);
    Serial.print('/');
    Serial.print(now_time.month(), DEC);
    Serial.print('/');
    Serial.print(now_time.day(), DEC);
    Serial.print(now_time.hour(), DEC);
    Serial.print(':');
    Serial.print(now_time.minute(), DEC);
    Serial.print(':');
    Serial.print(now_time.second(), DEC);
Serial.println();

  delay(2000);

}


texts: How can I burn the bootloader onto atmega328 (not atmega328p)?

texts:
Hi I bought some atmega328 chips (not to be confused with atmega328p). They are very similar but the atmega328p chips are just more power efficient, so I've read. Anyways, my goal is to burn the arduino bootloader onto these chips so that I can make some breadboard arduinos. I used the arduino ISP sketch and hooked up everything like so ->

I was following instructions from the following link ->
https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
However, when I press the Burn Bootloader button under Tools, it keeps telling me that it can't verify that my chip is an atmega328p. Well it is not atmega328p but everywhere online says it does not matter since they are the same architecture. The error also tells me that I can override by typing -F, but it doesn't tell me where to input this. I'm pretty sure that may fix the issue, but I am not sure where I'm supposed to put the -F.
Also I saw another post that was similar to this one but the answer said that the problem is the atmega328 chip itself. Is it even possible to add the bootloader to these chips??? Other sources said it is, but I can't seem to do it.