Interactive Target System - 3D Archery

Hi.

Got a little challenge I hope you guys can help me with.

But first, a little back ground……..

I built another target system about 5 yrs ago, pretty basic, single sensor & that was my introduction to Arduino systems.

Thread here - Introducing a proximity sw as an end to the loop

My back ground is mechanical, not electrical (Machinist turned Mech Engineer)

So, onto the current project.

Ive recently re-discovered my fettish for Archery & my involvement with the local club has me thinking….no obsessing with developing an interactive system to go on some 3D targets.

The plan is to use a couple of sensors & wifi to sense impacts & movement.

Depending on which sensor is triggered, the mp3 will play a different sound for each.

1st is a walk up sensor, where it (PIR sensor) is triggered as people aproach the location - This triggers a soft sounding feeding noise or that of an animal rooting around in the bush, before you can see the target.

2nd is an accelerometer on the back of the 3D target which picks up the Arrow impact - this triggers a distress type squeal (Pig), a Roar (Bear) or Bleat (Goat) etc,

3rd is another PIR sensor in the central unit that will pick up an Arrow in flight (If this is possible). The purpose of this one is to set up an “IF” scenario in the code. “IF” Arrow detected & Vibration not detected = a miss. The mp3 then plays a “fail” type sound, like on a game show BZZZZT! type sound or Southpark, HaHa! I would have 3-4 of these sounds & be set to play in a random order, one each time.

So the Hardware is pretty much sorted.

No,1 - Wemos D1 Mini pro & a SR501 PIR sensor

No,2 - Wemos D1 Mini pro & a SW420 Vibe sensor

No, 3 - Central unit - Arduino UNO R2, another SR501 PIR sensor, a DY-SV5W mp3 player & an nRF24L01+ Wifi reciever

The first bit I’d like some help with is setting up sensor #2 - the Vibe sensor.

(No,1 will be pretty much the same anyway, just a different pipeline)

Setting up pinmodes & inputs/outputs is pretty straightforward but it is setting up the transmit code that has me stumped ATM as that is something I have not done before & pulling bits of code from AI sources & the like is just as confusing, ask the same question 3 times & get 3 different sets of code!!!

The other thing to mention is I also have an LED blink finction in there to indicate power on. it is an extarnal LED set to blink 0.5 sec on & 2 sec, off.

This is what I have so far.

Q1. How do I set up the pipeline. (To the nRF24)

Q2. How do I get it to transmit “Vibe detected”

void setup() {
  Serial.begin(9600);
  pinMode(A0, INPUT); // Captures signal from the vibration sensor
  pinMode(D6, OUTPUT); // Output for LED
  //esp_now_init() How do I use this

}

