• 0 Posts
  • 9 Comments
Joined 2 年前
cake
Cake day: 2024年3月28日

help-circle

  • Read about multiplexing. There are various ways to achieve it, the easiest way is to just arrange it on a grid. Let’s say 5×5. So with 10 pins, you can address 25 doors. For the lock, the easiest would be a solenoid / magnetic lock. You can also use a motor, but that would require a more complex addressing to reverse the rotation for opening and closing

    Edit for more clarity about the simple method: Think of every door as a solenoid connected to GND. You only need VCC to open it. You can use relay module to switch the row and column to connect the VCC of the solenoid. But you need to wire every solenoid in “AND” switch configuration so it only turns on if and only if both row and column switch are closed


  • If your lithium battery has BMS, it should be fine since a lot of BMS will have a lot of protection including over current. If your raw dog the cell, then as the other said, any voltage and current into the battery should be capped. Ideally, you should monitor each cell as well to prevent an over voltage of any of the cells in the pack. If you want to be safe without monitoring every cell, then just make sure nothing gets back into the battery. Nothing goes in = can’t get overcharged by accident from back emf.


  • There is a lot to unpack here. But my suggestion is “cheap” esp32 devboard. At least where I live, going with older / raw MCU (not a “devboard”) will ended up more expensive. I’ll give an example. The STM32F103C8T6 “Blue Pill” cost the same as ESP32 DOIT Devkit (around USD 3). BUT the bare MCU of both cost around 1-5 cent more due to the economy of scale. So unless you plan to design a custom board in bulk/size constraint, buying the devkit and making a daughter board can ended up cheaper


  • Yeah, CTS and RTS is useful for the module since you may overflow the module buffer (instead of the module overflowing your UART buffer). With proper HW flow control, hopefully your device UART respects the signal and pauses the tx until it is clear again without you having to code the pause yourselves. It can happen when the GSM bandwidth is lower than the UART bandwidth.

    The module suddenly talking should also be handled by your device UART gracefully. When your rx buffer is full for whatever reason (not reading it for a long time?), the module won’t be sending anymore data until you read your rx buffer. Theoretically, no data should be lost that way.



  • I assume you mean RXD to TX0. As for sporadic packets like that, I’d honestly check for the signal integrity. Maybe somehow the data line is picking up noise high enough to cause disturbance. It could be caused by a lot of things, but the most likely culprit are the connector/cable. Any connection going into/out of pcb should be checked. Or check your timing. Make sure the baud and other config (start, data, stop, parity) are matched. Small drift in baudrate is usually tolerable. UART is designed for async communication after all, meaning that any device may send anytime so CTS and RTS isn’t usually needed provided that it is a hardware UART (not bit banging). You can check out Ben Eater video about it. In short, the TX is usually held high, the RX then can detect a falling edge which is a signal that a packet is starting. The UART hardware then processes the signal according to the config that you give it and is usually able to do a DMA transfer.

    Edit: Ahh, after reading the code I suspect that your code processes the data faster than the module can send the full reply. The first loop that you are waiting for the first data to arrive, you immediately process everything in the buffer until it is empty, not knowing that maybe the module has not yet finished transmitting. CTS and RTS would not help since they are used to signal if both devices would like to (or probably could) send / receive data. Not signalling end of data transfer

    Edit 2, the solution: Either parse the received packet until the expected end, or wait until timeout before returning.