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.

Filter by
Sorted by
Tagged with
1
vote
0answers
19 views

How to parse data most efficiently coming through mqtt with ESP8266

I am writing a program that is currently set up like so: Python script running on my computer. Raspberry pi is the broker for the mqtt data transmission An ESP8266 is programmed to listen to/...
0
votes
1answer
35 views

Alternative IDE for compiling and running arduino code?

I am not super experienced with c++ and I know that the syntax for C++ and the code written/compiled by the arduino IDE are slightly different. I would like to be able to write code, compile it the ...
0
votes
1answer
24 views

Publish chipid to mqtt using ESP32-CAM

I have been trying to push the data of temp, humidity, and pressure from a sensor to MQTT using ESP 32Cam, and was able to do using the following code: pressure = bme.readPressure(); //Convert the ...
0
votes
1answer
46 views

C++ State Machine / Wpmf-convesion

I'm quite a newbie using C ++. I am trying to implement in C ++, the state machine described in this link for C language: https://barrgroup.com/Embedded-Systems/How-To/Coding-State-Machines. I have ...
0
votes
1answer
49 views

Variable sets to 32767 - MATLAB Arduino

I am running out of ideas of what may be causing this problem, and I would appreciate some help identifying anything I am overlooking. Quick Problem Summary A variable gets set to 32767 quite often ...
0
votes
1answer
37 views

How to use existing (non-arduino-specific) library with subfolders in Arduino IDE?

I have a generic c++ library that i'd like to use in an arduino project without making changes to the library code. The library contains subfolders and files in the library include other files of the ...
0
votes
3answers
47 views

Incompatible types in assignment of 'uint8_t {aka unsigned char}' to 'uint8_t [1] {aka unsigned char [1]}'

I'm trying to send custom data. But it doesn't seem to work. I can't find a way to parse my string to a unit8_t. I tried to follow other people's solutions but they don't seem to work for me. // ...
0
votes
0answers
49 views

Byte not written to the memory

In the following code I'm computing crc and setting it as last (11th) byte in the array. The problem is it's sent on I2C just when I print it on the serial terminal. static constexpr uint8_t ...
0
votes
1answer
17 views

What are the sizes of each primitive datatype on a Metro M4 Express SAMD51?

What are the data sizes of all the primitive datatypes on a Metro M4 Express SAMD51 C++ implementation? In some C++ implementations, int has 16 bits and in other implementations it has 32 bits. Is
1
vote
1answer
20 views

Ramping up and down arduino motor due to ultrasonic sensor input

Im working on an arduino robot that needs to follower a leader robot infront of it. The leader robot can accelerate, decelerate , and stop and my robot needs to be able to follow the leader without ...
-1
votes
0answers
38 views

Robot code is not running properly [duplicate]

I have an obstacle avoidance program that came on my robot (Elegoo uno R3 smart car) and all I've added to it is the remote program but for some reason that code only works for one time. what i mean ...
0
votes
2answers
93 views

Yet another basic and silly question about C++ strings

