texts: How do you post json data to HTTPS endpoint from ESP8266MOD?

texts:
Board: ESP8266MOD module from AI Thinker.

Using ArduinoHttpClient I am unable to send a post message to an Azure IOT Hub endpoint. The endpoint is listening on 443 and expects a shared key passed via a custom header.

The error I get is "Connection Timed Out"

Here is the brief sketch

char serverAddress[] = "myapp.azure-devices.net";
int port = 443;
string sig = "Azure shared access signature";
HttpClient client = HttpClient(wifiClient, serverAddress, port);
  String jsonPayload = payload; // passed into this function
  client.beginRequest();
  String contentType = "application/json";
  client.post("/devices/deviceId/messages/events?api-version=2016-02-03");
  client.sendHeader(HTTP_HEADER_CONTENT_TYPE, contentType);
  client.sendHeader("Authorization", sig);
  client.sendHeader(HTTP_HEADER_CONTENT_LENGTH, jsonPayload.length());
  client.beginBody();
  client.print(jsonPayload);
  client.endRequest();

  statusCode = client.responseStatusCode();
  response = client.responseBody();

The Status Code is -3 indicating a Timeout

I then created a simple REST API that accepts the JSON. Hosted it as an Azure website on port 80.

The board is able to connect to this HTTP endpoint

Question(s):
1. Is the board underpowered to handle HTTPS?
2. Is creating an HTTP proxy the only option?
3. Am I not using the right library?

Thanks


texts: How to avoid Multiple definition of 'Blynk' error?

texts:
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 compile time. The header file contains following:

static WiFiClient _blynkWifiClient;
static BlynkArduinoClient _blynkTransport(_blynkWifiClient);
BlynkWifi Blynk(_blynkTransport);

How can I get the Blynk declarations into a second or third module, without multiple definitions error? Editing the header/library file/s is not an option!

By the question in How to create global variables/includes/functions for use in multiple source files it is still not clear what a working solution is...


texts:
I have spent the better part of today trying to figure out why I can't get this to work...
I have this project where, because of previous design considerations, have implemented a singleton class that initializes a bunch of separate sensors in this system that I am running.
The system was originally built for the Particle Boron, but now I am trying to make it work with the Adafruit Feather M0, so I have had to refactor several things and omit lots of lines of Particle RTOS specific things.
However, in doing this, I find that my singleton class no longer works.
Sensors.h:
.
.
.

class Sensors{

    static Sensors *instance;

public:
    static Sensors *getInstance() {
        if (!instance) {
            instance = new Sensors;
        }
        return instance;
    }

}

private:
    Sensors();

.
.
.

Sensors.cpp:
.
.
.

Sensors::Sensors() : dht22(DHTPIN, DHTTYPE) {
#ifdef PLATFORM_ID
    sensorLog("app.Sensors");
#endif
}

.
.
.

main.ino:
.
.
.

// Sensors
Sensors *Sensors::instance = nullptr;
Sensors *allSensors = allSensors->getInstance();

void setup(){

.
.
.

As I try to compile this with ArduinoISP, no matter what I try, I get the following error:
sketch/main.ino.cpp.o: in function `Sensors::getInstance()':
sketch/lib/Sensors/src/Sensors.h:23: undefined reference to `Sensors::Sensors()'
collect2: error: ld returned 1 exit status
exit status 1
[Error] Exit with code=1

I have tried things like changing the line
instance = new Sensor;

to
instance = new Sensor();

making the instance public, changing the Sensor constructor, but all of this to no avail. Could this be a compiler issue? Why would this work on a Particle board, but not an Adafruit Feather M0?


texts: Is it possible to make an arbitrary lake bottom generator?

texts:
I'm trying to generate an arbitrary lake bottom sonar returns using my Arduino.

I would like to seed a function with a "depth." This would be the starting depth. I would then like to randomize a set of parameters each time the function is called. The output would look something like a time-truncated sine wave. The parameters would include:

Randomized Amplitude of waveform (which wouldn't vary too much)
Randomized Period (or frequency) of waveform (also wouldn't vary too much)
Randomized exit point. Say the period is 10 seconds but function ends at 7 seconds. This would allow for a changing in depth over time even if random.
If possible, I would like to low pass filter the output to smooth any hard transitions.

Any suggestions on where to get started?


texts: Change device Function Summary for Teensy-LC

texts:
I found this thread here which describes procedure to change the produce-name of Teensy
However when we open device properties we see 'Teensy USB Serial (COM xx) in the Device function summary.

Please find the image below to understand what I am referring to.

So is there any way to change this details as well?


texts: How to read long value sent by Arduino in C

texts:
I have a quick question regarding this code below in Arduino:

Serial.print("0");
Serial.print(5);
Serial.print("0");
Serial.print(1);
Serial.print("0");
Serial.print(5);
Serial.print("0");
Serial.print(1);
Serial.print("0");
Serial.println(5);

In C code, currently I'm receiving the message using this method below:

int serialport_read_until(int fd, char* buf, char until, int buf_max, int timeout)
{
    char b[1];  // read expects an array, so we give it a 1-byte array
    int i=0;
    do {
        int n = read(fd, b, 1);  // read a char at a time
        if( n==-1) return -1;    // couldn't read
        if( n==0 ) {
            usleep( 1 * 1000 );  // wait 1 msec try again
            timeout--;
            if( timeout==0 ) return -2;
            continue;
        }
        buf[i] = b[0];
        i++;
    } while( b[0] != until && i+1 < buf_max && timeout>0 );

    buf[i] = 0;  // null terminate the string
    return 0;
}

In C i defined:

char message[13];
uint32_t num;
char until = '\n';

serialport_read_until(fd, message, newLine, sizeof message, 20000);
// the 20000 is timeout in millisec
// this method stores the data in serial buffer into message array

printf("message is %d\n", num);

I am expecting a raw value of 0501050105 first.
Then I convert this raw string into 501050105 using:

sscanf(message, "%d", &num);

Currently it works fine, but I strongly believe it is not the correct way to do it (or rather not the optimized way to do it).

In addition, when i use serialport_read_until() method above, even though i specify the char until as '\n', the method terminates after reading '\r' (leaving the \n in the serial buffer), and the '\n' is only captured in the next method call.

Q1: Am i reading the \r\n wrongly from the println (I saw in Arduino documentation that println prints \r\n)? What resulted in C 'cutting off' the message when it detected a \r from Arduino even though I specifically set to kill it only when \n is received?

Q2: Instead of printing a string to me and converting it back to integer in C, is there a way for Arduino to send me a long value directly instead? eg 501050105 or 51515. how should I rewrite the serial print or method? And how do i capture that integer correctly in C? If i'm not wrong if a raw integer is print out from Arduino, it converts it into ASCII code. I'm still very new to C and Arduino and hope some guidelines to be given so I can improve on the current coding.

Thank you very much.


texts: How to drive SPI MAX7219 7-segment led module using MCP23S17 extender

texts:
I have used Nick Gammon's (MAX7219) and (bitBangedSPI) libraries to drive SPI 7-segment 8 digit led modules successfully from the Arduino Uno.  I would like to extend the number of Slave Select (CS) choices by using the MCP23S17 chip.  The Mcp23s17 libraries to use might be https://github.com/dreamcat4/Mcp23s17 or https://github.com/MajenkoLibraries/MCP23S17.  I have found the stackExchange entry How do you use SPI on an Arduino? to be helpful and this entry to be helpful http://www.ermicro.com/blog/?p=1050, but all the examples just turn on LED lights, not digits of 7-segment led modules.

I realize I might have to modify the MAX7219 and bitBangedSPI libraries where the digitalWrite command is used.  However, I'm not sure how to modify or drive these 7-segement modules using the MCP23S17 chip.

A skeleton script to display PI selected on pin 6 on the Uno and address 0x0 of the MCP23S17 is shown below.  I would like to choose which pinout to utilize as well but am not sure how this would be coded.

#include <SPI.h>
#include <bitBangedSPI.h>
#include <MAX7219.h>
// Mcp23s17 library available from https://github.com/dreamcat4/Mcp23s17
#include <Mcp23s17.h>

// Wire up the SPI Interface common lines:
// #define SPI_MOSI             7 //arduino   <->   SPI Master Out Slave In   -> SI  (Pin 13 on MCP23S17 DIP)
// #define SPI_MISO   not used 12 //arduino   <->   SPI Master In Slave Out   -> SO  (Pin 14 on MCP23S17 DIP)
// #define SPI_CLOCK            8 //arduino   <->   SPI Slave Clock Input     -> SCK (Pin 12 on MCP23S17 DIP)

// Then choose any other free pin as the Slave Select (pin 10 if the default but doesn't have to be)
#define MCP23S17_SLAVE_SELECT_PIN  6 //arduino   <->   SPI Slave Select           -> CS  (Pin 11 on MCP23S17 DIP)
// MULTIPLE DEVICES
// Up to 8 MCP23S17 devices can share the same SPI bus and slave select pins.
// Assign each chip a unique 3-bit device address (by setting the A2,A1,A0 pins)
// Then below, device address is optional 2nd parameter to the constructor fn...
// MCP23S17 Mcp23s17_0 = MCP23S17(MCP23S17_SLAVE_SELECT_PIN,0x0);
// ...
// MCP23S17 Mcp23s17_7 = MCP23S17(MCP23S17_SLAVE_SELECT_PIN,0x7);

// SINGLE DEVICE
// Instantiate a single Mcp23s17 object
MCP23S17 Mcp23s17_0 = MCP23S17(MCP23S17_SLAVE_SELECT_PIN,0x0);
const byte chips = 1;
static char outputBuffer[20]; // outputBuffer[] likely 2x the size it needs to be.

 // 1 chip, bit banged SPI on pins 6, 7, 8

MAX7219 display(chips, 6, 7, 8);  // Chips / LOAD / DIN / CLK
void setup()
{
    // Set all pins to be outputs (by default they are all inputs)
    Mcp23s17_0.pinMode(OUTPUT);

    display.begin();
    display.setIntensity(1);
    float pi = PI;
    dtostrf(pi, 7, 7, outputBuffer);
    display.sendString(outputBuffer);

}  // end of setup

void loop() { }

An example of the 8-digit 7-segment display.  They are available on Amazon, Ebay, AliExpress etc. This one has 0.33 inch digits; other modules are 0.56 inch digits.


texts: The ATmega328p can run on 5v but will it cause problems if it runs on 3.3 v and one input signal is 5v?


texts: Controlling amplifier using remote control jack

texts:
Many older amplifiers support wired remote control through connector jacks or ports. My 10-year old Marantz also supports this function, using a simple RCA connector.

Originally these were used with external IR receivers when the unit was not kept in plain sight.

I wonder if there is a way to control the amplifier using an Arduino, which probably means by generating the required signal over the connector instead of receiving it from an IR receiver. Any pointer to a similar project is appreciated as well.


texts: Arduino Micro: how to switch off its blue power LED?

texts:
everybody!

I have a genuine Arduino Micro ("designed with adafruit", made in Italy) which is working perfectly well.

One thing I'd like to do but cannot figure out how (or at all), is to turn off the blue power LED. I hate blue LEDs, they hurt my eyes, and this one is particularly bright too.

I could just paint it over with black paint but maybe there are programmatic ways to switch it off?

Regards


texts:
Is there a variable data type available for Arduino? I have a class that should have a member that will differ in data type, in the past I have used the "variable" keyword in c++ but when I tried to use it the compiler yelled at me. I searched online and found a couple of articles that mentioned that if you are using an alternate GUI (I am using eclipse mars) that you can enable the feature but I can not find the correct settings as the examples I had found were for Juno and below.

Here is an example of what I am trying to accomplish

class DisplayItem{

   public:
   variant *displayVar;

   void Display(){
      Serial.println(displayVar);
   }
}

int intDisplay;
String strDisplay;

DisplayItem item();
item.displayVar = &intDisplay;
item.Display();
item.displayVar = &strDisplay;
item.Display();

I realize I could create a overloaded function to display different data types but it would be allot easier if I could simply assign a reference to a variant datatype and reuse the variable.

Edit

So after looking through the answers I think I have this figured out. I needed to keep track of which variable was being set, I put together a quick example in hopes it will help someone else out with the same question.

class DisplayItem{

   private:
   int iVarType;

   union{
      int *i;
      float *f;
   } displayVar;

   public:
   void SetVar(int *var){
      displayVar.i = var;
      iVarType = 0;
   }

   void SetVar(float *var){
      displayVar.f = var;
      iVarType = 1;
   }

   void Display(){
      if (iVarType == 0){
         Serial.println(displayVar.i);
      }else if (iVarType == 1){
         Serial.println(displayVar.f);
      }
   }
}

int intDisplay = 1;
float floatDisplay = 0.123;

DisplayItem item();
item.SetVar(&intDisplay);
item.Display();
item.SetVar(&floatDisplay);
item.Display();

Will Display:

1
0.123


texts:
I am trying to decode the IR signals from a remote. I'm using an Arduino Pro Micro, and a TSOP38238 IR receiver.

I found out that the remote uses the Nokia32(RCMM) protocol, and I have been able to partially decode it using cyborg5/IRLib (specifically this one: rcmm.ino). I tweaked the values of the example using the LIRC file corresponding to my remote, mainly the absolute error tolerance (Freebox_V5.lircd.conf).

Compared to other remotes I tried (with different protocols) the RCMM algorithm doesn't manage to decode the signal every time. Around 40% of the time when I press a button I got an "Unknown type received" output from the decoder.

The following is three outputs (for the same button) of the algorithm for a successful decoding and below two other outputs corresponding to two failures. Could anyone tell me what could be done to increase the success of the decoding algorithm?

Successful

Decoded RCMM: Value:2400A601 (32 bits)
Raw samples(36): Gap:63264
  Head: m410  s290
0:m160 s290 1:m160 s590      2:m210 s390    3:m210 s240
4:m210 s240 5:m210 s240      6:m210 s240    7:m210 s240
8:m210 s540 9:m210 s590      10:m210 s390   11:m210 s590
12:m160 s290    13:m160 s290         14:m160 s240   15:m210 s440

16:m160
Extent=9810
Mark  min:160    max:210
Space min:240    max:590

Failure 1

Unknown type received. Ignoring.
Decoded Unknown(0): Value:0 (0 bits)
Raw samples(36): Gap:3148
  Head: m410  s290
0:m160 s240 1:m210 s590      2:m210 s390    3:m210 s240
4:m210 s240 5:m210 s240      6:m160 s290    7:m160 s290
8:m160 s590 9:m210 s590      10:m160 s440   11:m210 s590
12:m160 s240    13:m210 s240         14:m210 s240   15:m210 s390

16:m210
Extent=9810
Mark  min:160    max:210
Space min:240    max:590

Failure 2

Unknown type received. Ignoring.
Decoded Unknown(0): Value:0 (0 bits)
Raw samples(32): Gap:27904
  Head: m410  s290
0:m160 s290 1:m160 s590      2:m160 s490    3:m160 s240
4:m210 s240 5:m160 s290      6:m160 s290    7:m160 s290
8:m160 s290 9:m160 s590      10:m160 s490   11:m160 s590
12:m160 s1190   13:m160 s440         14:m160
Extent=9460
Mark  min:160    max:210
Space min:240    max:1190


texts: Help Needed! How do I attach a color sensor to a 2WD robot and use it to control its movement?

texts:
I'm relatively new to the world of Arduino, so don't be frustrated if I ask questions that could be silly. This project has a deadline, so any input is appreciated.

THE PROJECT:

I am planning to build a 2WD vehicle, with an arm using 2 servos, and a TCS3200 color sensor. The goal is to make the robot avoid obstacles while simultaneously searching for a GREEN colored object (using the color sensor). After finding the GREEN object, it would stop and use the robotic claw to grab the object. Finally, it would continue to avoid obstacles until you reach a RED colored area. It would drop the object and start again.

QUESTIONS:

That said, I have some questions about the use of different sensors to control a robot (do not hesitate to put any input that may be useful)

1) How would you connect it to the sensor shield considering the other components? Could you use analog pins or (converting digital to analog) or use fewer pins? (I just need Green and Red)

2) How would make it so that the Arduino receives data from both sensors at the same time? How can I make both sensors control the same two motors?

WIRING:

NOTE: in the second image the ultrasonic sensor should be connected to the bottom right pins

EDIT:
@Peter Paul Kiefer---Could you please elaborate on how I can achieve for both sensors to control the same motors at the same time? Link to website where it is explained?

@jsotola 1) what do you mean by output? 2) I know that, I just want for the Arduino Uno to receive data from both the Ultrasonic and color detection at the same time. Using the data, I want the Arduino to control the motors to avoid obstacles, while using the color sensor to detect the GREEN object(at the same time)

