New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Hakan Keskin

hakan_dev

@keskin-h · Joined December 2025

Newcomer

Backend geliştirici · yazılım

Topics
5
Replies
38
Points
0
Newcomer10 points to Member

Forum Replies Created

Viewing 15 posts – 16 through 30 (of 38 total)

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

Ağ geçidi yine bağlanıyor…
Accepted solution♥ 5

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.

Ağ geçidi yine bağlanıyor…
Accepted solution♥ 5

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.

Ağ geçidi yine bağlanıyor…
Accepted solution♥ 2

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:

  1. 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.
  2. Kendi kutunuzda (bizde bir Pi) pymodbus ile okuyup v1/gw/telemetry ile 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

Ağ geçidi yine bağlanıyor…
Accepted solution♥ 8

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 😄

Ağ geçidi yine bağlanıyor…
♥ 0

İ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.

Ağ geçidi yine bağlanıyor…
Accepted solution♥ 4

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.

Ağ geçidi yine bağlanıyor…
♥ 0
Viewing 15 posts – 16 through 30 (of 38 total)