Aula Jazmati
Published © MIT

Make Simple Raspberry Pi Weather Station With Hexabitz

Embark on a journey to create a weather station like no other!

IntermediateFull instructions provided1 hour1,005
Make Simple Raspberry Pi Weather Station With Hexabitz

Things used in this project

Story

Read more

Schematics

H0AR9x-Hardware

https://github.com/HexabitzPlatform/H0AR9x-Hardware/tree/H0AR91

Code

Hexabitz-Weather-Station GUI Code -Test with FTDI USB-UART 3.3V cable

Python
#AulaJazmati
from tkinter import *
import time
import serial
from datetime import date

today = date.today()
print("Today's date:", today)
ser = serial.Serial(        
               port='/dev/ttyUSB0',
               baudrate = 921600,
               parity=serial.PARITY_NONE,
               stopbits=serial.STOPBITS_ONE,
               bytesize=serial.EIGHTBITS,
               timeout=1
           )

print(ser.name)
Main_window = Tk()
Main_window.config(background = "gray86")
Main_window.title('Hexabitz Weather Station')

Main_window.geometry('700x250+50+50')
def sensorhub():
    global t
    read = ser.read(5)
    if len(read)!= 0:
        t = read.decode("utf-8").strip()
        print(t)
        my_label.config(text = t)
        ser.flushInput()
        ser.flushOutput()

my_button = Button(Main_window,  text="Refresh", bg="gold", font=("Arial", 16), command = sensorhub)
my_label1 = Label(Main_window, text = today , font = "Helvetica 24 bold")
my_label = Label(Main_window, text = " ", fg = "white", bg = "red", font = "Helvetica 48 bold")
my_label2 = Label(Main_window, text = "Temperature (c) & Humidity (%)" , font = "Helvetica 24 bold")
my_button.pack()
my_label1.pack()
my_label2.pack()
my_label.pack(fill=BOTH, expand=1)
Main_window.mainloop()

Hexabitz-Weather-Station Module Code

C/C++
/*
 BitzOS (BOS) V0.2.9 - Copyright (C) 2017-2023 Hexabitz
 All rights reserved

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"
uint8_t MESG_T[5];

uint8_t MESG_H[5];

char a1 ,a2;
/* Private variables ---------------------------------------------------------*/
 float temper;
 float humidity;
/* Private function prototypes -----------------------------------------------*/
// char *user_data = "The application is running\r\n"; //demo data for transmission-
/* Main function ------------------------------------------------------------*/

int main(void){

	Module_Init();		//Initialize Module &  BitzOS

	//MX_USART5_UART_Init();
		//Don't place your code here.
	for(;;){}
}


/* User Task */
void UserTask(void *argument){

//StreamTemperatureToPort(1, 4, 100, 5000000);

//	HAL_UART_Transmit (&huart4, H0AR9_temperature;, 11, 0xffff);
	// put your code here, to run repeatedly.
	while(1){
	 SampleTemperature(&temper);
	 sprintf(MESG_T, "%f",temper);

     HAL_UART_Transmit_IT(&huart5, MESG_T,5);
	 Delay_ms(10);


	 SampleHumidity(&humidity);
	 sprintf(MESG_H, "%f",humidity);

	 HAL_UART_Transmit_IT(&huart5, MESG_H,5);
	 Delay_ms(10);

	}
}



/*-----------------------------------------------------------*/

Hexabitz-Weather-Station GUI Code -Test with HF1R0 module

Python
#AulaJazmati
from tkinter import *
import time
import serial
from datetime import date
from struct import *
today = date.today()
print("Today's date:", today)
ser = serial.Serial(        
               port='/dev/ttyUSB0',
               baudrate = 921600,
               parity=serial.PARITY_NONE,
               stopbits=serial.STOPBITS_ONE,
               bytesize=serial.EIGHTBITS,
               timeout=1
           )

print(ser.name)
Main_window = Tk()
Main_window.config(background = "gray86")
Main_window.title('Hexabitz Weather Station')

Main_window.geometry('700x250+50+50')
def byte_to_dec(b):
    x = struct.unpack('d', b)
    return x
def sensorhub():
    global t
    read = ser.read(8)
    if len(read)!= 0:
        [t,] = byte_to_dec(read)
        print(t)
        t = t*aa
        my_label.config(text = round(t,2))
        ser.flushInput()
        ser.flushOutput()

my_button = Button(Main_window,  text="Refresh", bg="gold", font=("Arial", 16), command = sensorhub)
my_label1 = Label(Main_window, text = today , font = "Helvetica 24 bold")
my_label = Label(Main_window, text = " ", fg = "white", bg = "red", font = "Helvetica 48 bold")
my_label2 = Label(Main_window, text = "Temperature (c) & Humidity (%)" , font = "Helvetica 24 bold")
my_button.pack()
my_label1.pack()
my_label2.pack()
my_label.pack(fill=BOTH, expand=1)
Main_window.mainloop()

Hexabitz-Weather-Station GUI Code

H0AR9x-Firmware

Credits

Aula Jazmati

Aula Jazmati

52 projects β€’ 215 followers
πŸ’‘πŸ•ŠοΈ

Comments