UNO and Pro Mini 3.3v 8Mhz wireless sensor node

Hi All
I am new to Arduino and I would appreciate any advice, please.
I have two UNO boards and two 315mhz rf modules, in a wireless node project that is working.

I move the transmitter to a Pro Mini 3.3v 8Mhz because I want to run it on a battery, after uploading the same transmitter sketch use on the UNO I am not receiving anything on the receiver UNO and I am thinking if it has to do with the UNO 16mhz and the pro mini 8mhz clock speed?

Kind regards
nexsis

I am thinking if it has to do with the UNO 16mhz and the pro mini 8mhz clock speed?

Maybe it has. Did you change the board settings in the IDE before uploading the sketch to the Pro Mini?

Why did you fail to post the code here? If there's a problem in the code we cannot know about it because you're the only person who did see it.

How did you wire the two boards? Post a wiring diagram showing all connections! Post a link to the used RF modules!

Hi Pylon
Thank you for your reply.
Yes, I did change the board settings in the IDE before uploading the sketch to the Pro Mini. The pro mini I mention is actually a custom board I made with a blank atmega328p-au and I was successful in burning the bootloader from the instructions provided by Nick Gammon tutorial, the sketch also uploaded without any problems, after testing the board to see if it was transmitting which it did not, I uploaded the blink sketch and that worked. I then re-burn the bootloader using Arduino as ISP and try again with the same results.
Please see the Tx and Rx sketch and also the custom board schematic

RF links: https://www.nicerf.com/product_132_132.html
https://www.nicerf.com/product_132_82.html

//Transmitter code

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
#define NODE_ID 1
#define OUTPUT_PIN 11
RH_ASK driver;

//Constants:
const int ledPin = 13; //pin 9 has PWM funtion
const int potPin = A0; //pin A0 to read analog input
const int donePin = 10; //pin 10 to indicate new transmition input

//Variables:
int rawValue;
int oldValue;
byte potPercentage;
byte oldPercentage;

int time_counter=0;
bool ten_secs_flag = false ;

void setup(){
//Input or output?
pinMode(ledPin, OUTPUT);
pinMode(donePin, OUTPUT);
pinMode(potPin, INPUT); //Optional
Serial.begin(9600); // initialize serial communication at 9600 bits per second:

if (!driver.init())
Serial.println("init failed");

//Setup Timer2 to fire every 1ms
TCCR2B = 0x00; //Disbale Timer2 while we set it up
TCNT2 = 130; //Reset Timer Count to 130 out of 255
TIFR2 = 0x00; //Timer2 INT Flag Reg: Clear Timer Overflow Flag
TIMSK2 = 0x01; //Timer2 INT Reg: Timer2 Overflow Interrupt Enable
TCCR2A = 0x00; //Timer2 Control Reg A: Wave Gen Mode normal
TCCR2B = 0x05; //Timer2 Control Reg B: Timer Prescaler set to 128

// //------------------------- timer 1 (1S)
// noInterrupts();
// TCCR1A = 0x80;
// TCCR1B = 0x0C;
// OCR1AH = 0xF4;
// OCR1AL = 0x23;
// TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
// interrupts();

}

ISR(TIMER2_OVF_vect) // timer compare interrupt service routine
{
time_counter++;
if( time_counter == 5000)
{
ten_secs_flag = true ;
time_counter=0;

}

}

void loop()
{
if( ten_secs_flag == true)
{
read_Pot();
send_Pot();
digitalWrite(donePin, HIGH);
delay(500);

ten_secs_flag = false ;
digitalWrite(donePin, LOW);

}
}

void read_Pot()
{
//Read analog value from potentiometer twice
rawValue = analogRead(potPin);
rawValue = analogRead(potPin); // double read
// ignore bad hop-on region of a pot by removing 8 values at both extremes
rawValue = constrain(rawValue, 0, 1023);
// add some deadband
if (rawValue < (oldValue - 4) || rawValue > (oldValue + 4)) {
oldValue = rawValue;
// convert to percentage
potPercentage = map(oldValue, 0, 1023, 0, 100); //Map value 0-1023 to 0-100 (PWM)
// Only print if %value changes
if (oldPercentage != potPercentage) {
// print out the Pot percentage you read:
Serial.print("Pot percentage is: ");
Serial.print(potPercentage);
Serial.println(" %");
oldPercentage = potPercentage;
}
}
}

void send_Pot()
{
// CODE EMETTEUR
const char *msg = "Hello World!";
itoa(potPercentage, msg, 10);
driver.send((uint8_t *)msg, strlen(msg)+ 1);
driver.waitPacketSent();
Serial.println(msg);

}

Receiver sketch

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <SoftwareSerial.h>

RH_ASK driver;

int potCompare;
int potReceived = -1;
int potOffset= 0;
int sender_id = 1 ;
int final_id = 0;

const int buzzer_pin = 8; //buzzer to arduino pin 8

int time_counter = 0;
int buzzer_counter = 0;
bool nr_flag = true ;
bool flag_20 = false ;
bool flag_5 = false ;

SoftwareSerial mySerial(10, 9); // RX, TX

void setup() {
// pins for switches are inputs
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);

pinMode(buzzer_pin, OUTPUT);

Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");

//Setup Timer2 to fire every 1ms
TCCR2B = 0x00; //Disbale Timer2 while we set it up
TCNT2 = 130; //Reset Timer Count to 130 out of 255
TIFR2 = 0x00; //Timer2 INT Flag Reg: Clear Timer Overflow Flag
TIMSK2 = 0x01; //Timer2 INT Reg: Timer2 Overflow Interrupt Enable
TCCR2A = 0x00; //Timer2 Control Reg A: Wave Gen Mode normal
TCCR2B = 0x05; //Timer2 Control Reg B: Timer Prescaler set to 128
mySerial.begin(115200);
}

