Hi,
i need to say first that this is a clone. But i will order a Moteino in the future to support you
It's a Pro Mini with RFM69W and DS18B20.
I had it working with Nano's 50cm apart on breadboard but did not make a long range test because
the RFM12B's did work through the whole house over 3 floors.
So i did build the thing with a 3.3V/8MHz Pro Mini and uploaded the same code i used on the Nano.
I took him to the other end of the house and it worked for 3 minutes
So i did another one on breadboard because maybe my soldering is wrong or whatever...
But same behavior so i checked the serial console and ATC is going crazy...
Wild fluctuations:
no:2,tmp:22.50,mV:3246,rssi:-90 - ACK sent.
no:2,tmp:22.50,mV:3246,rssi:-72 - ACK sent.
no:2,tmp:22.37,mV:3246,rssi:-74 - ACK sent.
no:2,tmp:22.31,mV:3246,rssi:-77 - ACK sent.
no:2,tmp:22.19,mV:3246,rssi:-79 - ACK sent.
no:2,tmp:22.12,mV:3246,rssi:-80 - ACK sent.
no:2,tmp:22.06,mV:3246,rssi:-99 - ACK sent.
no:2,tmp:21.94,mV:3246,rssi:-98 - ACK sent.
no:2,tmp:21.87,mV:3246,rssi:-77 - ACK sent.
no:2,tmp:21.81,mV:3246,rssi:-98 - ACK sent.
no:2,tmp:21.75,mV:3246,rssi:-98 - ACK sent.
no:2,tmp:21.69,mV:3246,rssi:-94 - ACK sent.
no:2,tmp:21.62,mV:3246,rssi:-74 - ACK sent.
no:2,tmp:21.56,mV:3246,rssi:-94 - ACK sent.
no:2,tmp:21.44,mV:3246,rssi:-92 - ACK sent.
Also i did set "enableAutoPower" to minimum -85
After no more receiving (pulling the plug and putting it back in did not bring back anything in the receiver) i did a reset on the
receivers console and got three more lines before it stopped again:
The frequency is 868 Mhz, Kenneth!
RFM69_ATC Enabled (Auto Transmission Control)
no:2,tmp:12.44,mV:3352,rssi:-91 - ACK sent.
no:2,tmp:12.69,mV:3362,rssi:-91 - ACK sent.
no:2,tmp:11.81,mV:3382,rssi:-128 - ACK sent.
So it looks like ATC goes down until there is no more power?
But i did set minimum -85?
Also i thought -100 is minimum?
So here is the code. I did comment out some power saving stuff to make sure that's not the problem.
Transceiver (8MHz Pro Mini):
// RFM69W sender with ACK and encryption and Automatic Transmission Control
// Temp sensor with DALLAS DS18B20
#include <RFM69.h> // https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h> // https://www.github.com/lowpowerlab/rfm69
#include <SPI.h> // Comes with Arduino IDE
#include <OneWire.h> // https://github.com/PaulStoffregen/OneWire
#include <DallasTemperature.h> // https://github.com/milesburton/Arduino-Temperature-Control-Library
#include <JeeLib.h> // https://github.com/jcw/jeelib
ISR(WDT_vect) { Sleepy::watchdogEvent(); } // Interrupt handler for JeeLabs Sleepy power saving
/**************************************************************
* RADIO SETUP *
**************************************************************/
#define NODEID 2 // Unique for each node on same network
#define NETWORKID 204 // The same on all nodes that talk to each other
#define GATEWAYID 1
#define FREQUENCY RF69_868MHZ // Frequency of the hardware version of the radio module
#define ENCRYPTKEY "M>9L+4*t[m#Dv\5b" // Exactly the same 16 characters/bytes on all nodes!
#define ENABLE_ATC // comment out this line to disable AUTO TRANSMISSION CONTROL
#define ACK_TIME 20 // Number of milliseconds to wait for an ack
#define RETRY_PERIOD 5 // How soon to retry (in seconds) if ACK didn't come in
#define RETRY_LIMIT 5 // Maximum number of times to retry
/**************************************************************
* CONNECTIONS *
**************************************************************/
const byte ONE_WIRE_BUS = 3; // DS18B20 Temperature sensor is connected on D3
const byte ONE_WIRE_POWER = 4; // DS18B20 Power pin is connected on D4
/**************************************************************
* MISC SETUP *
**************************************************************/
#define SERIAL_BAUD 115200 // Set serial speed
#define DEBUG 1 // Set to 1 for serial port output
OneWire oneWire(ONE_WIRE_BUS); // Setup oneWire instance to communicate with any OneWire devices.
DallasTemperature sensors(&oneWire); // Pass oneWire reference to Dallas Temperature.
#ifdef ENABLE_ATC
RFM69_ATC radio;
#else
RFM69 radio;
#endif
/**************************************************************
* DATA STRUCTURE TO BE SENDE *
**************************************************************/
typedef struct {
int nodeId; // Store this nodeId
float temp; // Temperature reading
int vcc; // Battery voltage
} Payload;
Payload theData;
/**************************************************************
* SEND PAYLOAD DATA *
**************************************************************/
static void rfwrite() {
radio.receiveDone();
if (radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData), RETRY_LIMIT, ACK_TIME)) {
if (DEBUG) {
Serial.print("ACK received! ");
Serial.print("Sending ");
Serial.print(sizeof(theData));
Serial.println(" bytes... ");
Serial.flush();
}
radio.sleep(); // Put radio to sleep
} else {
if (DEBUG) {
Serial.println("No ACK response!");
Serial.flush();
}
//Sleepy::loseSomeTime(RETRY_PERIOD * 1000); // If no ack received wait and try again
}
}
/**************************************************************
* READ BATTERY VOLTAGE *
**************************************************************/
long readVcc() {
// bitClear(PRR, PRADC); ADCSRA |= bit(ADEN); // Enable the ADC
long result;
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); // For ATmega328
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result; // Back-calculate Vcc in mV
// ADCSRA &= ~ bit(ADEN); bitSet(PRR, PRADC); // Disable the ADC to save power
return result;
}
/**************************************************************
* SETUP *
**************************************************************/
byte pin[] = {5, 6, 7, 8, 9}; // Array of unused digital pins
byte pinCount = sizeof(pin) / sizeof(pin[0]); // Count unused digital pins
void setup() {
radio.initialize(FREQUENCY,NODEID,NETWORKID);
radio.encrypt(ENCRYPTKEY);
#ifdef ENABLE_ATC
radio.enableAutoPower(-85);
#endif
radio.sleep(); // Put radio to sleep
// PRR = bit(PRTIM1); // Only keep timer 0 going
// ADCSRA &= ~ bit(ADEN); bitSet(PRR, PRADC); // Disable the ADC to save power
sensors.setResolution(12); // Set sensor resolution
// Output setup
pinMode(ONE_WIRE_POWER, OUTPUT); // Set power pin for DS18B20 to output
for (byte i = 0; i < pinCount; i++) {
pinMode(pin[i], OUTPUT); // Set unused digital pins as output
digitalWrite(pin[i], LOW); // Set unused digital pins state to low
}
startupTasks(); // Run tasks
}
void startupTasks() {
if (DEBUG) {
char buff[50];
Serial.begin(SERIAL_BAUD); // Open serial communications and wait for port to open
while (!Serial) {;} // Wait for serial port to connect
sprintf(buff, "\nThe frequency is %d Mhz, Kenneth!", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
#ifdef ENABLE_ATC
Serial.println("RFM69_ATC Enabled (Auto Transmission Control)\n");
#endif
}
}
void loop() {
digitalWrite(ONE_WIRE_POWER, HIGH); // Turn DS18B20 on
//Sleepy::loseSomeTime(5); // Allow 5ms for the sensor to be ready
delay(5); // The above doesn't seem to work for everyone (why?)
sensors.begin(); // Start Dallas Temperature library
sensors.requestTemperatures(); // Get the temperature
theData.temp=(sensors.getTempCByIndex(0)); // Read first sensor
digitalWrite(ONE_WIRE_POWER, LOW); // Turn DS18B20 off
theData.nodeId = NODEID;
theData.vcc = readVcc(); // Get battery voltage
rfwrite(); // Send data via RF
Sleepy::loseSomeTime(5000);
}