i have attached 2 X DS18b20 Waterproof Temperature Sensors to pin 9 of an Arduino nano
and before the connection, it all seems fine with other projects but it seems to blow the Nanos one wire capability as it doesn't receive and data from the 2 sensors
i try it on an uno and its fine and on a mega its fine but as soon as i move it to a nano I get nothing.
is there some reason a nano won't work with these sensors
the idea is a get the temp from 2 DS18b20 on pin 9
then transmit over an rf signal to another nano with a screen
this all works on an uno but not nano
sketch below
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24Network.h>
// Data wire is plugged into digital pin 9 on the Arduino
#define ONE_WIRE_BUS 9
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
int deviceCount = 0;
float tempC;
// nRF24L01(+) radio attached (CE, CSN)
RF24 radio(7,8);
// Network uses that radio
RF24Network network(radio);
// Channel of our node
const uint16_t channel = 90;
// Address of our node
const uint16_t this_node = 1;
// Address of the other node
const uint16_t other_node = 0;
// How many packets have we sent already
unsigned long packets_sent;
// Structure of our payload, limited to 32 bytes
struct payload_t // 32 bytes max
{
unsigned long counter; // 4 bytes
float tempC; // 4 bytes
};
void setup(void)
{
sensors.begin(); // Start up the library
Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(channel, this_node);
// Power down the radio. Note that the radio will get powered back up on the next write() call.
radio.powerDown();
delay(2000);
// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
deviceCount = sensors.getDeviceCount();
Serial.print(deviceCount, DEC);
Serial.println(" devices.");
Serial.println("");
}
void loop(void)
{
// Pump the network regularly
network.update();
// Send command to all the sensors for temperature conversion
sensors.requestTemperatures();
// Display temperature from each sensor
for (int i = 0; i < deviceCount; i++)
{
Serial.print("Sensor ");
Serial.print(i+1);
Serial.print(" : ");
tempC = sensors.getTempCByIndex(i);
Serial.print(tempC);
payload_t payload = { packets_sent++, tempC };
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header,&payload,sizeof(payload));
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
Serial.print((char)176);//shows degrees character
Serial.println("F");
}
Serial.println("");
delay(2000);
}