ISR(TIMER2_OVF_vect) // timer compare interrupt service routine
{
time_counter++;
buzzer_counter++;
if ( time_counter == 20000)
{
flag_20 = true ;
time_counter = 0;

}
if (flag_20)
{
if (nr_flag)
{

Serial.println("20 mins passed with out rx");
mySerial.println(-1);
}
flag_20 = false ;

}
if ( buzzer_counter == 5000)
{
flag_5 = true ;
buzzer_counter = 0;
}
}

void loop()
{
potReceived = receive_Pot();
potOffset = read_Offset();
if (potReceived <= potOffset && potReceived != -1 && sender_id == final_id)
{
potCompare = 0; // Value < Offset
Serial.print("offset is ");
Serial.println(potOffset);
Serial.print("potCompare is ");
Serial.println(potCompare);
mySerial.println(potCompare);
}

else if (potReceived == -1)
{
Serial.println("not matching ID ");
}

else if (sender_id == final_id)
{
potCompare = map(potReceived, potOffset, 100, 0, 100); //Map value 0-1023 to 0-100 (PWM)
Serial.print("offset is ");
Serial.println(potOffset);
Serial.print("potCompare is ");
Serial.println(potCompare);
mySerial.println(potCompare);
}
// else Serial.println("llllloooooollll");

if (flag_5 && ( potOffset != 0) && ((potCompare == 50) || (potCompare == 0) ) ) {

tone(buzzer_pin, 1000 , 3000);
Serial.print("offset is ");
Serial.println(potOffset);
Serial.print("potCompare is ");
Serial.println(potCompare);
flag_5 = false ;

}

delay(1000);

}

int read_Offset()
{
// CODE OF DIP SWITCH (OFFSET)
const byte BinaryInput[] = {6, 5, 4, 3, 2};
unsigned int binary;
binary = 0;
for (byte x = 0; x < 5; x++)
{
byte value = digitalRead(BinaryInput[x]);
binary = binary + (value << x);
}

Serial.println(binary);

return binary ;

}

int receive_Pot()
{
// CODE OF RX
uint8_t buf[12];
uint8_t buflen = sizeof(buf);

if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.

char data = (char)buf;
String cast = "";
String pot_r_value = "";
int x = 0, y = 0;
String id = "";
while ( data[x] != '@')
{
cast = cast + (data[x] - '0');
x++;
}

while (1)
{
if (data[y] == '@')
{
id = id + data[y + 1];
id = id + data[y + 2];
// Serial.print("id=");
// Serial.println(id);
break;
}
y++;

}

int id_v[2] = {0};
id_v[0] = id[0] - '0';
id_v[1] = id[1] - '0';
final_id = id_v[0] * 10 + id_v[1];
Serial.print("tx_id_is:");
Serial.println(final_id);
// Serial.println(cast);

// Serial.print("Pot percentage is: ");
// Serial.println((char*)buf);
// return (atoi(buf)) ;

if (sender_id == final_id)
{
nr_flag = false ;
pot_r_value = cast;
cast = "";
potReceived = 0;
return (pot_r_value.toInt()) ;

}

else
{
return (-1) ;
}

}

}

RX UNO wiring.pdf (47.4 KB)

TX UNO WIRING.pdf (45.8 KB)

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Hi Tom
Yes, I should have read the posting requirements.
Please see the schematic of the transmitter circuit
Regards
nexsis

That's a LOT of code.

Don't you have a much shorter sketch that just tries to send a "hello" message to the other side? That's where you should start with. Get that connection to work with the simplest code possible. That helps isolating the problem.

Hi,
OPs circuit;


I thought you were using a UNO and ProMini 3V3?
Draw the UNO and ProMini as blocks with I/O and power pins.

Tom.. :slight_smile:

If the schematic is real, then I dont understand how a switch turns a 3.6V battery into a 3.3V VCC supply.

Thanks to all the members who reply, I know that you all had better things to do with your time.

TomGeorge you ask for a UNO and ProMini as blocks with I/O and power pins. I did my best please see. I would still like to know if the transmitter pro mini runs at 8Mhz and the UNO at 16Mhz If ist an issue or not ?

UNO_001.png

Hi,
Look at this link, 3V3 is 8Mhz and 5V is 16Mhz.

https://store.arduino.cc/usa/arduino-pro-mini

Make sure you have configured it correctly in your IDE.
You should be able to read the crystal frequency on the PCB.

Tom... :slight_smile:

Thanks, TomGeorge
I always dislike forums maybe that's why I could never make a good post.
so much attitude and sarcasm from members, anyway I guess its a human condition.

I would like to let you know that the custom board is working, the problem was a connector that was not seated properly. I thank you for your time in replying, God bless.

nexsis

The rule here is quite simple. Quite sure it applies to other forums, I've asked for help myself often enough and usually got it.

You want lots of response, lively discussion of your project, and make progress? Show you did your homework! That includes things like having read & following the info in the sticky; giving complete details of your project; explaining what you tried; what works and what not and where exactly you are stuck; clickable links to used hardware; etc. Then answer the questions from forum members replying you. In short: be helpful.

You want sarcasm and complaints? Create a post like "It doesn't work, and you have to help me out." That usually does the job. And yes, we're human, and sometimes nothing better than having some fun at the expense of someone who obviously didn't do their homework, or worse, thinks they don't have to do their homework.