Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++]

C++ is the standard language used to program the Arduino IDE. However, the Arduino IDE does have lots of libraries built in, so functions such as "main" are not called directly in the sketch code. Most Arduino code online is written in this language.

1
vote
1answer
33 views

How to combine time into a variable

I have an Arduino Uno project which is recording student attendance using fingerprint sensor. So when sensor found a match, the serial monitor will be printing out Student ID and current time like ...
0
votes
2answers
33 views

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

I am student that is new to Arduino and working on a project to trigger an alert if the sound level detected exceeds the threshold for a period of 2 mins. But I am stuck, would like to check how do I ...
-1
votes
1answer
26 views

ESP8266 WebServer not responding (connection time out)

My web server running on ESP8266, stop working after while. I cannot connect to it - browser shows connection time out error. No error, no crash... nothing. Have you any idea how to fix it? My code: ...
0
votes
2answers
50 views

Custom Classes - Redefinition of void error [closed]

I'm getting a redefinition error from my classes, but can't see what I did wrong. Error: Icon.cpp:3:6: error: redefinition of 'void Icon::setIcon(byte (*)[8])' Can any help me out on this? Thanks! ...
0
votes
1answer
33 views

Value assignment on Arduino

I have a thermocouple k. I want this thermocouple to select the first value OF TEMPERATURE that it read and assign it to a variable in an Arduino program. How should I do that?
1
vote
2answers
45 views

How to convert this sketch to keep only one if-else statement? [closed]

int ldrPin = A0; int rainPin = A1; int smokePin = A2; int greenLED = 6; int redLED = 7; // you can adjust the threshold value int thresholdValue = 500; int LightSensorThreshold = 500; int ...
0
votes
1answer
35 views

How do i fade a colorwipe from off to on in 1 color?

So I want to make the same effect as a colorwipe (like going around in a circle turning leds on till they all turn on) except that instead of going from off to 100% brightness immediately I need it to ...
1
vote
2answers
72 views

What exactly does the Arduino preprocessor do?

Arduino claims to be a "language," not just an "application framework," and Arduino files have their own extension, .ino. The language is obviously C++, but not quite. My understanding is that ...
0
votes
1answer
41 views

Read Multiple Sensors Data from a text file located in SD Card in Arduino/ESP32

