hakan_dev
@keskin-h · Joined December 2025
Backend geliştirici · yazılım
- Topics
- 5
- Replies
- 38
- Points
- 0
Forum Replies Created
Okumayı hızlı, göndermeyi seyrek yap, ikisi ayrı şeyler. Biz su tarafında böyle kuruyoruz:
- Pi her saniye okumaya devam etsin.
- Her değer için bir ölü bant: PT100’de 0.2 °C, debide %1 gibi. Değer son gönderilenden ölü banttan fazla saparsa gönder.
- Hiç değişmese bile her 5 dakikada bir heartbeat olarak gönder.
- Tepeler için anlık debiye güvenme, debimetrenin toplam (totalizer) register’ını gönder. Arada ne olursa olsun toplam kaybolmaz, Hermetry’de increase ile saatlik hacmi alırsın.
Mesaj sayısı için: bir mesajın içinde kaç kayıt olduğu önemli değil, mesaj başına sayılıyor. Değişenleri biriktirip 30 saniyede bir ts’li dizi olarak tek mesajda gönderirsen hem kotaya hem detaya iyi gelir.
1.4e-38 kelime sırası. İki 16 bitlik register’ı ters birleştiriyorsun. Debimetrenin dokümanına bak, çoğu CDAB kullanıyor:
import struct
hi, lo = rr.registers[0], rr.registers[1]
abcd = struct.unpack(">f", struct.pack(">HH", hi, lo))[0]
cdab = struct.unpack(">f", struct.pack(">HH", lo, hi))[0]
Kota hesabı burada: Mesaj kotası ve kullanım
Pille 3 yıl Wi-Fi ile olmaz. Kendi radyonla devam edeceksen kontrol odasında bir Pi, Hermetry’ye gateway olarak bağlanır, her sensör child cihaz olur. Gateway yazılımını sen yazarsın.
2400 baud’u ben de bilmiyordum, not aldım.
Sanırım Hermetry gateway için Basics Station istiyordu, ESP32’de o çalışır mı bilmiyorum.
Translated from Türkçe by AI ·
I fell into the BMP280 trap too, get well soon 🙂
BMP280 tuzağına ben de düşmüştüm, geçmiş olsun 🙂
bluetooth servisi çalışıyor mu? systemctl status bluetooth
Translated from Türkçe by AI ·
i2cdetect -y 0 try it, maybe it’s on the other bus.
i2cdetect -y 0 dene, belki diğer bus’tadır.
Translated from Türkçe by AI ·
I experienced both, in a weighing scale project.Port name: the ttyUSB number is assigned based on enumeration order, so don’t trust it. Check with ls -l /dev/serial/by-id/, there is a permanent name containing the converter’s serial number, use that. If you have two of the same chip and no serial numbers, you can name them by USB port with a udev rule, but most of the time by-id is enough.readline: by default it waits for . Most indicators end lines with
, so it never returns. Also, if you don’t set a timeout, it waits forever when the cable is unplugged. What I use:
PORT = '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10K3XYZ-if00-port0'
ser = serial.Serial(PORT, 9600, bytesize=8, parity='N', stopbits=1, timeout=2)
buf = b''
while True:
chunk = ser.read(64)
if not chunk:
continue # no data for 2 s, log here
buf += chunk
while b'' in buf:
line, buf = buf.split(b'', 1)
w = parse_weight(line) # e.g. b'ST,GS,+0012.45kg'
if w is not None:
client.publish('v1/telemetry', json.dumps({'weight_kg': w}), qos=1)
If the indicator prints several times a second, don’t send every line. Send once per second, or only the ST (stable) lines. Write a systemd unit for the service, put your own user in the User= line, and use Restart=always.
İkisini de yaşadım, bir kantar projesinde.
Port adı: ttyUSB numarası takılma sırasına göre veriliyor, güvenme. ls -l /dev/serial/by-id/ ile bak, orada çeviricinin seri numaralı kalıcı adı var, onu kullan. Aynı çipten iki tane varsa ve seri numaraları yoksa udev kuralıyla USB portuna göre isim verirsin, ama çoğu zaman by-id yetiyor.
readline: varsayılan olarak bekliyor. Çoğu indikatör satırı
ile bitiriyor, o yüzden hiç dönmüyor. Bir de timeout vermezsen kablo çıktığında da sonsuza kadar bekler. Benim kullandığım:
PORT = '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10K3XYZ-if00-port0'
ser = serial.Serial(PORT, 9600, bytesize=8, parity='N', stopbits=1, timeout=2)
buf = b''
while True:
chunk = ser.read(64)
if not chunk:
continue # 2 sn veri yok, burada log yaz
buf += chunk
while b'
' in buf:
line, buf = buf.split(b'
', 1)
w = parse_weight(line) # örn. b'ST,GS,+0012.45kg'
if w is not None:
client.publish('v1/telemetry', json.dumps({'weight_kg': w}), qos=1)
İndikatör saniyede birkaç kez basıyorsa her satırı gönderme. Hermetry’de cihaz başına varsayılan limit saniyede 10 mesaj, üstü sessizce düşüyor. Saniyede bir, ya da sadece ST (stabil) satırlarını yolla. Servis için systemd unit yaz, User= satırına kendi kullanıcını koy, Restart=always.
Translated from Türkçe by AI ·
You already have PZEM’s own counter, energy_wh. Use it, don’t bother deriving energy from watts. I went through the same thing when I measured my fridge at home with the same module.In the Chart card, select the energy_wh key, bucket 1 day (1d), aggregate increase. increase is meant for counter-type values: it subtracts the last value of the previous bucket from the last value of each bucket. If the counter goes down (if you reset the PZEM or it rolls over at 9999 kWh), it counts that bucket as if it started from zero, so you won’t see a negative value.The advantage is this: even if the ESP32 drops off for a while, the counter keeps counting on the PZEM, and when it reconnects the energy difference in between isn’t lost. avg × 24 loses that gap.I think the midnight split you mentioned is this: day buckets are cut according to UTC, midnight to midnight UTC. Since Turkey is UTC+3, your “day” appears to start at 03:00 local time. If you write one line about this in the report, it won’t be a problem.If you also want a derived key in the stream (for example the difference at each reading), there is a Delta block, but it isn’t needed for a daily total. Both are explained here: Derived values.
Elinde zaten PZEM’in kendi sayacı var, energy_wh. Onu kullan, watt’tan enerji türetmekle uğraşma. Ben aynı modülle evdeki buzdolabını ölçerken aynı şeyi yaşadım.
Chart kartında energy_wh anahtarını seç, kova olarak 1 gün (1d), aggregate olarak increase. increase sayaç tipi değerler için var: her kovanın son değerinden bir önceki kovanın son değerini çıkarıyor. Sayaç geri düşerse (PZEM’i resetlersen ya da 9999 kWh’de dönerse) o kovada sıfırdan başlamış gibi sayıyor, yani eksi değer görmezsin.
Avantajı şu: ESP32 bir süre koparsa bile sayaç PZEM’de saymaya devam ediyor, tekrar bağlandığında aradaki enerji farkı kaybolmuyor. avg × 24’te o boşluk kayıp.
Gece yarısı bölünme dediğin şey de bence şu: gün kovaları UTC’ye göre kesiliyor, gece yarısından gece yarısına UTC. Türkiye UTC+3 olduğu için senin “gün”ün sabah 03:00’te başlıyor gibi görünür. Rapora bunu bir satırla yazarsan sorun olmaz.
Akış içinde ayrıca bir türetilmiş anahtar istersen (mesela her okumadaki fark) Delta bloğu da var, ama günlük toplam için gerek yok. Burada ikisi de anlatılıyor: Türetilmiş değerler.
preTransmission ve postTransmission fonksiyonlarını tanımladınız mı? Onlar olmadan MAX485 hiç göndermez.
Bir operatör bilgisayarına uzaktan tuş yazdıran bir cihaz güvenlik açısından ciddi bir şey. Kartın komut listesinde sadece bu komut olsun, raw komut yetkisini kimseye vermeyin.
Bir su projesinde aynı kararı verdik, şöyle yaptık ve çalışıyor:
Hazır bir IO-Link master aldık, Ethernet tarafında Modbus TCP konuşanlardan. Birkaç üreticinin böyle modeli var, her portun proses verisi ve ISDU ile okunan teşhis değerleri Modbus register’larına haritalanıyor. Model seçerken tek şart: dökümanında register haritası açıkça yazıyor olsun.
Sonra iki yol var:
- Lisanslı bir ağ geçidi Modbus TCP’yi okuyorsa (hangi protokoller olduğu modele bağlı) master’ı orada tanımlıyorsunuz, her sensör Hermetry’de ayrı child cihaz olarak çıkıyor.
- Kendi kutunuzda (bizde bir Pi) pymodbus ile okuyup
v1/gw/telemetryile gönderiyorsunuz:
{"PT-101": {"values": {"p_bar": 3.42, "sensor_temp": 31.5}},
"LT-102": {"values": {"level_cm": 214, "dirty_lens": 0}}}
Hermetry her ismi ilk raporda child cihaz olarak açıyor. Ağ geçidini eklerken “This device is a gateway” işaretli olmalı, yoksa v1/gw/* konuları reddediliyor. Teşhis bitlerini 0/1 sayı olarak gönderin ki grafikte görünsün ve alarm kurulabilsin.
Dökümantasyon: Ağ geçidinin arkasındaki cihazlar
Translated from Türkçe by AI ·
Derya Hanım, thank you very much, it has been working for two days. On the first save the card showed a location warning; after I added the site as an asset and entered the coordinates, it saved. I connected the MOSFET with a pull-down, and now the lights no longer blink while the Pi boots. I had also tried a relay, but the clicking sound apparently bothered the guard 😄
Derya Hanım çok sağ olun, iki gündür çalışıyor. İlk kaydetmede kart konum uyarısı verdi, siteyi varlık olarak ekleyip koordinatı girince kaydetti. MOSFET’i pull-down ile bağladım, Pi açılırken lambalar artık yanıp sönmüyor. Röle de denemiştim, tık sesi bekçiyi rahatsız ediyormuş 😄
İkisi de doğru, ikisini birden düzeltmen lazım.
Baud: ESP’ye bir kez 115200’den kalıcı baud değiştirme komutu gönder. SoftwareSerial 115200’de yazarken genelde sorun çıkarmıyor, okurken bozuyor, o yüzden komut gider. Birkaç deneme gerekebilir:
mySerial.begin(115200);
mySerial.println("AT+UART_DEF=9600,8,1,0,0");
delay(200);
mySerial.begin(9600);
mySerial.println("AT"); // artık temiz OK gelmeli
Güç: Uno’nun 3.3V pini 50 mA civarı veriyor, ESP-01 gönderirken birkaç yüz mA çekiyor. “WIFI DISCONNECT” ve “busy p…” tam bunun belirtisi. 5V’tan ayrı bir AMS1117-3.3 ile besle, ESP’nin dibine 100 µF + 100 nF koy. Uno TX → ESP RX hattına da gerilim bölücü (1k/2k), ESP 3.3V seviyesinde.
Hermetry kısmı: cihaz API’si HTTPS bekliyor. AT firmware’inde SSL desteği sürüme göre değişiyor ve ESP-01’in belleğinde zorlanıyor. Benim tavsiyem Uno’yu tamamen çıkarmak: ESP-01’e Arduino core ile kendi sketch’ini yükle, sensörü doğrudan ona bağla, WiFiClientSecure ile POST at.
Translated from Türkçe by AI ·
The ESP32 should actually be at microamp level in deep sleep, the 10 mA may be coming from the USB chip and LED on the DevKit board. Measure again with the bare module.
ESP32 deep sleep’te mikroamper seviyesinde olmalı aslında, 10 mA DevKit’in üstündeki USB çipi ve LED’den geliyor olabilir. Çıplak modülle tekrar ölç.

