I have two devices transmitting temperature to one receiver. Right now only one at a time will work displaying the proper temperature. This verifies that the hardware on each transmitter is working and Serv1 & Serv2 are properly set up.
In the code:
Mirf.getData((byte *) &temp1); //small board
//Mirf.getData((byte *) &temp2); //large board
When either Mirf.getData((byte *) &temp1); or just Mirf.getData((byte *) &temp2); is used I can see the correct temperature of each of the two transmitters.
when both lines are not commented out I can see that one temperature is correct but the other reads a constant wrong temperature.
I'm no good at code as you can tell so any help would be great.
#include <MirfHardwareSpiDriver.h>
int16_t h = 64;
int16_t w = 128;
// OLED I2C bus address
#define OLED_address 0x3c
Adafruit_SSD1306 display(OLED_RESET);
float temp1; //int
float temp2;
void setup()
{
Serial.begin(9600);
Wire.begin();
Mirf.cePin = 8;
Mirf.csnPin = 9;
display.begin(SSD1306_SWITCHCAPVCC, 0x3c); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay(); // clears the screen and buffer
Wire.begin();
init_OLED();
reset_display();
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"serv1"); //has to be serv1 !
Mirf.setRADDR((byte *)"serv2"); //has to be serv2 !
Mirf.payload = sizeof(temp1);
Mirf.payload = sizeof(temp2);
Mirf.config();
}
void loop()
{
while(!Mirf.dataReady())
{
}
//Can only use one at a time or gives an error one on Serv2
Mirf.getData((byte *) &temp1); //small board
//Mirf.getData((byte *) &temp2); //large board
Serial.println(temp1);
Serial.println(temp2);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,10);
display.print("Small Brd:");
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(70,10); //over,up
display.print(temp1);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,40);
display.print("Large Brd:");
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(70,40); //over,up
display.print(temp2);