Mundarija:

EnergyChain: 4 qadam
EnergyChain: 4 qadam

Video: EnergyChain: 4 qadam

Video: EnergyChain: 4 qadam
Video: 'Chaar Kadam' FULL VIDEO Song | PK | Sushant Singh Rajput | Anushka Sharma | T-series 2024, Noyabr
Anonim
EnergyChain
EnergyChain

/ * Ish davom etmoqda */

Energiya zanjiri - IOC va Blockchain -ni birlashtirgan POC.

Biz yaratgan narsalar odamlarga ishlab chiqaradigan energiyasini hech kimga keraksiz sotish imkonini beradi. Ishlab chiqaruvchi va iste'molchi o'rtasida xavfsizlikni ta'minlash uchun iste'molchi o'zi xohlagan narsani bog'lab, energiya olishi mumkin. Qutida iste'mol qilingan oqim miqdori o'lchanadi va ekvivalenti yoziladi

1 -qadam: materiallar

Materiallar
Materiallar
Materiallar
Materiallar
Materiallar
Materiallar

Ushbu loyihani yaratish uchun biz quyidagilarni ishlatamiz:

- 1 ta Raspberry Pi Zero

- 1 ta oqim sensori AS712 (20A)

- 1 ADC 16bit I2C ADS1555

- 1 ta RFID sensori RC522

- 1 ta 5V o'rni

- Farnelldan 1AC/DC 5V/2A konvertori ECL10US05-E

- 1 ta elektr rozetkasi

2 -qadam: simlarni ulash

Ulanish
Ulanish

Rasmda ko'rsatilgandek, biz hamma narsani bir -biriga bog'lab qo'yishimiz kerak, Raspberry Pi etkazib beradigan oqimdan ehtiyot bo'ling.

Buyruq simlari:

  • 3v3 quvvat - o'rni 5V Vcc/oqim sensori Vcc/RFID Vcc/ADC Vcc
  • 5v quvvat - AC/shahar konvertori 5v
  • Topraklama - 5V GND/oqim sensori GND/AC/DC konvertori GND/RFID GND/ADC kirish va chiqish GND
  • BCM 2 - ADC SDA
  • BCM 3 - ADC SCL
  • BCM 4 - ADC CLK
  • BCM 6 - RFID SDA
  • BCM 9 - RFID MISO
  • BCM 10 - RFID MOSI
  • BCM 11 - RFID SCK
  • BCM 17 - 5V IN o'rni
  • BCM 24 - RFID sozlamalarini tiklash
  • BCM 25 - RFID RFID

3 -qadam: kod

Bu kod quyidagicha ishlaydi:

RFID sensori tegni kutadi va uni terminalga yozadi, keyin joriy sensor iste'mol qilinadigan AC oqimini o'lchaydi va terminalda har 100 o'lchovda bir lahzali quvvatni ko'rsatadi. Buning yordamida biz kVt soatni olishimiz mumkin.

import soketi, json

tishli importdan sys import pirc522 dan mavzu RFID import RPi. GPIO sifatida GPIO ## Import GPIO kutubxonasi import signalini import vaqtini import qilish Adafruit_ADS1x15 GPIO.setmode (GPIO. BOARD) GPIO.setup (11, GPIO. OUT) GPIO.output (11, True) rdr = RFID () util = rdr.util () util.debug = True TCP_IP = '172.31.29.215' TCP_PORT = 5000 BUFFER_SIZE = 1024 adc = Adafruit_ADS1x15. ADS1115 () def end_read (signal, ramka): global ishga tushirish print ("\ nCtrl+C yozildi, o'qish tugadi.") run = False rdr.cleanup () sys.exit () signal.signal (signal. SIGINT, end_read) def loopRead (s): DemandeTag = 1 DemandeMesure = 0 bol = Haqiqiy vaqt (bol): agar DemandeTag == 1: tag () DemandeTag = 0 DemandeMesure = 1 bo'lsa DemandeMesure == 1: Mesure2 () try: data = s.recv (BUFFER_SIZE), agar ma'lumotlar bo'lmasa: chop etish ma'lumotlarini buzishJSON = jSON ['xabar'] == "chiqish": chop etish ("Talabdan chiqish") GPIO.output (11, GPIO. HIGH) DemandeTag = 0 DemandeMesure = 0 bol = False if dataJSON ['message'] == "on": GPIO.output (11, GPIO. LOW) DemandeMesure = 1 DemandeTag = 1 agar dataJSON ['message'] == "off" bo'lsa: GPIO.output (11, GPIO. HIGH) DemandeTag = 1 message = '' istisno bundan mustasno e: davom s.close () def tag (): rdr.wait_for_tag () (xato, ma'lumotlar) = rdr.request () time.sleep (0.25) (xato, uid) = rdr.anticoll () ID = str (uid [0])+'. '+str (uid [1])+'. '+str (uid [2])+'. '+str (uid [3]) chop etish ("Kartani o'qish UID:"+ID) GPIO. chiqish (11, GPIO. LOW) def Mesure (): mesure_voltage = 0 Nbre_mesure = 100 i = 0 i Mesure2 (): mesure_voltage = 0 Nbre_mesure = 200 max_voltage = 0 min_voltage = 32768 mVparAmp = 100 Puissance = 0 i = 0 readValue = 0 imax_voltage: max_voltage = readValue if readValue def Mesure3 (): print (str (adc.read_adc (0, daromad = 1)))) if _name_ == "_main_": s = socket.socket (socket. AF_INET, socket. SOCK_STREAM)) #s.connect ((TCP_IP, TCP_PORT)) #s.setblocking (0) loopRead (s)

4 -qadam: quti

Barcha elektronikani ixchamroq qilish uchun biz ichidagi hamma narsani o'z ichiga oladigan qutini yaratdik. Hamma narsani burish uchun biz M3 vintlarini ishlatamiz.

Tavsiya: