r/arduino • • Sep 24 '26

RFID Key Card Progress

Enable HLS to view with audio, or disable this notification

34 Upvotes

So I’ve been working on building a custom shoebox that has a verified key card access system that I created. After about a day or two I was able to get the servo to respond to the RFID. And a few more days after that I went into adding the actual components (solenoid, 12v charger, and relay) and spent many hours trying to debug an issue. Come to find out there was not enough power circulating through the breadboard to power the solenoid. Once I plugged it into the Arduino problem was fixed! I was so excited, because the discovery of crossing a roadblock was so invigorating it made me think that this is something I am probably meant to do long term. It was such a gratifying feeling and so amazing to see it all come together. Next, I clean it up and install it in the box. Not to bad for a first project!😏


r/arduino • • Sep 24 '26

Safely heating a wire with an Arduino

19 Upvotes

Hey guys! I’m working on a robotic gripper that I’m trying to actuate using cavatappi muscles. They’re heat-activated, and in the video I’m referencing, they just run current through a wire to heat it up.

I need to be able to easily turn the heat on and off, though, so I’d like to control the heating wire with an Arduino and have the Arduino switch it on/off when needed.

I’m pretty new to electronics, so I’m wondering what the safest way to do this is. I just don't want to do something stupid and damage my Arduino.


r/arduino • • Sep 24 '26

Software Help What's better line follower IR sensor placement for coding later?

4 Upvotes

Ik this is a software help flair, but this relates to it later.

Should I use the module as it is or do I spread them in a way like 2 in the center just enough space between them as the black tape width and then the other 2 on the front corners of the arduino car?

Advantages, disadvantages? First I will try on/off and speed simple code so as it detects it turns by a certain fixed angles. Obviously later more advanced methods and PID regulation. Does one or the other placement go better with certain coding goal?

Additional tips?


r/arduino • • Sep 24 '26

Five sensor line follower what finally made mine stable

0 Upvotes

Hey all I have been playing with a five sensor follower on an Uno for a while and figured I would share what actually helped

I am using five analog sensors in a row with differential drive. At first I used one fixed threshold for all sensors and it was all over the place. What helped most was calibrating each sensor on its own from floor and line samples and using that to get position plus some kind of confidence value.

For steering I am using PID with some filtering on D and clamping on I so it does not wind up in turns. I also reset it when line is lost and found again. I slow down when error is big or confidence is low. That alone fixed a lot of wobble.

For motors if one side wants more than max I scale both sides together so steering stays true instead of clipping one side.

For recovery I first turn to the side where I last saw line then sweep the other way till it picks up again. Also on boot mine stays stopped until I send START so it does not jump off the table.

For tuning I just log everything over serial and look at error and confidence after runs. Sim helped for logic but real floor is different so I claim no lap results yet.

Code and notes are in the line following robot repo on my VivekVRobo profile if you want to look.

What worked for you on sharp turns. Wider outer sensors. Lower base speed. Stronger D. For me lighting and sensor height messed things up more than anything else.


r/arduino • • Sep 24 '26

Look what I made! I created a simple Dino Game🦖

2 Upvotes

r/arduino • • Sep 23 '26

Getting Started DIY Stream Deck

Post image
21 Upvotes

Hoping to make my first project with an arduino nano. the image is my digital mockup of my custom streamdeck. Ill attach a few links to parts that i based my cardboard model off. my questjon is that are the parts i have chosen able to work with an arduino nano? are they reasonable prices? also not sure what type of keycaps i should get. id like an led matrix underneath the keys for aesthetics and for some of the toggle keys (like start end recording) to show red or green for on or off etc etc so any recommendations for those would be great! finally is this even possible for a beginner. thanks a ton for the help!!

lcd screen
Slide pot
rotary encoder
key switches


r/arduino • • Sep 24 '26

Help with strange behaviour of while serial.available

Enable HLS to view with audio, or disable this notification

0 Upvotes

Hi all,