void loop() {
  int signalState = analogRead(A0);
  if (signalState == HIGH) {
    Serial.println("Signal Triggered!"); // Sends signal over USB/Serial
    delay(500);
    //esp_now_send() How do I use this

  }

  digitalWrite(D6, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a second
  digitalWrite(D6, LOW);   // turn the LED off by making the voltage LOW
  delay(2000);                      // wait for a second
}

Thx in advance, Mick.

PIR stands for Passive InfraRed
How much IR does an arrow emit ?

You will need to use a different approach

Yeah that one is optional, can figure that one out later.

Main goal at this point is the Wifi sensors 1 & 2.

Mick.

This is not likely to do what you intend:

HIGH equals 1, and an analogRead is going to return a value between 0 and 1023, inclusive. I'd bet that if the PIR system is tuned to give numbers near 1, you'd get non-1 numbers more often than not.

So maybe go back to my original plan - Use D2 as my sensor input on both the wemos boards (PIR & Vibe sensors) & change it back over to digitalRead, yeah?

Mick.

You could compare an analog signal to an analog threshold different than 1:


const int ActionThreshold = 125; // tune this number for sensitivity
…

int signalState = analogRead(A0);
if (signalState <= ActionThreshold ) {

But also, as @UKHeliBob indicated, the small ambient temperature arrow may not provide much of a signal.

Easy enough, I just switched it back to D2, Input last night & ordered a microwave sensor to pick up the arrow flight.

As I said above, setting pin modes & hardware is the easy bit, I can sort that.

What I really need help with is setting up the Wifi channels & send/recieve commands, I have never done this & am totally lost at the moment.

Transmiting from the Wemos D1 to an nRF24.

Can someone help with this pls?

Ive only gone for the nRF24 because I have 6 UNO boards on hand.

I’m begining to wonder if I should do away with the nRF24 & UNO as my main control & just use another Wemos there for simplicity if it can be coded to drive the mp3 operations.

Regards, Mick.

Will you be using WiFi (150m) or nRF24 (with antenna, 1000m)? A favorite Arduino maker is Random Nerds Tutorials who covers nRF24 (and much more).

Sound and vibration are two things arrows do while passing and hitting targets.

Thx for the heads up on RD’s Tutorials.

Though I didnt find anything specific for what Im doing (ie transmit from a wemos to an Rf24)

So Im now a little closer but farther away at the same time…….:zany_face:

I have discovered I cannot use the ESP_NOW function that one would normally use between two Wemos boards, I have to use the Rf24 protocals, or at least that is where I believe I need to be.

Current Transmitter code (with questions & errors texted in)

pls help show me how to correct these.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

const int vibePin = D2;
const int LEDPin = D6;

void setup() {
  Serial.begin(9600);
  pinMode(D2, INPUT); // Captures signal from the vibration sensor
  pinMode(D6, OUTPUT);


// CE, CSN pins
RF24 radio(D2, D1); // Is this defining the CE/CSN pins on the rf24 board (not the wemos) 
//I would have thought that was built into the rf24 library above.

const byte address[6] = "00001"; // Can this 00001 protocal be changed & what is its function.
// I intended to use this numerical figure on my mp3 files comanded by the UNO at the recieving end.

  radio.begin();
  radio.openWritingPipe(Pipe1C); // Error here somewhere.
  radio.setPALevel(RF24_PA_MED); // Error here somewhere
  radio.stopListening(); // Set as transmitter
}

void loop() {
  const char text[] = "Hello World";
  int vibration = digitalRead(vibePin);
  if (vibration == HIGH);
  radio.write(Vibration detected); // Error here somewhere
  delay(500);
}
{ // Error here Somewhere, something to do with this bracket.
  digitalWrite(D6, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a half second
  digitalWrite(D6, LOW);   // turn the LED off by making the voltage LOW
  delay(2000);                      // wait for 2 seconds
  }

Then this is the Reciever code I have ATM (nRF24 connected to a UNO board)

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

const int vibePin = D2;
const int LEDPin = D6;

void setup() {
  Serial.begin(9600);
  pinMode(D2, INPUT); // Captures signal from the vibration sensor
  pinMode(D6, OUTPUT);


// CE, CSN pins
RF24 radio(D2, D1); // Is this defining the CE/CSN pins on the rf24 board (not the wemos) 
//I would have thought that was built into the rf24 library above.

const byte address[6] = "00001"; // Can this 00001 protocal be changed & what is its function.
// I intended to use this numerical figure on my mp3 files comanded by the UNO at the recieving end.

  radio.begin();
  radio.openWritingPipe(Pipe1C); // Error here somewhere.
  radio.setPALevel(RF24_PA_MED); // Error here somewhere
  radio.stopListening(); // Set as transmitter
}

void loop() {
  const char text[] = "Hello World";
  int vibration = digitalRead(vibePin);
  if (vibration == HIGH);
  radio.write(Vibration detected); // Error here somewhere
  delay(500);
}
{ // Error here Somewhere, something to do with this bracket.
  digitalWrite(D6, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a half second
  digitalWrite(D6, LOW);   // turn the LED off by making the voltage LOW
  delay(2000);                      // wait for 2 seconds
  }

You have marked this topic "solved."
What needs correcting?
What do you observe?

Heaps…….

Not solved.

still trying to work out how that got tagged like that???

P.s

Reply to your previous post - “Sense impacts & movement”

Impacts being the hit on the target (Vibe sensor) & movement being persons moving into the area (PIR sensor)

Mick.

Do I understand this? Arduino #1 monitors sound and vibration near a target and transmits that event to Arduino #2.

If so, I would make several small projects...

  1. A stand-alone Arduino monitoring sound and vibration. This might be as simple as reading an analog pin for both of them. Can a sensor "hear" a sound? Can a sensor "feel" a vibration?
  2. RF24L01 - Can both of your MCUs configure and operate this device, and supply power?
  3. RF2401 to RF2401 - Can you transmit data from one to the other?

DroneBotWorkShop has an article and a video describing the RF24L01, how to use it, how to connect it, how to write code for it, and how to use it to transmit data. Worth a read/watch.

Two x Wemos D1 Mini’s as the transmitters - one with a PIR attached to pick up people aproaching, the other with a Vibe sensor attached (target)

These are two seperate, remote units.

Both are transmitting to a UNO R2 via an nRF24L01 set up as the only reciever. (seperate unit again which has an mp3 player in it) Im begining to think I should swap these out for a UNO R4.

Both the Transmitters will be ultemately the same code, same pinModes etc.

The only differences being the naming conventions so the RF24 can pick the difference between the two & pass that on to the UNO.

At this point, im just focusing on getting one of them talking to the Rf24, then I can move on from there.

Ive got an Excel spread sheet on my work computer with all the hardware connections in a seperate table for each unit, I will post that when I get to work tomorrow for some clarity.

Regards, Mick.

Yes... you name the server and clients... also because I am lost on what is what going to what.

nRF2401 has the capability of multiple nodes (your Wemos/8266?) and one receiver (your Uno?) A web search of "wemos arduino rf24L01 multiple nodes" show many good looking articles showing extensible networks.

Sorry, should have been clearer as above.
The nRF24 is only there because the UNO R2 does not have Wifi capability.
The UNO is only there to manage the Mp3 player (ignoring the microwave sensor for now)

Mick.

Start with one to one. The video in DroneBot does a great job of showing and telling.

Except it is nRF to nRF.

I,m trying to initiate transmission from the Wemos.
From what Ive seen, it uses a different set of protocols (which would be fine) but it appears when transmitting from Wemos to nRF it is a blended set of code.

Does the straight up nRF code work on a Wemos?

Mick.

What have you seen, how does it work, or has it ever worked?

It was an answer to a question I asked AI.
"Can you transmit from a Wemos D1 mini to an nRF24L01"

Answer was yes but the code given has thrown me as I had it in my head at the time that I needed to use the ESP_NOW function to get the Wemos to transmit as is normal for a Wemos to Wemos connection.

Anyway.
Ive just had a chat with some-one who does well with computer programing but not familiar with the hardware I'm trying to use & he said something so obvious, it made me feel like a complete idiot!

Set up a like for like connection as a trial run & work from there! :zany_face:

I have spare UNO's & spare nRF24's............so that is a plan!
Was getting pretty frustrated with it earlier, overwhelmed with code from all over the place & figured it was time to walk away for a bit........Always works a treat! :+1:

Edit to Add:-
Well here's a twist!
The above mentioned AI response was simply using google AI.
I just posed the same question to Chat GPT & here is the answer -

You said:

Can a wemos D1 Mini transmit to an nRF24L01 reciever

ChatGPT said:

Short story: not by itself.
Longer (useful) story: yes, but only if you add an nRF24L01 module to the Wemos D1 Mini.

Here’s why :backhand_index_pointing_down:

Why it won’t work directly

  • Wemos D1 Mini = ESP8266, speaks Wi-Fi (2.4 GHz) using TCP/IP.
  • nRF24L01 = a proprietary 2.4 GHz RF transceiver, not Wi-Fi.

Even though they’re both at 2.4 GHz, they’re speaking totally different “languages.” They cannot hear each other directly.

How to make it work

You need to put an nRF24L01 on the Wemos D1 Mini as well.

So the setup becomes:

  • Wemos D1 Mini + nRF24L01 → transmitter
  • MCU (Arduino, another ESP, etc.) + nRF24L01 → receiver

They then communicate using the nRF24 protocol, not Wi-Fi.
........................................................................................................................................

So Ive been chasing my bloody Tail all along.... :slightly_frowning_face:

Back to the hardware drawing board for me!
Either use a nRF24 as a transmitter with a Nano or Wemos as the board (gaining size I didnt want)
OR
maybe swap the Rf24 out for another Wemos?

Mick.

Look for "ESP8266 wireless" for setting up a client/server network. Here is an example: ESP8266 Client-Server Wi-Fi Communication Between Two Boards (NodeMCU) | Random Nerd Tutorials

You mentioned nRF24, so I answered with nRF24.

ChatGPT is a "yes" man. Ask your friend.

[edit] and why not ESP-NOW? It's device-device. Stop talking to chatGPT.