/r/arduino

Photograph via snooOG

An unofficial place for all things Arduino!

We all learned this stuff from some kind stranger on the internet. Bring us your Arduino questions or help answer something you might know! 😉

/r/arduino

669,084 Subscribers

1

Sync D1 Mini (ESP8266) with MS Teams Status

Hello :)

Im doing a project for work: I want to make a sign for our office that automatically activates, when our daily meeting starts and turns off when it ends. Im using a D1 Mini and already made it, so i can manually turn the LED on the breadboard on and off via WiFi. Does anyone have some advice for me? (its my first programming project ever)

0 Comments
2024/10/21
12:52 UTC

1

Can I burn bootloader to atmega328 chip with MCP2515 connected?

https://preview.redd.it/zaihnozx33wd1.png?width=1282&format=png&auto=webp&s=2b8324069b4c7cb154da046401c2b234b6b715e4

Hello, I am designing this circuit for a diy smart servo board. i am planning to solder everything to one PCB. If i do it like this i would have to burn the bootloader to the Atmega328 via the SPI pins with the MCP2515 connected to the same pins. My question is could i burn the bootloader to the Atmega without damaging the MCP2515?

2 Comments
2024/10/21
10:15 UTC

1

Burned USB controller of laptop?

Hi all, I was working with some Arduino stuffs and I think I screwed up, because at some point all the USB port of my laptop have gone out.

I was trying to control a servo motor (MG996 360°) with a NodeMCU v3 board.

The NodeMCU was connected to one of the USB ports of the laptop, and the servo took 5V from the VU pin (the pin that provide power directly from USB of the board) of the NodeMCU.

But the problem it's that I have then connected the ground of the servo to another board: an Arduino Mega 2560 connected throught USB to the same laptop.

That because I was trying the servo first with Mega board and then with NodeMCU and at some point I found myself in this situation without thinking.

Initially did not seem to cause any problems, but at some point all the USB ports of the laptop have gone out (the laptop instead did not power off) and now, even after a reboot, USB ports don't even provide power, completely dead.

It's possible that I have burned the USB controller of the laptop?

3 Comments
2024/10/21
09:05 UTC

2

Macro keyboard with secured password?

Please bear with me; I never programmed Arduino before, but willing to learn... I am currently conceptualising a macro keyboard which can also writeout a password. To make it secure enough, I'll need a fingerprint reader so I can do something like "if fingerprint OK then writeout 'Pa$$W0rd' ". But I need it also to keep the program non-readable. I read something about lock bits; would these make this possible? It's okay to rewrite the sketch, but it should be impossible to unplug the keyboard and read/disassemble the embedded code.

Is this possible with Arduino?

1 Comment
2024/10/21
08:12 UTC

1

How to output a variable but fairly low AC voltage/current?

Working on a project that needs to replicate an AC sensor's output, which provides 0-200mV AC (60 Hz). The load on this sensor would be 2 Ohms which means the current will range from 0-100 mA AC. The basic plan is to use one Arduino to read the sensor and make the value available over a local network, then a second board will replicate that sensor voltage out to the equipment to which the sensor would normally be directly connected.

From what I can tell, the current to be supplied by the second board exceeds the maximum current limit for most Arduino boards themselves so external components will be needed. But I'm having trouble identifying an out-of-the-box component that will supply that much AC current, that little voltage, and also be controllable from an Arduino board. Any suggestions on components that might work or how to do this? Any help would be appreciated, thanks.

2 Comments
2024/10/21
05:07 UTC

1

PN MOSFET

Hi,

I’m looking for an N-MOS that I can control with my ESP32. I’m using a IRLZ44N, but the drain-to-source voltage doesn’t fully pass through.

2 Comments
2024/10/21
01:51 UTC

2

why my screen is not working?

These are the connections I have made to my screen but I don't know why it doesn't show any message. I only have a breadboard, an Arduino Uno board and an LCD screen. The model and program are Arduino 1.8.0 and the screen had already worked before. What can I do?

https://preview.redd.it/4x4mmznze0wd1.png?width=921&format=png&auto=webp&s=10e00a7e3d20cd64af736463fca777e2d8bd0478

https://preview.redd.it/cx1kque0f0wd1.png?width=495&format=png&auto=webp&s=9e72fd9bca9c7b3b9d90695d13e3d5ed43126842