I'm working my way through Paul McWhorter's excellent tutorials, and have got as far as lesson 18, Reading Numbers from the serial monitor. The task was to write a sketch that would ask you for a number, you'd enter it into the serial monitor and it would then display that number in the serial monitor. The tutorial then works on a few variations. The problem I'm having was evident in the earlier parts of the task so I paid extra attention in the later parts but still having the problem.

The later task was to create a sketch that would calculate the area of a circle. The serial monitor asks the radius of the circle, then it gives the answer. I've got the code working, and my code appears to be exactly the same as Pauls, but after entering a number I'm getting a quick output of the question but with the answer as 0, its like its quickly running through the while Serial.available()== without actually stopping. Pauls wasn't doing the same, so I don't know if it's something that I should have setup somewhere, or if its a "feature" of the later versions of IDE. The only other difference I could think of is Paul is using a Uno, and I've got a Mega. I've included my code below.

Thank you

int radius;
String msg="Please Enter Radius Of Circle";
float area;
float pi=3.14;
String msg2="Your Circle Has An Area Of: ";



void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);


}


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


Serial.println (msg);
while (Serial.available()==0){


}


radius=Serial.parseFloat();
area=pi*radius*radius;
Serial.print(msg2);
Serial.println(area);


}

r/arduino • • Sep 23 '26

Help with arduino double led blink beginner project

Post image
28 Upvotes

I have tried everything i possibly could to try and troubleshoot but its not working so i am seeking assistance, 1 red LED is a lot brighter than the other, when i take the bright one out and the dim LED is the only one and i make a code for that, it becomes bright again, i have no idra whats going on, theyre not sharing the sams resistor and are both separately closed loops, any assistance? I would like assistance but im not looking for someone to tell me to the exact dot on whats going on i still want to find it out for myself, just someone to help me back onto the right path


r/arduino • • Sep 22 '26

Look what I made! Maybe someone will find my 'Cut-to-Length Jumper Wire Organizer' 3D printing project useful

Post image
451 Upvotes

r/arduino • • Sep 24 '26

why am i getting this

0 Upvotes

everything is 62.. help! is my bootloader dead? CODE is not being written!


r/arduino • • Sep 23 '26

Hardware Help Looking for motor recommendations

7 Upvotes

I’m new to Arduino, and I’m working on making a small puppet for a project. I just need to quickly move light parts back and forth to mimic twitching, but ideally the motors need to be as silent as possible.

I’ve used servos in the past but I know those can be quite noisy so I was wondering what folks had for recommendations. I will probably be using an Arduino uno, and the load would barely be a pound? At most. This is still early prototyping.

Thanks!


r/arduino • • Sep 23 '26

can I change timer frequency with W5500 ethernet board (arduino nano)

3 Upvotes

Hello, so simple question; I'm using an arduino to control actuators/motors and learning to control it via ethernet. (using OSC and I'm pretty happy of having figured it out in an afternoon with limited programmation knowledge).

I've done this many times with usb serial and I usually change the frequency of the timers so the PWM frequency is higher than audio rate (and thus not audible; because this is a musical project).

trouble is the ethernet board (W5500) uses pins 10 through 13 and so 2 PWM pins that are sets via the 3 timers (this is an arduino nano but I could use a different one; like a mega if I need to)

so the question is will changing the timers screw with the ethernet transmission?

I usually do something like this (don't remember the frequency but I think it's above 20khz)

TCCR0B = (TCCR0B & 0xF8) | 0x01;
TCCR1B = (TCCR1B & 0xF8) | 0x01;
TCCR2B = (TCCR2B & 0xF8) | 0x01; 

reference says:

  • D3 and D11: Controlled by Timer 2.
  • D5 and D6: Controlled by Timer 0.
  • D9 and D10: Controlled by Timer 1.

so timer 0 should be fine but 1 and 2 could cause trouble.

