Components and supplies
RF RX+TX Module
Resistor 4.75k ohm
DS18B20
Resistor 1k ohm
1.8 SPI TFT 128*160
BME280
Arduino UNO
SOLAR Shield
Tools and machines
Soldering iron (generic)
Project description
Code
TX Part
arduino
1/* ------------------------------------------------------------------------------- */ 2// Weather Station v1.3 3//Transmitter part 4 5#include <Wire.h> //Management of wire connections 6#include <VirtualWire.h> //Management of Virtual Wire for RF transmission 7#include "cactus_io_BME280_I2C.h" //Manage BME280 temp, humidity, pressure sensor 8#include <stdlib.h> //Library for string conversion 9#include <LowPower.h> //Library for energy efficency 10 11// Create the BME280 object 12BME280_I2C bme; // I2C using default 0x77 13//BME280_I2C bme(0x76); // I2C using address 0x76 14//int backLight = 13; // pin 13 will control the backlight managed by button 15 16const int TX_DIO_Pin = 7; //Definition of Transmission DATA PIN 17static char outstr[10]="0.00"; //Buffer String for convert BME readed values 18static char message[12]={0}; 19 20void setup() 21{ 22 Serial.begin(9600); //Serial communication 9600 23 if (!bme.begin()) { //Check if BME280 is connected and working 24 Serial.println("Could not find a valid BME280 sensor, check wiring!"); 25 while (1); 26 } 27 28 bme.setTempCal(-1); //Claibrate BME280 sensor 29 initialize_transmitter(); //Initialize transmitter 30} 31 32 33void loop() //Main looping code 34{ 35 bme.readSensor(); 36 37 dtostrf(bme.getPressure_MB(), 6, 2, outstr); //Read Pressure and convert in string 38 39 strcat(message,"P"); 40 strcat(message,outstr); 41 42 vw_send((int8_t *)message, strlen(message)); //Transmitt Pressure 43 //Serial.println(bme.getPressure_MB()); 44 message[0] = (char)0; 45 delay(1000); //Delay for transmission 46 47 dtostrf(bme.getHumidity(), 5, 2, outstr); //Read Humidity and convert in string 48 49 strcat(message,"H"); 50 strcat(message,outstr); 51 vw_send((int8_t *)message, strlen(message)); //Transmitt Humidity 52 //Serial.println(bme.getHumidity()); 53 message[0] = (char)0; 54 delay(1000); //Delay for transmission 55 56 dtostrf(bme.getTemperature_C(), 5, 2, outstr); //Read Temperature in C and convert in string 57 58 strcat(message,"T"); 59 strcat(message,outstr); 60 vw_send((int8_t *)message, strlen(message)); //Transmitt Temperature in C 61 //Serial.println(bme.getTemperature_C()); 62 message[0] = (char)0; 63 delay(1000); //Delay for transmission 64 65 dtostrf(bme.getTemperature_F(), 5, 2, outstr); //Read Temperature in F and convert in string 66 67 strcat(message,"F"); 68 strcat(message,outstr); 69 vw_send((int8_t *)message, strlen(message)); //Transmitt Temperature in F 70 //Serial.println(bme.getTemperature_F()); 71 message[0] = (char)0; 72 delay(1000); //Delay for transmission 73 74 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); // instead of delay(3000) ; 75 //delay(3000); //just here to slow down the output so it is easier to read 76} 77 78void initialize_transmitter() { 79 vw_set_tx_pin(TX_DIO_Pin); // Initialises the DIO pin used to send data to the Tx module 80 vw_set_ptt_inverted(true); // Set the transmit logic level (LOW = transmit for this version of module) 81 vw_setup(2000); // Transmit at 2000 bits per second 82} 83 84 85/* ------------------------------------------------------------------------------- */ 86
GFX Library
ST7735 Library
VirtualWire
ST7735 Library
VirtualWire
RC
Dallas Temperature
OneWire
RX Part
arduino
1/* ------------------------------------------------------------------------------- */ 2// Weather Station v1.3 3//Receiver code with LCD management 4// Andrea Martignoni 5// martignoni.a@gmail.com 6 7/* ------------------------------------------------------------------------------- */ 8 9#include <LiquidCrystal.h> //Liquid Cristal Mgt Lib 10#include <Wire.h> //Management of wire connections 11#include <VirtualWire.h> //Virtual Wire for sensor reading 12#include <stdlib.h> //Library for string conversion 13#include <Adafruit_GFX.h> // Core graphics library 14#include <Adafruit_ST7735.h> // Hardware-specific library 15#include <SPI.h> 16 17#include <OneWire.h> 18#include <DallasTemperature.h> //Dallas Temperature Sensor 19 20// Data wire is plugged into pin 4 on the Arduino 21#define ONE_WIRE_BUS 4 22// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 23OneWire oneWire(ONE_WIRE_BUS); 24 25// Pass our oneWire reference to Dallas Temperature. 26DallasTemperature sensors(&oneWire); 27 28// Pins definition for LCD 29#define TFT_CS 10 30#define TFT_RST 9 31#define TFT_DC 8 32Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 33#define TFT_SCLK 13 // set these to be whatever pins you like! 34#define TFT_MOSI 11 // set these to be whatever pins you like! 35 36const int RX_DIO_Pin = 2; //Pin for RX receiver 37int received; 38float rec; 39static char outstr[10]; 40String message; 41char swith; 42char* out; 43 44void setup() { 45 46 Serial.begin(9600); 47 48 sensors.begin(); 49 // Use this initializer if you're using a 1.8" TFT 50 tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab 51 52 uint16_t time = millis(); 53 54 tft.fillScreen(ST7735_BLACK); 55 time = millis() - time; 56 57 // large block of text 58 tft.fillScreen(ST7735_BLACK); //initialize the screen in black 59 tft.setRotation(90); //rotate the screen for my convenience 60 testdrawtext("Hello!", ST7735_MAGENTA, 0,0,3); //Title of the screen 61 delay(1000); //1 sec delay 62 initialize_receiver(); //initialize Receiver 63 //Create fixed graphic for the screen 64 testdrawtext("Pres hPa", ST7735_YELLOW, 0,29,1); 65 testdrawtext("OUT", ST7735_YELLOW, 0,37,1); 66 testdrawtext("Hum %", ST7735_BLUE, 0,49,1); 67 testdrawtext("OUT", ST7735_BLUE, 0,57,1); 68 testdrawtext("Temp F", ST7735_RED, 0,69,1); 69 testdrawtext("OUT", ST7735_RED, 0,77,1); 70 testdrawtext("Temp C", ST7735_GREEN, 0,89,1); 71 testdrawtext("OUT", ST7735_GREEN, 0,97,1); 72 testdrawtext("Temp C", ST7735_MAGENTA, 0,129,1); 73 testdrawtext("IN ", ST7735_MAGENTA, 0,137,1); 74} 75 76/* Main program */ 77void loop() { 78 uint8_t buf[VW_MAX_MESSAGE_LEN]; //Buffer for received message 79 uint8_t buflen = VW_MAX_MESSAGE_LEN; //lenght of message 80 vw_get_message(buf, &buflen); //read message 81 message = (char*)buf; //temporary string 82 Serial.print(message); //check on serial received message just for wire and soldering check 83 swith=message[0]; //check which kind of value has been received 84 85 switch (swith) { //based on kind of message pool 86 case 'P': 87 //clean received string 88 message=message.substring(1,7); 89 testdrawtext(message, ST7735_YELLOW, 55,30,2); 90 break; 91 92 case 'H': 93 //clean received string 94 message=message.substring(1,6); 95 testdrawtext(message, ST7735_BLUE, 55,50,2); 96 break; 97 98 case 'F': 99 //clean received string 100 message=message.substring(1,6); 101 testdrawtext(message, ST7735_RED, 55,70,2); 102 break; 103 104 case 'T': 105 //clean received string 106 message=message.substring(1,6); 107 testdrawtext(message, ST7735_GREEN, 55,90,2); 108 break; 109 110 default: 111 // if messages are not coming from receiver 112 testdrawtext("N/A", ST7735_YELLOW, 55,30,2); 113 testdrawtext("N/A", ST7735_BLUE, 55,50,2); 114 testdrawtext("N/A", ST7735_RED, 55,70,2); 115 testdrawtext("N/A", ST7735_GREEN, 55,90,2); 116 break; 117 } 118 119 sensors.requestTemperatures(); //Read temperature from internal sensor 120 testdrawtext(dtostrf(sensors.getTempCByIndex(0),3,2,outstr), ST7735_MAGENTA, 55,130,2); 121 delay(200); 122 123} 124 125 126/* DO NOT EDIT BELOW */ 127 128void initialize_receiver() { 129 /* Initialises the DIO pin used to receive data from the Rx module */ 130 vw_set_rx_pin(RX_DIO_Pin); 131 /* Receive at 2000 bits per second */ 132 vw_setup(2000); 133 /* Enable the receiver */ 134 vw_rx_start(); 135} 136 137void testdrawtext(String text, uint16_t color, int x, int y, int textSize) { 138 tft.setCursor(x, y); 139 tft.setTextColor(color, ST7735_BLACK); 140 tft.setTextSize(textSize); 141 tft.setTextWrap(true); 142 tft.print(text); 143}
TX Part
arduino
1/* ------------------------------------------------------------------------------- 2 */ 3// Weather Station v1.3 4//Transmitter part 5 6#include <Wire.h> //Management 7 of wire connections 8#include <VirtualWire.h> //Management of Virtual Wire for 9 RF transmission 10#include "cactus_io_BME280_I2C.h" //Manage BME280 temp, humidity, 11 pressure sensor 12#include <stdlib.h> //Library for string conversion 13#include 14 <LowPower.h> //Library for energy efficency 15 16// Create the BME280 object 17BME280_I2C 18 bme; // I2C using default 0x77 19//BME280_I2C bme(0x76); // I2C 20 using address 0x76 21//int backLight = 13; // pin 13 will control the backlight 22 managed by button 23 24const int TX_DIO_Pin = 7; //Definition of Transmission 25 DATA PIN 26static char outstr[10]="0.00"; //Buffer String for convert BME readed 27 values 28static char message[12]={0}; 29 30void setup() 31{ 32 Serial.begin(9600); 33 //Serial communication 9600 34 if (!bme.begin()) { //Check if BME280 35 is connected and working 36 Serial.println("Could not find a valid BME280 sensor, 37 check wiring!"); 38 while (1); 39 } 40 41 bme.setTempCal(-1); //Claibrate 42 BME280 sensor 43 initialize_transmitter(); //Initialize transmitter 44} 45 46 47void 48 loop() //Main looping code 49{ 50 bme.readSensor(); 51 52 53 dtostrf(bme.getPressure_MB(), 6, 2, outstr); //Read 54 Pressure and convert in string 55 56 strcat(message,"P"); 57 strcat(message,outstr); 58 59 60 vw_send((int8_t *)message, strlen(message)); //Transmitt 61 Pressure 62 //Serial.println(bme.getPressure_MB()); 63 message[0] = (char)0; 64 65 delay(1000); //Delay 66 for transmission 67 68 dtostrf(bme.getHumidity(), 5, 2, outstr); //Read 69 Humidity and convert in string 70 71 strcat(message,"H"); 72 strcat(message,outstr); 73 74 vw_send((int8_t *)message, strlen(message)); //Transmitt 75 Humidity 76 //Serial.println(bme.getHumidity()); 77 message[0] = (char)0; 78 79 delay(1000); //Delay 80 for transmission 81 82 dtostrf(bme.getTemperature_C(), 5, 2, outstr); //Read 83 Temperature in C and convert in string 84 85 strcat(message,"T"); 86 strcat(message,outstr); 87 88 vw_send((int8_t *)message, strlen(message)); //Transmitt 89 Temperature in C 90 //Serial.println(bme.getTemperature_C()); 91 message[0] 92 = (char)0; 93 delay(1000); //Delay 94 for transmission 95 96 dtostrf(bme.getTemperature_F(), 5, 2, outstr); //Read 97 Temperature in F and convert in string 98 99 strcat(message,"F"); 100 strcat(message,outstr); 101 102 vw_send((int8_t *)message, strlen(message)); //Transmitt 103 Temperature in F 104 //Serial.println(bme.getTemperature_F()); 105 message[0] 106 = (char)0; 107 delay(1000); //Delay 108 for transmission 109 110 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); // instead 111 of delay(3000) ; 112 //delay(3000); //just 113 here to slow down the output so it is easier to read 114} 115 116void initialize_transmitter() 117 { 118 vw_set_tx_pin(TX_DIO_Pin); // Initialises the DIO pin used to send data 119 to the Tx module 120 vw_set_ptt_inverted(true); // Set the transmit logic level 121 (LOW = transmit for this version of module) 122 vw_setup(2000); // 123 Transmit at 2000 bits per second 124} 125 126 127/* ------------------------------------------------------------------------------- 128 */ 129
RC
RX Part
arduino
1/* ------------------------------------------------------------------------------- 2 */ 3// Weather Station v1.3 4//Receiver code with LCD management 5// Andrea 6 Martignoni 7// martignoni.a@gmail.com 8 9/* ------------------------------------------------------------------------------- 10 */ 11 12#include <LiquidCrystal.h> //Liquid Cristal Mgt Lib 13#include <Wire.h> 14 //Management of wire connections 15#include <VirtualWire.h> //Virtual Wire for 16 sensor reading 17#include <stdlib.h> //Library for string conversion 18#include 19 <Adafruit_GFX.h> // Core graphics library 20#include <Adafruit_ST7735.h> // 21 Hardware-specific library 22#include <SPI.h> 23 24#include <OneWire.h> 25#include 26 <DallasTemperature.h> //Dallas Temperature Sensor 27 28// Data wire is plugged 29 into pin 4 on the Arduino 30#define ONE_WIRE_BUS 4 31// Setup a oneWire instance 32 to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 33OneWire 34 oneWire(ONE_WIRE_BUS); 35 36// Pass our oneWire reference to Dallas Temperature. 37 38DallasTemperature sensors(&oneWire); 39 40// Pins definition for LCD 41#define 42 TFT_CS 10 43#define TFT_RST 9 44#define TFT_DC 8 45Adafruit_ST7735 46 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 47#define TFT_SCLK 13 // set 48 these to be whatever pins you like! 49#define TFT_MOSI 11 // set these to be 50 whatever pins you like! 51 52const int RX_DIO_Pin = 2; //Pin for RX receiver 53int 54 received; 55float rec; 56static char outstr[10]; 57String message; 58char swith; 59char* 60 out; 61 62void setup() { 63 64 Serial.begin(9600); 65 66 sensors.begin(); 67 68 // Use this initializer if you're using a 1.8" TFT 69 tft.initR(INITR_BLACKTAB); 70 // initialize a ST7735S chip, black tab 71 72 uint16_t time = millis(); 73 74 75 tft.fillScreen(ST7735_BLACK); 76 time = millis() - time; 77 78 // large block 79 of text 80 tft.fillScreen(ST7735_BLACK); //initialize the screen in black 81 82 tft.setRotation(90); //rotate the screen for my convenience 83 testdrawtext("Hello!", 84 ST7735_MAGENTA, 0,0,3); //Title of the screen 85 delay(1000); //1 sec delay 86 87 initialize_receiver(); //initialize Receiver 88 //Create fixed graphic for the 89 screen 90 testdrawtext("Pres hPa", ST7735_YELLOW, 0,29,1); 91 testdrawtext("OUT", 92 ST7735_YELLOW, 0,37,1); 93 testdrawtext("Hum %", ST7735_BLUE, 0,49,1); 94 testdrawtext("OUT", 95 ST7735_BLUE, 0,57,1); 96 testdrawtext("Temp F", ST7735_RED, 0,69,1); 97 98 testdrawtext("OUT", ST7735_RED, 0,77,1); 99 testdrawtext("Temp C", ST7735_GREEN, 100 0,89,1); 101 testdrawtext("OUT", ST7735_GREEN, 0,97,1); 102 testdrawtext("Temp 103 C", ST7735_MAGENTA, 0,129,1); 104 testdrawtext("IN ", ST7735_MAGENTA, 0,137,1); 105 106} 107 108/* Main program */ 109void loop() { 110 uint8_t buf[VW_MAX_MESSAGE_LEN]; 111 //Buffer for received message 112 uint8_t buflen = VW_MAX_MESSAGE_LEN; //lenght 113 of message 114 vw_get_message(buf, &buflen); //read message 115 message = (char*)buf; 116 //temporary string 117 Serial.print(message); //check on serial received message 118 just for wire and soldering check 119 swith=message[0]; //check which kind of value 120 has been received 121 122 switch (swith) { //based on kind of message pool 123 124 case 'P': 125 //clean received string 126 message=message.substring(1,7); 127 128 testdrawtext(message, ST7735_YELLOW, 55,30,2); 129 break; 130 131 132 case 'H': 133 //clean received string 134 message=message.substring(1,6); 135 136 testdrawtext(message, ST7735_BLUE, 55,50,2); 137 break; 138 139 140 case 'F': 141 //clean received string 142 message=message.substring(1,6); 143 144 testdrawtext(message, ST7735_RED, 55,70,2); 145 break; 146 147 case 148 'T': 149 //clean received string 150 message=message.substring(1,6); 151 152 testdrawtext(message, ST7735_GREEN, 55,90,2); 153 break; 154 155 156 default: 157 // if messages are not coming from receiver 158 testdrawtext("N/A", 159 ST7735_YELLOW, 55,30,2); 160 testdrawtext("N/A", ST7735_BLUE, 55,50,2); 161 162 testdrawtext("N/A", ST7735_RED, 55,70,2); 163 testdrawtext("N/A", 164 ST7735_GREEN, 55,90,2); 165 break; 166 } 167 168 sensors.requestTemperatures(); 169 //Read temperature from internal sensor 170 testdrawtext(dtostrf(sensors.getTempCByIndex(0),3,2,outstr), 171 ST7735_MAGENTA, 55,130,2); 172 delay(200); 173 174} 175 176 177/* DO NOT EDIT BELOW 178 */ 179 180void initialize_receiver() { 181 /* Initialises the DIO pin used to receive 182 data from the Rx module */ 183 vw_set_rx_pin(RX_DIO_Pin); 184 /* Receive at 185 2000 bits per second */ 186 vw_setup(2000); 187 /* Enable the receiver */ 188 189 vw_rx_start(); 190} 191 192void testdrawtext(String text, uint16_t color, int 193 x, int y, int textSize) { 194 tft.setCursor(x, y); 195 tft.setTextColor(color, 196 ST7735_BLACK); 197 tft.setTextSize(textSize); 198 tft.setTextWrap(true); 199 tft.print(text); 200}
Dallas Temperature
OneWire
Downloadable files
WeatherStation 1.3 RX part
RX Part
WeatherStation 1.3 RX part
Weather Station 1.3 TX
TX Part
Weather Station 1.3 TX
Weather Station 1.3 TX
TX Part
Weather Station 1.3 TX
WeatherStation 1.3 RX part
RX Part
WeatherStation 1.3 RX part
Comments
Only logged in users can leave comments
derapados
0 Followers
•0 Projects
Table of contents
Intro
16
0