- Raspberry Pi (We've tested this on model 3B+ - with headers)
- SD with Raspian Buster installed
- PIR sensor
- Pi Camera
- Huawei E303 Cellualar USB dongle with Sim card (we got both from Hologram.io)
- External Battery (Currently we are using a Ravpower 26800 mAh battery)
- ThingSpeak account and API key
Other things to help development or in constructing the sensor - these are not neccessary
- HDMI cable
- Adafruit T-cobbler w/ serial cable
- Bread board
- 12in camera cable
- female to female wires
- case/container to keep trail counter in
Once you sign upfor an account, create a channel. Select your channel and add field names according to those found in the detect.py file.
- Field 1 = current_date
- Field 2 = last_date
- Field 3 = bicycle
- Field 4 = person
- Field 5 = horse
- Field 6 = car
Then Click on API Keys and Generate New Write API Key, copy key and save for step 3.
cd /home/pi/Public/
Then
git clone https://github.com/fpdcc/trail-counter-RPi3-setup.git
cd trail-counter-RPi3-setup
./rasp_pi_installs.sh
Connect external sensors/devices
Connect PIR sensor
- GND on sensor to a ground pinon the pi.
- 5v pin to 5v pin on pi.
- out pin to xxx pin on pi.
Allow camera
sudo raspi-config
select
Interface options Camera > YES
Connect Raspberry Pi Camera Rev 1.3 1.Ribbon cable from camera goes into slot labeled camera on pi.
Plug in Huawei E303 3G Wireless into USB port
Update sample_config.py, rename to config.py and put in your own ThingSpeak API KEY and CHANNELID.
Create systemd service to run on boot
sudo nano /lib/systemd/system/trail_counter.service
Copy and paste into file
[Unit]
Description=Start trail counter service
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/python /home/pi/Public/trail-counter-RPi3-setup/counter.py
Restart=always
[Install]
WantedBy=multi-user.target
Exit nano
ctrl+X
and y
to save
sudo chmod 644 /lib/systemd/system/trail_counter.service
sudo systemctl daemon-reload
sudo systemctl enable trail_counter.service
Reboot to start service
To check status of service use these tools
top
or htop
Look for something called trailcounter.service
also systemctl and journalctl help to view logs of the service and troubleshoot issues.
sudo systemctl status trail_counter.service
sudo journalctl -f -u trail_counter.service
(ctrl+c to exit journalctl command)
To check log files after use in the field go to
/var/log/syslog
Each time the counter detect an object it printed the URL to the log file. This can be checked against what you are recieving in ThingSpeak.
sudo raspi-config
Boot options Desktop / CLI
Then choose an option depending on your preference.
nano /boot/config.txt
add lines
dtoverlay=pi3-disable-bt
dtoverlay=pi3-disable-wifi
python3 detect.py \
--model detect.tflite \
--labels coco_labels.txt \
--threshold 0.55 \
--image /home/pi/Public/images/counter_image.jpg
Currently detect.py has default values set so you dont have to include any flags when running it as specified above.