I am trying to get a value of temperature that has been transmitted. and applying this value to z for example. This value is required only once so I can place a marker on an OLed.
Can some one help me with the required code. The correct receipt of the temperature is marked with a high on pin 13 when this flashes 3 times rhen the fourth value should be applied to z so that I can use this value on the OLed. This should happen only once when the board is switched on.
// Receiving Temp. Data and displaying in on an OLed with a bar graph.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VirtualWire.h>
#define OLED_RESET 4
float temperatureNow;
int count;
int graphpos = 0;
Adafruit_SSD1306 Display(OLED_RESET);
float r = 0;
float a = 0;
int i = 0;
void setup(void) {
Display.drawLine(a,40,a,64, WHITE);// draw white vertical line at ambient temp.
Serial.begin(9600); // Debugging only
Serial.println(“setup”); //Prints “Setup” to the serial monitor
vw_set_rx_pin(12); //Sets pin D12 as the RX Pin
//vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
#if (SSD1306_LCDHEIGHT !=64)
#error (“Height incorrect, please fix Adafruit_SSD1306.h!”);
#endif
Display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64)
Display.begin();
Display.clearDisplay();
DrawTitles();
}
void loop(void) {
graphpos = 0;
String tempHolder = “”;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (int i = 0; i < buflen; i++)
{
char c = (buf*);*
-
tempHolder += c;*
-
}*
-
count++;*
-
//Serial.print(count);*
-
temperatureNow = tempHolder.toInt();*
-
temperatureNow = temperatureNow / 100;*
-
Serial.print(temperatureNow);*
-
Serial.println(" Degrees C");*
-
Serial.println(a);*
-
}*
-
// get Temperature*
-
r = temperatureNow;*
-
a = (r+30);*
-
Display.setTextSize(2);*
-
// note set the background color or the old text will still display*
-
Display.setTextColor(WHITE, BLACK);*
-
Display.setCursor(0, 20);*
-
Display.print(r);*
-
Display.println(" C");*
-
//draw the bar graph*
-
Display.fillRect(a, 50, 128 - a, 10, BLACK);*
-
Display.fillRect(3, 50, a, 10, WHITE);*
-
for (i = 1; i < 13; i++) {*
_ Display.fillRect(i * 10, 50, 2, 10, BLACK);_ -
}*
-
// now that the display is build, display it…*
-
Display.display();*
}
void DrawTitles(void)
{ -
Display.setTextSize(1);*
-
Display.setTextColor(WHITE);*
-
Display.setCursor(0, 0);*
-
//Display.print(r);*
-
Display.println(“Thermal Search”);*
}