This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import json | |
| # SAME RASPBERRY PI TESTING | |
| SERVER_IP = "127.0.0.1" | |
| # For another Raspberry Pi: | |
| # SERVER_IP = "192.168.x.x" | |
| PORT = 5000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import time | |
| import json | |
| import board | |
| import adafruit_dht | |
| # ----------------------------- | |
| # DHT SENSOR SETUP | |
| # ----------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| SERVER_IP = '192.168.1.10' # Replace with your server IP | |
| PORT = 5000 | |
| client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| client_socket.connect((SERVER_IP, PORT)) | |
| print("Connected to server") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import Adafruit_DHT | |
| import time | |
| # Sensor setup | |
| sensor = Adafruit_DHT.DHT11 | |
| pin = 4 | |
| # Server setup | |
| HOST = '0.0.0.0' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Adafruit_DHT | |
| sensor = Adafruit_DHT.DHT11 | |
| pin = 4 | |
| humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) | |
| if humidity is not None and temperature is not None: | |
| print(f"Temperature: {temperature}°C") | |
| print(f"Humidity: {humidity}%") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Shape { | |
| void display() { | |
| System.out.println("Shape Class"); | |
| } | |
| } | |
| class Parallelepiped extends Shape { | |
| double l, b, h; | |
| Parallelepiped(double l, double b, double h) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Shape { | |
| // Volume methods | |
| double volume(double l, double b, double h) { | |
| return l * b * h; // Parallelepiped | |
| } | |
| double volume(double r) { | |
| return (4.0 / 3.0) * Math.PI * r * r * r; // Sphere | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Vehicle{ | |
| protected String licence_number; | |
| protected int speed; | |
| protected String color; | |
| protected String owner_name; | |
| Vehicle(String licence_number, int speed, String color, String owner_name){ | |
| this.licence_number = licence_number; | |
| this.speed = speed; | |
| this.color = color; |