title: Python script for RTU Modbus
body: <p>I am working on a automation of my home using a raspberry pi 3B+</p>
  
  <p>I bought a electronic energy meter MEMO4-M-MOD. 
  <a href="https://docs-emea.rs-online.com/webdocs/152f/0900766b8152f22b.pdf" rel="nofollow noreferrer">https://docs-emea.rs-online.com/webdocs/152f/0900766b8152f22b.pdf</a>
  To connect it to raspberry pi i bought a cable RS485/USB.</p>
  
  <p>I am interested to read some values from the energy meter 
  ( exemple in the datasheet of the energy meter it says that the register adress of voltage is on the adress 2000(hexa)  )
  i wrote this code
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#!/usr/bin/env python3
  import minimalmodbus
  import serial
  
  
  instrument = minimalmodbus.Instrument('/dev/ttyUSB0',0) 
  instrument.serial.port
  instrument.serial.baudrate = 9600
  instrument.serial.bytesize = 8
  instrument.serial.parity =serial.PARITY_NONE
  instrument.serial.stopbits = 1
  instrument.serial.timeout = 0.05
  instrument.mode = minimalmodbus.MODE_RTU
  
  try:
      
      valeur= instrument.read_register(2000,1,3,False) 
      print(valeur) 
  except IOError:
      print("no connection")</code></pre>
  </div>
  </div>
  
  Problem I am facing here is it print no connection, so that make me think i use correctly the library.
  Have you used this library?can you give me some advice to make that work?
   thank you so much</p>