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.

0
votes
1answer
16 views

Issue with analog readings on Arduino atMega with YL-69 moisture sensors

I've connected four YL-69 sensors to my arduino at-mega2560 on analogs pins 0-3. This is combined with four DHT11 sensors that are in digital pins. The DHT work fine, and I can work one YL-69 ...
0
votes
0answers
30 views

Ethernet Shield - Not Working Properly Always

I'm working on a school project and using Arduino Uno. The basic working method for the project is as follows: Read temperature from LM-35. Read CO2 level in air using MH-Z14A. Upload data to server ...
0
votes
1answer
29 views

error: 'View' does not name a type

The code seems to be good, but I get the mentioned error. Let's have a look at the code: view.h #ifndef _VIEW_H_ #define _VIEW_H_ #include <Arduino.h> #include <ds3231.h> #include "info....
0
votes
1answer
27 views

Dynamically modifying the call stack using pointers

In a C++ Arduino library, can we modify the call stack from inside a function by intentionally decrementing a pointer to a stack variable so that it's out of range? Like this: void FooBar() { char ...
1
vote
2answers
73 views

Need help with the syntax for a function that takes a closure [on hold]

My C++ is very out-of-date. (20+ years, before C++ had closures). I'm a senior SW engineer, and I spent several hours yesterday trying to figure this out, but I could not work it out. The background:...
0
votes
1answer
51 views

what does * command when using it with string? [on hold]

I want to figure out what does "*" command? For example code below; int numOfRegisters=2; byte* registerState; void setup() { registerState = new byte[numOfRegisters]; for (size_t i = 0; i < ...
-1
votes
0answers
29 views

I need help for my science project (Follow the sun) Why is there a -1 * next to tolerence? [closed]

int tol = 50; // int tol = analogRead(5)/4; // check if the difference is in the tolerance else change horizontal angle if (-1*tol > dhoriz || dhoriz > tol)
-1
votes
0answers
29 views

For my follow the sun project. What does the * mean? [closed]

#include <Servo.h> // include Servo library // 180 horizontal MAX Servo horizontal; // horizontal servo int servoh = 90; // 90; // stand horizontal servo int servohLimitHigh = 180; int ...
0
votes
0answers
28 views

How do I spilt a string of data into four different parts [closed]

The string has seconds, miles away from our point and latitude and longitude, and all we need is the lag and long 4271.645999999997,s,28.00301266666665,mi,28.48737418308778,N,-81.36210510944983,E. we ...
0
votes
3answers
76 views

Creating a library for arduino

I found a really nice 24 bit I2C adc which was fairly cheap as well (ADS1219) but as far as I could tell there are no libraries for it so I decided to make my own. I have managed to write functions ...
1
vote
2answers
42 views

Most efficent way to adjust value

I am working on a system that starts a process based of a set time value (startHour). The user sets the start hour and can only select values from 00-23. I have been asked to start the same process at ...
1
vote
3answers
398 views

Why to store a function parameter value in a class private variable?

I'm just curious, I'm going through a C++ library for the mcu2.4 TFT display. And this method I notice when I run through C++ libraries. Which is when a parameter is passed through a function, it's ...
1
vote
1answer
68 views

Get ESP32 Chip ID into a string variable (Arduino/C++ newbie here)

It's just a few days since I started using Arduino IDE ( programming an ESP32 ). As I learn, I am trying to write some snippets. I wanted to store the Chip ID of ESP32 into a variable (preferably ...
-1
votes
0answers
106 views

WeMOS ATmega 2560 +esp8266 wifi R3 Won't find any wifi networks

I have a WeMOS ATmega 2560 +esp8266 wifi R3 that I want to send sensor data to thingspeak with. I'm just getting started with it, and am having trouble finding a wifi network. I followed this guide: ...
0
votes
1answer
23 views

How can I call the constructor of a Class after it called once? [closed]

I have a problem with Classes. I have a bunch of code, that code is uses Adafruit MQTT FONA library. I call the Class for make new Instance and Connect to specified server with this code; ...
0
votes
1answer
37 views

How to avoid Multiple definition of 'Blynk' error?

By including #include <BlynkSimpleEsp8266.h> Blynk library (https://github.com/blynkkk/blynk-library) from more than 1 module/cpp file, "Multiple definition of `Blynk’" error is thrown at ...
0
votes
1answer
46 views

How can I concatenate these two values as a string?

I've tried all the supposed solutions for the exact error, pasted into google, that I could find on every forum including this one and no matter the alleged solution I will either get the error about ...
0
votes
2answers
32 views

Transient buttons control non-transient behaviour of LEDs

Imagine a system where you have two transient non-exclusive buttons and two LEDs. When you press button 1, the LED 1 is HIGH and LED 2 is LOW (and stays that way). When you press button 2, the LED ...
0
votes
0answers
15 views

Arduino lcd game problems, endless runner code not working

i have a game i have downloaded and built, have a file here, (file is too large to put on here), i am posting the whole thing because i dot know why the code wont work. that file is the original (from ...
1
vote
1answer
37 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
39 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
97 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
70 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
49 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
46 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
2answers
45 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
78 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
95 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
117 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
102 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
164 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
623 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
39 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
288 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
49 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
44 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
67 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
152 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
2k 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
816 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
105 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
473 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
72 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
57 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
422 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
41 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
385 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
30 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
107 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
468 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 ...