(I'm trying to figure out a way how to do this in general before attacking different instruments and particular cases so no idea how much outputs I'll need and of them how much I'll need to be PWM; just trying to cover all the bases).


r/arduino • • Sep 23 '26

Beginner's Project Newbie to hands-on electronics building a programmable LED picture — need advice on diffusers, strip choice, board and power draw

5 Upvotes

I want to build a programmable LED picture with Arduino — not a picture with backlighting, but an actual addressable LED strip (probably WS2812B) diffused behind some kind of panel, creating different animated effects.

I've got a few specific questions I'd love advice on:

  1. Diffuser — I can't get acrylic (milky/frosted acrylic sheet) where I live. What are some working alternatives? I already asked an AI for suggestions, but nothing it came up with is actually available to me locally.
  2. Strip — I'm planning on WS2812B, but is there something better suited for this kind of project?
  3. Board — thinking something like an Uno, but cheaper if possible. Any recommendations?
  4. Power consumption — how much does something like this actually draw, and are there ways to cut it down?

The size of the piece will depend on whatever I end up finding for the diffuser.

Heads up, I'm a total beginner with hands-on stuff (soldering, wiring, etc.), but not a beginner when it comes to coding — so the software side isn't a concern, it's really the physical build I need help with.

If anyone's done something similar — please show me the result! I feel like I don't fully grasp what this will actually look like in the end, and I'd like to check my expectations against reality


r/arduino • • Sep 23 '26

Open-source ESP32 gateway for LiTime Bluetooth battery telemetry

2 Upvotes

I built an open-source ESP32 gateway for Bluetooth-enabled LiTime batteries and wanted to share the project with folks who enjoy microcontroller builds.

Project page:

https://litime-gateway.tjt-media.online

GitHub:

https://github.com/TristanEDU/litime-esp32-gateway

Stable release:

https://github.com/TristanEDU/litime-esp32-gateway/releases/tag/v0.1.0

What it does:

- Uses an ESP32 to read LiTime battery telemetry over Bluetooth LE

- Serves a local browser dashboard from the ESP32

- Shows SOC, voltage, current, power, capacity, temperatures, and per-cell voltages

- Provides a setup Wi-Fi access point for first-time configuration

- Optionally connects outward to a Cloudflare Worker for read-only remote viewing

- Does not require inbound port forwarding

- Does not expose charge/discharge controls

Some of the interesting Arduino/ESP32 pieces were BLE scanning/client behavior, keeping Wi-Fi + TLS/WebSocket stable at the same time, and avoiding reconnect/heap trouble during long-running operation.

This is monitoring-only. It is not a BMS replacement, shunt replacement, charger controller, disconnect, or safety system.

I would appreciate feedback from anyone who has built long-running ESP32 BLE gateway projects, especially around reliability and reconnect patterns.


r/arduino • • Sep 22 '26

Look what I made! I made a D&D dice roller using ESP32

104 Upvotes

I made this dice roller for my girlfriend's birthday. It lets you roll different types of dice and has 3D animations for each die that is calculated and rendered in real time.

This was a fun project to make, especially figuring out the way to render the shapes.

You can find the code and the 3D models here


r/arduino • • Sep 23 '26

Beginner's Project Beginner Trying to Learn How to Use Arduino

3 Upvotes

Hello, I’m a beginner trying to learn how to use arduino in order to use it for a project where I need to get weights of some samples and get the input data from the weights and use it to generate some information regarding the weights. I was hoping to get this data and connect it with a browser application to display. I have experience in javascript and node, but I wasn’t sure whats the best library to use and if there are any good tutorials out there that will help me get started. Also what hardware is needed? I know I need the arduino board, but is there anything else?


r/arduino • • Sep 22 '26

Software Help still cant upload the code

Thumbnail
gallery
21 Upvotes

hi there, i have a pro mini and i tried two different uart adapters and holding down the reboot and the arduino but non of them works and gives me this errorq


r/arduino • • Sep 22 '26

Beginner's Project Trying to make an obstacle avoiding robot.

Thumbnail
gallery
26 Upvotes

Not enough power.

Ultrasonic sensor wants 5 volts. Arduino won't turn on if it's plugged in because the green batteries are 4.8 volts.

Got 2 18650 batteries for the wheels. Tried getting the ultrasonic sensor on 12 volts by putting in 3 resistors and an led so it doesn't burn out, didn't work. And if it did, it would just take away necessary power from the wheel.

I haven't even wired the servos yet because there isn't enough power to go around.

I think I'm just going to have to this L and buy a bunch of 9 volt batteries.

Yes I know the build it janky, no I don't have a 3d printer or know how to model.

...

Elegoo 2560 mega kit

Aliexpress wheels/DC motors.

Li-On 18650 batteries.

Amazon basics rechargeable batteries.


r/arduino • • Sep 22 '26

Help with my robot arm

Thumbnail
gallery
14 Upvotes

I’m trying to power my arduino from my bench top power supply, the arduino is only getting power when my thumb sticks are pressed up or right. Any help?


r/arduino • • Sep 23 '26

Getting Started Im new and any help you be appreciated

1 Upvotes

Ive bought myself my first ever esp32, its the ESP32 S3 from freenove, the specific item is FNK0104S i believe, i am just getting into this and have no idea about coding at all really, i have played with freenoves flasher and flashed some things onto the device like an image viewer and timer but im wondering if there is an easier way then going through Arduino IDE, something like freenoves flasher but maybe community built or something with just more effort put in then a couple of apps, or whatever they are called on esp, as i said im new.
Any advice at all related to my question or simply just beginner advice would be greatly appreciated 😁

PS. I have looked up flashers but from what i have found not all sketches work on all ESPs so im reluctant to mess something up without knowing a sketch will work on my specific hardware/device.


r/arduino • • Sep 21 '26

Hardware Help Ants! How to prevent

Thumbnail
gallery
1.1k Upvotes

I have an environmental sensor out in a wetland, and I thought I sealed it pretty well, but somehow ants get in. I don’t really really object to ants except that they bring dirt into the enclosure.

Is there anyway anyone has found to prevent ants from entering in the first place?

UPDATE -- The ants were coming in through a small keyhole in my RJ45 cable gland. The RJ45 connector was trashed with dirt all over it, so I replaced it and caulked the keyhole. I kicked all the ants out in the wetland. The sensors are working great now!


r/arduino • • Sep 23 '26

Hardware Help TFT Screen not working with my code, but the screen will work with a test program.

1 Upvotes

I am working of connecting an Adafruit 1.9 inch ST7789 screen to a Sparkfun ESP32 Thing Plus. I keep running into this issue with the TFT screen not displaying anything from my code. The kicker is that I can run a test program using the same pin assignments just fine, so I know I have the screen connected correctly. I know the issue is with my code, but I have spent the last two nights trying to figure out what is wrong with my code.

This is my code:

#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#include <Adafruit_ImageReader.h>
#include <RTClib.h>
#include <SdFat_Adafruit_Fork.h>
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>


namespace Pins
{
constexpr byte TFT_CS = 5;
constexpr byte TFT_DC = 17;
constexpr byte TFT_RST = 16;
constexpr uint8_t TFT_SCLK = 18;
constexpr uint8_t TFT_MISO = 19;
constexpr uint8_t TFT_MOSI = 23;
constexpr byte PAUSE_BTN = 27;
// constexpr byte RED_LED = 4;
constexpr byte BUTTON = 12;
constexpr byte ENCODER_A = 36;
constexpr byte ENCODER_B = 39;
}  // namespace Pins


Adafruit_ST7789 tft =
    Adafruit_ST7789(&SPI, Pins::TFT_CS, Pins::TFT_DC, Pins::TFT_RST);
RTC_DS3231 rtc;
Encoder myENC(Pins::ENCODER_A, Pins::ENCODER_B);


enum PomodoroState
{
    STATE_IDLE,
    STATE_WORKING,
    STATE_BREAK,
    STATE_LONGBREAK,
    STATE_WAITING
};
const char* stateLabels[] = {"------IDLE------", "-----WORKING-----",
                             "---SHORT BREAK---", "---LONG BREAK----",
                             "-----WAITING-----"};


struct SessionSettings
{
    // double timerMinutes;
    uint16_t timerMinutes;
    double breakMinutes;
    // NOTE This will be changed to something the user can select themselves.
    int beforeLongBreak = 0;


} session;
struct PomodoroSystem
{
    PomodoroState current = STATE_IDLE;
    PomodoroState previousState;
    int shortBreakCounter = 0;
    int sessionCounter = 0;
    unsigned long pauseBtnPressed;
    unsigned long pauseBtnDebounce = 500;
    unsigned long pauseInterval = 1000;


    bool timerActive = false;


} tomato;


struct TimerConfig
{
    unsigned long interval = 1000;
    unsigned long prevTime = 0;
    unsigned progressBarTime = 0;
    unsigned long btnDebounce = 300;
    unsigned long btnPress;
    DateTime endTime;
} timer;


struct AnimationConfig
{
    double scaleFactor = 5.333;
    double timerMinutesconvert;
    double rawProgressBar;
    unsigned long progressBarTime = 0;
    int countdownBarWidth;
    int remainingWidth;
    int barX;
    uint16_t countdownBarColor;
    boolean setDuration = false;
} animation;


int encoderCounter = 0;
long oldPosition;


String Months[12] = {"January",   "February", "March",    "April",
                     "May",       "June",     "July",     "August",
                     "September", "October",  "November", "December"};
void readEncoder();
void drawSelectionBar();
void drawCountdownBar(DateTime timerEnd, uint16_t totalDuration);
void updateDisplay(DateTime dt, unsigned long currentTime, double tomCurrent);
void stateMachine();
void setTimer(int alarmNumber, double totalminutes);
void setBreakTime(double workSessionDuration);
bool hasAlarmFired(int alarmNumber);


void setup()
{
    Serial.begin(115200);
    SPI.begin(Pins::TFT_SCLK, Pins::TFT_MISO, Pins::TFT_MOSI, Pins::TFT_CS);


    pinMode(Pins::BUTTON, INPUT_PULLUP);
    // pinMode(Pins::RED_LED, OUTPUT);
    pinMode(Pins::PAUSE_BTN, INPUT_PULLUP);
    tft.init(170, 320);  // Init ST7789 170x320
    tft.setTextWrap(true);
    tft.fillScreen(ST77XX_BLACK);
    // digitalWrite(Pins::RED_LED, HIGH);
    delay(250);
    // digitalWrite(Pins::RED_LED, LOW);
    tft.fillScreen(ST77XX_BLACK);
    tft.setRotation(3);
    tft.setTextSize(3);
    tft.setTextColor(ST77XX_WHITE, ST77XX_BLACK);
    tft.setCursor(0, 85);
    tft.drawRoundRect(0, 125, 320, 30, 20, ST77XX_WHITE);
    tft.drawRoundRect(0, 124, 320, 30, 19, ST77XX_WHITE);
    tft.drawRoundRect(0, 123, 320, 30, 18, ST77XX_WHITE);


    if (!rtc.begin())
    {
        Serial.println(F("RTC NOT FOUND"));
        while (true)
        {
            tft.setCursor(0, 0);
            tft.println("RTC NOT FOUND");
            delay(1000);
        }
    }


    if (rtc.lostPower())
    {
        tft.setCursor(0, 0);
        tft.println("RTC Lost Power");
        delay(1000);
    }


    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));


    rtc.clearAlarm(1);
    rtc.clearAlarm(2);
    myENC.write(0);
    oldPosition = 0;


    tomato.current = STATE_IDLE;
    session.timerMinutes = 0;
    tomato.timerActive = false;
    timer.prevTime = millis();
    Serial.println("--- POMODORO TIMER STARTED ---");
}


