SmartHome cu Arduino prin RS485

Introducere

Scopul proiectului este sa folosesc un arduino pentru a interfata cateva tipuri diferite de senzori cu RS485 - Modbus, pentru a putea fi folositi intr-un proiect de tipul SmartHome.

Schema Bloc

Hardware Design

Lista de piese:

  • Arduino UNO
  • Breadboard
  • Senzor optic CNY70
  • UART TTL to RS485 converter
  • USB to serial RS485

Software Design

Proiectul e format din 2 parti:

  • slave - Arduino
  • master - Python

Codul de slave citeste regulat senzorul si raspunde la requesturi(citiri) modbus. Foloseste biblioteca ArduinoModbus.

Codul de master ruleaza pe calculator, si citeste date de la sclavii conectati la busul RS485. Foloseste biblioteca de python minimalmodbus.

Rezultate Obținute

Am reusit sa citesc senzorul pe arduino si sa afisez la seriala. Calculatorul si Arduinoul comunica prin RS485-Modbus dar checksumul raspunsurilor de la Arduino este prost. Nu am reusit sa fac debugging intrucat folosesc seriala pentru comunicare prin RS485.

Eroare checksum:

Traceback (most recent call last):
  File "./master-rs485.py", line 13, in <module>
    val = instrument.read_register(0, 0, 3)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 258, in read_register
    return self._genericCommand(functioncode, registeraddress, numberOfDecimals=numberOfDecimals, signed=signed)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 697, in _genericCommand
    payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 798, in _performCommand
    payloadFromSlave = _extractPayload(response, self.address, self.mode, functioncode)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 1075, in _extractPayload
    raise ValueError(text)
ValueError: Checksum error in rtu mode: '\x01\x83' instead of '\x00\x00' . The response is: '\x01\x83\x02\xc0\xf1\x01\x83' (plain response: 
'\x01\x83\x02\xc0\xf1\x01\x83')

smarthomers485-poza.jpeg

https://youtu.be/BwLi745r3rU

Download

Bibliografie/Resurse

pm/prj2021/abasoc/smarthome.txt · Last modified: 2021/06/03 11:58 by tudor.niculescu0610
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0