6 Comments
2024/10/21
01:09 UTC

2

LED Matrix Power/Memory

I am working on cobbling together a marquee to fit a very specific-sized area. I was able to work out that I can connect eight MAX7219 8-in-one modules and two MAX7219 4-in-one modules together in a rectangle to fit the space precisely. Attached is a crude diagram of the resulting Matrix collection (drawn vertically).

Regarding power supply, what sort of external power supply would be required to run this?

How much memory would likely be needed to drive this? Would an Arduino Uno suffice, or do I need something beefier?

Here are the 8-in-one modules I am using: https://www.amazon.com/dp/B0BXDNCVRT?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1

Here are the 4-in-one modules I am using: https://www.amazon.com/dp/B07FFV537V?ref=ppx_yo2ov_dt_b_fed_asin_title

5 Comments
2024/10/20
23:57 UTC

1

Audio Amp Suggestions?

I've had very little experience with Arduino, but I've decided to learn as I go and do a DIY project to make a custom display for a collectible of mine, complete with LEDs and music.

What is the best audio amp chip for this purpose? I’ve come across the LM386, which seems popular, but I'm open to other suggestions. Ideally, I'd like something that can drive a CE38MB-32 speaker, which has a 32-ohm impedance.

Any recommendations or advice would be greatly appreciated!

3 Comments
2024/10/20
21:40 UTC

2

ESP32 crashing due to pinMode() and FastLED

Hey,

I'm trying to create a project using FastLED and Arduino but I'm getting stuck by trying to set it up.
The set up is realy simple but when I include the FastLED library and set up a button with pinMode() then the ESP gets in a bootloop. I'm using FastLED instead of NeoPixel because I want to control a lot of LEDs and my ESP can't handel that. But it does work for FastLED.

Microcontroller: ESP32-S3-Wroom1
IDE: ArduinoIDE
Arduino Board: ESP32S3 Dev Module
ESP board library: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
FastLED version: 3.7.8

Check the following code that I'm curently trying out:

#include <FastLED.h>

#define LED_PIN     18  // Try a different pin for LED data
#define BUTTON_PIN  21  // Use GPIO 21 for the button

#define NUMPIXELS   256
#define BRIGHTNESS  20

CRGB leds[NUMPIXELS];

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

  // Set pinMode before FastLED setup
  pinMode(BUTTON_PIN, INPUT); // <---------------- It crashes here! But continues when removed.
  Serial.println("PinMode set for button.");

  // Initialize FastLED after pinMode
  FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUMPIXELS);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
  FastLED.show();
  Serial.println("FastLED initialized successfully.");
}

void loop() {
  leds[0] = CRGB::Red;
  FastLED.show();
  delay(1000);

  leds[0] = CRGB::Blue;
  FastLED.show();
  delay(1000);
}

This gives me the following error:

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403772b1
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x109c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xb50
load:0x403cc700,len:0x2fe4
entry 0x403c98ac
E (97) rmt(legacy): CONFLICT! driver_ng is not allowed to be used with the legacy driver

abort() was called at PC 0x4200698f on core 0

Backtrace: 0x40376c9e:0x3fceb200 0x4037b69d:0x3fceb220 0x40380b49:0x3fceb240 0x4200698f:0x3fceb2c0 0x4200b5b2:0x3fceb2e0 0x40376fa3:0x3fceb310 0x403cdb0e:0x3fceb340 0x403cdea5:0x3fceb380 0x403c9919:0x3fceb4b0 0x40045c01:0x3fceb570 0x40043ab6:0x3fceb6f0 0x40034c45:0x3fceb710

ELF file SHA256: 392e10711b065807

E (168) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
E (176) esp_core_dump_elf: Elf write init failed!
E (181) esp_core_dump_common: Core dump write failed with error=-1

If anyone would have a solution for me on how to fix this then I would be realy greatfull!

xxx
Rianne

2 Comments
2024/10/20
21:19 UTC

1

Stepper motor doesn't behave as it should according to code

Hello guys,

I am trying to move a stepper motor with a TB6600 controlling with a potentiometer-joystick. Depending on the value of potentiometer it will move in direction, the opposite direction or stay still.

I have done similar projects before, but this time the motor won't stay still unless I disable the enable pin but the motor will lose its position.