I made a sketch like this: void setup() { // put your setup code here, to run once: Serial.begin(9600); char str1[64] = "test with spaces"; char str2[32] = "test with spaces"; Serial....
0
votes
1answer
53 views

expected primary-expression before ',' token

EDIT: have solved the problem. It was missing the quotation marks around each letter. Thanks for your help, st2000! I am very new to Arduino and C++ (coding in general!). Have copied an example code, ...
0
votes
1answer
24 views

Using a scrolling text in OLED Adafruit_SSD1305

I have been in internet for the past week looking for a way of programming a scrolling text (either left or right) using Adafruit_SSD1305 but I only find scrolling commands for Adafruit_SSD1306. Has ...
1
vote
1answer
53 views

How to read voltage using ADS1115

I'm very new to this. I found this tutorial. But it don't explain how to read voltages higher than Arduino 5V. I have connected a 100K ohm resistor to positive and 10K ohm to negative of my 24V power ...
0
votes
1answer
59 views

Is std::array (from the C++ STL) safe to use on arduino? Does it use dynamic memory allocation?

I'd like to use std::array on a project that will need to be very stable, and have all memory pre-allocated to avoid heap fragmentation. I am reading in characters from the serial port, following a ...
1
vote
2answers
90 views

Where do class files go in Sloeber Eclipse project?

I'm attempting to create a new Arduino project using Sloeber (Eclipse). Assume it's a newly-created project whose main entry file is ".\ArduinoMainClass.ino" Now... assume I want to create a half ...
0
votes
0answers
140 views

CLion + Arduino — Cannot find any CMake profile

I'm trying to get CLion 2019.2 working with Vladimir Schneider's Arduino Support plugin (v1.4.4, from the Jetbrains Plugin repository) I installed MinGW from https://sourceforge.net/projects/mingw/ ...
2
votes
2answers
97 views

Use std::list in Arduino programming

When trying to compile #include <list> std::list<byte> l = { 7, 5, 16, 8 }; in the Arduino IDE (with ATtinyCore for ATtiny4313), I get this message: error: list: No such file or ...
0
votes
2answers
175 views

Weird sound when modulating the pulse width on Arduino

I'm trying to generate a pulse width modulated sound using Arduino Nano. But it generates the weird sound unlike my expectation. Here's my code: class Phasor { public: Phasor(const float ...
0
votes
0answers
27 views

I cant seem to form a code to read both DHT11 and pulse sensor

I combined both the heart pulse sensor code and the DHT11 code. I can get a decent reading from the pulse sensor however an error is given from the DHT11 sensor. I am able to get them to function ...
1
vote
1answer
55 views

74HC595 not working properly

I've used the following code to light 8 yellow leds sequentially but it only runs as it's supposed to be on Proteus. However in my breadboard the 8 leds keeps blinking all together, the resistors used ...
0
votes
0answers
81 views

No known conversion for argument 1 from 'Object*' to 'int*'

I'm terrible with pointers and need help passing an object to a library I'm writing. I'm getting the error no known conversion for argument 1 from 'LCDMenuItem*' to 'int*' when I try to compile. How ...
-1
votes
2answers
49 views

Do comments occupy space in compiled C++ sketch? Arduino / NodeMCU

I tend to leave old code around as comments until I am sure that my current version is stable. Just the way I like working. I am concerned that I may be unnecessarily bloating up my sketches. Do ...
0
votes
1answer
59 views

Can't Compile .ino using ArduinoJson Library

I am using an ESP32 NodeMCU for which I wrote working software before. This also occurs when I just try to compile without uploading, so no hardware problem. I am using the newest version of ...
0
votes
1answer
39 views

What does (byte*)variable_name mean in C++?

Gentlemen, I am a novice C++ programmer, When I was trying to learn how to use EEPROM with Arduino, I came across this statement i2c_eeprom_write_page(0x57, 0, (byte *)somedata, sizeof(somedata)...
0
votes
2answers
41 views

How do I code the release of a momentary touch sensor in IDE?

I am a performing musician and quite new to the Arduino community. Just learning as I go. I am interested in using a momentary touch sensor with Adafruit's MP3 shield or Wave Shield. I have ...
0
votes
0answers
33 views

MPU-6050 showing all -1s

I am following this tutorial and have an MPU-6050 connected to an Arduino Micro with the following connections VCC - 5V/3.3V GND - GND SDA - A2 SCL - A3 I'm trying to run the short example ...
0
votes
2answers
39 views

How to include Vref in thermistor temperature calculation?

simulate this circuit – Schematic created using CircuitLab This is the code that I'm using to get the temperature: #define COEFF_A 0.8662984364E-03 #define COEFF_B 2.780704551E-04 #define ...
0
votes
0answers
35 views

Error: " stray '##' in program in

I am trying to use #define in Arduino IDE as I used to do in Atmel Studio like: #define PROGRAM(N) void PROG_##N(void) However I am getting a stray error because of the hashes, is there a way to ...
0
votes
1answer
101 views

Multiple WiFi client/server connections

I'm implementing a WiFi HTML web server using the WiFiNINA library, an Adafruit Airlift ESP32 coprocessor, and a Teensy 3.5. It's starting to work, but I have a couple of questions. This simplified ...
1
vote
2answers
116 views

How to actually concatenate two Strings?

I'm using the SPISlave library, and I have the following code snippet: String arg; SPISlave.onData([arg](uint8_t *data, size_t len) { data[len] = 0; arg += String((char *)data); // ... } The ...
0
votes
1answer
83 views

How to scale a bitmap (uint8_t array) in Arduino?

So I have a project where I send text to an Arduino, which is then printed out as a QR code on a thermal printer that can take a bitmap image with a given width and height. Is there a way I can "...
0
votes
0answers
49 views

Creating global webserver without port forwarding

I'm setting up a "Smart House" project with Arduino+Esp01F(Serial Communication). But I want to make it global server. For it I use WiFiEsp library. But for it I must Get any port (neither 80 nor 443),...
1
vote
4answers
75 views

Delay stops execution forever sometimes

I have an arduino to control an irrigation system, consisting on one pump (called "bomba" on the code) and 5 12V water valves. Each valve controls one irrigation circuit and the idea is to open each ...
0
votes
0answers
79 views

SPI receive register size of ESP32

ESP32 has 64 byte SPI FIFO size, but I could not find what is the largest bit size it can receive over SPI? P.S. I need to interface a sensor, which returns 32 bit response. EDIT to clarify why I am ...
0
votes
0answers
32 views

Why sometimes parsed data is null in WiFiEsp?

I'm setting up web server with args. As host.com/?pin=9. I parsed the response by indexOf and substring functions. In first connection response has been successfully parsed and number has been parsed ...
0
votes
1answer
39 views

Non-blocking incrementation with single button pressure

I am looking for a way to increment a variable by one each time a button is pressed. Current approach is the following : if (redButton.isPressed()) { a++; delay(100); } ...
0
votes
0answers
97 views

Exception(28) when calling `WiFi.status()`

Exception(28) intermitent, apparently caused by low quality connection, when connecting to WiFi. Seems like it has something to do with WiFi.status(). Is this caused by a problem with WiFi,status() ?...
0
votes
1answer
36 views

How To Get Data From Arduino Uno Onto My Laptop Through The USB

I want to write a c++ program that does something with the data from one of the input analog pins as the program runs, but I want to know how to get the value from the arduino uno though the USB port (...
0
votes
1answer
41 views

Class member variable would not update

Code would not update variable inside drive method. The variable is updated inside the drive method, but it doesn't change in the rest of the class. I wrote a simple similar method in normal C++ and ...
0
votes
1answer
39 views

How can I assign a variable to a function output in Arduino?

I'm trying to assign the output of my function (which adjusts a DAC output) to a variable so I can print and display it in my serial monitor. Here's the code #include <Wire.h> #include <...
0
votes
1answer
40 views

Making a PID Controller for BAR 30 pressure sensor

I am having issues with my PID controller for a BAR 30 depth sensor. The issue that I have is my ESC have two initial start up { 1500 - 1900} is min - max respectively clockwise and { 1500-1900} is ...
0
votes
0answers
82 views

Having problem in coding Arduino Uno

I'm making a timer program which takes the Time Duration as input from the user by two button switches (one for 'up' and one for 'down'), and after pressing an another button switch ('start'), the ...
0
votes
2answers
400 views

Using the YS-IRTM with an Arduino Uno

Picked up a YS-IRTM IR Transmitter/Receiver module to do some testing for a project. There's not a lot of details on it but eventually came across two very important sources: Translated Module ...
1
vote
3answers
55 views

How to Specify Array Length during Object Construction within Arduino IDE?

I'm working on a group project to involving the creation of an in-house library using the Arduino IDE. As the Arduino IDE uses C++, the library must be a class. One of the classfields is an array of ...
1
vote
1answer
47 views

Order of Evaluation for #define Macros

EDIT: I think this fits better in the C++ Stack Overflow, so I'm going to re-post this there. I am working on a menu system with #define macros (inspired by the Marlin firmware on my 3D printer) I am ...
0
votes
0answers
75 views

Fingerprint sensor Arduino IDE code errors (Arduino Uno)

This code is for a fingerprint sensor. I keep getting the "function definition is not allowed before '{' token" error on the Arduino IDE. Any further corrections would also be immensely appreciated. #...
0
votes
1answer
66 views

Is this the right way to blink a character on LCD?

The code is this: #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); unsigned long blinkTime = 0; int ValueA = 22; String placeHolder = " "; void ...
0
votes
0answers
43 views

What does using [i] consecutive in a function means?

I read a code but i could not understand it! for (int i = 0; i < msg->length(); i++) { uart_->send(msg->data()[i]); } In above code what does this line means? data()[i]