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.
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
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.
- Go to file, preferences
- There you can add a link in the inputbox next to additional boards manager URL's
- Add this link https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.json
- Click ok
- Go to tools, board, boards manager
- Select the type contributed
- Search digistump
- Install digistump avr boards
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
Participated in the
Arduino Contest 2020