The sensor It is called a TCS3200 color sensor by the way, and seems to only use digital pins. I am connecting it to the sensor sensor shield along with other things. (refer to images in the first post)This is how it looks like:


texts: Arduino IDE sketch for firebase-Dragino Shield v1.4

texts:
I would really appreciate it if someone could recommend a sketch for Arduino IDE that I can use to connect my arduino Lora shield v1.4 to firebase. All the sketches I find are for only esp8266 module.
Thank you in advance.


texts: How to store an RFID tag number in a string

texts:
I want to send RFID tag number to PHP page. So far I have sent a fixed string to php and it worked, now I am not getting data in string when i scan rfid tag. I want to store every RFID tag number in a string when it is scanned, so that I can send it to php page.

if (rfid.isCard()) {

    String rfid_uid = "";
    if (rfid.readCardSerial()) {
        String rfid_uid = "";
        for (int i = 0; i < 4; i++) {
            Serial.print(rfid.serNum[i], HEX);
            rfid_uid = rfid.serNum[i];
        }

        Serial.println();
    }
    //delay(7000);
    Serial.print("User ID \n");
    Serial.println(rfid_uid);
    make_request(rfid_uid);
}

This is the path to php page

         String method = "GET /ethernet/data.php?rfid_uid=";


texts:
I want to use an ATtiny as data logger for the opening and closing of a door/window. For that I am using a reed-switch. Since I want to run it from a 3V coin battery, long term power consumption is crucial. Therefore the ATtiny (currently 13A) is in system down mode most time and is only listening to Pin-Change-Interrupts. Depending on the state of the reed-switch the power consumption differs in an order of magnitude.

switch open:    0.1µA
switch closed: 74.5µA
my Multimeter has a tolerance of ±0.1µA

This is a difference of an order of magnitude. But it is plausible as the datasheet of the ATtiny13A states in chapter 10 that a GPIO pin can only be pulled up and is otherwise dangling. The pull-up resistor is somewhere between 20k and 50k as stated in chapter 18.2.

So in my setup the pin is pulled up and the reed-switch is grounded.

How can I reduce the power consumption in the case where the switch is closed?

Alternatively: Can I somehow revert the state of the switch, as windows and doors are closed most of the time?

The MCU is running with the 128kHz internal Clock with CKDIV8 so practically running @ 16kHz.

The minimum viable code:

/*
  3V0               SW0
   |     |     |     |
 -----------------------
 |                     |
 |                     |
 |      ATtiny13A      |
 |                     |
 |                     |
 -----------------------
   |     |     |     |
               TX   GND
 */

#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <iso646.h>
#include <stdbool.h>
#include <util/delay.h>

#define BIT_SET( PORT, BIT_FIELD ) PORT |=  BIT_FIELD
#define BIT_CLR( PORT, BIT_FIELD ) PORT &= ~BIT_FIELD

#define TX_PIN          PB4
#define SW0_PIN         PB0
#define INT0_MASK       PCINT0

// MARK: - POWER

static void power_down(void) {
    BIT_SET(GIFR, _BV(PCIF));       // Clear interrupt signal
    BIT_SET(GIMSK, _BV(PCIE));      // Pin Change Interrupt Enabled
    sleep_enable();
    sleep_cpu();                    // Enter sleep mode
    sleep_disable();
    BIT_CLR(GIMSK, _BV(PCIE));      // Pin Change Interrupt Disabled
}

ISR(PCINT0_vect) {}

// MARK: - Setup

static void setup(void) {
    cli();

    // Set up output pins
    DDRB = _BV(TX_PIN);
    BIT_CLR(PORTB, _BV(TX_PIN));

    BIT_SET(PORTB, _BV(SW0_PIN));        // pull up interrupt pins
    BIT_SET(PCMSK, _BV(INT0_MASK));   // set PCINT0 to trigger interrupt
    BIT_SET(GIFR, _BV(PCIF));       // Clear interrupt signal
    BIT_SET(GIMSK, _BV(PCIE));      // Pin Change Interrupt Enabled
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);

    sei();
}

static void loop() {
    BIT_SET(PORTB, _BV(TX_PIN));
    _delay_ms(1);
    BIT_CLR(PORTB, _BV(TX_PIN));

    power_down();
}

int main(void) {
    setup();

    while (true) {
        loop();
    }
}


texts: NodeMCU server stops responding after a while

texts:
I'm new to NodeMCU and ESP. I've created a basic web server on my NodeMCU.
The server works fine for the first few minutes after resetting the board or re-uploading code. But after about half an hour, the server just stops responding and becomes unreachable. Funny thing is, after sending a few failed requests, server starts to respond normally again.
The code i'm using:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

String wifiName = "blablabla";
String password = "blablabla";

ESP8266WebServer server(9090);

void setup() {
  Serial.begin(115200);
  pinMode(5, OUTPUT);
  digitalWrite(5,LOW);

  connectToWifi();
  server.on("/", handleHomepage);
  server.on("/action", handleAction);
  server.begin();
}

void loop() {
  server.handleClient();
}

void handleHomepage() {
  server.send(200, "text/plain", "Welcome to esp8266 homepage!");
}

void handleAction() {
  String parameter = server.arg("value");

  if (parameter == "") {
    server.send(200, "text/plain", "No parameter supplied.");
    return;
  } else {
      if (parameter == "on") {
        digitalWrite(5,HIGH);
      } else if (parameter == "off") {
        digitalWrite(5,LOW);
      }
    server.send(200, "text/plain", "Action received successfully.");
  }
}

void connectToWifi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(wifiName, password);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

What should I do to keep the server always active? Thanks in advance.


texts:
The NeoICSerial documentation contains a table that states for the Uno:

Transmit: 9
Receive: 8
PWM Unusable: 10

Pin 8 and 9 are used for the serial connection. Pin 10 is part of the pins for the SPI on the Uno. Does this mean SPI connections can't be used together with NeoICSerial or is this specific for using pin 10 for PWM?


texts:
An application of ATtiny with SD card is complicated due to missing of hardware SPI in attiny.
The "ATmega" code for creating of a "SD file" is:
#include <SPI.h>
#include <SD.h>

File file;
int const pinCS = 2;

void setup()

{
SD.begin(pinCS);
file = SD.open("Test.txt", FILE_WRITE);
file.println("anything");
file.close();}

void loop()
{}

This code creates on SD card a file "Test.txt" and to this file records text "anathing".
Is it possible to rewrite this code for "ATtiny85"?


texts: Best Data model/Concept to Store Multi-Day Alarm for clock?

texts:
I'm writing a multiday day alarm program for a project.
I'm not sure how I want to store the format of each of 10 alarms....I need to store it...in SPIFFS retrieve it(at boot) and then compare it to the current day of the week and time so as to fire off the alarm..I was thinking of storing it in a 10 member array.
First alarm would be every day at 2PM and the second is turned off but would be Mon tues Thursday at 10AM. was going to use strtok_r to extract all of the pieces and compare them every minutte to see if an alarm is needed.
Every minute
{"1|M|T|W|T|F|S|S|14|00","0|M|T||T|||S|10|00"}


texts: How many transistors are there in an H Bridge?

