Hi everyone,
I have it all up and running now. Maybe someone else can use this in the feature.
Used hardware:
-
On the Raspberry Pi, install Raspbian
-
Run this commands:
sudo apt-get install -y autoconf libtool
git clone https://github.com/stephane/libmodbus/
cd libmodbus
./autogen.sh && ./configure --prefix=/usr && make && sudo make install
git clone https://github.com/gianfrdp/SDM120C.git
make clean && make
sudo make install
Required to read temperature from domoticz
sudo apt-get install jq
-
Make a new pvoutput.sh file and make it executable (chmod +x)
-
Copy this to the .sh file:
today=date '+%Y%m%d'
minute=date '+%H:%M'
echo ----------------
echo Current date and time in PVOutput compatible format
echo Date is $today
echo time is $minute
echo ----------------
values=sudo sdm120c -a 1 -b 2400 -e -p -v -P N -z 3 -q /dev/ttyUSB0
echo
echo ----------------
echo Modbus meter values
echo ${values}
echo ----------------
V=echo ${values} | awk '{print $1}'
W=echo ${values} | awk '{print substr ($2,2);}'
WH=echo ${values} | awk '{print $3}'
echo
echo ----------------
echo Values to uploaded to PVOutput
echo Watt Hour is $WH
echo Watt is $W
echo Voltage is $V
echo ----------------
temperature=curl -s 'http://10.0.0.10:8080/json.htm?type=devices&rid=142' | jq .result[0].Temp | sed 's/\"//g' | awk '{ print $1 }'
T=echo ${temperature} | awk '{print $1}'
echo
echo ----------------
echo Temperature read from Domoticz
echo Temperature is $T
echo ----------------
curl -d “d=$today” -d “t=$minute” -d “v1=$WH” -d “v2=$W” -d"v5=$T" -d “v6=$V” -d “c1=1” -H “X-Pvoutput-Apikey: your-api-key-here” -H "X-Pvoutput-SystemId:your-systemid-here " https://pvoutput.org/service/r2/addstatus.jsp
echo
- Schedule the file to run every 5 minutes with crontab (crontab -e)
*/5 * * * * sleep 4; /home/pi/scripts/pvoutput_upload.sh >/dev/null 2>&1
As you can see, i use my Domoticz system to read out the temperature. You can remove this part if you don’t have domoticz.