So I am using a Raspberry Pi 4 to connect the Arduino to. On the Raspberry Pi there runs a connector service which will handle the output of the Arduino and give it to the Scoreboard (in my case this is DaSCR-Board as you can tell).
For this purpose I am using go once again. You also can run DaSCR-Board and DaSCR-Machine all from that single Pi inside your darts machine. This should be enough ressources to handle both of it.
AttentionAs I am using the “embed” package of go introduced with go 1.16 you need to make sure you are using this version or a newer one.
Also you system needs to have a running operating system (I chost raspbian for simplicity) and be integrated into a network. You can do that either using WIFI or a cable. Best would be to connect to the system via SSH for the next steps.
Clone or download the repository to that Raspberry Pi. In the folder called service you will find the go program.
Issue those commands to build it:
Current go1.16rc1 workflow
go1.16rc1 mod download go1.16rc1 build -ldflags "-s -w" -o dist/dascr-machine
Now you will have an executable called dascr-machine in the folder called dist.
You can test run it from that folder calling the command from the listing below. Be sure to have the Arduino connected to the Pi.
You should see something like this when running:
❯ INT=any ./dist/dascr-machine INFO [2021-02-08 13:18:50] Navigate to http://0.0.0.0:3000 to configure your darts machine INFO [2021-02-08 13:18:51] Connected to websocket @ wss://demo.dascr.org/ws/dascr ....
Configure and autostart
You are almost already there. Now you just need to know how to configure it and how to autostart it when powering on the machine. That is pretty much simple.
First you need to understand that the webserver will be served on the IP address of whatever interface you provide with the environment variable INT. In the example above I chost it to be any which will just bind it to every interface. Most of the time this is the best option. You could have bound it to ethX or wifiX or whatever you Pi communicates with. I suggest you use any as I did.
Next up you can setup autostart using a systemd service file:
[Unit] Description=DaSCR Machine After=network.target [Service] Type=simple User=patrick Group=patrick Restart=always RestartSec=5s Environment=INT=any WorkingDirectory=/home/patrick/projects/dascr-machine/service/dist ExecStart=/home/patrick/projects/dascr-machine/service/dist/dascr-machine SyslogIdentifier=dascr-machine [Install] WantedBy=multi-user.target
Put the content of this listing into a file
/etc/systemd/system/dascr-machine.service and then call:
sudo systemctl daemon-reload sudo systemctl start dascr-machine sudo systemctl enable dascr-machine
This will reload the systemd service and start the machine connector service. Also it will mark it to be autostarted when the machine powers on.
You can check the status of the service with this command:
sudo systemctl status dascr-machine
Now you can navigate to the Raspberries IP address on port 3000 to setup the connection. When using any as interface it will tell you it’s 0.0.0.0 but it is not. You then will need to use the real IP address of your Pi like for example http://192.168.1.175:3000.
Navigate to it to configure your machine to use the Scoreboard and the Arduino.
You will see the start page and click on the Admin link in the top left to see the setup dialog.
Be sure to fill in everything correctly:
Ultrasonic delay will tell the machine how long to wait until switching to next player after it was triggerd
Piezo threshold is a variable to controll the senitivity of the piezo sensors which will detect missed darts bouncing from the case or landing into the outer catch ring. 20 is a default which was working quite well for me. So my guess is you could just leave it there
Serial port needs to represent the connection of your Arduino. It will be listed in the directory
/devof your operating system and will almost certainly be of type
ttyAXXX. So running
ls /dev/ttyA*in your PIs ssh session could tell you what to put here.
Hit ‘Save’ then to save the configuration.
Then proceed with scoreboard configuration
You need to fill in ip address and port of the system running the scoreboard. If you are running it on the same Raspberry Pi in the machine you can put
localhost and port
8000 I suppose. Otherwise refer to the system with the public IP address and the API Port. You also need to choose the game id the machine should send the score to.
When running against a publicly available instance of DaSCR-Board like I did in the screenshot above you might need to put in Basic Auth credentials and choose wether to use HTTPS or not.
If you ran through the guide of DaSCR-Board and how to get it up and running you certainly know what to put here.
There is a shutdown button to stop the underlying Raspberry Pi. If you want to use that you might need to issue this to allowing your user to shutdown the Pi:
sudo chmod 4755 /sbin/shutdown