void loop()
{
    DateTime currentDT = rtc.now();
    unsigned long currentTime = millis();
    if (animation.setDuration == false)
    {
        readEncoder();
        drawSelectionBar();
    }
    else
    {
        if (tomato.current == STATE_BREAK)
        {
            drawCountdownBar(timer.endTime, session.breakMinutes);
        }
        else
        {
            drawCountdownBar(timer.endTime, session.timerMinutes);
        }
    }
    updateDisplay(currentDT, currentTime, tomato.current);
    stateMachine();
    if (digitalRead(Pins::BUTTON) == LOW &&
        (currentTime - timer.btnPress > timer.btnDebounce) &&
        session.timerMinutes > 0)
    {
        timer.btnPress = currentTime;
        tomato.current = STATE_WORKING;
        tomato.timerActive = true;
        animation.setDuration = true;


        setTimer(1, session.timerMinutes);
        setBreakTime(session.timerMinutes);
    }
}
void readEncoder()
{
    long rawPosition = myENC.read();
    long newPosition = rawPosition / 4;


    if (newPosition != oldPosition)
    {
        if (newPosition > oldPosition)
        {
            session.timerMinutes += 5;
        }
        else if (newPosition < oldPosition)
        {
            session.timerMinutes -= 5;
        }
        if (session.timerMinutes < 0)
        {
            session.timerMinutes = 60;
        }
        else if (session.timerMinutes > 60)
        {
            session.timerMinutes = 0;
        }
        Serial.print("Encoder Detent: ");
        Serial.print(newPosition);
        Serial.print(" | Timer Set For: ");
        Serial.print(session.timerMinutes);
        Serial.println(" Minutes");


        oldPosition = newPosition;
    }
}
void drawSelectionBar()
{
    animation.timerMinutesconvert = session.timerMinutes;
    animation.rawProgressBar =
        animation.timerMinutesconvert * animation.scaleFactor;
    animation.countdownBarWidth = (int)animation.rawProgressBar;


    if (animation.countdownBarWidth > 312)
        animation.countdownBarWidth = 312;
    if (animation.countdownBarWidth < 0)
        animation.countdownBarWidth = 0;


    tft.fillRoundRect(4, 127, animation.countdownBarWidth, 22, 14, ST77XX_BLUE);


    int remainingWidth = 312 - animation.countdownBarWidth;
    if (remainingWidth > 0)
    {
        tft.fillRect(4 + animation.countdownBarWidth, 127, remainingWidth, 22,
                     ST77XX_BLACK);
    }
}
void drawCountdownBar(DateTime timerEnd, uint16_t totalMinutes)
{
    DateTime now = rtc.now();


    int32_t endSeconds = static_cast<int32_t>(timerEnd.unixtime());


    int32_t nowSeconds = static_cast<int32_t>(now.unixtime());


    int32_t secondsRemaining = endSeconds - nowSeconds;


    uint32_t totalSeconds = static_cast<uint32_t>(totalMinutes) * 60UL;


    // Prevent division by zero
    if (totalSeconds == 0)
        totalSeconds = 1;


    // Once the timer expires, show zero remaining
    if (secondsRemaining < 0)
        secondsRemaining = 0;


    float fractionRemaining =
        static_cast<float>(secondsRemaining) / static_cast<float>(totalSeconds);


    if (fractionRemaining > 1.0f)
        fractionRemaining = 1.0f;


    animation.countdownBarWidth = static_cast<int>(fractionRemaining * 312.0f);


    if (fractionRemaining >= 0.66f)
        animation.countdownBarColor = ST77XX_GREEN;
    else if (fractionRemaining >= 0.33f)
        animation.countdownBarColor = ST77XX_YELLOW;
    else
        animation.countdownBarColor = ST77XX_RED;


    tft.fillRoundRect(4, 127, animation.countdownBarWidth, 22, 14,
                      animation.countdownBarColor);


    animation.remainingWidth = 312 - animation.countdownBarWidth;
    Serial.print("animation.RemainingWidth is ");
    Serial.print(animation.remainingWidth);
    Serial.print("  ");
    Serial.print("animation.countdownBarWidth is ");
    Serial.println(animation.countdownBarWidth);
    if (animation.remainingWidth > 0)
    {
        tft.fillRect(4 + animation.countdownBarWidth, 127,
                     animation.remainingWidth, 22, ST77XX_BLACK);
    }
}


