Introduction: Digistump and Modbus RTU

Those who have seen my instructable on communication between Modbus RTU and a Raspberry Pi know that I'm planning a project for automating a greenhouse. I have made 2 small PCB's that can be put inside a projectbox. The link to the PCB's I will include later because I didn't receive them yet and I still need to test them.

As replacement for the arduino uno I will use a digistump. This is a very small ATTINY85 based board. Because the ATTINY85 doesn't have hardware serial I have used software serial to make serial communication work. Because most of my connected devices (pumps, solenoid valves,...) work on 24V I will include a converter onto the PCB. You can also use 12V which propably is a better choice.

Supplies

Hardware:

Libraries:

Step 1: Installing the Libraries

During testing of the digistump I came across some problems. First I didn't know that the board didn't have hardware serial. I already had installed software serial so I have given this a try. At first this didn't work and after searching the net I found that my version of software serial didn't support the 16.5 mhz digistump. In this case you can overwrite the library in the folder C:\Users\youruser\Documents\Arduino\libraries\SoftwareSerial-master

  • Download the softwareserial library as a zip
  • Download the modbus library as a zip
  • Add the library's via sketch, use library, add ZIP library

Step 2: Installing the Driver

In order to use the digistump board you need to install the drivers first.

  • Download the drivers
  • Install the right version of the driver onto your computer
  • Open device manager
  • Take view
  • Display hidden devices
  • If you connect your digistump you will see the device (image)

Step 3: Adding the Board to the Arduino IDE

In the last step you installed the drivers to use the digistump. Now you still need to add the board to the arduino IDE.

After installing you will see the board under tools,board.

Step 4: Programming the Digistump

The attached code makes use of some registers that can be written or read. In this code I use the arduino to read the analog value of an LDR and to write the value to one of the registers. In the future I plan to make the code universal for using different sensor types and maybe even to change the default Modbus address.

  • Download the code
  • Detach the digistump board from USB.
  • Select the Digispark default 16.5 Mhz board under tools,board
  • Press the upload button
  • Wait until you see the message plug in device now
  • Plug in the USB-cable

Step 5: Wiring the Digistump

In the schematic you can see how to wire the digistump. In the future you can also use my PCB.

Step 6: Change or Read the Registers Using Python

You can use the attached Python code to read and write the registers. Look at my other instructable if you like to run it on a Raspberry Pi

Arduino Contest 2020

Participated in the
Arduino Contest 2020