commit 96b2d8e331f2976f0f35155b6497afda08af505b Author: Xavier Date: Tue Aug 22 19:57:03 2023 +0200 first commit diff --git a/README.md b/README.md new file mode 100755 index 0000000..077d3b3 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ + Telecommande QO100 +=========================== + +## Pre-requis + +sudo apt-get install rpi.gpio git + +
ou en manuel + +wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz
+tar -xvf RPi.GPIO-0.5.11.tar.gz
+cd RPi.GPIO-0.5.11
+sudo python setup.py install
+ +## 1) Installation +Commande de 16 relais
+Pour installer ce script, aller dans /home/pi
+ +copier control.zip et déziper le dans /home/pi
+
+ +## 2) Pour un démarrage auto + +éditer dans /etc/rc.local
+sudo nano /etc/rc.local
+ajouter en fin avant exit
+ +#gestion Relay a 0
+./home/pi/relay.py power 1
+gohttp.sh
+ +puis de faire un fichier executable
+gohttp.sh dans /usr/local/sbin contenant:
+``` +#!/bin/bash +cd /home/pi +./gohttp.py +exit 0 +``` + +faire un reboot
+ +configurer config.json
+ +url= ip du RPi
+port= le port choisi
+com1 à 16 = les discription des relais
+ +## 3) Pour le arduino nano + +programmer le avec telemetry.ino
+cabler USB sur le port com du raspberry pi
+Dans schema vous avec le plan et les fichier gerber
diff --git a/control.zip b/control.zip new file mode 100644 index 0000000..2961a2e Binary files /dev/null and b/control.zip differ diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..c1b264e Binary files /dev/null and b/favicon.ico differ diff --git a/schema/Gerber_PCB_telemetry.zip b/schema/Gerber_PCB_telemetry.zip new file mode 100644 index 0000000..41a283c Binary files /dev/null and b/schema/Gerber_PCB_telemetry.zip differ diff --git a/schema/Schematic_telemetry_2023-07-23.png b/schema/Schematic_telemetry_2023-07-23.png new file mode 100644 index 0000000..0e46661 Binary files /dev/null and b/schema/Schematic_telemetry_2023-07-23.png differ diff --git a/schema/relay.png b/schema/relay.png new file mode 100644 index 0000000..bf50d32 Binary files /dev/null and b/schema/relay.png differ diff --git a/schema/thermostat.jpg b/schema/thermostat.jpg new file mode 100755 index 0000000..9d44b19 Binary files /dev/null and b/schema/thermostat.jpg differ diff --git a/telemetry.ino b/telemetry.ino new file mode 100644 index 0000000..662f252 --- /dev/null +++ b/telemetry.ino @@ -0,0 +1,228 @@ +// Suitable with 12v battery, adaptor wattage, current and voltage monitoring. +// Resistor divider network need more upgradation if voltage is higher that 15.6 +// Try 0x3D OLED address if screen did not work. +// Precision of the voltage depends on the tolerance of the resistors. + +#include +#include +#include +#include +#include + +#define OLED_RESET -1 +Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET); + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); + + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Change the address to your's one + display.clearDisplay(); + // Start up the library + sensors.begin(); + display.clearDisplay(); + + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(0, 30); + // Display static text + display.println("F4IYT 1.00"); //Write custom text here + display.display(); + delay(100); + // Scroll in various directions, pausing in-between: + display.startscrollright(0x00, 0x0F); + delay(2000); + display.stopscroll(); + delay(1000); + display.startscrollleft(0x00, 0x0F); + delay(1000); + display.stopscroll(); + delay(1000); + display.startscrolldiagright(0x00, 0x07); + delay(1000); + display.startscrolldiagleft(0x00, 0x07); + delay(1000); + display.stopscroll(); + delay(1000); +} + +float Vref=5.00; +float pts=1024.0; +//5v +float R4=10000.0; // R4 10K +float R6=10000.0; // R6 10K +//12v +float R3=100000.0; // R4 100K +float R5=10000.0; // R6 10K +//27v +float R1=100000.0; // R4 100K +float R2=10000.0; // R6 10K + +//amp => 0.100 for 20A, 0.185 for 30A, 0.66 for 5A +// follow this link: +//https://startingelectronics.org/articles/arduino/measuring-voltage-with-arduino/ +float amp=0.185; + +void loop() { + // put your main code here, to run repeatedly: + int adc0 = analogRead(A0); + int adc1 = analogRead(A1); + int adc2 = analogRead(A2); + int adc3 = analogRead(A3); + int adc6 = analogRead(A6); + int adc7 = analogRead(A7); + //Gestion 27v + float voltage0 = (adc0 * Vref) / pts; + float voltage1 = (((adc1 * Vref)/pts)/(R2/(R1+R2))); // resistor divider basics needed to be learn + float current0 = (voltage0 - 2.5) / amp; + //Gestion 12v + float voltage2 = (adc2 * Vref) / pts; + float voltage3 = (((adc3 * Vref)/pts)/(R5/(R3+R5))); // resistor divider basics needed to be learn + float current2 = (voltage2 - 2.5) / amp; + //Gestion 5V + float voltage6 = (adc6 * Vref) / pts; + float voltage7 = (((adc7 * Vref)/pts)/(R6/(R4+R6))); // resistor divider basics needed to be learn + float current6 = (voltage6 - 2.5) / amp; + + + // request to all devices on the bus + sensors.requestTemperatures(); // Send the command to get temperatures + + // After we got the temperatures, we can print them here. + // We use the function ByIndex, and as an example get the temperature from the first sensor only. + float tempC0 = sensors.getTempCByIndex(0); + float tempC1 = sensors.getTempCByIndex(1); + float tempC2 = sensors.getTempCByIndex(2); + + + //Check + if (voltage1<0.99) { + voltage1=0.00; + } + if (voltage3<0.99) { + voltage3=0.00; + } + if (voltage7<0.99) { + voltage7=0.00; + } + if (current0 < 0.16) { + current0 = 0; + } + if (current2 < 0.16) { + current2 = 0; + } + if (current6 < 0.16) { + current6 = 0; + } + if (tempC0<0.00) { + tempC0=0.00; + } + if (tempC1<0.00) { + tempC1=0.00; + } + if (tempC2<0.00) { + tempC2=0.00; + } + //if (Serial.available()>0) { + //if (Serial.read()=='m') { + //Courant + Serial.print(current0); + Serial.print(F(",")); + Serial.print(current2); + Serial.print(F(",")); + Serial.print(current6); + Serial.print(F(",")); + //Tension + Serial.print(voltage1); + Serial.print(F(",")); + Serial.print(voltage3); + Serial.print(F(",")); + Serial.print(voltage7); + Serial.print(F(",")); + //Temperature + Serial.print(tempC0); + Serial.print(F(",")); + Serial.print(tempC1); + Serial.print(F(",")); + Serial.print(tempC2); + Serial.print(F("\n")); + //} + //} + + //Gestion display + display.clearDisplay(); + display.setTextSize(1); + display.setTextColor(WHITE); + + display.setCursor(0,0); + display.print("A: "); + display.print(current0); + display.display(); + + display.setCursor(0,10); + display.print("V: "); + display.print(voltage1); + display.display(); + + display.setCursor(0,20); + display.print("P: "); + display.print(current0*voltage1); + display.display(); + + display.setCursor(60,0); + display.print("A: "); + display.print(current2); + display.display(); + + display.setCursor(60,10); + display.print("V: "); + display.print(voltage3); + display.display(); + + display.setCursor(60,20); + display.print("P: "); + display.print(current2*voltage3); + display.display(); + + display.setCursor(0,30); + display.print("A: "); + display.print(current6); + display.display(); + + display.setCursor(0,40); + display.print("V: "); + display.print(voltage7); + display.display(); + + display.setCursor(0,50); + display.print("P: "); + display.print(current6*voltage7); + display.display(); + + display.setCursor(60,30); + display.print("T0: "); + display.print(tempC0); + display.display(); + + display.setCursor(60,40); + display.print("T1: "); + display.print(tempC1); + display.display(); + + display.setCursor(60,50); + display.print("T2: "); + display.print(tempC2); + display.display(); + + + delay(3000); +}