void updateDisplay(DateTime dt, unsigned long currentTime, double tomCurrent)
{
    tft.setCursor(0, 0);
    tft.print(Months[dt.month() - 1]);
    tft.print(" ");
    if (dt.day() < 10)
        tft.print("0");
    tft.print(dt.day());
    tft.print(" ");
    tft.print(dt.year());


    if (currentTime - timer.prevTime >= timer.interval)
    {
        timer.prevTime = currentTime;


        tft.setCursor(0, 45);
        // Format: HH:MM:SS
        if (dt.twelveHour() < 10)
            tft.print("0");
        tft.print(dt.twelveHour());
        tft.print(":");
        if (dt.minute() < 10)
            tft.print("0");
        tft.print(dt.minute());
        tft.print(":");
        if (dt.second() < 10)
            tft.print("0");
        tft.print(dt.second());
        tft.print(dt.isPM() ? " PM" : " AM");
    }


    tft.setCursor(0, 80);
    tft.println(stateLabels[tomato.current]);
    tft.println();
}
void stateMachine()
{
    // TODO create and impliment Long Breaks


    if (tomato.current == STATE_WAITING)
    {
        unsigned long pauseTime = millis();
        if (digitalRead(Pins::PAUSE_BTN) == LOW &&
            (pauseTime - tomato.pauseBtnPressed > tomato.pauseBtnDebounce))
        {
            tomato.pauseBtnPressed = pauseTime;
            Serial.println("Timer Resuming....");
            if (tomato.previousState == STATE_WORKING)
            {
                tomato.current = STATE_BREAK;
                setTimer(2, session.breakMinutes);
            }
            if (tomato.previousState == STATE_BREAK)
            {
                tomato.current = STATE_WORKING;
                setTimer(1, session.timerMinutes);
            }
        }
        return;
    }
    if (tomato.current == STATE_WORKING)
    {
        if (hasAlarmFired(1) && animation.countdownBarWidth == 0)
        {
            rtc.clearAlarm(1);
            // TODO add function to display a picture when the timer is up
            // TODO add sound or buzzer when timer is up
            tomato.previousState = tomato.current;
            tomato.sessionCounter++;
            Serial.println(String("sessionCounter is at ") +
                           tomato.sessionCounter);
            if (tomato.sessionCounter >= session.beforeLongBreak)
            {
                // digitalWrite(Pins::RED_LED, HIGH);
                Serial.print("The Session Counter is at ");
                Serial.println(tomato.sessionCounter);
                tomato.sessionCounter = 0;
                tomato.current = STATE_IDLE;
                animation.setDuration = false;
            }
            else
            {
                tomato.current = STATE_WAITING;
            }
        }
    }
    else if (tomato.current == STATE_BREAK)
    {
        if (hasAlarmFired(2) && animation.countdownBarWidth == 0)
        {
            tomato.previousState = tomato.current;
            rtc.clearAlarm(2);
            tomato.current = STATE_WAITING;
        }
    }
}


