Compare commits

...

10 Commits

3 changed files with 20 additions and 24 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 KiB

After

Width:  |  Height:  |  Size: 256 KiB

View File

@ -1,15 +1,28 @@
# 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)
3. GND
3. Data GND
4. NC
5. DATA (TX 115200 inverted)
5. Data (TX 115200 inverted open drain)
6. GND
Add voltage divider to Pico RX pin:
- 10k between pico RX pin and GND
- 10k between HAN pin 5 and pico RX pin
PicoW connection:
- Connect HAN port pin 1 and 2 to pico 5V
- 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
![front](20220814_231222.MEDIUM.jpeg)
![back](20220814_231229.MEDIUM.jpeg)

17
main.py
View File

@ -45,23 +45,6 @@ wdt.feed()
print("Setting up UART")
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):
data = data.replace("'b'", "")
data_list = data.split("\\r\\n")