texts: I've controlled a motor going one direction using only one transistor. With an H Bridge, I can make a motor go forward, backward and brake. Does an H Bridge have only three transistors inside it to perform these functions, or does it take a larger number?


texts: Why does static member std::map reset ESP8266 when outside the .ino file?

texts:
Here's an example of a class which crashes the ESP8266-03 causing it to reset:

Test.hpp file:

#include <map>

class Test {
public:
    int data() const;

    Test(int x);
    ~Test();
protected:
    int _data;

    static std::map<int, Test const *>thing;

    static void _Reserve(Test const * const t);
};

Test.cpp file:

std::map<int, Test const *> Test::thing;

int Test::data() const
{
    return this->_data;
}

void Test::_Reserve(Test const * const t) {
    Test::thing[t->data()] = t; // Works fine if this line is removed.
}

Test::Test(int x): _data(x)
{
    Test::_Reserve(this);
}

Test::~Test() {};

Project.ino:

#include "ESP8266WiFi.h"
#include "Test.hpp"

Test test(2);

void setup() {
    Serial.begin(115200);
}

void loop() {
    Serial.print("Timer: ");
    Serial.println(millis());
    delay(1000);
}

The following does NOT crash the ESP8266-03 and prints the time as it should:

#include "ESP8266WiFi.h"
#include <map>

class Test {
public:
    int data() const
    {
        return this->_data;
    }

    Test(int x): _data(x)
    {
        Test::_Reserve(this);
    }
    ~Test() {};
protected:
    int _data;

    static std::map<int, Test const *>thing;

    static bool _Reserve(Test const * const t) {
        Test::thing[t->data()] = t;
    }
};

std::map<int, Test const *> Test::thing;

Test test(2);

void setup() {
    Serial.begin(115200);
}

void loop() {
    Serial.print("Timer: ");
    Serial.println(millis());
    delay(1000);
}

When the first version is uploaded to the board, I get the following in the serial monitor:

 ets Jan  8 2013,rst cause:1, boot mode:(1,7)

 ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

When I reset it and boot it regularly, no upload mode, the following repeats every ~1 second:

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld


texts: Send data to a pc localhost with ESP-01 wifi module

texts:
i use a linux machine with a localhost php server installed. Wifi machine is connected to the ESP-01 module (access point mode) and i can send several datas to the Arduino via the ESP-01 set as:

  sendData("AT+RST\r\n",2000,DEBUG); // reset module
  sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
  sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
  sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
  sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80

The php server can send data by GET method and Arduino receives pin=11:

 http://192.168.4.1:80/?pin=11

But, now, i would like to send to the php server datas from the Arduino. I tried this configuration but in my sketch but, it returns, error.

sendData("AT+CIPSTART=0,'TCP','http://localhost',80\r\n",1000,DEBUG);

Serial monitor:

   ERROR
   AT+CIPSTART=0,'TCP','http://localhost/test_php',80

   Link type ERROR

So please, how can i send and receive data with my ESP-01 module?


texts: Arduino Clone - A request for the USB device descriptor failed

texts:
I was working with my arduino clone and that was working well till last night.
I was trying to add l298p motor shield and after a few times of testing without any achievement, my PC suddenly did not recognize the arduino.
The device status in device manager is :

Windows has stopped this device because it has reported problems. (Code 43)
A request for the USB device descriptor failed.

What should I do now??
My OS is windows 8.1


texts:
I have a very simple code of door sensor (magnetic) which gives results in 1 & 0 format. But I want to run the NodeMCU only when a door is open or close. Rest of time I want to keep it in deep sleep mode. Here is my code looks like :

int doorClosed = 1;

#define REED_SWITCH D5

void setup() {
  // put your setup code here, to run once:

  Serial.begin(115200);
  pinMode(BUILTIN_LED, OUTPUT);
  digitalWrite(BUILTIN_LED, HIGH);

  pinMode(REED_SWITCH, INPUT_PULLUP);
}

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

   Serial.println(digitalRead(REED_SWITCH));

    if ((digitalRead(REED_SWITCH) == HIGH) && (doorClosed == 1))
    {
      Serial.println("DOOR OPEN!!");
      doorClosed = 0;
      digitalWrite(BUILTIN_LED, LOW);
      ESP.deepSleep(0);
    }
    else if ((digitalRead(REED_SWITCH) == LOW) && (doorClosed == 0))
    {
      Serial.println("DOOR CLOSED!!");
      doorClosed = 1;
      digitalWrite(BUILTIN_LED, HIGH);
      ESP.deepSleep(0);
    }
    delay(500);
}

Here I am able to put the NodeMCU in deep sleep. But it never wakes up. How can I wake up my chip. After attaching the D0 with RST, I don't event get Serial Logs. I am not sure what kind of behaviour is this. If someone can help me to fix this code will be great!

Thank you!


texts: Two Arduinos get out of sync after a few seconds

texts:
I built a small PCB that has some LEDs (bare NeoPixel 5050) and an IR receiver on it. The microcontroller is an ATtiny85, and the PCB is powered by a LiPoly battery (3.7V). The circuit normally stays in ULP sleep mode until a pin change interrupt wakes the circuit. The pin change interrupt is tied to the IR receiver so when the receiver gets a signal from a remote (38kHz modulated IR burst) a lighting sequence is triggered. I have multiple of these PCBs running the exact same code (shown below). When the PCBs receive an IR signal they all start at the same time, but then after a few seconds they start to drift apart. The lighting needs to be synchronized. What is the reason for this drift and how can I eliminate it? Is it due to different battery voltages? That would be the only physical difference between any two PCBs. Thanks for your help.

#define IR_PIN      4
#define LIGHT_PIN   0
#define DELAY_TIME  200

#include <Adafruit_NeoPixel.h>
#define NUM_PIXELS  2
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, LIGHT_PIN, NEO_GRB + NEO_KHZ800);

#include "avr/interrupt.h"
#include "avr/sleep.h"

void setup() {
  pinMode(IR_PIN, INPUT);
  strip.begin();
  pixelsOff();
}

void loop() {
  sleep();

  for (int i = 0; i < 5; i++) {
    pixelsOnRed();
    delay(DELAY_TIME);
    pixelsOff();
    delay(DELAY_TIME);
    pixelsOnGreen();
    delay(DELAY_TIME);
    pixelsOff();
    delay(DELAY_TIME);
  }

  for (int i = 0; i < 5; i++) {
    pixelsOnBlue();
    delay(DELAY_TIME);
    pixelsOff();
    delay(DELAY_TIME);
    pixelsOnRed();
    delay(DELAY_TIME);
    pixelsOff();
    delay(DELAY_TIME);
  }

  for (int i = 0; i < 5; i++) {
    pixelsOnGreen();
    delay(DELAY_TIME);
    pixelsOff();
    delay(DELAY_TIME);
    pixelsOnRed();
    delay(DELAY_TIME);
    pixelsOff();
    delay(DELAY_TIME);
  }
}

void pixelsOff() {
  strip.setPixelColor(0, 0, 0, 0);
  strip.setPixelColor(1, 0, 0, 0);
  strip.show();
}

void pixelsOnRed() {
  strip.setPixelColor(0, 255, 0, 0);
  strip.setPixelColor(1, 255, 0, 0);
  strip.show();
}

void pixelsOnGreen() {
  strip.setPixelColor(0, 0, 255, 0);
  strip.setPixelColor(1, 0, 255, 0);
  strip.show();
}

void pixelsOnBlue() {
  strip.setPixelColor(0, 0, 0, 255);
  strip.setPixelColor(1, 0, 0, 255);
  strip.show();
}

ISR(PCINT0_vect)
{
    //This is not needed for the current sketch
}

void sleep() {
    GIMSK |= _BV(PCIE);                     // Enable Pin Change Interrupts
    PCMSK |= _BV(PCINT4);                   // Use PB3 as interrupt pin
    ADCSRA &= ~_BV(ADEN);                   // ADC off
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement

    sleep_enable();                         // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
    sei();                                  // Enable interrupts
    sleep_cpu();                            // sleep

    cli();                                  // Disable interrupts
    PCMSK &= ~_BV(PCINT3);                  // Turn off PB3 as interrupt pin
    sleep_disable();                        // Clear SE bit
    ADCSRA |= _BV(ADEN);                    // ADC on

    sei();                                  // Enable interrupts
}


texts: Is there any way so an ethernet shield to ask the router for an available ip address? For example to ask for an ip an the router to return 192.168.1.2 if it is available. I am asking it because if we set the ip programmatically and it is attached to another device we gonna have problem.


texts: I wanted to know if there is a way for my arduino to keep the last command I sent to it before I disconnected it from my computer. Thanks.


texts: Is there a preprocessor constant for memory size

texts:
I would like my compiles to exclude some code depending upon the flash/program space available. To be used in the demo code of a library I support. Whereas my current solution is to use a #ifdef of processor type. But I would like to be more general and not have to specify all the various chips. Rather it would be nice if there was a pre-processor constant that stated the available size.

Where I am not fluent enough in gcc and or avr-gcc I might expect to find some constants similar those that define the beginning and end of the heap.

On case example. Is that both the UNO and Leo have 32K of Flash. But the Leo's core library uses 4K for USB support, resulting in only 28K available. My Library's demo is near max'ed out on the UNO and I would like to automatically trim out based on available program space.


texts: Getting coordinates from a touch panel with I2C

texts:
Hello world (this is my first message in this forum).

I am quite a just-married-to-Arduino guy, I am very passionate about this platform that I kew since long time but never had the time to dedicate.

Now I have done several home projects that made me both feel happy and feel sooooo rookie... But hey, here I am trying more and more complex things.

I am trying to do something I haven't found information about: I have a 10" touch panel (I am not talking about a screen, just the touch surface) which is a capacitive 10 pin panel that communicates with I2C protocol (there are SCL and SDK pins). I have managed to scan the address and turns out it is in the #40.

However, other than that I do not have the knowledge to get the coordinates out of that panel. My question is: is there any library that can help me with that or will I need to code everything?

I am attaching some pictures of the panel and the pinout to have a clearer picture of what I am talking about.

I thank you all for your time reading my post, I hope some day I will be able to provide some answers rather than questioning!

Joan.


texts: Arduino continuously reading ADC value using interrupt

