thompsonplc
@lthompson · Se unió el mayo 2025
Automation engineer · pharma · 14 years in the field
- Temas
- 7
- Respuestas
- 65
- Puntos
- 0
Respuestas de foro creadas
The readings stored before the fix keep the wrong value, so if that night matters, export it and correct it by hand.
Traducido del English por IA ·
No necesitas tokens por dispositivo en el firmware. Divide el problema en dos.Wi-Fi: mantén WiFiManager. Añade un campo personalizado en el portal si quieres un nombre de dispositivo amigable; si no, usa la MAC.Token: deja que el nodo pida el suyo. En el perfil del dispositivo abre la pestaña Provisioning, pon la estrategia en Allow creating new devices, guarda, luego pulsa Create key y copia el secreto (se muestra una sola vez). Esa clave y secreto son los mismos para las 12 compilaciones. En el primer arranque el nodo se conecta con el usuario provision y una contraseña vacía, se suscribe a v1/provision/res y publica su solicitud. La respuesta incluye su token de acceso; lo guardas en NVS y a partir de entonces inicia sesión normalmente.
// first boot only, after Wi-Fi is up
mqtt.setServer(host, 8883); // WiFiClientSecure, TLS
mqtt.connect(clientId, "provision", "");
mqtt.subscribe("v1/provision/res", 1);
String req = String("{"deviceName":"aq-") + mac6 +
"","provisionDeviceKey":"pk_xxx","provisionDeviceSecret":"ps_xxx"}";
mqtt.publish("v1/provision/req", req.c_str());
// in the callback: parse credentialsValue when status == "SUCCESS",
// prefs.putString("tok", value); then reconnect with the token as username
Dos cosas nos dieron problemas en una planta farmacéutica. Los dispositivos nuevos creados así acaban en cuarentena: se conectan, pero sus datos se descartan hasta que un administrador los active, así que avisa al responsable de la organización para que los busque. Y el nombre debe ser único; una segunda solicitud con el mismo nombre recibe device_exists, porque nunca entrega una credencial dos veces. Por eso no borres la NVS a la ligera. Los detalles están en Adding and claiming devices.
You don’t need per-device tokens in the firmware at all. Split it in two problems.
Wi-Fi: keep WiFiManager. Add one custom field in the portal if you want a friendly device name, otherwise use the MAC.
Token: let the node ask for its own. On the device profile open the Provisioning tab, set the strategy to Allow creating new devices, save, then Create key and copy the secret (it’s shown once). That key + secret is the same for all 12 builds. On first boot the node connects with username provision and an empty password, subscribes to v1/provision/res and publishes its request. The answer carries its access token, you store that in NVS and from then on it logs in normally.
// first boot only, after Wi-Fi is up
mqtt.setServer(host, 8883); // WiFiClientSecure, TLS
mqtt.connect(clientId, "provision", "");
mqtt.subscribe("v1/provision/res", 1);
String req = String("{"deviceName":"aq-") + mac6 +
"","provisionDeviceKey":"pk_xxx","provisionDeviceSecret":"ps_xxx"}";
mqtt.publish("v1/provision/req", req.c_str());
// in the callback: parse credentialsValue when status == "SUCCESS",
// prefs.putString("tok", value); then reconnect with the token as username
Two things bit us on a pharma site. New devices created this way land in quarantine, they connect but their data is dropped until an admin activates them, so tell whoever owns the org to look for them. And the name must be unique, a second request with the same name gets device_exists because it never hands out a credential twice. So never wipe NVS casually. Details are on Adding and claiming devices.
Traducido del English por IA ·
Kstewart tiene razón. Hay una pasarela Basics Station en el laboratorio de QA del piso de arriba, registrada en nuestra organización por el equipo de QA. Esa es la que captó mis tramas «esporádicas», mi placa de desarrollo nunca reenvió ni una. La tomé prestada para el banco, quité la placa de un solo canal y el truco del canal. El join funciona a la primera, los uplinks cada 60 s en los ocho canales. El truco de 868.1 sí funcionó mientras tanto, para que conste.
Kstewart got it. There is a Basics Station gateway in the QA lab on the floor above, registered in our org by the QA team. That’s what heard my «sporadic» frames, my dev kit board never forwarded a single one. Borrowed it for the bench, removed the single-channel board, removed the channel hack. Joins first time, uplinks every 60 s on all eight channels. The 868.1 trick did work in between, for the record.
Traducido del English por IA ·
Aoife, por desgracia la Pi no tiene modo de suspensión profunda. Es una caja Linux: o está funcionando o está apagada. Así que corta todo lo que puedas y haz que la radio trabaje menos.Lo que haría, por orden de beneficio:
- Pi:
dtoverlay=disable-wifiydtoverlay=disable-bten config.txt, HDMI apagado (tvservice -oen imágenes antiguas), LED de actividad apagado. En una Zero eso te deja en unos 80 mA. - GPS: apaga el motor GNSS entre fijaciones (
AT+CGPS=0, y luegoAT+CGPS=1otra vez). Un arranque en caliente del SIM7600 tarda unos pocos segundos. - Frecuencia: 30 s en movimiento, de 15 a 60 min aparcado. Decide según la velocidad o la distancia desde la última fijación.
- Lotes: almacena las fijaciones y envía un mensaje cada pocos minutos como un array con ts. El GPS da un reloj correcto, así que las marcas de tiempo son fiables. Una llamada HTTPS en lugar de diez supone menos tiempo de radio y consume un mensaje de la cuota mensual en vez de diez.
[{"ts": 1757683200000, "values": {"lat": 52.95231, "lon": -1.14972, "speed_kmh": 31.5}},
{"ts": 1757683230000, "values": {"lat": 52.95410, "lon": -1.14701, "speed_kmh": 33.0}}]
Como el dispositivo solo se comunica cada pocos minutos, pon la regla de en línea de su perfil en Recent message con un intervalo esperado que coincida con tu frecuencia aparcado; si no, aparecerá como desconectado toda la noche.Si una semana es un requisito estricto, la respuesta honesta es un microcontrolador (ESP32 o nRF) que duerma y despierte el módem, o un chip temporizador como el TPL5110 que corta la alimentación de toda la Pi entre ciclos. Una placa Linux en reposo a 80 mA nunca llegará a eso con 10 Ah.
Aoife, the Pi has no deep sleep, sadly. It’s a Linux box, it’s either running or off. So you cut everything you can and make the radio work less.
What I’d do, in order of payoff:
- Pi:
dtoverlay=disable-wifianddtoverlay=disable-btin config.txt, HDMI off (tvservice -oon older images), activity LED off. On a Zero that gets you to roughly 80 mA. - GPS: switch the GNSS engine off between fixes (
AT+CGPS=0, thenAT+CGPS=1again). A warm start on the SIM7600 is a few seconds. - Rate: 30 s while moving, 15 to 60 min while parked. Use speed or the distance from the last fix to decide.
- Batch: buffer fixes and send one message every few minutes as an array with ts. GPS gives you a correct clock, so the timestamps are trustworthy. One HTTPS call instead of ten is less radio time, and it costs one message out of the monthly quota instead of ten.
[{"ts": 1757683200000, "values": {"lat": 52.95231, "lon": -1.14972, "speed_kmh": 31.5}},
{"ts": 1757683230000, "values": {"lat": 52.95410, "lon": -1.14701, "speed_kmh": 33.0}}]
Because the device only talks every few minutes, set its profile’s online rule to Recent message with an expected interval that matches your parked rate, otherwise it shows offline all night.
If a week is a hard requirement, the honest answer is a microcontroller (ESP32 or nRF) that sleeps and wakes the modem, or a timer chip like a TPL5110 that cuts power to the whole Pi between runs. A Linux board idling at 80 mA will never get there on 10 Ah.
No register trick, I’m afraid. As far as I remember the sleep mode table in the 328P datasheet, the analog comparator is only a wake source in idle (and ADC noise reduction), not power-down. In power-down only the external interrupts, pin change, TWI address match and the watchdog wake it. Your idle current is the clocks running.
Move the comparator outside. A nanopower comparator with push-pull output into INT0 (D2) lets the 328P sit in power-down at a few µA. TLV3691 draws about 75 nA, and the reference can be a micropower 2.5 V shunt. Add hysteresis with a resistor from output to the + input, a few hundred mV at the battery side, otherwise a battery hovering at 11.8 V will wake you a hundred times a night as the load changes.
attachInterrupt(digitalPinToInterrupt(2), wake, FALLING);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable(); sleep_cpu(); // wakes on INT0 only
// on wake: read ADC once for the real value, send it, sleep again
Aoife: you can use the bandgap internally, but the comparator itself still can’t wake power-down, so it doesn’t help here.
On the Hermetry side I’d still send a heartbeat once a day with the voltage. Then an offline alarm on the profile tells you a sensor died, which a wake-only design never would. Put the low-voltage alarm rule on bat_v with some hysteresis too.
Monitor was on «Newline». Both NL & CR and NAME and UART went through at once. Kevin, the baud was fine, AT mode is always 38400 on these.
Traducido del English por IA ·
Hice esto con un montón de SG90 para un montaje didáctico. La modificación:
1. Abre la carcasa, saca el engranaje de salida. Corta o lima la pequeña lengüeta de plástico de su parte inferior que choca con el tope final.
2. El potenciómetro bajo el eje de salida es la realimentación de posición. Desuéldalo y pon dos resistencias de 2,2 kΩ en su lugar como divisor fijo (los extremos a las pistas exteriores, el centro a la pista del cursor). El servo ahora siempre cree que está en el centro.
3. Vuelve a montarlo. Ahora el ancho de pulso controla la velocidad y la dirección en lugar de la posición: unos 1,5 ms lo detienen, más corto gira en un sentido y más largo en el otro. Encuentra el valor exacto de parada por prueba y error, ya que la tolerancia de las resistencias lo desplaza.
A tu segunda pregunta: no, ya no sabe dónde está, igual que un FS90R. En una persiana eso importa, así que haz lo que dijo Keisha: añade un interruptor reed o un microinterruptor en totalmente abierta y totalmente cerrada, y cuenta el tiempo o añade un encoder barato intermedio. Sinceramente, un SG90 también es débil para una persiana real; un motor paso a paso 28BYJ-48 con placa ULN2003 te da la posición gratis y más par.
En cuanto a la placa: añade blind.set con un parámetro Number de 0 a 100 en la pestaña Commands del perfil del ESP32, nivel Basic. El Slider envía el valor una vez al soltarlo, no mientras arrastras, lo que encaja con un motor. Haz que el ESP32 publique su posición real como blind_pct y vincula el Current value del Slider a ella, para que la tarjeta muestre dónde está realmente la persiana.
Alimenta el servo o el paso a paso con su propia fuente de 5 V, no con el pin del ESP32.
Did this to a pile of SG90s for a teaching rig. The mod:
1. Open the case, take out the output gear. Cut or file off the little plastic tab on its underside that hits the end stop.
2. The potentiometer under the output shaft is the position feedback. Unsolder it and put two 2.2k resistors in its place as a fixed divider (ends to the outer pads, the middle to the wiper pad). The servo now always thinks it’s at centre.
3. Reassemble. Now the pulse width sets speed and direction instead of position: about 1.5 ms stops it, shorter turns one way, longer the other. Find the exact stop value by trial, resistor tolerance shifts it.
To your second question: no, it no longer knows where it is, same as an FS90R. For a blind that matters, so do what Keisha said, add a reed switch or microswitch at fully open and fully closed, and count time or add a cheap encoder in between. Honestly, an SG90 is also weak for a real blind, a 28BYJ-48 stepper with a ULN2003 board gives you position for free and more torque.
On the board side: add blind.set with a Number parameter 0-100 to the ESP32’s profile Commands tab, Basic tier. The Slider sends the value once on release, not while you drag, which suits a motor. Have the ESP32 publish its real position as blind_pct and bind the Slider’s Current value to it, so the card shows where the blind actually is.
Power the servo or stepper from its own 5 V supply, not the ESP32’s pin.
USB-RS485 with auto direction plus 680 R bias resistors at the Pi end: zero CRC errors over 10,000 polls. Children show up in Hermetry as mixer-11 to mixer-16. Ciaran, thanks.
120 R at both ends. No bias resistors anywhere, I’d assumed the PIC boards had them.
Traducido del English por IA ·
El año pasado revisé un diseño similar para un contratista, así que aquí está el razonamiento para el informe.Separa lo público de lo secreto. El paquete CA es público; el certificado del servidor es público y se verifica con un paquete CA normal, por lo que guardarlo en la tarjeta no es problema. La contraseña de WiFi y el token del dispositivo son secretos, ya que identifican exactamente a este dispositivo.Los secretos en medios extraíbles fallan por dos motivos: quitar la tarjeta no deja ningún rastro, y la tarjeta suele copiarse en otras placas («clona la tarjeta sin más»), así que varios dispositivos comparten una misma credencial. Hermetry permite una sola sesión por dispositivo; dos placas con el mismo token se expulsarían constantemente entre sí, y verías una toma de control en la pestaña Log del dispositivo.Sobre X.509: para tus propias placas no está disponible. Los certificados de cliente deben provenir de la autoridad de certificación de dispositivos de Hermetry, y no se ofrece subir tu propia CA para dispositivos de terceros; esa vía es para dispositivos licenciados que generan su clave y envían ellos mismos una CSR. Tu ESP32 usa un token de acceso o MQTT basic.Lo que haría en un ESP32:1. El mismo binario para cada placa es aceptable. Guarda el token en NVS durante el aprovisionamiento (un pequeño comando serie en el primer arranque), no en la tarjeta.2. Activa el cifrado de flash y el cifrado de NVS, para que un volcado de la flash no revele el token.3. La tarjeta solo para el registro de datos y el paquete CA.4. En Hermetry, un dispositivo y un token por placa; rota el secreto si una placa se pierde. Eso termina sus sesiones de inmediato.La limitación de certificados está en la última sección de Device certificates.
Did a review of a similar design for a contractor last year, so here’s the reasoning for the report.
Separate public stuff from secret stuff. The CA bundle is public; the server certificate is a public one and you verify it with a normal CA bundle, so keeping that on the card is fine. WiFi password and the device token are secrets, they identify this exact device.
Secrets on removable media fail on two counts: removing them leaves no trace, and the card usually gets copied into other boards («just clone the card»), and then you have several devices sharing one credential. Hermetry allows one session per device, so two boards with the same token keep kicking each other off, and you’d see takeover in the device’s Log tab.
On X.509: for your own boards it’s not available. Client certificates must come from Hermetry’s device certificate authority, and uploading your own CA for third-party devices is not offered; that path is for licensed devices that generate their key and send a CSR themselves. Your ESP32 uses an access token or MQTT basic.
What I’d do on an ESP32:
1. Same binary for every board is fine. Put the token in NVS at provisioning (a small serial command on first boot), not on the card.
2. Turn on flash encryption and NVS encryption, so a flash dump does not give up the token.
3. Card only for data logging and the CA bundle.
4. In Hermetry, one device and one token per board; rotate the secret if a board goes missing. That ends its sessions at once.
The certificate limitation is on Device certificates, last section.
The pH jumping with the EC probe in is a ground loop. Both EZO circuits share the Pi’s ground and the EC probe drives current through the water, which shifts the pH reference. Atlas sells an isolated carrier board for exactly this, put at least one of the two on it.
Traducido del English por IA ·
Solo entre el teléfono y la antena, y la versión de 2G de esa protección es débil, por eso funciona el truco de la furgoneta. Más allá del núcleo del operador es internet sin cifrar. Trate la radio como no confiable.
Only between the phone and the tower, and 2G’s version of it is weak, which is why the van trick works. After the operator’s core it’s plain internet. Treat the radio as untrusted.
Until something like that exists, do the zone decision on the robot. That’s also what the personnel tracking solution expects: the tracker or its gateway reports the zone name, and Hermetry’s rules work on that. I run exactly this for carts in a warehouse, ESP32 scanning fixed BLE tags.
every 2 s: scan 1.5 s, keep RSSI per known tag (EMA, alpha 0.3)
best = tag with highest smoothed RSSI
switch zone only if best beats the current zone's tag by 6 dB
for 3 scans in a row (stops flapping at borders)
publish on change and every 60 s:
{"zone": "F3-east", "zone_id": 32, "zone_rssi": -71}
Send both: zone as text for tables and the alarm, zone_id as a number because text keys have no chart history and you’ll want «where was it at 14:00».
For the kitchen corridor: give each cleaner a server attribute forbiddenZone = «F0-kitchen» and an alarm rule on the robot profile where zone equals that attribute. Per-device thresholds from attributes work for text too with ==. Same pattern the tracking solution uses, described on Personnel tracking.
Polygons: no workaround on the map that I know of. Map the polygon to tag zones instead, one zone per forbidden area.
Traducido del English por IA ·
Bien. Aun así, conviene planificar un reemplazo para ese Edison; lleva años fuera de producción y los repuestos son cada vez más difíciles de conseguir.
Good. Plan a replacement for that Edison though, it’s been out of production for years and spares get harder to find.
Aoife has the core of it.
Cutting the solenoid only puts the directional valve into its rest position. Depending on the valve type that can trap air in the cylinder (closed-centre 5/3 valves do exactly that), so the cylinder can still move when someone opens a fitting, or hold a load that drops later. A stuck valve spool is the other failure: power off, valve doesn’t move. Pneumatic energy is stored energy, and for safe access you want it gone, not held. The dump valve exhausts the supply to atmosphere so the cell ends up at zero pressure. The safety relay usually also monitors the dump valve’s feedback (a pressure switch or a position contact), so a dump valve that fails to vent stops the cell from restarting. The two parts cover different failures. How much of this you need follows from the risk assessment and the required performance level under ISO 13849, which is your engineer’s job to document.
On Hermetry Safe: there’s no doc page for it, so I won’t guess what it does. Whatever it does, I would never put a cloud platform into the safety function itself. Even the personnel tracking page calls that solution an information tool, not a certified safety system. Emergency stop, safety relay and dump valve stay hardwired.
What works today and is useful: monitoring. Wire the safety relay’s auxiliary contact and the dump valve’s pressure switch into the cell PLC or a gateway and send them as telemetry, say estop.active and dump.vented. Then an alarm rule can tell maintenance when the e-stop has been active for a long time, or when the e-stop is active and dump.vented is still 0. That gives you records and notifications without touching the safety chain.