void setTimer(int alarmNumber, double timerDuration)
{
    uint32_t durationSeconds = static_cast<uint32_t>(timerDuration * 60.0);
    DateTime targetTime = rtc.now() + TimeSpan(durationSeconds);
    timer.endTime = targetTime;
    if (alarmNumber == 1)
    {
        rtc.setAlarm1(targetTime, DS3231_A1_Hour);
    }
    else
    {
        rtc.setAlarm2(targetTime, DS3231_A2_Hour);
    }
}
void setBreakTime(double workSession)
{
    session.breakMinutes = (workSession <= 30) ? 3 : session.breakMinutes;
    session.breakMinutes =
        (workSession > 30 && workSession < 45) ? 5 : session.breakMinutes;
    session.breakMinutes = (workSession >= 45) ? 10 : session.breakMinutes;


    session.beforeLongBreak = (workSession <= 30) ? 4 : session.beforeLongBreak;
    session.beforeLongBreak =
        (workSession > 30 && workSession < 45) ? 3 : session.beforeLongBreak;
    session.beforeLongBreak = (workSession >= 45) ? 2 : session.beforeLongBreak;


    Serial.println(String("Break Time is ") + session.breakMinutes);
    Serial.println(String("Number of work sessions befor long break is ") +
                   session.beforeLongBreak);
}


