Questions tagged [cpp]
The cpp tag has no summary.
25 questions
1
vote
0
answers
77
views
`__has_include` macro on ESP board
I am working on a code for ESP boards that can be used on either ESP32 or ESP8266 and I want to make sure I include the correct libraries.
I know I can check if ESP32 OR ESP8266 are defined, but I ...
0
votes
1
answer
213
views
Use class object inside an ISR
I have to simulate an ADC that behaves as an I2C slave. The simulated values that the ADC shall expose are sent over serial, saved on an attribute and are requested by a master device over I2C.
A ...
5
votes
1
answer
924
views
Delay() and millis() functions don't work in cpp external files
I'm currently facing an issue using delay() and millis() functions in an external cpp file.
The issue is that when I used delay() in my main program (meaning .ino file) it works well but when I call ...
0
votes
1
answer
85
views
CPP Function param use function with multi params [closed]
I want to specify a function with parameters for a function parameter, but it doesn't come together.
////////////////////////////////////////////////////////////////////////
// Example funch...
void ...
0
votes
2
answers
972
views
How to convert an int to const int in Arduino?
For a specific project, I need to convert an int to a const int variable type.
int i = 10;
boolean ShiftRegister[i] //Throws error
const int i = 10;
boolean ShiftRegister[i]// Works Fine
as i am ...
0
votes
1
answer
188
views
Can't change pins in AM2320 code, types mismatch
I took a simple A2320 temperature sensor and connected it not to A4/A5, but to A1/A0 pins. SDA => A1, SCL => A0. (In C code they are number 15 and 14). But I can't call the library to take ...
0
votes
1
answer
677
views
String array length in function
I know this question has been asked a thousand times, but I can't find a solution for my case.
I what to get the length of a string array in a given function. This is for an arduino board.
#define LEN(...
0
votes
1
answer
78
views
what is causing my esp8266 setup function to reinitialise?
Here is code I have written:
#include <stdio.h>
#include <ESP8266WebServer.h>
#define MAX_WIFI_INIT_RETRY 50
#define WIFI_RETRY_DELAY 500
const char* wifi_ssid = "ssid";
const char* ...
0
votes
1
answer
108
views
trying to make wemos d1 code modular causes collect2: error: ld returned 1 exit status exit status 1
#include "connection.h"
void setup() {
Serial.begin(115200);
Funcs::Connect conn;
conn.connectWifi();
}
void loop() {
}
then connection.h file:
// connection.h
namespace Funcs
{
class ...
1
vote
1
answer
85
views
Update class attribute with attachInterrupt
I want to refactor this code
/*
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: www.hobbytronics.co.uk
*/
volatile int flow_frequency; // ...
0
votes
2
answers
1k
views
WifiClient and aREST on esp32 - loop until new instructions recieved?
I've created a simple sketch for an esp32 that hosts a REST API that can be accessed via HTTP. Based on the instructions received from the client, the esp32 controls some neopixels with some various ...
1
vote
1
answer
8k
views
getting error 'Serial' was not declared in this scope
I am adding Dust Sensor to my particle photon project at home,
I got this GitHub project that I want to test before implementing a final code.
I am not an expert in cpp, I wanted to modularise the ...
0
votes
1
answer
184
views
Changing outputs infinitely for no reason
Im a student and working on a arduino project for IoT competition and me and my team have built a house and I made this code below.
For some reason when I upload it to my Arduino MKR1000 it constantly ...