I'm trying to build an indoor/outdoor thermometer using 433 MHz rf modules, OLED display, and DHT22. As a beginner, I'm basically just combining code from the examples in the libraries. I can make all the three parts work independently, but when I combine the RH_ASK code with the OLED code, the message gets extra gibberish tacked on to the message, and the Void loop only iterates once. I'm guessing there is some sort of conflict between the libraries, or else I'm doing something stupid. I'm using two Uno R3 clones. Here is the code:
XMTR:
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
const char *msg = "RF Msg";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
Serial.println("Xmit");
}
Rcvr:
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
RH_ASK driver;
String testmsg = "test";
int j = 1;
void setup()
{
Serial.begin(9600); // Debugging only
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
Serial.println("SSD1306 Allocation Failed");
if (!driver.init())
Serial.println("init failed");
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,18); // (X,Y)
display.print("Setup");
display.display();
Serial.println("Setup");
delay(1000);
display.clearDisplay();
display.display();
}
void loop()
{
/* display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,18);
display.print("Loop");
*/
uint8_t buf[6];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
Serial.print("Message: ");
Serial.println((char*)buf);
display.clearDisplay();
display.setCursor(0, 0);
display.print(testmsg);
display.setCursor(64,0);
display.print(j);
display.setCursor(0, 18);
display.print((char*)buf);
display.display();
j++;
}
}
Thanks