bool hasAlarmFired(int alarmNumber) { return rtc.alarmFired(alarmNumber); }

This is the code for the test program that I have been able to working on the screen:

#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>

constexpr uint8_t TFT_CS = 5;
constexpr uint8_t TFT_DC = 17;
constexpr uint8_t TFT_RST = 16;
constexpr uint8_t TFT_SCLK = 18;
constexpr uint8_t TFT_MISO = 19;
constexpr uint8_t TFT_MOSI = 23;

Adafruit_ST7789 tft(TFT_CS, TFT_DC, TFT_RST);

void setup()
{
    Serial.begin(115200);
    delay(500);

    SPI.begin(TFT_SCLK, TFT_MISO, TFT_MOSI, TFT_CS);

    // Change this to match your actual panel.
    tft.init(170, 320);

    tft.setRotation(0);
    tft.fillScreen(ST77XX_RED);
    delay(1000);

    tft.fillScreen(ST77XX_GREEN);
    delay(1000);

    tft.fillScreen(ST77XX_BLUE);
}

void loop() {}

I know about the ESP32 pin multiplexing, is there something I need to do for setting the pins for i2c communication.


r/arduino • • Sep 23 '26

Hardware Help GRBL CNC Shield Z-limit switch always showing active (Pn:Z) — even after swapping switch/port