texts:
I have a mono jack audio act as analog input for arduino UNO. The microphone outputs voltage that varies in terms of amplitude (volume) and frequency. In order to get the high sampling rate, I use prescaler 16 and set high baudrate for serial communication to print the value. I save the analog read from that jack audio to buffer array with maximum value is 256 (8-bit). This is my code (I modify from the Nick Gammon's blog about ADC here) :

const byte adcPin = 0;  // A0

const int MAX_RESULTS = 256;

volatile int results [MAX_RESULTS];
volatile int resultNumber;

void setup ()
  {
  Serial.begin (230400);
  Serial.println ();

  // reset Timer 1
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1 = 0;
  TCCR1B = bit (CS11) | bit (WGM12);  // CTC, prescaler of 8
  TIMSK1 = bit (OCIE1B);
  OCR1A = 39;
  OCR1B = 39;   // 20 uS - sampling frequency 50 kHz

  ADCSRA =  bit (ADEN) | bit (ADIE) | bit (ADIF);   // turn ADC on, want interrupt on completion
  ADCSRA |= bit (ADPS2);  // Prescaler of 16
//  ADCSRA |= (1 << ADPS1) | (1 << ADPS0);    // 8 prescaler for 153.8 KHz
  ADMUX = bit (REFS0) | (adcPin & 7);
  ADCSRB = bit (ADTS0) | bit (ADTS2);  // Timer/Counter1 Compare Match B
  ADCSRA |= bit (ADATE);   // turn on automatic triggering

}

// ADC complete ISR
ISR (ADC_vect)
{
    results[resultNumber++] = ADC;
    if(resultNumber == MAX_RESULTS)
    {
      ADCSRA = 0;  // turn off ADC
    }
}

EMPTY_INTERRUPT (TIMER1_COMPB_vect);

void loop () {

  while (resultNumber < MAX_RESULTS)
    { }

  for (int i = 0; i < MAX_RESULTS; i++)
  {
    Serial.println (results [i]);
  }
}

With that code, I got a nice result of sinusoidal graph represented audio value up to 4000 Hz like this :

But one thing that didn't work is if I change the volume or frequency (while displaying data) of analog input (jack audio), the graph I print and display via serial plot audio won't change. So I had to close it and open again to see the change. The question is how can I achieve the continuous and real time reading of this ? Thank you very much.


texts: How to use an Arduino as an emulator to filter signals?

texts: What should be the Arduino code to emulate it as a 3rd order IIR filter?


texts:
This posting contains 2 sketches. the analogmux1 compiles successfully. Concerning analogmuvvolts sketch an error stating updateMux1 was not declared in this scope results. The int Mux1_State [8] = 0: is defined exactly the same in both however the error results.

I'm learning Arduino programming so there are other errors in the sketch. What I'm trying to accomplish is to display the actual voltage of each channel, not numbers which appear in the analogMux.

It would be appreciated if the community could provide me with some guidance.

Analogmux:

int pin_Out_S0 = 8;
int pin_Out_S1 = 9;
int pin_Out_S2 = 10;
int pin_In_Mux1 = A0;
int Mux1_State[8] = {0};

void setup() {
  pinMode(pin_Out_S0, OUTPUT);
  pinMode(pin_Out_S1, OUTPUT);
  pinMode(pin_Out_S2, OUTPUT);
  //pinMode(pin_In_Mux1, INPUT);
  Serial.begin(9600);
}

void loop() {
  updateMux1();
  for(int i = 0; i < 8; i ++) {
    if(i == 7) {
      Serial.println(Mux1_State[i]);
    } else {
      Serial.print(Mux1_State[i]);
      Serial.print(",");
    }
  }
}

void updateMux1 () {
  for (int i = 0; i < 8; i++){
    digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
    digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
    digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
    Mux1_State[i] = analogRead(pin_In_Mux1);
  }
}

And  analogmuxvolts

int pin_Out_S0 = 8;
int pin_Out_S1 = 9;
int pin_Out_S2 = 10;
int pin_In_Mux1 = A0;
int Mux1_State[8] = {0};
//float Mux1_State[i] =0;
int RawValue=0;
float Voltage = 0;
void setup() {
  pinMode(pin_Out_S0, OUTPUT);
  pinMode(pin_Out_S1, OUTPUT);
  pinMode(pin_Out_S2, OUTPUT);
  pinMode(pin_In_Mux1, INPUT);
  Serial.begin(9600);
}

void loop() {
 RawValue = analogRead(pin_In_Mux1);
 Voltage = (RawValue * 5.0) / 1024; //scale the ADC
  updateMux1();
  Serial.println(Mux1_State);
  for(int i = 0; i < 8; i ++) {
    if(i == 7) {
      Serial.println(Mux1_State[i]);
    } else {
      Serial.print(Mux1_State[i]);
      Serial.print(",");
      //vout = (value * 5.0) / 1024.0;
    }
  }
  Serial.print("Raw  Value = " );
  Serial.print(RawValue);
}


texts: Control LED strip IR controller using Arduino

texts:
Is it possible to connect to one of these, which run at 12v, to turn on the LED strip using an ESP8266? It doesn't matter if it's an Arduino or the ESP8266, both should be able to do this. The board looks like this:

If I turn on the red light, the "R" gets grounded and therefore applies 12v to the rail. The 3 MOSFETs on the images are P0903BDG MOSFETs.

Alternatively, I can hook into the IR signal and send an IR signal using the ESP8266. That would be really awesome, as it only requires 3 wires. How that is possible, I'm not really sure, though.

I know it's possible to make your own circuit using IRLZ44N MOSFETs, which I have done before, but I want to try and use as much as this circuit as possible.


texts:
I am using a function outside loop(), which is called after an interrupt. Inside this function, I am setting several relays that need to change after a second or two, depending on my setting. I tried the delay, it doesn't work. millis() isn't working as well; I found out it stops counting when I exit the loop function.

My code looks something like this:

const long on_interval = 2000;
unsigned long currentMillis = millis();
bool hv_bool = false;

void hv_switch() {
    if (digitalRead(hv_pin)==HIGH){
        hv_startup();
    }
}

void hv_startup() {
    unsigned long previousMillis = 0;
    digitalWrite(pre_charge, HIGH);
    digitalWrite(main_charge, LOW);
    //Wait interval
    previousMillis = currentMillis;
    while (currentMillis - previousMillis < on_interval) {
        Serial.println(millis());
        //Wait
    }
    digitalWrite(pre_charge, LOW);
    digitalWrite(main_charge, HIGH);
    hv_bool = true;
    loop();
}

void setup(){
    //Set some ports

    //Initiate interrupt
    attachInterrupt(digitalPinToInterrupt(hv_pin), hv_switch, RISING);
}

void loop() {
    //Low voltage loop after startup, high voltage off
    while (hv_bool == false) {
        Serial.println("Waiting on high voltage");
        digitalWrite(hv_led, LOW);
        digitalWrite(pre_charge, LOW);
        digitalWrite(main_charge, LOW);
    }
}


texts: Can I make a USB Device with only data output

texts:
This is about how USB ports/devices work

Lets say i have a USB port on my computer

If I have an arduino board or something similar, am I able to connect output to Data+ and sort of make my own USB keyboard.
What I aim to achieve is send without having to receive

1) Would I need to connect it to both D+ and D- so it forms a circuit in order for the USB port to read the data? (or would the data simply be read and then disappears so I don't have to worry about two wires?)

If Yes: 2) If I manage to forcefully push electricity through the wire onto the Data pins, would I only need one wire?

Else: 3) is this physically impossible and the whole universe would explode if I tried?


texts: Output to LCD is sometimes shifted to the side

texts:
I have an Arduino Uno connected to a LCD. When I try to write to it using the LCD library and the following sketch, it will keep shifting the output around, sometimes drastically.
The sketch:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 10, 11, 9, 8, 7, 6, 5, 4, 3, 2);

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

void loop ()
{
  lcd.clear ();
  lcd.home ();

  for (int i = 0; i < 2; i++)
  {
    for (int j = 0; j < 16; j++)
    {
      lcd.setCursor (j, i);
      lcd.print ("s");
    }
  }

  delay (1000);
}

You would expect it to print

SSSSSSSSSSSSSSSS
SSSSSSSSSSSSSSSS

But it will often print

SSSSSSSSSSSSSSS
SSSSSSSSSSSSSSS

As in, it skips the first line. And, occasionally, it will even print like this:

SSSSSSSSSSS
SSSSSSSSSSS

Is it the LCD's fault, or might there be something wrong with the way it is connected?
EDIT:
It is a common Hitachi HD44780-compatible LCD.
EDIT 2:
 Hopefully it is correctly wired up.


texts: How to use the Osepp proximity module with arduino uno

texts:
I have recently purchased an Osepp proximity module at Radio Shack and am attempting to use it with my Arduino Uno. How should I connect it to the
Arduino, and what library do I use?


texts:
Hello I have an Arduino program that loads strings from a file and stores them in an array. It works fine when I load it the first time but when I load it a second time it doesn't seem to work.

 String content = "";

 char character23;

 String result[10];
 int arraysize = 10;

 void loadPrograme(String sss){
   File file = SD.open("basic.txt", FILE_READ);
   Serial.print("Reading, Checking and Compiling \n\n\n");

   for (int i = 0; i < arraysize; i++) {
     result[i] = "";
   }

   for (int i = 0; i < arraysize; i++) {
     while (file.available()) {
       character23 = file.read();
       if (character23 == '\n') break;
       if (character23 != '^') {
         content += character23;
       }
     }
     content.trim();
     if (content != "") {
       result[i] = content;
       content = "";
     }
   }

   for (int i = 0; i <arraysize; i++) {
     Serial.print("result[");
     Serial.print(i);
     Serial.print("]: ");
     Serial.println(result[i]);
   }
   file.close();
 }

This works fine when I call loadProgramme("basic.txt") in the setup function.

void loadfileMethod(String s){
  if(consolemode){
    u8g.setFont(u8g_font_micro);
    u8g.drawStr(2, 6-camy, s.c_str());
    camy+=6;
  }
  camy = 0;
  loadPrograme("names.txt");
}

When I call loadprograme in this method it runs through loadrograme but only gets as far as the while loop and it doesn't do anything in the while loop.(I check this using serial.println().

Can someone tell me what I'm doing wrong that makes it work the first time and not the second?

EDIT: I found the problem but I don't know how to fix it. when I do Serial.println(file.name()); it prints the correct name the first time but the second time it just prints a tiny box which I presume is nothing or an error.

How can I fix this?


texts:
I am trying to find cheap options for displays about 3 x 6 inches to display time, weather, simple clip-art type images, and other marquee messages.  What are my best options to work with arduino if my goal is cost-cutting?

2" x 4" or greater in size
40 dpi minimum
readable from 15 feet in normal indoor conditions
everything else is unimportant to me at this point: RGB, pitch, power draw, etc.


texts: Can I power an NodeMCU trough VIN providing 5v

texts:
I have a spb 8266 board, an ESP-12E NodeMCU.
I broke my micro USB.

There's this piece of information but my case is unclear:

Can I use the micro usb's 5v to power the board through the VIN or do any solution require more equipment than that ?

(The board only has 3.3V and no 5V)


texts: How to send command from coordinator to router in Xbee?

texts:
I am using an XBee-PRO S2b module. I have sent data from the router Xbee to the coordinator Xbee.

Now I want to send a command packet from the coordinator to the router Xbee to set a pin high.

My coordinator is in API mode and the router is in AT mode.

Can anyone say how to do that?


texts:
I am sending a HTTP GET request to a server I deployed on digital ocean (Ubuntu/Node.js). On the web browser when I go to my URL 'http://Server_Ip_Address/event/astarttime' or 'http://Server_Ip_Address/event/aendtime' the application on the web successfully performs its transaction.

However, I tried doing the same on my D1 R2 ESP8266 with this code in Arduino IDE: Sometimes it works sometimes it doesn't...I can't figure out why it only works some times and other times it doesn't work at all. Any idea of what it could be? Thank you for your help in advance.

Using these libraries:

#include "ESP8266WiFi.h"
#include <ESP8266HTTPClient.h>

http.begin("http://Server_Ip_Address:80/event/astarttime");
int httpCode = http.GET(); //Send the request
http.end();  //Close connection
http.begin("http://Server_Ip_Address:80/event/aendtime");
int httpCode = http.GET(); //Send the request
http.end(); //Close connection


texts: Powering Moisture sensor via arduino pin

texts:
Can someone help me. I have this sensor

I just connected it to the 3V pin of my arduino only I read online that its better to connect it to a Arduinopin for power so you can put it off when not measuring. How do I do this? Can I just connect it to, let's say D4 and put this to HIGH and LOW or do I need something more. I googled a bit but found all kinds of different solutions. Some even talked about the need to PULLUP and PULLDOWN. whats the best way to do this.


texts:
I'm building a simple mobile controlled relay switch. however, I'm out of relay modules, but I do have these esp-01 relays: https://ae01.alicdn.com/kf/HTB1VIKLeJLO8KJjSZFxq6yGEVXaW.jpg

I'm wondering if these can work with a nodemcu? So far no luck.


texts:
I am trying to amplify the signal from an Adafruit Small enclosed piezo.  The piezo is working using the Arduino Knock example but I want to increase the sensitivity using an amplifier.  The wiring shown below does not work using the Knock sketch and I am assuming it is a problem with the wetware and the wiring(NOOB here).
Any advice in amplifying the piezo is appreciated.


texts:
I am very new to coding and I am attempting to teach myself the best I can.  I have no prior knowledge of coding and am filling in the blanks via YouTube and forums alike.  One place I keep getting hung up on is what seems to be an unsigned integer.

I have tried to figure out how these work (assignment and such) to no avail. I was wondering if anyone could offer some insight for me or at the least a link that gets specific for the Arduino.