In my previous projects I used a different wiring ( Arduino's groundings to driver's grounding, and pins to driver's pins) but with this TB6600 I bought recently I can only make them work with this wiring

This is the wiring and the code I am using:

https://preview.redd.it/ukglaq86ryvd1.png?width=1163&format=png&auto=webp&s=7d94d09cf7fcdb59cdba8dc6369fba4aa0443387

#define BASE_STEP_PIN      1
#define BASE_DIR_PIN       4
#define BASE_ENABLE_PIN    7

int potPin = A0;  // Pin connected to the potentiometer (analog input)
int potValue = 0; // Variable to store the potentiometer value

void setup() {
  Serial.begin(9600);
  pinMode(BASE_STEP_PIN, OUTPUT);
  pinMode(BASE_DIR_PIN, OUTPUT);
  pinMode(BASE_DIR_PIN, OUTPUT);
  digitalWrite(BASE_ENABLE_PIN, HIGH);
}

void loop() {
  potValue = analogRead(potPin);
  Serial.print("Potentiometer Value: ");
  Serial.println(potValue);

  if(potValue < 100){
    Serial.println("----------------");
    digitalWrite(BASE_DIR_PIN , HIGH);    
    digitalWrite(BASE_STEP_PIN , HIGH);
    delay(20);
    digitalWrite(BASE_STEP_PIN , LOW);
    delay(20);
  }
  if(potValue > 800 ){
    Serial.println("+++++++++++++");
    digitalWrite(BASE_DIR_PIN , LOW);
    delay(20);
    digitalWrite(BASE_STEP_PIN , LOW);
    delay(20);
  }
  if(potValue < 800 && potValue > 100 ){ // I add this if for debbuging purpose since the motor doest stop moving
    Serial.println("000000000000000000");
    digitalWrite(BASE_STEP_PIN, LOW); //just in case, to be extra sure it doesnt activate 
    }
}
0 Comments
2024/10/20
19:56 UTC

0

IRLZ44N not switching

Hi, I'm trying to build an mqtt switch using an ESP32-01 as the client. The Esp32 01 runs on 3.3V solely so I tried to read up on Transistors.

Maybe a dumb decision, but in my defense I don't know a lot about transistors yet, so I asked chat gpt to recommend one for my circuit and it recommended the IRLZ44N

Now that the transistors arrived I tried to build a simple circuit esp01 gpio 0 is set as an output and will emit 3.3v (measured already and seems to work fine) that is connected to gate I tried putting a 1k resistor from the same breadboard lane to ground as a pulldown since I read the transitior can float otherwise. Drain is connected to the negative pole of a little light bulb and source is connected to both the esp01s ground as well as the 5v power supply's ground (said to do this in the data sheet of the IRLZ44N) the light bulbs plus pole is directly connected to the power supply's plus pole.

When I trigger the esps gpio 0 nothing visible happens. When I instead connect the power supply's 5v to the gate pin the lamp glows bright

Is 3.3v not sufficient to trigger the IRLZ44N?

My final goal is to use the esp01 to control a DC motor that takes 4.5v and maybe in the future other things that could take like 12v

7 Comments
2024/10/20
21:26 UTC

1

Does Serial.available() apply to external hardware?

I’m assuming it does since the documentation just mentions whatever is available on the “Serial port” but does that reference pin 11? Which is the MOSI pin on the arduino nano?

I’ve been looking for similar projects where the arduino is used as the slave peripheral but none of them actually use Serial.available nor do they really apply to my project.

2 Comments
2024/10/20
15:33 UTC

1

Can't connect HC-05 Master to ELM327

21:24:36.117 -> Command: AT+CLASS=0
21:24:36.117 ->
21:24:36.157 -> OK
21:24:39.960 -> Command: AT+INQ
21:24:39.960 ->
21:24:40.075 -> +INQ:AAC5:FF:187F58,10091C,FFC8
21:24:40.111 -> OK
21:25:54.819 -> Command: AT+PAIR=AAC5,FF,187F58,120
21:25:54.819 ->
21:25:54.819 -> ERROR:(5)

I'm trying to pair my HC-05 in master mode to HC-05, that's my MAC device for it, I find it on INQ, but I can't pair it, I'm trying this manually first, connection to HC-05 and AT mode is not an issue, I get that ERROR(5) inmmediatly which I don't know exactly what means. The OBD2 is working correctly I can connect it on my phone with no issues.

I've already tried this set of commands and keep getting the same issue:

The only command not working in her is AT+PAIR which returns ERROR(5)

    sendATCommand("AT");  
    sendATCommand("AT+CMODE=0");  
    sendATCommand("AT+ROLE=1");  
    sendATCommand("AT+RESET");  
    sendATCommand("AT+CLASS=0");  
    sendATCommand("AT+IAC?");     
    sendATCommand("AT+INQM=0,5,9");  
    sendATCommand("AT+INQ");  
    sendATCommand("AT+INIT");  
    sendATCommand("AT+PAIR=AAC5,FF,187F58,120");
    sendATCommand("AT+BIND=AAC5,FF,187F58");
    sendATCommand("AT+LINK=AAC5,FF,187F58");
    sendATCommand("AT+RESET"); 
0 Comments
2024/10/20
14:47 UTC

2

Weather proofing my LED arduino setup.

So I am making a sensor setup that lights follow you when you walk by for a friends work truck. He will be able to turn it on and the pir sensors notice him and the LED's light up where he is standing. My problem is how to best weatherproof my sensors without blocking the LED's. I saw some IP6K boxes but I can't find small ones any recommendations?

2 Comments
2024/10/20
20:17 UTC

0

18650 battery’s and Arduino (esp32)

I’m trying to power an ESP 32 with some spare 18650 is there a chip that has USB-C on it, can charge the batteries also output a steady voltage for the ESP 32.

0 Comments
2024/10/20
20:02 UTC

42

12v load timer.

Hi folks. I have a single solar panel connected to an mppt and a battery, the load is a small water pump. I want to control it and set a timer with my board. I was wondering if this circuit would help.

11 Comments
2024/10/20
19:16 UTC

0

Is there an e ink display for arduino?

Simple question: Is there an e ink display that works with arduino similar to those mini oled screens? Preferably SPI or I2C interface.

10 Comments
2024/10/20
13:50 UTC

1

Servo Jittering

Hey,

So I have 2 servos powered from a separate power supply(5v 2.4A, 12Watt) to the Arduino, but with common ground, but I'm still getting really bad servo jitter. When I used the crappy servo which came in one of those "first-timer Arduino kits" when I was testing the code it was fine, but when I tried these other hobby servos I could never get them to move smoothly.

I've included the GitHub repository I've just made for this post if you can point out where I'm going wrong.

Any comments/ suggestions are appreciated. However, I don't have a wiring diagram of the setup.

1 Comment
2024/10/20
12:38 UTC

1

Help with an LCD and LCDSmartie

Hi there,

I recently decided to build myself a little display to use with LCDSmartie, however I have this problem and I can't find a definitive answer.

When sending text from the Arduino IDE, it displays fine but when LCDSmartie is sending informations to the screen, every line is shifted and there is a "dead zone" on the bottom right that never clears up.

I am using an Arduino Uno and an LCD Display from AZ-Delivery that has been wired using this tutorial. LCDSmartie is set to use the matrix.dll library at 9600 bauds.

This is the code I used: https://pastebin.com/7hneGzKh

0 Comments
2024/10/20
13:05 UTC

2

Stepper Motor Not Working with A4988 Driver - Motor Won't Step

Hi everyone, I’m working on a basic stepper motor project using an A4988 driver and an ESP32-C3 (you can see the schematic attached). I’ve written code for stepping the motor, but when I plug the stepper motor into the A4988’s output pins (1A, 1B, 2A, 2B), the motor doesn’t move. Here’s what I’ve tried:

  • Wiring: I've wired the motor correctly (double-checked with a multimeter to identify the coils). I’ve also confirmed power connections to the motor and driver.
  • Code: The Arduino code is generating step pulses on pin 21 (STEP pin) and I’m toggling the DIR pin for direction. The EN pin is set to low to enable the motor. The step pulse is 50 microseconds.
  • Power: The driver is powered from 3.3V logic, and motor power is supplied through VBB, so I don’t think it’s a power issue.
  • Testing: I’m also using pin 8 (MIRROR_PIN) to mirror the step pulse, and this toggles correctly based on the code. Still, the motor doesn’t budge.

I suspect either the pulse timing or the driver settings might be wrong, but I can’t figure it out. Has anyone run into something similar? I’m also attaching the relevant part of my schematic and code for reference.

Any help or advice would be appreciated!

https://preview.redd.it/vc84t217kwvd1.png?width=886&format=png&auto=webp&s=0b965c6599dc7c29cd334c6c334441ecf4522536

https://preview.redd.it/tl143417kwvd1.png?width=789&format=png&auto=webp&s=ba0701ae5dde98a33924083b19552c0d07a8ff4c

https://preview.redd.it/m2dq9317kwvd1.png?width=1018&format=png&auto=webp&s=5e3fa7468849702fc1d1b4d02b38058e480eced6

#include <Arduino.h>

// Pin Definitions for A4988 Stepper Driver
#define STEPPER_STEP_PIN 21
#define STEPPER_DIR_PIN 20
#define STEPPER_EN_PIN 9
#define OUTPUT_PIN 3
#define MIRROR_PIN 8  // Define pin 8

const unsigned long STEP_INTERVAL = 1000;  // 1ms between steps

unsigned long lastStepTime = 0;

void setup() {
  pinMode(STEPPER_STEP_PIN, OUTPUT);
  pinMode(STEPPER_DIR_PIN, OUTPUT);
  pinMode(STEPPER_EN_PIN, OUTPUT);
  pinMode(OUTPUT_PIN, OUTPUT);
  pinMode(MIRROR_PIN, OUTPUT);  // Pin 8 configured as output

  digitalWrite(STEPPER_DIR_PIN, HIGH);  // Set direction (HIGH for clockwise, LOW for counterclockwise)
  digitalWrite(STEPPER_EN_PIN, LOW);    // Enable the stepper driver
  digitalWrite(OUTPUT_PIN, HIGH);
  digitalWrite(MIRROR_PIN, LOW);  // Initialize pin 8 to LOW
}

void loop() {
  unsigned long currentTime = millis();

  // Step the motor at regular intervals
  if (currentTime - lastStepTime >= STEP_INTERVAL) {
    lastStepTime = currentTime;

    digitalWrite(STEPPER_STEP_PIN, HIGH);
    digitalWrite(MIRROR_PIN, HIGH);  // Set pin 8 HIGH
    delayMicroseconds(50);  // A4988 requires minimum 1μs pulse
    digitalWrite(STEPPER_STEP_PIN, LOW);
    digitalWrite(MIRROR_PIN, LOW);  // Set pin 8 LOW
  }
}

1 Comment
2024/10/20
12:13 UTC

1

Project: nRF52x & Wireless Audio Streaming over Radio with I2S & PWM

I've been struggling with getting I2S audio output working on the nRF52840 for quite some time now (months) off and on but finally got it working! The libraries showcased should support any devices that utilize the nRF52x chips. I am using some XIAO Sense 52840s in this video, which I am really liking a lot.

YouTube Video

In the end I had to create two separate libraries to make this happen, the Auto Analog Audio library + nrf_to_nrf Radio library, but am pretty proud of the results n had to share.
I just did a new release of the AAAudio lib to support I2S functionality which will be available via Arduino Library manager within 24hrs. Examples used to make the video are included with the library.

0 Comments
2024/10/20
12:08 UTC

0

Connecting copy Arduino Nano with stepdown to ebike engine.

Hi I have created a code for an ebike shimano step e6100. But I'm having trouble with the electric part. I have previously connected the Stepdown to the copy of the Arduino nano but it got burn. So apparently I'm doing something wrong. If someone could help me I will really appreciate.

The code is made for the input of the sendor to go const int sensorPin = 2; const int outPin = 13;

The voltage needs to go down to 5v and the engine gives 12v The connection the engine goed though pin 13. How do I connect the stepdown? I was soldering can I used a board to connect all of it?

1 Comment
2024/10/20
10:28 UTC

1

Issue: weird signal interference with Arduino Mega + 2xSPI devices

Hello everyone!

I’m currently working on a project using an Arduino Mega, where I have two devices connected via SPI: a BB-ADS1220 (for reading 2 strain gauges) and an LSM6DSO (accelerometer/gyroscope). I was able to connect both sensors separately and read data out of each of them with no issue. Yay! :slight_smile:

However, I’m experiencing some interference issues when trying to read them together (on the same SPI bus).

Although I can read both, when I touch the accelerometer, it seems to introduce noise + fluctuations in the readings from the strain gauge circuit (which should not read anything as it is far from the accelerometer).

Has anyone encountered similar issues when using multiple devices on the same SPI bus? Any suggestions on how to mitigate this interference? I should mentioned that I'm switching between two SPI modes in my code (SPI mode 0 for the LSM6DSO and SPI mode 1 for the ADS1220). I fear this might be the issue?

Here’s a quick overview of my setup:

  • Microcontroller: Arduino Mega
  • Sensors: BB-ADS1220 (strain gauge) and LSM6DSO (accelerometer)
  • Level shifter: PiHut TXB0104
  • Connections: Both devices are connected via SPI with appropriate wiring and grounding (see attached schematic)

Any advice or insights would be greatly appreciated!

[code]#include <SPI.h>

#include "Protocentral_ADS1220.h"

//TODO: bug. If I move the accelerometer, the load cell signal is affected. How come?

// LSM6DSO Configuration

#define LSM6DSO_CS_PIN 10

#define WHO_AM_I_REG 0x0F

#define CTRL1_XL 0x10

#define CTRL2_G 0x11

#define OUTX_L_A 0x28

#define OUTX_H_A 0x29

#define OUTY_L_A 0x2A

#define OUTY_H_A 0x2B

#define OUTZ_L_A 0x2C

#define OUTZ_H_A 0x2D

#define OUTX_L_G 0x22

#define OUTX_H_G 0x23

#define OUTY_L_G 0x24

#define OUTY_H_G 0x25

#define OUTZ_L_G 0x26

#define OUTZ_H_G 0x27

// ADS1220 Configuration

#define PGA 4 // Programmable Gain = 1

#define VREF 2.048 // Internal reference of 2.048V

#define VFSR (VREF / PGA)

#define FULL_SCALE (((long int)1<<23) - 1)

#define ADS1220_CS_PIN 9

#define ADS1220_DRDY_PIN 8

Protocentral_ADS1220 pc_ads1220;

int32_t adc_data;

void setup() {

Serial.begin(115200);

// Initialize SPI

SPI.begin();

// Initialize LSM6DSO

pinMode(LSM6DSO_CS_PIN, OUTPUT);

digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect LSM6DSO

configureLSM6DSO();

// Initialize ADS1220

pinMode(ADS1220_CS_PIN, OUTPUT);

digitalWrite(ADS1220_CS_PIN, HIGH); // Deselect ADS1220

configureADS1220();

}

void loop() {

// Read data from LSM6DSO

readLSM6DSO();

// Read data from ADS1220

readADS1220();

}

// Function to configure LSM6DSO

void configureLSM6DSO() {

Serial.println("Configuring LSM6DSO...");

digitalWrite(LSM6DSO_CS_PIN, LOW); // Select LSM6DSO

SPI.setDataMode(SPI_MODE0); // Set SPI mode to 0

// Send initialization commands

writeRegister(CTRL1_XL, 0x60); // Enable accelerometer

writeRegister(CTRL2_G, 0x60); // Enable gyroscope

digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect LSM6DSO

}

// Function to read data from LSM6DSO

void readLSM6DSO() {

digitalWrite(LSM6DSO_CS_PIN, LOW); // Select LSM6DSO

SPI.setDataMode(SPI_MODE0); // Ensure SPI mode is set to 0

int16_t accelX = read16bitRegister(OUTX_L_A, OUTX_H_A);

int16_t accelY = read16bitRegister(OUTY_L_A, OUTY_H_A);

int16_t accelZ = read16bitRegister(OUTZ_L_A, OUTZ_H_A);

Serial.print(accelX); Serial.print(" ");

Serial.print(accelY); Serial.print(" ");

Serial.print(accelZ); Serial.print(" ");

digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect LSM6DSO

}

// Function to configure ADS1220

void configureADS1220() {

Serial.println("Configuring ADS1220...");

digitalWrite(ADS1220_CS_PIN, LOW); // Select ADS1220

SPI.setDataMode(SPI_MODE1); // Set SPI mode to 1

// Send initialization commands

// ... (Initialize ADS1220 settings)

// Initialize ADS1220 with Chip Select and Data Ready pins

pc_ads1220.begin(ADS1220_CS_PIN, ADS1220_DRDY_PIN);

// Configure ADS1220 settings

pc_ads1220.set_data_rate(DR_330SPS); // Data rate of 330 samples per second

pc_ads1220.set_pga_gain(PGA_GAIN_1); // PGA gain set to 1

pc_ads1220.set_conv_mode_single_shot(); // Set to single-shot conversion mode

digitalWrite(ADS1220_CS_PIN, HIGH); // Deselect ADS1220

}

// Function to read data from ADS1220

void readADS1220() {

digitalWrite(ADS1220_CS_PIN, LOW); // Select ADS1220

SPI.setDataMode(SPI_MODE1); // Ensure SPI mode is set to 1

// Read data from ADS1220

// ... (Implement ADS1220 read logic)

// Read from channel 0

adc_data = pc_ads1220.Read_SingleShot_SingleEnded_WaitForData(MUX_SE_CH0);

float ch0 = convertToMilliV(adc_data);

// Read from channel 1

adc_data = pc_ads1220.Read_SingleShot_SingleEnded_WaitForData(MUX_SE_CH1);

float ch1 = convertToMilliV(adc_data);

// Calculate the differential voltage (half-bridge value)

float differentialVoltage = 40000*(ch1 - ch0);

// Print the differential voltage for the Serial Plotter

Serial.println(differentialVoltage);

digitalWrite(ADS1220_CS_PIN, HIGH); // Deselect ADS1220

}

// Function to write to a register

void writeRegister(byte regAddress, byte data) {

digitalWrite(LSM6DSO_CS_PIN, LOW); // Select device

SPI.transfer(regAddress & 0x7F); // Send register address (write mode)

SPI.transfer(data); // Send the data to write

digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect device

}

// Function to read a 16-bit register

int16_t read16bitRegister(byte regL, byte regH) {

byte lowByte = readRegister(regL);

byte highByte = readRegister(regH);

return (int16_t)((highByte << 8) | lowByte);

}

// Function to read a single register

byte readRegister(byte regAddress) {

digitalWrite(LSM6DSO_CS_PIN, LOW); // Select device

SPI.transfer(regAddress | 0x80); // Send register address with read bit (0x80)

byte regValue = SPI.transfer(0x00); // Send dummy byte and read response

digitalWrite(LSM6DSO_CS_PIN, HIGH); // Deselect device

return regValue; // Return the register value

}

// Function to convert raw ADC data to millivolts

float convertToMilliV(int32_t i32data) {

return (float)((i32data * VFSR * 1000) / FULL_SCALE);

}

[/code]

https://preview.redd.it/oaphx4uplvvd1.png?width=1490&format=png&auto=webp&s=122998ba368a9e28c94a7df4172c38ee56047977

Thanks in advance!

1 Comment
2024/10/20
08:58 UTC

1

issues with keyboard emulation

I Have been looking around through libraries looking for a hid library but it seems like the one from arduino is no longer working. Any help on this would be appreciated.

I just want to have the arduino run set key presses in a loop after pressing a button just in case this helps.

I am running the arduino mega also if that helps

2 Comments
2024/10/20
07:36 UTC

1

How to get started with Arduino and IoT and build a complex yet feasible semester project ?

Hi everyone! I am a former software engineer (2Y as a front-end dev) who is currently pursuing his post-graduation at a University of Applied Sciences in Germany. As with all Hochschules or Applied Science universities, there is heavy emphasis on projects and collaborative Work.

We have this subject named - Practical Studies/Industry 4.0 in our first semester and it was just announced that we have to do a project with Arduino and the group that I have been assigned to will work on Smart Farming!

Can someone please provide me some guidance on how do I get started on this as a complete beginner and no experience with IoT, embedded systems and other things.

My primary concerns are the following:

  1. Knowing what all to learn and how deep to go
  2. How much time would it take to learn and start building. We have only 2 months!
  3. How complex or easy the project should be for a group of 4 ?
6 Comments
2024/10/20
09:20 UTC

224

Got my first Arduino kit - excited to dive in! Any beginner tips?

62 Comments
2024/10/20
04:56 UTC

44

Added a bit more to my Gengar animation, OLED, arduino Mega 2560

He now comes out of a pokeball! Plus a inverted version at the end. Thinking about making a little mini Pokédex or something similar but will probably run out of storage space.

1 Comment
2024/10/20
02:54 UTC

Back To Top