I am working on a small home project 'glucose meter' via non invasive techniques. I am using four sensors like RGB color sensor, two multi-wavelength photo diodes (A & B) and temperature sensor (K-...
0
votes
1answer
60 views

No data sent over serial port in linux c++

TL;DR - I am attempting serial communication with Arduino with code that I found here and nothing gets sent over (Arduino programmed to respond, and I checked that it does with its serial monitor) Hi ...
0
votes
1answer
50 views

ESP8266 SPIFFS not saving correctly?

Hey all I am having some issues with the SPIFFS for this Wemos D1 mini ESP8266 controller. This is my Arduino sketch: #include <FS.h> #include <ArduinoJson.h> struct RGBLA { uint8_t R;...
2
votes
1answer
133 views

Arduino std::map returning random values

I'm working with an arduino UNO. I would like to be able to send it set and get commands over serial and have it update class data class members accordingly by key value pair. I spoke to users in the ...
0
votes
1answer
176 views

Arduino Convert std:string to String

I'm working on BLE project with espressif library. And It returns me founded BLE device. std::string getManufacturerData(); std::string getName(); int getRSSI(); BLEScan* getScan(); When ...
0
votes
2answers
36 views

What is the purpose of '&' while passing bool as a function parameter [closed]

If I use this function without & before change_x (in function parameter), change_x never changes to false and it keeps on printing forever. Why do I need &? void some_function(bool &...
1
vote
1answer
114 views

How to pass non-static class member to callback?

I am using the arduinoWebSockets library in my own Arduino library. I'm having trouble with trying to assign a class member as the websocket library onEvent callback function. MyClass.cpp: #include &...
0
votes
0answers
48 views

How to separate programming parts corresponding to different peripherals

Often I want Arduino board to control several peripherals. Writing program for all of them in one document using #define SOME_PIN 4 constructions seems pretty inconvenient to me. Especially in such a ...
1
vote
1answer
40 views

Thermistor doesn't work [closed]

Connecting all like shows the image, thermistor shows, that I'm going to be burnt: The code is simple: #define analogPin A0 //the thermistor attach to #define beta 4090 #define resistance 10 ...
0
votes
1answer
49 views

ESP8266 12-E can't connect to any Access Point with converted variables from strings to char arrays

I'm using an esp8266 12-E nodemcu I wrote a code that scans the available WiFi networks, print them through serial communication,ask the user which network he wants to connect to and then the password ...
0
votes
2answers
98 views

Memory leakage caused by String Concatenation

In this link, section "Memory, memory, memory" it's been told that doing many String concatenations in sequence, e.g.: using operator+() multiple times, will cause memory fragmentation, which may lead ...
1
vote
1answer
1k views

How to convert char array to String in arduino?

I want to convert const char array in PROGMEM to String. How do I do this? const char charArray[] PROGMEM = "Some text";
1
vote
3answers
492 views

error: expected primary-expression before '(' token

I have a decent level of programming skill, or at least I thought so. I've been getting an error when compiling this Ardulno sketch. I don't really know what this error means or how to fix it. What's ...
1
vote
1answer
64 views

Flashing NodeMCU with .ino file?

I'm brand new to the Arduino world. I recently purchased a NodeMCU in order to have it act as a sort of foothold to get into Arduinos as it's something I've always wanted to do. However, it was only ...
2
votes
1answer
272 views

C++ Undefined reference to 'Class:Function()'

I have these files: Project.ino Sensor.h Sensor.cpp IMU/L3G.h IMU/L3G.cpp Sensor.h #ifndef Sensor_h #define Sensor_h #include <EEPROM.h> #include "IMU/L3G.h" #define CUTOFF_FREQ 30 #define ...
1
vote
1answer
67 views

Which platform is better to debug Arduino memory problems? Linux or Windows?

I am developing a product. I developed every module in the firmware individually. Now I am integrating them but getting memory issues. I am not able to see how the memory is allocated inside the MCU ...
0
votes
0answers
48 views

How do I send a string after initiatint transmission in Arduino through SPI

I'm trying to send "hello\n" from master to slave but before I want to send qn initialization command like SPI.transfer(1) Example master code. #include <SPI.h> void setup (void) { ...
0
votes
0answers
324 views

SAMD: 'function' in namespace 'std' does not name a type

I'm trying to compile a sketch that uses the following code: std::function<void(char*)> callback = std::bind(&Animator::_callback, this, std::placeholders::_1); Verification of the sketch ...
1
vote
1answer
40 views

Changing type of one variable dramatically changes compile size

I have a sketch containing the following method: // Writes zeros to the complete screen clearing it: void clearScreen(uint8_t val) { setDrawArea(0x00, 0x7f, 0x00, 0x07); // complete screen ...
0
votes
1answer
208 views

compile error when using two typename in template class

I am using Arduino 1.8.5 ide. I am just creating a class with two typename which name is "Map". This class takes all int and String variations. Like; class Map<int, int>; class Map<int, ...
1
vote
1answer
29 views

Problems with passing objects in tree structure [closed]

I'm new to C++ and arduino. I want to build an object Tree, but it did not behave like I expected. Here is the code: TreeNode.h class TreeNode { public: TreeNode(String inputNodeName); ...
0
votes
2answers
70 views

How do i send ads1115 data over spi to master arduino

I am trying to send ADS 1115 data which is connected with Arduino mega_1 over I2C and arduino Mega_1 is connected with arduino Mega_0 over SPI. Arduino Mega_1 is act as a slave and send ADS 1115 data ...
0
votes
2answers
208 views

Creating formatted String (including floats) in Arduino-compatible C++

I'm using a Mega2560 and a generic SSD1306 OLED display with the Adafruit_SSD1306 (and by extension, Adafruit_gfx) library. I need to print a bunch of float values (ranging between 30.0 and 99.9) to ...
2
votes
1answer
76 views

Write and read operation via synchronous serial port (Arduino Uno + ADNS2610)

1.Preliminaries I have optical sensor ADNS2610 (see datasheet here) which I plug in to Arduino Uno R3 board. It is possible either to read from either to write to the sensor. Here is what datasheet ...
0
votes
1answer
134 views

won't verify a simple code

When I tried to verify a simple “Hello world” program I get the following message: class hardwareSerial has no member named printin. What does it mean?
0
votes
0answers
816 views

IOT-GA6 gsm module Arduino +CME error 58

I've recently bought a IOT-GA6 gsm module . I want to use it to send an mms but doesn't work. The SMS and call work. When I execute the void function (mms) the monitor shows the error message +CME ...
0
votes
2answers
118 views

Can i use a range in a switchcase like in pascal?

in pascal's case statement i can use this: Var i : integer; ... Case i of 1..5 : DoSomething; end; i was wondering if there is a way in can do this with c/c++ in the arduino compiler using:...
-3
votes
2answers
168 views

Simulating a real time clock module with software [closed]

I am building a clock with an Arduino. Most clocks have a RTC module or some kind of RTC chip in order to get the time. I do not. How do i replace this chip with software? Is there a C/C++ library ...
1
vote
1answer
346 views

Increase sample rate in ESP32 board

For my final project on the university as a Systems Engineer, I'm working on a "electronic stethoscope", which is giving me a lot of headaches. I bought a Adafruit Feather ESP32 Huzzah (https://learn....
0
votes
1answer
174 views

const char* to double

I'm trying to use an if statement to check when the time goes past a specific point and run a specific function. To do this I'm looking to convert time into a double and running something along the ...
0
votes
0answers
81 views

Camera VC0706 No camera found?

I have followed steps of this tutorial https://www.elecfreaks.com/7861.html But the problem No camera found? #include camera_VC0706.h #include SD.h #include SoftwareSerial.h #define chipSelect 10 ...
1
vote
1answer
51 views

Arduino program has suddenly stopped updating

I am writing a speedo/odometer program which was all working beautifully until I introduced an LCD screen and code for the LCD. The screen works on power up, displays the distance recorded on an SD ...
0
votes
2answers
2k views

I have the error: expected unqualified-id before 'if'

This is my Sketch or code: const int EchoPin = 5; const int TriggerPin = 6; const int LedPin = 13; void setup() { Serial.begin(9600); pinMode(LedPin, OUTPUT); pinMode(TriggerPin, OUTPUT); ...
0
votes
0answers
43 views

data streaming using Bluetooth + RFduino

I am trying to send ECG data using RFduino. I am using two RFduino modules. The transmitter module is using the device code while the receiver is using the host code. I have common baud rate between ...
-1
votes
1answer
72 views

Factory Pattern on Arduino

I'm looking to create a factory pattern to identify which of N objects is attached to my Serial port. Assuming each object has a unique response to the input stream "What topic is this?", How can I ...
0
votes
2answers
80 views

Can increasing the size of the software RX buffer cause problem in Arduino Uno

If I were to increase the of the buffer array from 64 to say 512 will this bring any long term problem in the Arduino Uno. Changing from this: #ifndef _SS_MAX_RX_BUFF #define _SS_MAX_RX_BUFF 64 // ...
0
votes
1answer
60 views

Arduino variables loaded from SD card

I am trying to load some variables from an SD card on the start up of my arduino Uno. I have been given some advice but am unable to communicate at the same hours. Using this advice, I have the ...
0
votes
1answer
316 views

Arduino: load variables with values read from SD card

I am having a bit of trouble loading values stored on an SD card and assigning them to variables within my program. I can achieve this as one big block of data, but would much prefer them to be saved ...
2
votes
2answers
254 views

Arduino Libraries: Declaring variables as public?

How come I never see any Arduino Library expose some of it's internal variables as public in the header file? I only see functions which are declared as public, while every variable is declared ...
0
votes
1answer
47 views

Why is this variable giving me always the value of 0?

I am doing a project and here is the code that I am using, but I do not know why the values of duration and sofia is always 0 so the values of distance and monroy are also 0 const int trigPin = 9; ...
0
votes
0answers
47 views

BareConductive TouchBoard MP3 not playing

I am working on a project that measures people heartbeat for a timespan of 10s and displaying the average BPM with the LED strip. I want to play some music while it is measuring during that 10s and ...
0
votes
0answers
16 views

How use an interrupt function defined inside a class [duplicate]

I want to define only one interrupt function inside a class and then initialize this class with pin number. This is the Arduino sketch: #include <EnableInterrupt.h> class PinTouch { int pin;...