Compare commits
10 Commits
2eb76abcc5
...
18b11a9503
| Author | SHA1 | Date | |
|---|---|---|---|
| 18b11a9503 | |||
| 33bad73206 | |||
| 6f35a3b3c7 | |||
| 989d1df522 | |||
| 52bac7009d | |||
| f60f0d4f3e | |||
| df4928c984 | |||
| d601ad7fec | |||
| 0decffb1da | |||
| 5e63b49c6b |
Binary file not shown.
|
Before Width: | Height: | Size: 573 KiB After Width: | Height: | Size: 256 KiB |
27
README.md
27
README.md
@ -1,15 +1,28 @@
|
|||||||
# Han Mqtt Adapter
|
# Han Mqtt Adapter
|
||||||
Han port pinout:
|
|
||||||
1. 5V
|
### Install
|
||||||
|
1. Setup picoW with MicroPython [link](https://www.raspberrypi.com/documentation/microcontrollers/micropython.html)
|
||||||
|
2. Add dependencies (umqtt)
|
||||||
|
3. Copy main.py and config.py to picoW root
|
||||||
|
4. Edit config.py to correct SSID, Password and MQTT broker IP
|
||||||
|
|
||||||
|
### Protocol
|
||||||
|
[link to HAN protocol](https://hanporten.se/svenska/protokollet/)
|
||||||
|
|
||||||
|
### Hardware
|
||||||
|
Han port pinout (RJ12):
|
||||||
|
1. 5V (max 250mA)
|
||||||
2. Data request (connect to 5V to enable)
|
2. Data request (connect to 5V to enable)
|
||||||
3. GND
|
3. Data GND
|
||||||
4. NC
|
4. NC
|
||||||
5. DATA (TX 115200 inverted)
|
5. Data (TX 115200 inverted open drain)
|
||||||
6. GND
|
6. GND
|
||||||
|
|
||||||
Add voltage divider to Pico RX pin:
|
PicoW connection:
|
||||||
- 10k between pico RX pin and GND
|
- Connect HAN port pin 1 and 2 to pico 5V
|
||||||
- 10k between HAN pin 5 and pico RX pin
|
- Connect HAN port pin 3 and 6 to pico GND
|
||||||
|
- Connect HAN port pin 5 to pico 1 (RX)
|
||||||
|
- Add pullup resistor (15k) between Pico RX pin and 3V3
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|||||||
17
main.py
17
main.py
@ -45,23 +45,6 @@ wdt.feed()
|
|||||||
print("Setting up UART")
|
print("Setting up UART")
|
||||||
uart = machine.UART(0, 115200,invert=UART.INV_RX)
|
uart = machine.UART(0, 115200,invert=UART.INV_RX)
|
||||||
|
|
||||||
def readUntil(uartObject, termination, maxlen=-1, includeTermination=True):
|
|
||||||
terminatedFlag=False
|
|
||||||
result = ''
|
|
||||||
while maxlen < 0 or len(result) < maxlen:
|
|
||||||
if uartObject.any():
|
|
||||||
result += chr(uartObject.read(1)[0])
|
|
||||||
for terminal in termination:
|
|
||||||
if result.endswith(terminal):
|
|
||||||
terminatedFlag=True
|
|
||||||
if not includeTermination:
|
|
||||||
result = result[:-len(terminal)]
|
|
||||||
break
|
|
||||||
if(terminatedFlag==True):
|
|
||||||
return result
|
|
||||||
time.sleep_us(10)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def parse_han_protocol(data):
|
def parse_han_protocol(data):
|
||||||
data = data.replace("'b'", "")
|
data = data.replace("'b'", "")
|
||||||
data_list = data.split("\\r\\n")
|
data_list = data.split("\\r\\n")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user