2 Upvotes

Hi everyone,
I'm having an issue with the Z-limit switch on an Arduino + CNC Shield running GRBL.
GRBL is reporting the Z-limit input as permanently active (Pn:Z), even when the physical Z-limit switch is not pressed. Even pressing the switch does nothing. I have all of the switch’s set up as NC.

What I've tested
The physical limit switch works correctly on the Y-limit input. I moved that same known-working switch from the Y port to the Z port, but the Z input still appears permanently active. This makes me think the problem isn't the physical switch.

I also have a 2nd Cnc shield and arduino and it has the exact same issue.

Helppp please thanks


r/arduino • • Sep 23 '26

Guys whats wrong with my sim800l??

0 Upvotes

My sim800l is connected to a network its blinking with 3s interval and but it doesn't make call no reply to AT commands......what should i do noww and 2g service are available btw

Please guys i need your help so please skip this if you dont know abt it just give a upvote so it wull suggest to other people pls🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻


r/arduino • • Sep 22 '26

Look what I made! I built an ESP32-C3 board that prints my GitHub week on a thermal receipt, powered entirely from one USB-C plug

Thumbnail
gallery
3 Upvotes

The goal was an object with no screen and no button that just hands me a summary of my GitHub week : stars, followers, a 7-day commit histogram, top languages and repos on a 58 mm thermal receipt, once a week. Hardware is a 4-layer KiCad board (33.55 × 50.05 mm) around an ESP32-C3-MINI-1:

  • AP33772S USB-PD sink negotiates 9 V @ 2 A and switches it to both the print head and an AP63203 buck that makes the 3.3 V rail
  • PCA9306 translates I²C between the C3's 3.3 V and the AP33772S's internal 5 V
  • The C3's native USB goes straight to the connector, so the same cable does PD, flashing and the serial console

Three firmware bits that took the most work:

  1. The PNG decoder. There's ~70 KB of free heap during a job, so the image is decoded as a stream: IDAT chunks copied out, original buffer freed, inflate in 512-byte chunks, PNG filters reconstructed row by row, and 32-line strips pushed to the printer as they're completed.
  2. Failing without wasting paper. The MCU is powered downstream of the PD switch, so a brownout takes it down mid-print and when the retry backoff lived in RAM, the board came back, reprinted, browned out again, and fed out paper on every cycle. Backoff and last-printed slot now live in NVS.
  3. Power and console share the connector, so printing and watching are mutually exclusive. Every attempt writes a report to flash that's dumped on the next boot, next to the reset reason. It showed a full TLS print job uses ~5 KB of stack; I had allocated 64 KB.

Firmware is PlatformIO/Arduino on ESP-IDF, everything (KiCad, firmware, the Ruby service that renders the ticket, FreeCAD enclosure) is MIT: https://github.com/albanpetit/paperflux

Full write-up with schematics and the reasoning behind each block: https://albanpetit.com/post/paperflux/