I see them used as uint8_t, uint16_t, and uint_32 in various places.  Am I correct that it is an unsigned integer?  Meaning it is a whole positive number only.

The code I have attached is from Adafruit's article on multi-tasking.  I am trying to adapt my sketch for millis() over delay().

      uint32_t Color1, Color2;  // What colors are in use
      uint16_t TotalSteps;  // total number of steps in the pattern
      uint16_t Index;  // current step within the pattern

For instance: on the variable declarations they use these for the color.  I will need to change the colors, but have only seen them expressed in RGB.  They are in every sketch I see, but I am struggling to answer this question on my own.  Thanks in advance for any help.


texts: What's the problem? My motor works properly only when we press the left key and not others

texts:
int mf11=13;//motor1 1st terminal
int mf12=12;//motor1 2nd terminal
int mf21=9;//motor2 1st terminal
int mf22=8;//motor2 2nd  terminal
int fr=2;//front key
int bk=3;//back key
int rt=4;//right key
int lt=5;//left key

void setup() {
    pinMode(mf11,OUTPUT);
    pinMode(mf12,OUTPUT);
    pinMode(mf21,OUTPUT);
    pinMode(mf22,OUTPUT);
    pinMode(fr,INPUT);
    pinMode(bk,INPUT);
    pinMode(rt,INPUT);
    pinMode(lt,INPUT);
}

void loop() {
    int s = digitalRead (fr);
    int h = digitalRead (bk);
    int i = digitalRead (rt);
    int v = digitalRead (lt);
    if(s==HIGH) {
         digitalWrite(mf11,HIGH);
         digitalWrite(mf12,LOW);
         digitalWrite(mf21,HIGH);
         digitalWrite(mf22,LOW);
    }
    if (h==HIGH) {
        digitalWrite(mf11,LOW);
        digitalWrite(mf12,HIGH);
        digitalWrite(mf21,LOW);
        digitalWrite(mf22,HIGH);
    }
    if (i==HIGH) {
         digitalWrite(mf11,LOW);
         digitalWrite(mf12,HIGH);
         digitalWrite(mf21,HIGH);
         digitalWrite(mf22,LOW);
    }
   if (v==HIGH) {
        digitalWrite(mf11,HIGH);
        digitalWrite(mf12,LOW);
        digitalWrite(mf21,LOW);
        digitalWrite(mf22,HIGH);
   } else {
       digitalWrite(mf11,LOW);
       digitalWrite(mf12,LOW);
       digitalWrite(mf21,LOW);
       digitalWrite(mf22,LOW);
  }
}


texts: Asynchronous function calls in Arduino sketch

texts: In an Arduino sketch, is there a way to make asynchronous function calls within the loop? Like listening to requests through http server and process them in a non-blocking way.


texts:
I found this Haptic Headband project on YouTube (link below) and I am trying to verify the code that was given in the instructions with the Arduino IDE. However, I keep getting the message below and am not too sure what I need to do to fix it. I'd appreciate any help I could get to solve this issue.
I have also attached a pdf of the instructions with the code to use for the headband.
PDF: https://cdn-learn.adafruit.com/downloads/pdf/haptic-headband.pdf?timestamp=1602887165
https://www.youtube.com/watch?v=xD7bfBx5D9M&ab_channel=AdafruitIndustries

libraries\Adafruit_DRV2605_Library\Adafruit_DRV2605.cpp.o (symbol from plugin): In function `Adafruit_DRV2605::Adafruit_DRV2605()':
(.text+0x0): multiple definition of `Adafruit_DRV2605::setRealtimeValue(unsigned char)'
sketch\Adafruit_DRV2605.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Adafruit_DRV2605_Library\Adafruit_DRV2605.cpp.o (symbol from plugin): In function `Adafruit_DRV2605::Adafruit_DRV2605()':
(.text+0x0): multiple definition of `Adafruit_DRV2605::useERM()'
sketch\Adafruit_DRV2605.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Adafruit_DRV2605_Library\Adafruit_DRV2605.cpp.o (symbol from plugin): In function `Adafruit_DRV2605::Adafruit_DRV2605()':
(.text+0x0): multiple definition of `Adafruit_DRV2605::useLRA()'
sketch\Adafruit_DRV2605.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.


texts: Reading data from Adafruit SGP30 Air Quality Sensor

texts:
I am trying to conect  Adafruit SGP30 Air Quality Sensor to arduino nano and get values from it,  but it seems that my code is not working properly. I followed instruction on the adafruit webpage, installed the Adafruit_SGP30 library and uploaded to my microcontroller.
But surprisingly when I open serial monitor text appears: SGP30 test,        but no data.

Does anybody know where I made mistake?

This is my code:

#include <Wire.h>
#include "Adafruit_SGP30.h"

Adafruit_SGP30 sgp;

void setup() {
Serial.begin(115200);
Serial.println("SGP30 test");

if (! sgp.begin()){
Serial.println("Sensor not found :(");
while (1);
}
Serial.print("Found SGP30 serial #");
Serial.print(sgp.serialnumber[0], HEX);
Serial.print(sgp.serialnumber[1], HEX);
Serial.println(sgp.serialnumber[2], HEX);
}

void loop() {
sgp.IAQmeasure();
Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print("\t");
Serial.print("eCO2 "); Serial.println(sgp.eCO2);
delay(1000);
}


texts: setup() resets from loop, when I add parameters to http get `?identity=%2B0123456789&identityType=1`

texts:
I am trying to call a HTTP GET using my Arduino via SIM900A.

When I run the commands manually via the USB port, I am able to get the commands to run. Now, when I put the same sequence on arduino, the setup() is called repeatedly after the sendATcommand(httpAuthCommand, "OK", 2000);. Looks like a reset issue.

I read, this link to put all my code into loop to avoid the setup() reset issue. But seems like this is did not fix the issue.

I have debugged it to this one change.

This Works

char httpAuthCommand[] = "AT+HTTPPARA=\"URL\",\"http://www.m2msupport.net/m2msupport/http_get_test.php\"" ;

This Does Not work

char httpAuthCommand[] = "AT+HTTPPARA=\"URL\",\"http://1.1.1.1:8080/mytomcatservice/mypath/mycommand/Request?identity=%2B1234567890&identityType=1\"" ;

I debugged this a bit more, it does not work when I add ?identity=%2B0123456789&identityType=1 to the httpAuthCommand. Something crazy while sending parameters ??

In loop()

sendATcommand(httpAuthCommand, "OK", 2000);

sendATcommand method

int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;
    memset(response, '\0', 100);    // Initialice the string
    delay(100);
    while( Serial.available() > 0) Serial.read();    // Clean the input buffer
    Serial.println(ATcommand);    // Send the AT command
    x = 0;
    previous = millis();
    // this loop waits for the answer
    do{
        // if there are data in the UART input buffer, reads it and checks for the asnwer
        if(Serial.available() != 0){
            response[x] = Serial.read();
            x++;
            // check if the desired answer is in the response of the module
            if (strstr(response, expected_answer) != NULL)
            {
                answer = 1;
            }
        }
    // Waits for the asnwer with time out
    }while((answer == 0) && ((millis() - previous) < timeout));

    return answer;
}

Raw commands work on Chrome

  http://www.m2msupport.net/m2msupport/http_get_test.php

  http://1.1.1.1:8080/mytomcatservice/mypath/mycommand/Request?identity=%2B918177900460&identityType=1

My Guess

I am missing some escape sequence characters in the command (especially in the parameters section ?identity=%2B0123456789&identityType=1).


texts: How many WS2811 LED strips can I control with Arduino?

texts:
Is there any limitation to connecting more strips?

I plan to create for my temple Ganpati Street Lighting LED Decoration - Full HD Ahmednagar Mh India

Watch this video and give me some ideas and suggestions.


texts:
Hello i have made a PCB with atmega328p (arduino bootloader) and arduino sketch this circuit is designed to control 12v leds using transistors here is the full schematic

The problem is when powering all the leds the atmega328 reboot :(
i do not why and how to fix this
thank you for your help


texts:
Friend asked me to find problem with compilation for his DigiSpark AT Tiny85 board.
We are trying to compile sketch from here:
https://forum.arduino.cc/index.php?topic=314773.0

But with no luck - there is something mixed in headers or configuration and I do not know what exactly.

This ISR does not compile:

ISR(TIMER1_OVF_vect) {       //timer1 overflow

First there were some errors like TCCR1 = 0; not defined in this sketch, then after playing with #define __ AVR_ATtiny85__, #undef _AVR_IOXXX_H_ and replacing avr/io.h with iotn85.h errors like multiple definition of __vector_x(?) came. Commenting out this line:
//attachInterrupt(0,zeroCrossingInterrupt, FALLING)
helped, but now even this one works, but ISR not.

I know there is a lot of caches and you do not see what is going on behind curtains, but I am quite lost yet...

Maybe there is also problem I have multiple installs in different dirs, but do not know how to clean old ones (1.6.5-r2) and at the end both work same way now, my latest fresh installed is 1.8.9.

Does anyone have any experiences with or some working demo sketch using both compare match and overflow ISRs ?

Edit
Setup info
This board selected (...\AppData\Roaming\Arduino15\packages\digistump\hardware\avr\1.6.7\boards.txt):

digispark-tiny.name=Digispark (Default - 16.5mhz)
digispark-tiny.upload.using=micronucleusprog
digispark-tiny.upload.protocol=usb
digispark-tiny.upload.tool=micronucleus
digispark-tiny.upload.maximum_size=6012
digispark-tiny.build.mcu=attiny85
digispark-tiny.build.f_cpu=16500000L
digispark-tiny.build.board=AVR_DIGISPARK
digispark-tiny.build.core=tiny
digispark-tiny.build.variant=digispark
digispark-tiny.upload.wait_for_upload_port = false
digispark-tiny.upload.use_1200bps_touch = false
digispark-tiny.upload.disable_flushing = false

And these are available:

(...\AppData\Roaming\Arduino15\package_digistump_index.json)
...
"boards": [
  {
    "name": "Digispark (Default - 16.5mhz)"
  },
  {
    "name": "Digispark Pro (Default 16 Mhz)"
  },
  {
    "name": "Digispark Pro (16 Mhz) (32 byte buffer)"
  },
  {
    "name": "Digispark Pro (16 Mhz) (64 byte buffer)"
  },
  {
    "name": "Digispark (16mhz - No USB)"
  },
  {
    "name": "Digispark (8mhz - No USB)"
  },
  {
    "name": "Digispark (1mhz - No USB)"
  }
],
...

Edit 2
Fresh install attempt on W10
Few more links - 2nd manual here:
https://www.electronicshub.org/getting-started-with-attiny85/

http://digistump.com/package_digistump_index.json
have to be translated to
https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.json

https://downloads.arduino.cc/arduino-1.8.9-windows.zip
W10
When installing shows error downloading (timeout?):
http://downloads.arduino.cc/tools/avr-gcc-4.8.1-arduino5-i686-mingw32.zip

Downloaded by hand to (there was empty file of this name):
...\AppData\Local\Arduino15\staging\packages\
avr-gcc-4.8.1-arduino5-i686-mingw32.zip

...\AppData\Local\Temp\arduino_build_139604\core\core.a(wiring.c.o): In function `__vector_4':

...\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/wiring.c:93: multiple definition of `__vector_4'

...\AppData\Local\Temp\arduino_build_139604\sketch\sketch_jun28a.ino.cpp.o:...\arduino-1.8.9\SketchBook\sketch_jun28a/sketch_jun28a.ino:60: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Digispark (Default - 16.5mhz).

...\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny\core_build_options.h (not found that file in arduino dir):

/*=============================================================================
  Build options for the ATtiny85 processor
=============================================================================*/

#if defined( __AVR_ATtiny25__ ) || defined( __AVR_ATtiny45__ ) || defined( __AVR_ATtiny85__ )
#define __AVR_ATtinyX5__
#endif

#if defined( __AVR_ATtinyX5__ )

/*
  For various reasons, Timer 1 is a better choice for the millis timer on the
  '85 processor.
*/
#define TIMER_TO_USE_FOR_MILLIS                   1


texts: Use Adafruit 16-Channel 12-bit PWM/Servo Shield to switch relays

texts:
I'm wondering if using the Adafruit 16-Channel 12-bit PWM/Servo Shield is it possible to switch relays, such as use that shield as a multiplexer and use digital output without PWM.

Is it possible? example code?


texts: If I connect more power consuming components to Arduino, it gets reset. What is the cause of this observation?


texts: Unrecognizable Message From PROGMEM char*

texts:
I'm using a PROGMEM char* to store a massive array. When I try to print a certain part of the array, the message comes out mangled. How do I fix this?

The output should be "Poliwag", but it comes out as "arow".

#include <TrueRandom.h>
#include <EEPROM.h>
#define numPokemon 151
PROGMEM char* nameArray[] = {"MISSINGNO","Bulbasaur","Ivysaur","Venusaur","Charmander","Charmeleon","Charizard","Squirtle",
"Wartortle","Blastoise","Caterpie","Metapod","Butterfree","Weedle","Kakuna","Beedrill","Pidgey","Pidgeotto",
"Pidgeot","Rattata","Raticate","Spearow","Fearow","Ekans","Arbok","Pikachu","Raichu","Sandshrew","Sandslash",
"Nidoran♀","Nidorina","Nidoqueen","Nidoran♂","Nidorino","Nidoking","Clefairy","Clefable","Vulpix","Ninetales","Jigglypuff",
"Wigglytuff","Zubat","Golbat","Oddish","Gloom","Vileplume","Paras","Parasect","Venonat","Venomoth","Diglett","Dugtrio","Meowth",
"Persian","Psyduck","Golduck","Mankey","Primeape","Growlithe","Arcanine","Poliwag","Poliwhirl","Poliwrath","Abra","Kadabra","Alakazam",
"Machop","Machoke","Machamp","Bellsprout","Weepinbell","Victreebel","Tentacool","Tentacruel","Geodude","Graveler","Golem","Ponyta","Rapidash",
"Slowpoke","Slowbro","Magnemite","Magneton","Farfetch`d","Doduo","Dodrio","Seel","Dewgong","Grimer","Muk","Shellder","Cloyster","Gastly","Haunter",
"Gengar","Onix","Drowzee","Hypno","Krabby","Kingler","Voltorb","Electrode","Exeggcute","Exeggutor","Cubone","Marowak","Hitmonlee","Hitmonchan","Lickitung",
"Koffing","Weezing","Rhyhorn","Rhydon","Chansey","Tangela","Kangaskhan","Horsea","Seadra","Goldeen","Seaking","Staryu","Starmie","Mr. Mime","Scyther","Jynx",
"Electabuzz","Magmar","Pinsir","Tauros","Magikarp","Gyarados","Lapras","Ditto","Eevee","Vaporeon","Jolteon","Flareon","Porygon","Omanyte","Omastar","Kabuto","Kabutops",
"Aerodactyl","Snorlax","Articuno","Zapdos","Moltres","Dratini","Dragonair","Dragonite","Mewtwo","Mew"
};
int a = 0;
int b = 0;
int value;
String pokemonName = "Missingno";
int currentID = TrueRandom.random(1,numPokemon+1);
// a = CurrentID
void setup(){
  Serial.begin(9600);
  if (EEPROM.read(a)!=0){
    currentID = EEPROM.read(a);
    Serial.print("The Stored ID is ");
    Serial.println(EEPROM.read(a));
    Serial.println("Stored = true");
  }else{
    value = EEPROM.read(a);
    Serial.println(value);
    EEPROM.write(a,currentID);
    value = EEPROM.read(a);
    Serial.println(value);
    Serial.println("Stored = false");
  }
  pokemonName = nameArray[currentID];
  Serial.println(pokemonName);
}
void loop(){

}


texts: Change XBee shield TX/RX Software serial?

texts:
I am looking to have an Arduino UNO stack with a GSM Shield and an XBEE shield for wireless communication.

However, since the GSM Shield requires digital pins 2 and 3, I would have to reroute the RX/TX of the XBee to another digital pin.

I have tried changing

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

to other values, but this does not work.

How would I go about doing this?


texts: Powering 3 servo motors and Arduino Uno with one 9 V battery

texts:
I wish to power an Arduino Uno board AND 3 servo motors using a single 9 V battery.
I have connected the positive terminal of the 9 V battery to the VIN pin. The negative terminal of the battery is connected to the GND pin immediately following. This, I believe, powers the Arduino Uno board.
Next, I have connected the power wires of all 3 servo motors to the 5 V pin on the Arduino board ( using jumper wires and a  breadboard). Similarly, all the servo ground wires have been connected to the second GND pin in the 'POWER' set of pins on the Arduino Uno board. And finally, the 3 signal wires from the servos have been connected to the three PWM pins on the 'DIGITAL' row, exactly pins 9, 10 and 11. THE SERVOS ARE NOT OPERATED SIMULTANEOUSLY, THEY ARE BEING OPERATED ONE-BY-ONE (but the load is still attached to each of them, a couple of grams is all).
Since the servo motors operate between 4.8 V - 6 V, and I don't have any spare AA batteries to approximate a 6 V battery, I thought this could solve the problem.My question is, does this pose any problems for the board or devices, does this draw a higher current? Will it damage the Arduino Uno board or the servo motors or any of the individual pins?  Please let me know soon, thank you very much.


texts: cannot get low power with Adafruit Trinket

texts:
I want to get as low power use during sleep as possible with an Adafruit Trinket. Based on results presented on various places in the internet (blogs etc), I expect to be able to go down to 50 - 100 micro amps on the ATTiny85 of the Trinket. I am aware of the fact that using a board such as Trinket may add a bit of consumption, and I physically removed the power LED and the power regulator. I am feeding 5V directly on the 5V pin.

I am using the simplest sketch I can think about for low power, with nothing connected to any pin:

#include <avr/sleep.h>          // library for sleep

#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)

void setup() {
  // put your setup code here, to run once:
  delay(10000);

  // power_all_disable();
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  adc_disable();
  sleep_enable();
  sleep_mode();

}

void loop() {

}

But I cannot get less than around 1.3 milli amps consumption during sleep. Do you know what may be the cause of using ~1mA instead of ~100 microA? Any idea how I can decrease this further?

Edit 1: it should be even much less than ~50 - 100 micro Amps: ATtiny85: Power consumption vs clock speed ; even though this the libraries are maybe primary intended for the ATMega328P, it looks like it should work also with ATTiny85 as well: http://www.technoblogy.com/show?KX0

Edit 2: I had an ATMega328P-based Adafruit Metro Mini lying around. I took away the ON LED, and then using exactly this sketch, feeding power directly on the 5V pin of the Metro Mini, leads to a power consumption of around 150 micro Amps during sleep, which is more like what I expect. Strange it is 10 times more with the ATtiny while it should have been less (?). Am I missing something or is it maybe just broken library on ATtiny? This is a bit ironic, as I went for the lesser ATtiny85 based board for saving current compared with the ATMega328P...


texts:
So I have a bunch of functions (methods) made and I want to make it so that if the button is clicked (single click) the effects to change... I thought something like:

buttonState = digitalRead(buttonPin);
if(buttonState==HIGH) {
  counter++;
  if(counter>2) {
    counter=0;
   }
 }
if(counter==0) {
  Foo1();
}
if(counter==1) {
  Foo2();
}
if(counter==2) {
  Foo3();
}

But I noticed that it will only read the input button(buttonPin) if I click the button in the exact time (when the function has already ended and at digitalRead time)... So is there some way to do it even if the function is in progress to cancel it and go to the other ones (some way that the digitalRead will read it non stop)?


texts: XBee using Serial rather than SoftwareSerial--how to fix

texts:
So I have a couple of XBee S2Cs, and I have configured them properly--they can in fact communicate with each other. I am using them with Arduino Unos and this shield: https://store.arduino.cc/usa/shield-xbee-without-rf. I am attempting to interface with the XBees with SoftwareSerial, but for whatever reason, they are instead using just regular Serial. Anything I put on the SoftwareSerial appears to be ignored entirely, while anything I put on Serial appears in my serial monitor and also is transmitted to the other XBee. I have this code for transmitting:

#include <SoftwareSerial.h>
SoftwareSerial xbee (2, 3);
void setup() {
    Serial.begin(9600);
    xbee.begin(9600);
}

void loop() {
    xbee.println("hello");
    Serial.println("world");
    delay(5000);
}

And this code for receiving:

#include <SoftwareSerial.h>

SoftwareSerial xbee(2, 3);

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

void loop() {
    if (xbee.available() > 0) {
        Serial.println("xbee: " + xbee.readString());
    }
    else {
        Serial.println("no xbee data");
    }

    if (Serial.available() > 0) {
        Serial.println("serial: " + Serial.readString());
    }
    else {
        Serial.println("no serial data");
    }
    delay(5000);
}

Every 5 seconds, I get this output through the serial monitor on the transmitting side:

world

and this on the receiving side:

no xbee data
serial: world

I also get the string world when I connect a third XBee to my XCTU console.

So I have a couple of questions:

First off--how is this happening? I'm no Arduino expert, but as far as I can tell from what I've read, if the XBee is capturing my serial output, then I shouldn't also be able to see it in the serial monitor.

Second off--how can I get the SoftwareSerial to work? I could theoretically just use Serial forever, but that would make debugging way more trouble, and would probably create a code-maintenance headache later. If I had to guess, I might need to use different pins for my shield, but I have no idea how to find out what pins are the right ones to use.

Update: Based on what I've seen and read, it looks like the particular combination of the Uno with this shield leaves me with no options but to use the hardware serial. A different shield or Arduino board would grant me options to separate my serial output from my xbee output, but that does not appear to be an option here.


texts: DHT11 is not reading Temperature and Humidity when Arduino is powered on using DC power Supply (12V)

texts:
I am facing one problem. I have code which read temperature and humidity using DHT11 sensor. I uploaded following code using Arduino via USB serial, I can read values of temp, humidity. Values are being read as long as Arduino is connected to same laptop via USB.

TEMPERATURE AND HUMIDITY are being read as 0 when I power on Arduino using DC12v, 700MA adapter.

I want to deploy Arduino with DHT sensors connected with it in Greenhouse to read greenhouse environmental condition but when I power on using DC adapter or battery, it is giving "0" output.

PLEASE HELP TO SOLVE THIS PROBLEM.

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");

  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);


texts: I2C interference SENSOR(SCL+SDA) and MasterSlave comm

texts:
I am building a weather station with an Arduino slave (dedicated to a rain gauge - depicted below as a reed switch) and a NodeMCU master with some additional sensors.

One such sensor, a BMP280 uses D1 and D2 as SCL and SDA, while slave control is using D3 and D4 for communication with Arduino.

When I enable Wire.begin for slave communication, my BMP280 readings go nuts

#include <Adafruit_BMP280.h>

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10

Adafruit_BMP280 bmp;

// masterSlave
#include <Wire.h>
#define I2CAddressESPWifi 8
...

void setup() {

    if (!bmp.begin()) {
        Serial.println("Could not find a valid BMP280 sensor, check wiring!");
        while (1);
    }

    // masterSlave - generates problem with BMP280...
    Wire.begin(0,2);//Change to Wire.begin() for non ESP. D3 SDA  D4 SCL

  BMP280 Temp = -136.42 *C

  Pressure = 125136.25 Pa

as opposed to this reading when Wire.begin is commented out.

    // COMMENTED OUT FOR DEBUGGING
    //masterSlave - generates problem with BMP280...
    //Wire.begin(0,2);//Change to Wire.begin() for non ESP. D3 SDA  D4 SCL

  BMP280 Temp = 20.01 *C

  Pressure = 93464.36 Pa

I attempted setting D3 and D4 to LOW while reading from BMP280, but it had no effect on readings.


texts: How to write array of functions in arduino library?

texts:
I've nine functions each of type void as follow:

void zero();
void one();
void two();
void three();
void four();
void five();
void six();
void seven();
void eight();
void nine();

I've put all these functions into an array pointer as follow (without any error):

typedef void (*num_func) ();
num_func functions[] = { zero, one, two, three, four, five, six, seven, eight, nine};

Now I'm writing an arduino library and wanting to achieve the same, but after hours of thinking I'm not able to achieve. Please help me how can I accomplish this in a library?

Thanks in advance.


texts: Reading and Writing on different clock edges with Arduino SPI interface

texts:
I'm trying to simulate a certain µController to characterize and measure a certain chip.

I need to write my data on the negative edge of the master clock and read the data coming from the slave in the positive edge of the master clock. Is there any way I can have this kind of freedom in my code? Or do I have to do it manually without using the predefined SPI interface?

Also, I would like to have my master clock running continuously without going idle… is there a way to do that too?


texts: Wrong data receiving in my Arduino by bluetooth

texts:
I have programmed a client-server between an Arduino and my mobile app in Android. I´m using a buetooth HC-06. For the moment is a very basic code just to turn ON/OFF a led, regulate its voltage, and receive the charge of the battery.
This is my Arduino code for receiving the message:
#include <SoftwareSerial.h>
#include <TimerOne.h>
SoftwareSerial hc06(2,3);

char command;
String string;
boolean ledon = false;
const byte MAX_STRING_LEN = 40;
const int  BLINK_INTERVAL = 1000;

char inputString[MAX_STRING_LEN];  // a string to hold incoming data

int BatteryPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
float BatteryCar = 0;
int PercentageBatt = 0;
int intensidad = 0;
byte strLen   = 0;                 // current length of rec'd string

#define led 11
void setup()
{
  Serial.begin(9600);
  hc06.begin(9600);
  pinMode(led, OUTPUT);
  Timer1.initialize(10000); // set a timer of length 10000 microseconds (or 0.01 sec - or 1Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
  Timer1.attachInterrupt( SendVoltage );
}
void loop()
{

  sensorValue = analogRead(BatteryPin);
  BatteryCar = sensorValue * (5.0 / 1023.0);
  if (hc06.available() == 0)
  {
    analogWrite(led, 0);
    delay (10);
  }
  while(hc06.available() > 0)
  {
    command = ((byte)hc06.read());
    if((command == '\n') || (command == '\r'))
    {
      command =='\0';
      break;
    }
    else if (command == 'O')
      analogWrite(led, 255);
    else
      analogWrite(led, 0);
    delay(10);
    Serial.println(command);
  }
}

void SendVoltage ()
{

  PercentageBatt = (BatteryCar * 100)/4;
  hc06.println(PercentageBatt);
}

This is the data that I´m receiving:

It supposed that i should only receive "O" or "F". Any suggestion??
thanks in advanced,


texts: BLDC geared motor with encoder - How to wire the encoder? (6 wires)

texts:
I am quite a newbie to arduino and currently stuck with an encoder.
I have a BLDC geared motor with encoder, all I want to do is to get values from the encoder.
There are 6 wires, out A, out B, out Z, +V, 0V, F.G
How should I wire those six of them correctly?
Encoder specification says 5VDC is ok to power it, and I want to make a circuit to power encoder using Arduino Mega board.


texts: I have a system that uses Arduino and some modules. The system needs 5v dc power with 3A current at maximum(The system needs 3A current for some seconds every 5 minutes and after that the current will get back to 300-400mA) and on the other side i have a 5v dc charger with 400-500 mA current. So my problem is lack of amperage and i can't run correctly Arduino with 5v dc charger. For solving this problem i want to use a Lipo battery to connect to Arduino but the battery will ran out and i can't get energy from battery so i want to connect the battery to my charger while the Arduino uses the battery, How can i do that? Is there any module to do this work? Can i use TP4056 with protection version to do this work?(Note: I can't change charger)


texts:
I need to create a project where I need to send data via Wi-Fi using an Arduino.

I need the Arduino to have a U.FL connector to place an external Wi-Fi antenna (I can't use the MKR1000 with integrated Wi-Fi antenna because the Arduino will be placed inside a metal box).

Is there any solution-like Arduino for this without the need to use an external board like: SparkFun WiFi Shield - ESP8266 ?

I could also use the BeagleBoard Green Wireless that contains this U.FL connector for an Wi-Fi antenna, but I wanted something smaller such as an Arduino.

PS: Wi-Fi is the only option.


texts: ESP8266 & 2x VL53L0X Sensors cause WDT resets

texts:
I have a system that utilises 2 VL53L0X sensors. This works fine for the majority of time, but after around 20 hours till 2 days (varying), the ESP resets due to Software a WDT, I've managed to do a stack trace, and this is the result:

PC: 0x40100529: Twi::busywait(unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_si2c.cpp line 271
EXCVADDR: 0x00000000

Decoding stack results
0x40218f25: Twi::readFrom(unsigned char, unsigned char*, unsigned int, unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_si2c.cpp line 405
0x4010083e: millis() at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_wiring.cpp line 188
0x4021913c: twi_readFrom(unsigned char, unsigned char*, unsigned int, unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_si2c.cpp line 1042
0x402090b0: TwoWire::requestFrom(unsigned char, unsigned int, bool) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/Wire/Wire.cpp line 129
0x402090dc: TwoWire::requestFrom(unsigned char, unsigned char) at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/Wire/Wire.cpp line 143
0x402140eb: VL53L0X::readReg(unsigned char) at /Users/martin/Documents/Arduino/libraries/vl53l0x-arduino-1.02/VL53L0X.cpp line 322
0x40214442: VL53L0X::readRangeContinuousMillimeters() at /Users/martin/Documents/Arduino/libraries/vl53l0x-arduino-1.02/VL53L0X.cpp line 816
0x40201f00: readVLXSensors() at /Users/martin/Documents/Arduino/TEST_WS2812/TEST_WS2812.ino line 674
0x402083c7: loop() at /Users/martin/Documents/Arduino/TEST_WS2812/TEST_WS2812.ino line 596
0x40218404: loop_wrapper() at /Users/martin/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 172

This is the function that reads the sensors (initiated from the main loop):

void readVLXSensors() {

  if (readTop) {
    distSensorTop_distance = distSensorTop.readRangeContinuousMillimeters();
    if (distSensorTop.timeoutOccurred()) {
      distSensorTop_distance = 99999;
    }
    readTop = !readTop;

  } else {
    distSensorBottom_distance = distSensorBottom.readRangeContinuousMillimeters();

    if (distSensorBottom.timeoutOccurred()) {
      distSensorBottom_distance = 99999;
    }
    readTop = !readTop;
  }

}

As you can see as last desperate measure, I alternate the reading of the sensors, where as before I just read both sensors after each other. But even this approach still gives the WDT resets.

I don't believe it is (my)code nor the VL53L0X Library.. Any one an approach on this one?


texts: NeoPixels do not correctly display when calling strip.show()

texts:
I am trying to display some animations on a NeoPixel strip (more precisely, a WS2815 strip), using an ESP8266. For some reason, one of the animations will not display properly.
To give you an idea of the setup - I have a long string of WS2815 strips (4 strips, 300 LEDs each). The strips cross each other, forming loops (called "cycles" in my code). And I am trying to light these "cycles" separately.
In my loop(), I am doing something like this:
 for (uint16_t i = 0; i<loops; i++) {

    r = random(256);
    g = max ( 0, (int)(random(256)) - r);
    b = max ( 0, (int)(random(256)) - r - g);

    prevcycle = cycle;
    while (cycle == prevcycle) {
      cycle = random(NUM_CYCLES);
    }

    cycleSetColor(cycle, r, g, b);
    delay(wait);
    clearStrip();
  }

The actual function looks like this:
void cycleSetColor(uint8_t cycle, uint8_t r, uint8_t g, uint8_t b) {
  for(uint16_t pix=cycle_start[cycle]; pix!=cycle_end[cycle]; pix=cycle_next(cycle, pix)) {
      setPixelColor(pix, r, g, b);
  }
  strip.show();
}

Now the behavior is very strange - the only one of the cycles that lights up is the first one (the one that includes LEDs 0 to 300). Whenever I call the function for another cycle (one farther from the starting LED), nothing happens - the whole strip remains blank.
Trying to troubleshoot, I tried the following:

called strip.show() every time I set a pixel. Result - all the pixels light up correctly, in sequence:

void cycleSetColor(uint8_t cycle, uint8_t r, uint8_t g, uint8_t b) {
  for(uint16_t pix=cycle_start[cycle]; pix!=cycle_end[cycle]; pix=cycle_next(cycle, pix)) {
      setPixelColor(pix, r, g, b);
      strip.show();
  }
  strip.show();
}

called strip.show() every X pixels (100, for example). And this is where things get weird - I see the LEDs lighting up to a multiple of 100, but then the last part of the cycle remains blank. It is like strip.show() is called correctly in the loop, but the strip.show() outside the loop never gets called.

For example, if I have a cycle that includes LEDs from 420 to 600, then 730 to 890, I see LEDs lighting up all the way to LED number 800 - but the LEDs from 801 to 890 remain dark.
void cycleSetColor(uint8_t cycle, uint8_t r, uint8_t g, uint8_t b) {
  for(uint16_t pix=cycle_start[cycle]; pix!=cycle_end[cycle]; pix=cycle_next(cycle, pix)) {
      setPixelColor(pix, r, g, b);
      if (pix%100 == 0) {
        strip.show();  //This one lights the pixels
      }
  }
  strip.show();  //This one does not?!
}

Of course, if I surround the final call to strip.show() with Serial.println() messages, they are printed to the console - so it does look like the function is called properly. Yet somehow, the results do not show on the strip.
I have to mention that I do have some additional background tasks running (when doing setPixelColor, for example, I make sure every X milliseconds to take care of time-sensitive tasks, like WiFi and MQTT communication). But those should not interfere with strip.show(), which is called directly from the library.
I also have to mention that I can display other animations, including some that light up pixels all the way to the end of the strip, without any issues - so I would say that I managed to solve the power and control voltage issues. It is just this particular function that I cannot get to work.
Can anyone point me in the right direction? Thank you!


texts:
As the title says, I need 1khz frequency signal with 10-bit resolution. But I am not good with uControllers and complicated programming.

I need a simple code for this task.

I tried using this Interactive PWM from arduinoslovakia.eu but I dont know what the frequency is at 10-bit resolution and how to set frequency in this code.


texts:
The datasheet of arduino mega claimed that the board has 16Mhz processing power. But the question that doubt me is what would happen to the board if the board has no enough processing power.

For example,  if the board is used in an application that involves a lot of calculation in each loop. Would it stall the board?

Personally, i think the board would just give slower response instead of stalling the board. It was due request is done in sequential method in the code. Therefore it would not accumulate up the request until stalling the device like PC and I think it would be just at most an arduino which is always busy.

Is it what would happen if the board has no enough processing power?


texts: Trying to read different gas levels with MQ2 Gas Sensor

texts:
I found a link on how to connect MQ-2 Gas Sensor to Arduino Uno.
http://electronicsprojectshub.com/how-to-connect-mq2-gas-sensor-to-arduino/
After I bought all the parts and tried it out, the sensor gave me this in the serial monitor

Ro: 10.81 kohm
LPG:0.00ppm    CO:0.00ppm    SMOKE:0.00ppm
LPG:0.00ppm    CO:0.00ppm    SMOKE:0.00ppm

and so on.
Here is the code I used
#include <MQ2.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16,2);
int Analog_Input = A0;
int lpg, co, smoke;
MQ2 mq2(Analog_Input);

void setup(){
  pinMode(A0, INPUT);
  Serial.begin(9600);
  lcd.begin();
  lcd.backlight();
  mq2.begin();
}

void loop(){
  float* values= mq2.read(true);
  //lpg = values[0];
  lpg = mq2.readLPG();
  //co = values[1];
  co = mq2.readCO();
  //smoke = values[2];
  smoke = mq2.readSmoke();

  lcd.setCursor(0,0);
  lcd.print("LPG:");
  lcd.print(lpg);
  lcd.print(" CO:");
  lcd.print(co);
  lcd.setCursor(0,1);
  lcd.print("SMOKE:");
  lcd.print(smoke);
  lcd.print(" PPM");
  delay(1000);
}

Please help me fix it so that it can perform just the same as the video. Thanks.


texts: How to properly pass struct as argument?

texts:
This is my first question! i'm sorry if i'm doing something wrong.
I'm trying to write a code that blinks some leds, but i cant quite work out how to use structs as arguments.

This is the code:

void setup(){
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  //digitalWrite(2,HIGH); //debugging

}

struct Timer {
  unsigned long DutyCycle;
  unsigned long LastTime;
};

void SwitchPin(int pinn, bool ledstate,Timer timer) {
  if (millis() - timer.LastTime >= timer.DutyCycle) {
    if (ledstate == LOW) {
      ledstate = HIGH;
    } else {
      ledstate = LOW;
    }
    digitalWrite(pinn, ledstate);
  }
}

void loop()
{

}

When i try to verify it says:

exit status 1
'Timer' has not been declared

among other rubish.
I'm very new to programming in general, so probably i'm doing something very wrong without noticing it.
I would be very glad if you can explain exactly what im doing wrong, so i know what to do in the future.


texts: SPI Interface between Arduino UNO and EVK1100

texts: I'm using Arduino Uno board as master and AVR32UC3A0512 as slave. I've written code for arduino using SPI.h library, and Atmel Studio 6.2 using spi.h. I'm sending data from arduino to atmel i.e from SPDR register in arduino to RDR register in Atmel, but the data is not getting recieved. Hence, I'm not able to read the data. I've successfully interfaced SPI between two arduino boards and I'm using the same Arduino Master code while interfacing it with slave EVK. I've also set the baud rate same, I'm not sure what the problem might be. Can anyone please help me out?


texts:
I wish to build a remote for my Camera i.e Sony NEX 5R. It has a built in IR receiver and has several Sony as well as aftermarket remotes provided for it. Due to my interest in Micro controller design I wish to build one myself rather than use an aftermarket one.

A friend who did the same for his NEX 5 series camera posted a video of the same on Facebook, which inspired me to build my own. I plan to use an Arduino Uno R3 with the following additional components:

IR LED
NPN Transistor(for amplification)
Schmidt Triggers(for rectification)
9 Volt Battery

Ultimately I would like to swap out the Arduino for a standalone ATmega328 or ATtiny2313 but currently I have some issues as of now:

I currently do not have a schematic or a sample code which I can use. I have been trying to search the internet for the same but to no avail.
I am unsure of the protocol used by my camera. I have found it difficult to find documentation on the same.
How can I replace the 9-Volt battery for something smaller?
I would like to use a smaller micro controller but what differences will I encounter when trying to change my code for the smaller micro controller?
For such a project, will I need additional hardware?


texts:
So I am running my project on a NodeMCU, but I don't know how to let it add a yield in front of an else if. It will give me an error like this:

  Arduino:1.8.12 (Windows 10), 開發板:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Sketch + WiFi Settings, 115200"

  G:\資優班\科展\程式碼\Front_End\Main_Code_V5\Main_Server\Main_Server.ino: In function 'void loop()':

  Main_Server:84:5: error: 'else' without a previous 'if'

  exit status 1
  'else' without a previous 'if'

  This report would have more information with
  "Show verbose output during compilation"
  option enabled in File -> Preferences.

Here's the code:

#include <SPI.h>
#include <ESP8266WiFi.h>

#define MAX_SRV_CLIENTS 2
#define led LED_BUILTIN

WiFiServer server(80);
WiFiClient serverClients[MAX_SRV_CLIENTS];
IPAddress ip(10, 241, 241, 27);
IPAddress mask(255, 255, 255, 0);
IPAddress gateway(10, 241, 241, 254);
char ssid[] = "AP";
char pass[] = "Science_Fair";

void setup() {
  Serial.begin(9600);
  WiFi.config(ip, gateway, mask);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    yield();
  }
  server.begin();
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
}

void loop() {
  uint8_t i;
  Serial.setTimeout(10);
  for (i = 0; i < MAX_SRV_CLIENTS; i++) {
    Serial.println("Pre 1");
    if (server.hasClient()) {
      Serial.println("Pre 2");
      if (!serverClients[i] || !serverClients[i].connected()) {
        Serial.println("Pre 3");
        if (serverClients[i]) {
          Serial.println("Pre 4");
          serverClients[i].stop();
          Serial.println("Pre 5");
        }
        Serial.println("Pre 6");
        serverClients[i] = server.available();
        Serial.println("Pre 7");
        serverClients[i].setTimeout(10);
        Serial.println("Pre 8");
        Serial.print("New client: ");
        Serial.println("Pre 9");
        Serial.println(i);
        Serial.println("Pre 10");
        break;
      }
    }
    yield();
  }
  for (i = 0; i < MAX_SRV_CLIENTS; i++) {
    String fromClient = serverClients[i].readStringUntil('e');
    Serial.println("P1");
    yield();
    if (fromClient == "LR") {
      Serial.println("LR");
      String reply = Serial.readStringUntil('e');
      Serial.println("P2");
      yield();
      if (reply == "Warn_B") {
        yield();
        Serial.println("Confirm");
        Serial.println("P3");
        for (i = 0; i < MAX_SRV_CLIENTS; i++) {
          serverClients[i].print("Warn_B");
          Serial.println("P4");
          yield();
        }
      }
    }
    yield(); // this is the yield I need to add
    else if (fromClient == "RR") {
      Serial.println("RR");
      Serial.println("P5");
      String reply = Serial.readStringUntil('e');
      Serial.println("P6");
      yield();
      if (reply == "Warn_A") {
        Serial.println("P7");
        Serial.println("Confirm");
      }
      for (i = 0; i < MAX_SRV_CLIENTS; i++) {
        serverClients[i].print("Warn_A");
        Serial.println("P8");
        yield();
      }
    }
    yield();
  }
}

I need the yield() there but I don't know how to let it still do the else if. Please help me guys, thanks!


texts: Programmatically Change Arduino Com Port Name

texts:
I have some devices that, when I plug in, will display a unique name, usually a serial number, as opposed to "COM #" is there any way I can have my Arduino Uno (or Mega) give itself a different name in my program's set up structure?

Edit: My purpose here is that I'm writing a program on the computer side that needs to find the Arduino among multiple possible COM ports. I'm deploying this program over multiple computers that I don't have admin access to so changing the registry is likely a non-starter.

Right now, I'm going through each port and sending a *idn?\n (which my program responds to with a specific string). For another device I have, I can search the possible connections for a port named [device serial number] and test that one first.


texts:
Background: I'm using an Atmega1284P to add sensors to an off road racing truck onto a CANBUS network. The standard automotive sensors are thermistors, but the Dallas 1 wire temp sensors (DS18B20) with an integrated ADC caught my eye. They don't, however, come in a package that would work for my purposes so I would have to build one. I haven't been able to find one waterproofed in an NPT fitting with only a 1" probe length.

My question: how much more accurate would the 1 wire be over a thermistor?
How much of a difference would it make for processor efficiency to not have to do the math involved with thermistors and just read the value from the 1 wire? I don't mind building them, I just want to make sure they're worth it first.


texts: The BOOTRST fuse was disabled, but bootloader code is still running after chip reset

texts:
I am experimenting with an ATmega328P bootloader, and I created an Intel HEX (.hex) file with a program with an infinite loop in the beginning and with Optiboot code at the end of the hex file. (Code loaded into the chip is here: http://relliks.php5.cz/stackexchange/DUMP.bin.)

Then I disabled the BOOTRST fuse and pressed the restart button on Arduino Uno R3, but the bootloader still blinks with the LED on digital port 13.

How is it possible, that the bootloader is executed after chip restart and BOOTRST is disabled? My fuse settings are: Only SPIEN and BODLEVEL0 are set.

I found that when I disable the BODLEVEL0 fuse, the bootloader turns off.
BODLEVEL0 is used to set the brown-out voltage and shouldn't affect bootloader start. Where is the issue?


texts: Can I make multiple void loops with Arduino Uno?

texts:
I have a problem. I want to make a car with a motor, front lights and rear lights. I want to run them at the same time but in different loops.

This is my code.

const int red1 = 10;
const int red2 = 11;
const int blue1 = 12;
const int blue2 = 13;
const int front1 = 3;
const int front2 = 4;
const int back1 = 5;
const int back2 = 6;
const int enablePWMPin = 9;
const int controlPinA = 8;
const int controlPinB = 7;
int buzzer = A0;

void setup() {
  pinMode(red1, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(blue1, OUTPUT);
  pinMode(blue2, OUTPUT);
  pinMode(front1, OUTPUT);
  pinMode(front2, OUTPUT);
  pinMode(back1, OUTPUT);
  pinMode(back2, OUTPUT);
  pinMode(enablePWMPin, OUTPUT);
  pinMode(controlPinA, OUTPUT);
  pinMode(controlPinB, OUTPUT);

  digitalWrite(enablePWMPin, LOW);
  digitalWrite(front1, LOW);
  digitalWrite(front2, LOW);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW);
  digitalWrite(red1, LOW);
  digitalWrite(red2, LOW);
  digitalWrite(blue1, LOW);
  digitalWrite(blue2, LOW);
  noTone(buzzer);
}

void loop() {
  digitalWrite(enablePWMPin, HIGH);
  digitalWrite(controlPinA, HIGH);
  digitalWrite(controlPinB, LOW);
  delay(3000);
  digitalWrite(controlPinA, LOW);
  digitalWrite(controlPinB, HIGH);
  delay(3000);
}

void loop() {
  digitalWrite(red1, HIGH);
  digitalWrite(red2, HIGH);
  digitalWrite(blue1, LOW);
  digitalWrite(blue2, LOW);
  delay(250);
  digitalWrite(red1, LOW);
  digitalWrite(red2, LOW);
  digitalWrite(blue1, HIGH);
  digitalWrite(blue2, HIGH);
  delay(250);
}

void loop() {
  int directionA = digitalRead(controlPinA);
  int directionB = digitalRead(controlPinB);
  if (directionA == HIGH && directionB == LOW) {
    digitalWrite(front1, HIGH);
    digitalWrite(front2, HIGH);
    digitalWrite(back1, LOW);
    digitalWrite(back2, LOW);
  } else if (directionA == LOW && directionB == HIGH) {
    digitalWrite(back1, HIGH);
    digitalWrite(back2, HIGH);
    digitalWrite(front1, LOW);
    digitalWrite(front2, LOW);
  } else {
    digitalWrite(front1, LOW);
    digitalWrite(front2, LOW);
    digitalWrite(back1, LOW);
    digitalWrite(back2, LOW);
  }
}

I'm using an Arduino Uno. Can I start all the void loops at the same time?


texts: I am building a robot snake with a bunch of servos and ov7670. As I see, ov7670 operate with 3.3v and servos needs 5v. I will use Lipo battery for servos for this I need to connect ground pin of arduino and input of battery. But For ov7670, I already connect the ground pin of arduino. Can I connect ground with a jumper to another breadboard to connect with lipo battery and servos or I need two arduino nanos?


texts: Is there any better choice other than using delay() for a 6 hours delay?

texts: I am designing this incubator system and I need to drive a motor forward and reverse every 6 hours. Is there any better choice other than using delay(). A 6 hours delay seems a little unprofessional.


texts: How to compile Arduino ESP8266/32 on CI/CD (CLI shell cmd) platform?

texts:
Like make for not ESP Arduino target, is there a CLI command like esptool.py to upload in the hardware ?

I've seen makeEspArduino but seems to be not trivial ?

What about espressif ESP32 component ?

Is Visual Micro Arduino CLI (Command Line Interface) tool mature ?